[PATCH v2 0/3] mm,kernfs,proc: Unmap mmaps of removed files via file->f_mapping
Andrew Morton
akpm at linux-foundation.org
Sat Jul 25 14:37:37 PDT 2026
On Sat, 25 Jul 2026 21:05:46 +0000 Krzysztof Wilczyński <kwilczynski at kernel.org> 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/20260725210549.3716546-1-kwilczynski@kernel.org
More information about the kexec
mailing list