From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
James Clark <james.clark@linaro.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Oleg Nesterov <oleg@redhat.com>,
Andrii Nakryiko <andrii@kernel.org>,
Nicolas Pitre <nico@fluxnic.net>,
David Hildenbrand <david@kernel.org>,
"Liam R. Howlett" <liam@infradead.org>,
Vlastimil Babka <vbabka@kernel.org>,
Mike Rapoport <rppt@kernel.org>, Michal Hocko <mhocko@suse.com>,
Andrew Morton <akpm@linux-foundation.org>,
Lorenzo Stoakes <ljs@kernel.org>,
Suren Baghdasaryan <surenb@google.com>,
Shakeel Butt <shakeel.butt@linux.dev>,
Pedro Falcato <pfalcato@suse.de>, Jann Horn <jannh@google.com>,
Jan Kara <jack@suse.cz>,
Stephen Smalley <stephen.smalley.work@gmail.com>,
Paul Moore <paul@paul-moore.com>
Cc: Chris Mason <mason@kernel.org>,
linux-kernel@vger.kernel.org,
linux-trace-kernel@vger.kernel.org,
linux-perf-users@vger.kernel.org, linux-mm@kvack.org,
selinux@vger.kernel.org
Subject: [PATCH v2 0/2] mm: don't leak PFNs of CoW PFNMAP mappings to user space
Date: Thu, 03 Dec 2026 13:33:23 +0100 [thread overview]
Message-ID: <20261203-cow_pfnmap_pgoff-v2-0-2e06735c100d@kernel.org> (raw)
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.
I 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.
I'll route this through my tree, likely after the next merge window.
---
Changes in v2:
- Collected tag (thanks!).
- "mm/memory: store the PFN of CoW PFNMAP mappings in the anon page offset"
- Use vma_is_mm_managed() instead of vma_can_merge() in copy_vma().
- Add vma_set_cow_pfnmap_pfn() and vma_cow_pfnmap_pfn().
- Drop "unmergeable VMAs" comment from the vma_start_anon_pgoff() doc.
- Adjust comments and the patch description.
- Link to v1: https://patch.msgid.link/20261128-cow_pfnmap_pgoff-v1-0-ad3733299f24@kernel.org
---
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 | 9 +++--
kernel/events/uprobes.c | 30 ++++++++++-----
mm/memory.c | 81 +++++++++++++++++++++++++----------------
mm/vma.c | 6 +--
mm/vma.h | 3 +-
tools/testing/vma/include/dup.h | 3 +-
7 files changed, 83 insertions(+), 56 deletions(-)
---
base-commit: c5941b1abeffba401f7f9cbc8c4f0c5da75dcba5
change-id: 20261128-cow_pfnmap_pgoff-2df69c81fd0c
Best regards,
--
David Hildenbrand (Arm) <david@kernel.org>
next reply other threads:[~2026-12-03 12:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 12:33 David Hildenbrand (Arm) [this message]
2026-12-03 12:33 ` [PATCH v2 1/2] uprobes: skip mappings not managed by core mm David Hildenbrand (Arm)
2026-12-03 13:53 ` Oleg Nesterov
2026-12-03 12:33 ` [PATCH v2 2/2] mm/memory: store the PFN of CoW PFNMAP mappings in the anon page offset David Hildenbrand (Arm)
2026-12-03 13:47 ` Lorenzo Stoakes (ARM)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261203-cow_pfnmap_pgoff-v2-0-2e06735c100d@kernel.org \
--to=david@kernel.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=akpm@linux-foundation.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=andrii@kernel.org \
--cc=irogers@google.com \
--cc=jack@suse.cz \
--cc=james.clark@linaro.org \
--cc=jannh@google.com \
--cc=jolsa@kernel.org \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=ljs@kernel.org \
--cc=mark.rutland@arm.com \
--cc=mason@kernel.org \
--cc=mhiramat@kernel.org \
--cc=mhocko@suse.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=nico@fluxnic.net \
--cc=oleg@redhat.com \
--cc=paul@paul-moore.com \
--cc=peterz@infradead.org \
--cc=pfalcato@suse.de \
--cc=rppt@kernel.org \
--cc=selinux@vger.kernel.org \
--cc=shakeel.butt@linux.dev \
--cc=stephen.smalley.work@gmail.com \
--cc=surenb@google.com \
--cc=vbabka@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox