From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795904128; b=TCwmDA3XB2ZcFTUGugRnFFBQc2t64Td8bjlz9aVvekX1kfRR5HKKf43w/3lkVeq6QG6k x56cPljNxrXQ/UFUWBwoRgxIXbYMopzl38b7GNOE1No6dpm4slsstumupR3c3uC7j2n1M d3h+jk11tVOejnkLQsUFI44Ih0azHUa6/QyThTzV5sbuwKih5qH0gReFFjVK4BuM1IL6d lewuhF78rCfGmeUiFjEDKqScxNR7yFzeucnB3GeSHduxtDezTaRwGK8TSVtjcxh15LkpD XnWV9qv0zZxJFbmGNFWBsTtfUvK2FwOVdMswpta7vQJVbF40xhWiDNstncaRr9obN6w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795904128; h=Received:DKIM-Signature:From:Subject:Date:Message-Id:MIME-Version: Content-Type:Content-Transfer-Encoding:X-B4-Tracking:X-Change-ID:To: Cc:X-Mailer:X-Developer-Signature:X-Developer-Key; bh=lMbAnya0GKnhX0Sm1A8a/Fvkjw4LC5DoZ0NYB1EM2Dc=; b=UswYzzy/ub/zan2GHJADBtVc3g/sXsqG6ZZgpgz9ihBtiLle43LjqbW9rXBYWLNRu9DA snzLFY97kmiaHCplxlH0pabodBEr8tInfP5Kx7mOg29sC0Zc9EhjylxieTuGtXNnUEF8H boVl988BRAqPO2gukRLxiWSqB5uBnKsTQSogRwxjl3kFAiZs2ifoweo8HDbWb66tpRYtJ bWtpfMlqcdV17GDb8wqnlfkGBVx3l8KfKDADHKGnXQjAOMhAOO+LlEDopBdFbekYWL2hR Or+aWDcPyAMQ+lC6aPQ6cwtLdJ3j9yKsOVU0T6Jo1+h0swe8kLCPIVhMXLIUa4zy96A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=nBoVwgjk; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 10039606A323; Sat, 28 Nov 2026 22:15:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=nBoVwgjk Received: by smtp.kernel.org (Postfix) with ESMTPSA id 827201F00893; Sat, 28 Nov 2026 22:15:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795904127; bh=lMbAnya0GKnhX0Sm1A8a/Fvkjw4LC5DoZ0NYB1EM2Dc=; h=From:Subject:Date:To:Cc; b=nBoVwgjksAZ+Gp1a2rvF2qJK4kaUS4YsFrDxQW2nwdY3Vfu27u7vB/I1/U5XIHtPX ij48gyjji/0oYcMfHvwyinJRGzSz1MA9ICAuizJbjeMdNUSeZFGg2YfQLJOtE9O0L4 A8RBCz+SPOIaWcVQhkhE7r2UnYjYp3Xii/M/G8YCAV5bS1USaj6L9c8BLmCChH/5mE BmrBIhmrDPHyit2dOojnJKiOJJUZumeLoHx+0jacgVJzWrk4Yr20xn4N4f4eV7phHg CJ8wSpvMwYJMezKv1MB8gu29BV73iY9p3TfgFiMNxZgmNT1dL1uznkLMUiSZQp2DBw V/evNCds4siqA== From: "David Hildenbrand (Arm)" Subject: [PATCH 0/2] mm: don't leak PFNs of CoW PFNMAP mappings to user space Date: Sat, 28 Nov 2026 23:15:09 +0100 Message-Id: <20261128-cow_pfnmap_pgoff-v1-0-ad3733299f24@kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIAAAAAAAA/yXMQQrCMBAF0KuEv26gyaLUXEWktJOZOoJJSNQKp XcXdfk2b0fjqtwQzI7KL22aE4JxnQFd57Sy1Yhg4Hs/OOdHS3mbiqT7XKayZhHrowwnGp3EntA ZlMqi7195vvzdnsuN6fF9cBwfnJ5ixXQAAAA= X-Change-ID: 20261128-cow_pfnmap_pgoff-2df69c81fd0c To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , Masami Hiramatsu , Oleg Nesterov , Andrii Nakryiko , Nicolas Pitre , David Hildenbrand , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Michal Hocko , Andrew Morton , Lorenzo Stoakes , Suren Baghdasaryan , Shakeel Butt , Pedro Falcato , Jann Horn , Jan Kara , Stephen Smalley , Paul Moore Cc: Chris Mason , 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 X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2132; i=david@kernel.org; h=from:subject:message-id; bh=sZW1omnoKF7vHXNlE8OaGNe3otxgj95d0SwpMdc/6lM=; b=owGbwMvMwCF2/OVpCdfQ3ZWMp9WSGLK5gwrrE846fbq+5ZjHZL7tjTsnzvzuuW/21XjFQ39KU g+JOtjs6ihlYRDjYJAVU2QJCr5v8PLlutpqNz5mmDmsTCBDGLg4BWAiVcmMDAtYbVNWbWvcYM23 21u2NKbvD8cHj4mmR6aW/zjJULJROIyR4aP8tzO6GbFT2e4aVHRt1rqReGzV9Tc7Z2c2Nmy3Dv3 xkw0A X-Developer-Key: i=david@kernel.org; a=openpgp; fpr=1BD9CAAD735C4C3A460DFCCA4DDE10F700FF835A 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)