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] [day] [month] [year] [list]
Message-ID: <CAHp75VfuBTR6gO4SSZUZodWnBH7UfTS859PLCQy+qM+ABSkKdQ@mail.gmail.com>
Date:   Mon, 17 Apr 2023 13:07:57 +0300
From:   Andy Shevchenko <andy.shevchenko@...il.com>
To:     Lukas Wunner <lukas@...ner.de>
Cc:     Niklas Schnelle <schnelle@...ux.ibm.com>,
        Bjorn Helgaas <bhelgaas@...gle.com>,
        Gerd Bayer <gbayer@...ux.ibm.com>,
        Matthew Rosato <mjrosato@...ux.ibm.com>,
        linux-s390@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-pci@...r.kernel.org, Andy Shevchenko <andy@...nel.org>
Subject: Re: [PATCH v2 1/4] PCI: s390: Fix use-after-free of PCI resources
 with per-function hotplug

On Mon, Apr 17, 2023 at 10:46 AM Lukas Wunner <lukas@...ner.de> wrote:
> On Mon, Mar 06, 2023 at 04:10:11PM +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;
> > +             }
> > +     }
> > +
> > +     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;
> > +             }
> > +     }
> > +}
>
> I realize this has already been applied so s390.git/master,
> but nevertheless would like to point out there's a handy
> pci_bus_for_each_resource() helper which could have been
> used here instead of the for-loop.

Actually in this case it's not possible. The above code nullifies the
matched resource or removes it from the list. We don't have any good
iterator inside pci_bus_for_each_resource() to do the latter.

There might be other places in the kernel code where something like
above is used and we can split a separate helper exactly for matching
cases, but with the above context I dunno we need to do anything right
now.

P.S. Thanks for Cc'ing me.

-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ