Re: [PATCH v2 0/3] mm,kernfs,proc: Unmap mmaps of removed files via file->f_mapping
Andrew Morton <[email protected]> Sat, 25 Jul 2026 14:37:37 -0700
| Newsgroups | org.infradead.lists.kexec,dev.linux.lists.driver-core,org.kernel.vger.linux-pci,org.kernel.vger.linux-sound,org.kvack.linux-mm |
|---|---|
| Message-ID | <[email protected]> |
On Sat, 25 Jul 2026 21:05:46 +0000 Krzysztof WilczyĆski <[email protected]> wrote: > Hello, > > The PCI resource files in sysfs and the /proc/bus/pci device files swap > their f_mapping to the shared iomem address space at open time, so that > revoke_iomem() can unmap userspace mappings when a driver claims a > region, see commit 636b21b50152 ("PCI: Revoke mappings like devmem"). > > Their VMAs are therefore attached to the shared address space, which > neither removal path reaches: kernfs_drain_open_files() unmaps the > sysfs inode's own mapping, which contains none of them, and > proc_entry_rundown() does not unmap anything at all. > > As a result, userspace mappings of PCI BARs survive device removal, > and also survive a BAR resize on the sysfs side, keeping stale PTEs > into physical address space that the kernel may have reassigned since. > A mapping made before the device is removed still returns the previous > register value after the device has been released, through both > interfaces. Thanks. Can we please have full description of the userspace-visible effects of this? AI review might have found a few things: https://sashiko.dev/#/patchset/[email protected]