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]
Date:   Wed, 9 Sep 2020 12:36:13 +0100
From:   Lorenzo Pieralisi <lorenzo.pieralisi@....com>
To:     Catalin Marinas <catalin.marinas@....com>
Cc:     George Cherian <gcherian@...vell.com>,
        Yang Yingliang <yangyingliang@...wei.com>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "linux-pci@...r.kernel.org" <linux-pci@...r.kernel.org>,
        "linux-arm-kernel@...ts.infradead.org" 
        <linux-arm-kernel@...ts.infradead.org>,
        "will.deacon@....com" <will.deacon@....com>,
        "bhelgaas@...gle.com" <bhelgaas@...gle.com>,
        "guohanjun@...wei.com" <guohanjun@...wei.com>
Subject: Re: [PATCH] arm64: PCI: fix memleak when calling pci_iomap/unmap()

On Mon, Sep 07, 2020 at 12:21:19PM +0100, Catalin Marinas wrote:
> + Lorenzo
> 
> On Mon, Sep 07, 2020 at 10:51:21AM +0000, George Cherian wrote:
> > Catalin Marinas <catalin.marinas@....com> wrote:
> > > On Sat, Sep 05, 2020 at 10:48:11AM +0800, Yang Yingliang wrote:
> > > > diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c index
> > > > 1006ed2d7c604..ddfa1c53def48 100644
> > > > --- a/arch/arm64/kernel/pci.c
> > > > +++ b/arch/arm64/kernel/pci.c
> > > > @@ -217,4 +217,9 @@ void pcibios_remove_bus(struct pci_bus *bus)
> > > >  	acpi_pci_remove_bus(bus);
> > > >  }
> > > >
> > > > +void pci_iounmap(struct pci_dev *dev, void __iomem *addr) {
> > > > +	iounmap(addr);
> > > > +}
> > > > +EXPORT_SYMBOL(pci_iounmap);
> > > 
> > > So, what's wrong with the generic pci_iounmap() implementation?
> > > Shouldn't it call iounmap() already?
> > 
> > Since ARM64 selects CONFIG_GENERIC_PCI_IOMAP and not
> > CONFIG_GENERIC_IOMAP,  the pci_iounmap function is reduced to a NULL
> > function. Due to this, even the managed release variants or even the explicit
> > pci_iounmap calls doesn't really remove the mappings leading to leak.
> 
> Ah, I missed the fact that pci_iounmap() depends on a different
> config option.
> 
> > https://lkml.org/lkml/2020/8/20/28
> 
> So is this going to be fixed in the generic code? That would be my
> preference.
> 
> A problem with the iounmap() in the proposed patch is that the region
> may have been an I/O port, so we could end up unmapping the I/O space.

It boils down to finding a way to match a VA to a BAR resource so that
we can mirror on pci_iounmap() what's done in pci_iomap_range() (ie
check BAR resource flags to define how/if to unmap them), that would do
as a generic pci_iounmap() implementation.

In the pcim_* interface that looks easy to do, in the non-managed
case ideas welcome - at the end of the day the deal is having a way
to detect in a generic way what's behind a void __iomem *.

Lorenzo

Powered by blists - more mailing lists