Re: [PATCH v2 11/19] driver core: Introduce a generic device trust level
From: Leon Romanovsky
Date: Mon Nov 16 2026 - 07:27:48 EST
On Fri, Nov 13, 2026 at 10:30:23PM +1100, Alexey Kardashevskiy wrote:
> On 9/11/26 18:33, Leon Romanovsky wrote:
> > From: Leon Romanovsky <leonro@xxxxxxxxxx>
> >
> > Device setup needs a common operating policy before driver probing or DMA
> > configuration. Userspace must be able to hold devices disabled until it
> > authorizes them.
> >
> > Add generic trust admission with an immutable global boot policy. Restrict
> > the compatibility attachment API to explicit global full policy and full
> > operation, checking admission before probe. Keep the operating level
> > stable until teardown and retain normal locked admission for other callers.
> >
> > Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxx>
<...>
> > #define to_driver(obj) container_of(obj, struct driver_private, kobj)
> > +enum device_trust_state {
> > + DEVICE_TRUST_SELECTABLE,
> > + DEVICE_TRUST_WAITING,
>
> What is the exact difference between these? "Waiting" is waiting for what?
This is internal device trust state which is not visible to the users.
In this state driver is not yet allowed to be bound, but once will be
approved, the driver will be able to continue.
The difference between DEVICE_TRUST_WAITING and DEVICE_TRUST_SELECTABLE
is what happens when you choose a policy: SELECTABLE allows further changes
before admission, while choosing adversary or full from WAITING immediately
locks that choice.
>
> > + DEVICE_TRUST_AUTHORIZED,
> > + DEVICE_TRUST_COMMITTED,
>
> And exact difference between these two? Some documentation would be great.
>
> dev->trust_policy is how we want the device to operate.
Yes
> dev->p->trust_state is where the device is on its way to that final policy.
Partially, it is not only takes into account authorization (where the
device on its way), but also commitment (what is possible to do).
<...>
> > +static int __device_trust_prepare(struct device *dev,
> > + const struct device_driver *drv, bool full_only)
> > +{
> > + enum device_trust_policy policy;
> > + enum device_trust_level level;
> > + int ret;
> > +
> > + policy = dev->trust_policy;
> > +
> > + if (policy == DEVICE_TRUST_POLICY_DISABLED)
> > + return -EPERM;
> > + if (dev->bus && dev->bus->trust_resolve) {
> > + ret = dev->bus->trust_resolve(dev, drv, policy, &level);
> > + if (ret)
> > + return ret;
> > + } else {
> > + level = policy == DEVICE_TRUST_POLICY_ADVERSARY ?
> > + DEVICE_TRUST_ADVERSARY : DEVICE_TRUST_FULL;
> > + }
> > + if (level == DEVICE_TRUST_DISABLED)
> > + return -EPERM;
>
> This check can go right after trust_resolve() above. Thanks,
Right, thanks