Re: [PATCH 2/2] thunderbolt: Add support for de-authorizing devices

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jan 5, 2021 at 11:28 AM Mika Westerberg
<mika.westerberg@xxxxxxxxxxxxxxx> wrote:
>
> In some cases it is useful to be able de-authorize devices. For example
> if user logs out the userspace can have a policy that disconnects PCIe
> devices until logged in again. This is only possible for software based
> connection manager as it directly controls the tunnels.
>
> For this reason make the authorized attribute accept writing 0 which
> makes the software connection manager to tear down the corresponding
> PCIe tunnel. Userspace can check if this is supported by reading a new
> domain attribute deauthorization, that holds 1 in that case.

What a great feature! Thanks for implementing it.

BTW, is there any general way to disable the device operations before such a
disconnection? The user has a way to stop removable disks, for example, but
maybe other devices need additional precaution from the user (eGPU?).


>                 Possible values are supported:
>
> -               ==  ===========================================
> +               ==  ===================================================
> +               0   The device will be de-authorized (only supported if
> +                   deauthorization attribute under domain contains 1)
>                 1   The device will be authorized and connected
> -               ==  ===========================================
> +               ==  ===================================================
>
>                 When key attribute contains 32 byte hex string the possible
>                 values are:

As 0 is available for 'secure' security level too, you may want to reflect it in
the documentation here somehow.


> +static int disapprove_switch(struct device *dev, void *data)

Maybe it's better to mark `data` as `__maybe_unused`?

> +{
> +       struct tb_switch *sw;
> +
> +       sw = tb_to_switch(dev);
> +       if (sw && sw->authorized) {
> +               int ret;
> +
> +               /* First children */
> +               ret = device_for_each_child_reverse(&sw->dev, NULL, disapprove_switch);
> +               if (ret)
> +                       return ret;
> +
> +               ret = tb_domain_disapprove_switch(sw->tb, sw);
> +               if (ret)
> +                       return ret;
> +
> +               sw->authorized = 0;
> +               kobject_uevent(&sw->dev.kobj, KOBJ_CHANGE);
> +       }
> +
> +       return 0;
> +}
> +



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux