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: <20240227150744.GA235367@bhelgaas>
Date: Tue, 27 Feb 2024 09:07:44 -0600
From: Bjorn Helgaas <helgaas@...nel.org>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: Carlos López <clopez@...e.de>, cve@...nel.org,
	linux-kernel@...r.kernel.org, Bjorn Helgaas <bhelgaas@...gle.com>,
	Jonas Gorski <jonas.gorski@...il.com>,
	Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
	Mika Westerberg <mika.westerberg@...ux.intel.com>
Subject: Re: CVE-2023-52466: PCI: Avoid potential out-of-bounds read in
 pci_dev_for_each_resource()

[+cc Mika, author of 09cc90063240]

On Tue, Feb 27, 2024 at 02:26:26PM +0100, Greg Kroah-Hartman wrote:
> On Tue, Feb 27, 2024 at 02:18:51PM +0100, Carlos López wrote:
> > On 25/2/24 9:16, Greg Kroah-Hartman wrote:
> > > There is no actual issue right now because we have another check
> > > afterwards and the out-of-bounds read is not being performed. In
> > > any case it's better code with this fixed, hence the proposed
> > > change.
> > 
> > Given that there is no actual security issue this looks more like a
> > hardening, and thus not deserving of a CVE, no?
> 
> This was a tricky one, I think it's needed as we do not know how people
> are really using these macros, right?  If the PCI maintainer agrees (on
> the cc:), I'll be glad to revoke it, it's their call.

09cc90063240 ("PCI: Introduce pci_dev_for_each_resource()") added
pci_dev_for_each_resource(), which expands to:

  for (...; res = (&(dev)->resource[(bar)]), bar < PCI_NUM_RESOURCES; ...)

We compute "res" before the bounds-check of "bar", so the pointer may
be out-of-bounds, but the body of the pci_dev_for_each_resource() loop
is never executed with that out-of-bounds value.

So I don't think this is a security issue, no matter how
pci_dev_for_each_resource() is used, unless the mere presence of an
invalid address in a register is an issue.

The same address computation is used for "pci_resource_start(dev,
bar)", which is used in hundreds of places where drivers supply the
BAR index, and the index is not checked.

We could consider adding a bounds check in pci_resource_n() to turn a
potential out-of-bounds reference into a NULL pointer dereference,
e.g.,

  #define pci_resource_n(dev, bar) (bar < PCI_NUM_RESOURCES ?
      &(dev)->resource[(bar)] : NULL)

But of course, there's nothing stopping drivers from computing
"&dev->resource[junk]" themselves.

Bjorn

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ