lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <200907211415.47628.bjorn.helgaas@hp.com>
Date:	Tue, 21 Jul 2009 14:15:47 -0600
From:	Bjorn Helgaas <bjorn.helgaas@...com>
To:	Alex Chiang <achiang@...com>
Cc:	jbarnes@...tuousgeek.org, lenb@...nel.org,
	linux-pci@...r.kernel.org, linux-kernel@...r.kernel.org,
	linux-acpi@...r.kernel.org
Subject: Re: [PATCH v2 2/2] PCI Hotplug: acpiphp: get pci_bus from acpi handle correctly

On Tuesday 21 July 2009 01:57:55 pm Alex Chiang wrote:
> * Bjorn Helgaas <bjorn.helgaas@...com>:
> > On Tuesday 14 July 2009 02:53:33 pm Alex Chiang wrote:
> > > We cannot simply call acpi_get_pci_dev() on any random ACPI handle
> > > and hope that it works, because a PCI root bridge may not have
> > > an associated struct pci_dev.
> > > 
> > > This is allowed per the PCI specification, and is referred to as a
> > > non-materialized bridge.
> > > 
> > > So, depending on the type of PCI bridge that the handle points to,
> > > use the appropriate interface to return the struct pci_bus correctly.
> > > 
> > > Signed-off-by: Alex Chiang <achiang@...com>
> > > ---
> > > 
> > >  drivers/pci/hotplug/acpiphp_glue.c |   27 ++++++++++++++++-----------
> > >  1 files changed, 16 insertions(+), 11 deletions(-)
> > > 
> > > diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
> > > index 0cb0f83..fa4658b 100644
> > > --- a/drivers/pci/hotplug/acpiphp_glue.c
> > > +++ b/drivers/pci/hotplug/acpiphp_glue.c
> > > @@ -62,6 +62,21 @@ static void acpiphp_sanitize_bus(struct pci_bus *bus);
> > >  static void acpiphp_set_hpp_values(acpi_handle handle, struct pci_bus *bus);
> > >  static void handle_hotplug_event_func(acpi_handle handle, u32 type, void *context);
> > >  
> > > +static struct pci_bus *pci_bus_from_handle(acpi_handle handle)
> > > +{
> > > +	struct pci_bus *pbus;
> > > +
> > > +	if (acpi_is_root_bridge(handle)) {
> > > +		struct acpi_pci_root *root = acpi_pci_find_root(handle);
> > > +		pbus = root->bus;
> > > +	} else {
> > > +		struct pci_dev *pdev = acpi_get_pci_dev(handle);
> > > +		pbus = pdev->subordinate;
> > > +		pci_dev_put(pdev);
> > > +	}
> > > +	return pbus;
> > 
> > I worry that acpi_is_root_bridge() merely checks the device IDs of
> > "handle", which isn't quite the same as checking whether the pci_root
> > driver has claimed "handle".
> 
> Hm, I understand this concern in a theoretical sense, but could
> you explain more of what you're thinking about, and give me a
> concrete example of something that might go wrong here?

My concern is only theoretical -- I could imagine a PNP0A03 device
in the namespace (so acpi_is_root_bridge() is true) that has not been
claimed by the pci_root driver (so acpi_pci_find_root() returns NULL).

I don't think this will happen in practice because pci_root can't be
a module, but it's easier to analyze with just one check, since you
can learn everything you need from acpi_pci_find_root() without also
depending on acpi_is_root_bridge().

Bjorn
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ