[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAOSf1CHwj7qD6CdZ+AnY3s1JQXvO0eAG5CgoSHAUBGjtZ6+QfA@mail.gmail.com>
Date: Fri, 26 Jun 2020 17:52:57 +1000
From: "Oliver O'Halloran" <oohall@...il.com>
To: Rajat Jain <rajatja@...gle.com>
Cc: David Woodhouse <dwmw2@...radead.org>,
Lu Baolu <baolu.lu@...ux.intel.com>,
Joerg Roedel <joro@...tes.org>,
Bjorn Helgaas <bhelgaas@...gle.com>,
"Rafael J. Wysocki" <rjw@...ysocki.net>,
Len Brown <lenb@...nel.org>, iommu@...ts.linux-foundation.org,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
linux-pci <linux-pci@...r.kernel.org>,
linux-acpi@...r.kernel.org, Raj Ashok <ashok.raj@...el.com>,
"Krishnakumar, Lalithambika" <lalithambika.krishnakumar@...el.com>,
Mika Westerberg <mika.westerberg@...ux.intel.com>,
Jean-Philippe Brucker <jean-philippe@...aro.org>,
Prashant Malani <pmalani@...gle.com>,
Benson Leung <bleung@...gle.com>,
Todd Broch <tbroch@...gle.com>,
Alex Levin <levinale@...gle.com>,
Mattias Nissler <mnissler@...gle.com>,
Rajat Jain <rajatxjain@...il.com>,
Bernie Keany <bernie.keany@...el.com>,
Aaron Durbin <adurbin@...gle.com>,
Diego Rivas <diegorivas@...gle.com>,
Duncan Laurie <dlaurie@...gle.com>,
Furquan Shaikh <furquan@...gle.com>,
Jesse Barnes <jsbarnes@...gle.com>,
Christian Kellner <christian@...lner.me>,
Alex Williamson <alex.williamson@...hat.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Subject: Re: [PATCH 2/2] pci: Add parameter to disable attaching untrusted devices
On Fri, Jun 26, 2020 at 10:27 AM Rajat Jain <rajatja@...gle.com> wrote:
>
> Introduce a PCI parameter that disables the automatic attachment of
> untrusted devices to their drivers.
>
> Signed-off-by: Rajat Jain <rajatja@...gle.com>
> ---
> Context:
>
> I set out to implement the approach outlined in
> https://lkml.org/lkml/2020/6/9/1331
> https://lkml.org/lkml/2020/6/15/1453
>
> But to my surprise, I found that the new hotplugged PCI devices
> were getting automatically attached to drivers even though
> /sys/bus/pci/drivers_autoprobe was set to 0.
>
> I realized that the device core's "drivers_autoprobe":
>
> * only disables the *initial* probe of the device (i.e. from
> device_add()). If a subsystem calls device_attach() explicitly
> for its devices like PCI subsystem does, the drivers_autoprobe
> setting does not matter. The core will attach device to the driver.
> This looks like correct semantic behavior to me because PCI is
> explicitly calling device_attach(), which is a way to explicitly
> ask the core to find and attach a driver for a device.
Right, but we're doing using device_attach() largely because the
driver core doesn't provide any mechanism for deferring the initial
probe. I didn't think there was any deeper reason for it, but while
looking I noticed that the initial probe can be async and
device_attach() forces probing to be synchronous. That has the side
effect of serialising all PCI device probing which might be
intentional to avoid device renaming due to the change in probe order.
Userspace is better at dealing with device names changing now days,
but you might still get some people mad at you for changing it.
> 2) Make the drivers_autoprobe property available to PCI to use
> (currently it is private to device core). The PCI could use this
> to determine whether or not to call device_attach(). This still
> leaves the other problem (of not being able to set
> drivers_autoprobe via command line open).
>
> 3) I found the pci_dev->match_driver, which seemed similar to what I
> am trying to do, but can't be controlled from userspace. I considered
> populating that field based on drivers_autoprobe (still need (2)).
> But the problem is that there is the AMD IOMMU driver which is setting
> this independently, so setting the match_driver based on
> drivers_autoprobe may not be a good idea.
Huh, that's pretty weird. Even with that hack you should be able
trigger the bug they're working around by removing the IOMMU device in
sysfs and doing a rescan. I wouldn't worry much about making
match_device user controllable since you would need to work pretty
hard for it to be an issue.
Oliver
Powered by blists - more mailing lists