Re: [PATCH v2 07/12] tracing: Don't read user memory without an mm
From: Arnd Bergmann
Date: Wed Dec 02 2026 - 05:14:56 EST
On Wed, Dec 2, 2026, at 03:39, James Houghton wrote:
> Probe events (kprobe, eprobe and fprobe events) fetching user memory,
> event filters on user space strings (filter_pred_pchar_user()) and
> synthetic events with user space string fields can fire in any context,
> including kernel threads and tasks that have already gone through
> exit_mm(). There is no user memory to access there, so these accesses
> should simply fail.
>
> They currently call the user nofault helpers regardless. Without an mm,
> those don't reliably fail: the user half of the address space belongs
> to whatever mm happens to be lazily loaded, if any, so the event may
> record another task's memory.
>
> Check for a NULL current->mm before these accesses, and fail as if the
> access had faulted.
>
> A NULL mm here isn't a kernel bug, as these events don't choose the
> context they fire in, so this also keeps them from triggering the
> warning that a later patch in this series adds to the uaccess helpers.
>
> Each of these has read user memory without checking for an mm since it
> was added: user memory fetches in probe events in commit e65f7ae7f4da
> ("tracing/probe: Support user-space dereference") and commit
> 88903c464321 ("tracing/probe: Add ustring type for user-space string"),
> user space strings in event filters in commit 77360f9bbc7e ("tracing:
> Add test for user space strings when filtering on string pointers"),
> and user space strings in synthetic events in commit 0934ae9977c2
> ("tracing: Fix reading strings from synthetic events").
>
> Fixes: e65f7ae7f4da ("tracing/probe: Support user-space dereference")
> Fixes: 88903c464321 ("tracing/probe: Add ustring type for user-space
> string")
> Fixes: 77360f9bbc7e ("tracing: Add test for user space strings when
> filtering on string pointers")
> Fixes: 0934ae9977c2 ("tracing: Fix reading strings from synthetic
> events")
> Signed-off-by: James Houghton <jthoughton@xxxxxxxxxx>
Reviewed-by: Arnd Bergmann <arnd@xxxxxxxx>