All of lore.kernel.org
 help / color / mirror / Atom feed
From: "David Hildenbrand (Arm)" <david@kernel.org>
To: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
Cc: 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>,
	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>,
	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>, 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: Re: [PATCH 1/2] uprobes: skip mappings not managed by core mm
Date: Tue, 1 Dec 2026 10:36:10 +0100	[thread overview]
Message-ID: <a076b822-fb42-446f-b327-9ce020da9151@kernel.org> (raw)
In-Reply-To: <undine-1796085720443049537-a738eade6c72ea69@undined.local>

On 12/1/26 01:42, Masami Hiramatsu (Google) wrote:
> On Sat, 28 Nov 2026 23:15:10 +0100, David Hildenbrand (Arm) <david@kernel.org> wrote:
>> Uprobe writes breakpoints and updates the reference counters of SDT
>> markers through GUP, which refuses VM_IO and VM_PFNMAP mappings, and which
>> cannot access the parts of VM_MIXEDMAP mappings that are not backed by
>> "struct page".
>>
>> However, valid_vma() and valid_ref_ctr_vma() never excluded such
>> mappings. For example, cramfs XIP file mappings use either
>> remap_pfn_range() or VM_MIXEDMAP mappings. For such file mappings,
>> enabling a uprobe fails with -EFAULT, and disabling a uprobe that was
>> enabled before such a mapping appeared fails with -EFAULT as well,
>> leaking the uprobe.
>>
>> Further, since commit 83e3dc9a5d4d ("uprobes: simplify
>> find_active_uprobe_rcu() VMA checks"), the uprobe lookups no longer check
>> the VMA flags, assuming that a trap instruction in a VMA implies that we
>> installed a breakpoint there. But we never install breakpoints into
>> some VMAs, such as MAP_SHARED mappings. If the file itself contains a
>> trap instruction at the offset of a uprobe, executing it in such a VMA
>> will find the uprobe, and instead of delivering SIGTRAP, we let the task
>> loop on that trap instruction forever.
>>
>> Let's fix it by only considering VMAs managed by core mm, using
>> vma_is_mm_managed().
>>
>> Move the existing VMA flag checks in valid_vma() into a new helper
>> valid_vma_flags(), and call vma_is_mm_managed() from there.
>>
>> Then, check valid_vma() also in find_active_uprobe_rcu(), and
>> valid_vma_flags() in find_active_uprobe_speculative(), essentially
>> reverting 83e3dc9a5d4d.
>>
>> In valid_ref_ctr_vma(), only call vma_is_mm_managed(): using
>> valid_vma_flags() would be wrong as we don't need exec permissions.
>>
>> vma_is_mm_managed() refuses VM_PFNMAP and VM_MIXEDMAP mappings, which
>> covers VM_IO mappings as well for anything we would probe. For example,
>> remap_pfn_range() sets VM_IO together with VM_PFNMAP.
>>
>> This has low urgency and is likely not stable-worthy.
>>
>> Fixes: 2b1444983508 ("uprobes, mm, x86: Add the ability to install and remove uprobes breakpoints")
>> Fixes: 83e3dc9a5d4d ("uprobes: simplify find_active_uprobe_rcu() VMA checks")
>> Cc: Andrii Nakryiko <andrii@kernel.org>
>> Cc: Oleg Nesterov <oleg@redhat.com>
>> Reported-by: Chris Mason <mason@kernel.org>
>> Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
> 
> Looks good to me.
> 
> Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>

Thanks, I'll queue this once I have some more review on #2.

-- 
Cheers,

David

  reply	other threads:[~2026-12-01  9:36 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-28 22:15 [PATCH 0/2] mm: don't leak PFNs of CoW PFNMAP mappings to user space David Hildenbrand (Arm)
2026-11-28 22:15 ` [PATCH 1/2] uprobes: skip mappings not managed by core mm David Hildenbrand (Arm)
2026-11-29  2:26   ` + uprobes-skip-mappings-not-managed-by-core-mm.patch added to mm-new branch Andrew Morton
2026-12-01  0:42   ` [PATCH 1/2] uprobes: skip mappings not managed by core mm Masami Hiramatsu (Google)
2026-12-01  0:42     ` Masami Hiramatsu (Google)
2026-12-01  9:36     ` David Hildenbrand (Arm) [this message]
2026-12-01 20:41   ` [-] uprobes-skip-mappings-not-managed-by-core-mm.patch removed from -mm tree Andrew Morton
2026-11-28 22:15 ` [PATCH 2/2] mm/memory: store the PFN of CoW PFNMAP mappings in the anon page offset David Hildenbrand (Arm)
2026-11-29  2:26   ` + mm-memory-store-the-pfn-of-cow-pfnmap-mappings-in-the-anon-page-offset.patch added to mm-new branch Andrew Morton
2026-12-01 19:56     ` David Hildenbrand (Arm)
2026-12-01 18:25   ` [PATCH 2/2] mm/memory: store the PFN of CoW PFNMAP mappings in the anon page offset Lorenzo Stoakes (ARM)
2026-12-01 20:07     ` David Hildenbrand (Arm)
2026-12-01 20:01   ` [-] mm-memory-store-the-pfn-of-cow-pfnmap-mappings-in-the-anon-page-offset.patch removed from -mm tree Andrew Morton
2026-11-28 22:37 ` [PATCH 0/2] mm: don't leak PFNs of CoW PFNMAP mappings to user space sashiko-bot

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=a076b822-fb42-446f-b327-9ce020da9151@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.