[PATCH 0/2] mm: don't leak PFNs of CoW PFNMAP mappings to user space

From: David Hildenbrand (Arm)

Date: Sat Nov 28 2026 - 17:15:33 EST


remap_pfn_range() stores the first PFN of CoW mappings in vm_pgoff, which
is exposed to user space as the file offset, for example through
/proc/pid/maps. Ever since commit 8be71e1ba093 ("selinux: mark status and
policy inodes as immutable, drop status mmap write checks"), this exposes
the PFN of the selinux status page to any process. Let's store it in the
anon page offset instead.

In patch #1, we teach uprobes to skip any mappings not managed by core
mm. So far, uprobes only skipped CoW PFNMAP mappings by accident,
because the lookup by file offset did not find them. This also fixes
existing issues with VM_MIXEDMAP mappings, such as cramfs XIP files.

In patch #2, we then stop storing the PFN of CoW PFNMAP mappings in
vm_pgoff and instead store it in the anon page offset that Lorenzo
introduced recently. In contrast to vm_pgoff, the anon page offset is
never exposed to user space.

As a side effect, such mappings are now found in the i_mmap tree by
their file offset, and cramfs direct mappings no longer report the
physical address in /proc/pid/maps.

In ran targeted tests (PFN leak, CoW behavior, fork, mremap) on x86-64 and
32bit arm (without LPAE -> no pte_special() support) and selftests on
x86-64.

To avoid conflicts with Lorenzo's vm_flag conversions in uprobe, this
should ideally go through Andrew's tree.

---
David Hildenbrand (Arm) (2):
uprobes: skip mappings not managed by core mm
mm/memory: store the PFN of CoW PFNMAP mappings in the anon page offset

fs/cramfs/inode.c | 7 +-----
include/linux/mm.h | 10 +++++---
kernel/events/uprobes.c | 30 ++++++++++++++--------
mm/memory.c | 55 ++++++++++++++++++++---------------------
mm/vma.c | 6 ++---
mm/vma.h | 3 +--
tools/testing/vma/include/dup.h | 3 ++-
7 files changed, 61 insertions(+), 53 deletions(-)
---
base-commit: c5941b1abeffba401f7f9cbc8c4f0c5da75dcba5
change-id: 20261128-cow_pfnmap_pgoff-2df69c81fd0c

Best regards,
--
David Hildenbrand (Arm) <david@xxxxxxxxxx>