Linux Trace Kernel
 help / color / mirror / Atom feed
From: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>
To: "David Hildenbrand (Arm)" <david@kernel.org>
Cc: sashiko-reviews@lists.linux.dev,
	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>,
	 "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>,
	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>, Chris Mason <mason@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
Date: Fri, 4 Dec 2026 13:27:55 +0000	[thread overview]
Message-ID: <axK_vSfKpeyLaVvX@gremlin> (raw)
In-Reply-To: <c48802aa-fd04-4d5b-8e8c-b963940f9f66@kernel.org>

On Fri, Dec 04, 2026 at 02:05:07PM +0100, David Hildenbrand (Arm) wrote:
> On 12/4/26 13:34, sashiko-bot@kernel.org wrote:
> > Thank you for your contribution! Sashiko AI review found 1 potential
> > issue to consider:
> > - [Low] mm: vma_cow_pfnmap_pfn() calls linear_anon_page_index() when
> >   vm_ops is NULL
> > --
> >
> > commit d7059d46ab28e030b7a6940fa6aec3969604cdc8
> > Author: David Hildenbrand (Arm) <david@kernel.org>
> >
> > mm/memory: store the PFN of CoW PFNMAP mappings in the anon page offset
> >
> > This commit stores the base PFN of CoW VM_PFNMAP mappings in the VMA's
> > anonymous page offset instead of vma->vm_pgoff, avoiding leaking physical
> > addresses to user space.  It updates __vm_normal_page() and
> > remap_pfn_range() accordingly, and keeps copy_vma() from resetting the
> > anonymous page offset on non-mm-managed VMAs.
> >
> >> diff --git a/mm/memory.c b/mm/memory.c
> >> index 90fc7c3951247..d11074b461e14 100644
> >> --- a/mm/memory.c
> >> +++ b/mm/memory.c
> >> @@ -649,6 +649,30 @@ static void print_bad_pte(struct vm_area_struct *vma, unsigned long addr,
> > [ ... ]
> >> +static inline unsigned long vma_cow_pfnmap_pfn(const struct vm_area_struct *vma,
> >> +		unsigned long addr)
> >> +{
> >> +	VM_WARN_ON_ONCE(!vma_test(vma, VMA_PFNMAP_BIT));
> >> +	VM_WARN_ON_ONCE(!vma_is_cow_mapping(vma));
> >> +
> >> +	return linear_anon_page_index(vma, addr);
> >> +}
> >
> > [Severity: Low]
> > Can linear_anon_page_index() trigger a spurious VM_WARN_ON_ONCE() here when
> > vma->vm_ops is temporarily NULL during an in-flight f_op->mmap() failure?
> >
> > Legacy f_op->mmap() paths like drm_gem_shmem_mmap() clear vma->vm_ops on
> > imported dma-bufs and call dma_buf_mmap() -> system_heap_mmap() ->
> > remap_pfn_range().  If remap_pfn_range_notrack() fails partway through a
> > CoW mapping, zap_vma_range() runs before mmap_file() sets vma_dummy_vm_ops.
> >
> > On architectures without CONFIG_ARCH_HAS_PTE_SPECIAL and with
> > CONFIG_DEBUG_VM enabled, zap_vma_range() reaches vma_cow_pfnmap_pfn() while
> > vma_is_anonymous(vma) is still true and anon_pgoff (the PFN) differs from
> > linear_page_index(vma, addr), firing the warning in linear_anon_page_index().
> >
> > Since vma_cow_pfnmap_pfn() already asserts vma_is_cow_mapping(vma), calling
> > __linear_anon_page_index(vma, addr) directly would avoid this warning.
> >
>
> Apparently this can happen when the stars align. Not sure if we care.
>
> @Lorenzo, should I just use __linear_anon_page_index here?

Yeah that's fine maybe just add a comment to say /* Once in a blue moon < blah
blah what the AI said > */ or what not to explain why.

>
> --
> Cheers,
>
> David

--
Cheers, Lorenzo

      reply	other threads:[~2026-12-04 13:28 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 12:33 [PATCH v2 0/2] mm: don't leak PFNs of CoW PFNMAP mappings to user space David Hildenbrand (Arm)
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 15:09   ` Lorenzo Stoakes (ARM)
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)
2026-12-04  6:03   ` YinFengwei
2026-12-04 12:34   ` sashiko-bot
2026-12-04 13:05     ` David Hildenbrand (Arm)
2026-12-04 13:27       ` Lorenzo Stoakes (ARM) [this message]

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=axK_vSfKpeyLaVvX@gremlin \
    --to=ljs@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=david@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-mm@kvack.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=linux-trace-kernel@vger.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=sashiko-reviews@lists.linux.dev \
    --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