From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=115.124.30.131 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796364241; b=kVTAu6gVVAvBAwp690aC76Hlrn9smo5doJJKDI9ABBeN3tnr8PCmMJyKjzNBXDHyWjh2 0tnv5b85K1BCzRyAibGywbdSdBioyHi7zScvUyjQDi41XrfCzJGRzCVaqaQ402Pnr6M4n 5a43CnrWOmCpDypwy8F3rPk+EN7i8Ta7oYkRQoZk3GjiborNkdNT53PNJpJa8u3r10QGG 5FfU6hvPlUfqEBSZPJ31ePe+r3Q0Qdy+B2lM2Vvtzt36GZRj02e1yFtrhfj2PU5Q3igc/ H/f+M1i7if+ufxfWcgNB79pDboreotpijK87WFgW400B8E9X/i8wouvO3OU2iQeVLGQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796364241; h=DMARC-Filter:DKIM-Signature:X-Alimail-AntiSpam:Received:Date:From:To: Cc:Subject:Message-ID:References:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; bh=mAOHDYqfW58jdJbYjXiWxn/A+6JC4fjzkR/E9fHmybM=; b=h7hiOev9497q5F8IbrkZvEHpGBIKqiYEL1O+K9r9M9ipEvrcgI0gFJzqs6Csui+QgLZN UakLO1Ri+/onaNRucj7F0/J7dLaJcwQXePbYKFcxD/b7AoumbVAYruHSoGlR6gYPCGNNV T3ByFx7j4wJp/ftw3Dq5ut24mP0UM3rcWIDf8M2UtECgjjwVo0Mma2Ft9oqmUScz/feQC aFIWRZ1ggF2Xo8DvNaJ53SDThYWKFA+L4ZgWrFv7jSmmhSkJHqGRm3aJU3VS1xK+y9p6+ Hq151qsIITa8L+XgJg8wm6L3Wy/qCGvx2Zw7RXh5EN6g7SYQBBH5bQZ2OiCBEeGpDFQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=fGp5Q9f9; arc=none smtp.remote-ip=115.124.30.131 Received: from out30-131.freemail.mail.aliyun.com (out30-131.freemail.mail.aliyun.com [115.124.30.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 857FA606A322; Fri, 4 Dec 2026 06:03:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 857FA606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=fGp5Q9f9 DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1796364236; h=Date:From:To:Subject:Message-ID:MIME-Version:Content-Type; bh=mAOHDYqfW58jdJbYjXiWxn/A+6JC4fjzkR/E9fHmybM=; b=fGp5Q9f9WjWlR13Y6qyJl7ieNBvJ/VaYPMcO5I+mQvBvhQ9zBDBLoVe5MFM2HM5pOtRm2vhnDkwVFipVmgjaUFBgEuvkw4rVddJPr1J9lA8uVcbonRaFCZPGZvTJNnBBJCadIEeg0IbpwmwpiFWcamtx13w83g2lzAj+uNTF8o8= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R111e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033065142238;MF=fengwei_yin@linux.alibaba.com;NM=1;PH=DS;RN=34;SR=0;TI=SMTPD_---0XGGDdGU_1796364232; Received: from U-V2QX163P-2032.local(mailfrom:fengwei_yin@linux.alibaba.com fp:SMTPD_---0XGGDdGU_1796364232 cluster:ay36) by smtp.aliyun-inc.com; Fri, 04 Dec 2026 14:03:54 +0800 Date: Fri, 4 Dec 2026 14:03:52 +0800 From: YinFengwei To: "David Hildenbrand (Arm)" Cc: 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 , "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 , 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 Subject: Re: [PATCH v2 2/2] mm/memory: store the PFN of CoW PFNMAP mappings in the anon page offset Message-ID: References: <20261203-cow_pfnmap_pgoff-v2-0-2e06735c100d@kernel.org> <20261203-cow_pfnmap_pgoff-v2-2-2e06735c100d@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=us-ascii Content-Disposition: inline In-Reply-To: <20261203-cow_pfnmap_pgoff-v2-2-2e06735c100d@kernel.org> On Thu, Dec 03, 2026 at 01:33:25PM +0100, David Hildenbrand (Arm) wrote: > remap_pfn_range() and its mmap_prepare variant overwrite vm_pgoff with the > first PFN of the range in CoW mappings, such that __vm_normal_page() can > reliably identify CoW'ed anon folios without arch support for pte_special. > > However, vm_pgoff is also exposed to user space as the file offset, > through /proc/pid/maps, /proc/pid/smaps, PROCMAP_QUERY, PERF_RECORD_MMAP > and the NT_FILE note of core dumps, whereas /proc/pid/pagemap only > reports PFNs to CAP_SYS_ADMIN. > > Consequently, such mappings can leak physical addresses to user space. In > particular, since commit 8be71e1ba093 ("selinux: mark status and policy > inodes as immutable, drop status mmap write checks"), a MAP_PRIVATE > mapping of /sys/fs/selinux/status can leak PFNs that way. > > We don't want to expose the PFNs of mapped pages to user space. > > Now that we have the anon page offset per VMA, let's fix it by storing > the PFN in there instead. That value is never exported to user space. > > We already handle the anon page offset properly during VMA splits etc. > Only copy_vma() must be taught to not reset it for VMAs not managed by > core mm, which includes any PFNMAP mappings. > > This has medium urgency. Do not CC stable, as backports would be tricky > either way and not worth it. > > Fixes: 8be71e1ba093 ("selinux: mark status and policy inodes as immutable, drop status mmap write checks") > Reported-by: Chris Mason > Signed-off-by: David Hildenbrand (Arm) Reviewed-by: Yin Fengwei Regards Yin, Fengwei