Re: [PATCH v1] driver: base: Add driver filter support

From: Greg Kroah-Hartman
Date: Thu Aug 05 2021 - 13:49:34 EST


On Thu, Aug 05, 2021 at 09:37:28AM -0700, Dan Williams wrote:
> On Thu, Aug 5, 2021 at 12:58 AM Greg Kroah-Hartman
> <gregkh@xxxxxxxxxxxxxxxxxxx> wrote:
> >
> > On Thu, Aug 05, 2021 at 09:55:33AM +0200, Greg Kroah-Hartman wrote:
> > > On Thu, Aug 05, 2021 at 09:49:29AM +0200, Greg Kroah-Hartman wrote:
> > > > On Wed, Aug 04, 2021 at 12:50:24PM -0700, Andi Kleen wrote:
> > > > > > And what's wrong with the current method of removing drivers from
> > > > > > devices that you do not want them to be bound to? We offer that support
> > > > > > for all busses now that want to do it, what driver types are you needing
> > > > > > to "control" here that does not take advantage of the existing
> > > > > > infrastructure that we currently have for this type of thing?
> > > > >
> > > > > I'm not sure what mechanism you're referring to here, but in general don't
> > > > > want the drivers to initialize at all because they might get exploited in
> > > > > any code that they execute.
> > > >
> > > > That is exactly the mechanism we have today in the kernel for all busses
> > > > if they wish to take advantage of it. We have had this for all USB
> > > > drivers for well over a decade now, this is not a new feature. Please
> > > > use that instead.
> > >
> > > Hm, wait, maybe that didn't get merged yet, let me dig...
> > >
> >
> > Ok, my fault, I was thinking of the generic "removable" support that
> > recently got added.
> >
> > Both thunderbolt and USB have the idea of "authorized" devices, that is
> > the logic that should be made generic and available for all busses to
> > use, by moving it to the driver core, just like the "removable" logic
> > got moved to the driver core recently (see 70f400d4d957 ("driver core:
> > Move the "removable" attribute from USB to core")
> >
> > Please use that type of interface, as we already have userspace tools
> > using it, and expand it for all busses in the system to use if they
> > want. Otherwise with this proposal you will end up with multiple ways
> > to control the same bus type with different types of "filtering",
> > ensuring a mess.
>
> I overlooked the "authorized" attribute in usb and thunderbolt. The
> collision problem makes sense. Are you open to a core "authorized"
> attribute that buses like usb and thunderbolt would override in favor
> of their local implementation? I.e. similar to suppress_bind_attrs:

What about doing it the other way around and making it generic like was
done for the "removable" attribute? That way the logic from both
thunderbolt and USB moves into the driver core as they really should be
shared.

See the above git commit as an example of what I mean.

thanks,

greg k-h