[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <198c6f7f19d77b8471bd609767b3d359a989b9ca.camel@linux.ibm.com>
Date: Tue, 14 Feb 2023 11:00:53 +0100
From: Niklas Schnelle <schnelle@...ux.ibm.com>
To: Gerd Bayer <gbayer@...ux.ibm.com>
Cc: linux-s390@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-pci@...r.kernel.org,
Gerald Schaefer <gerald.schaefer@...ux.ibm.com>,
Heiko Carstens <hca@...ux.ibm.com>,
Vasily Gorbik <gor@...ux.ibm.com>,
Alexander Gordeev <agordeev@...ux.ibm.com>,
Christian Borntraeger <borntraeger@...ux.ibm.com>,
Sven Schnelle <svens@...ux.ibm.com>,
Bjorn Helgaas <bhelgaas@...gle.com>,
Pierre Morel <pmorel@...ux.ibm.com>,
Matthew Rosato <mjrosato@...ux.ibm.com>
Subject: Re: [PATCH] PCI: s390: Fix use-after-free of PCI bus resources with
s390 per-function hotplug
On Tue, 2023-02-14 at 10:46 +0100, Gerd Bayer wrote:
> Hi Niklas,
>
> when comparing pci_bus_remove_resource with pci_bus_remove_resources,
> I find that the "single-resource" variant might be ending too early.
>
> On Fri, 2023-02-03 at 12:48 +0100, Niklas Schnelle wrote:
> > +void pci_bus_remove_resource(struct pci_bus *bus, struct resource
> > *res)
> > +{
> > + struct pci_bus_resource *bus_res, *tmp;
> > + int i;
> > +
> > + for (i = 0; i < PCI_BRIDGE_RESOURCE_NUM; i++) {
> > + if (bus->resource[i] == res) {
> > + bus->resource[i] = NULL;
> > + return;
> ^^^^^^^
> Did you mean to "break" here, rather than end the routine?
No the return is intended. We're looking to remove a single resource
and if I understand things correctly then that resource can either be
in bus->resource[] (x)or in bus->resources depending on whether it is a
PCI bridge resource. Either way once found and removed from the
respective array/list we're done and can thus return immediately.
> > + }
> > + }
> > +
> > + list_for_each_entry_safe(bus_res, tmp, &bus->resources, list)
> > {
> > + if (bus_res->res == res) {
> > + list_del(&bus_res->list);
> > + kfree(bus_res);
> > + return;
> ^^^^^^^
> Here "break" and "return" have the same effect, but "break" would be
> "symmetric".
> > + }
> > + }
> > + return;
> > +
> > +}
>
> While this might be a nit, I'd like to better separate the "single-
> resource" variant's name. How about pci_bus_remove_one_resource - I
> know it's getting long...
>
> Thanks,
> Gerd
I have no strong feelings on the name.
Powered by blists - more mailing lists