Re: [PATCH v2 06/12] bpf: Don't read user memory without an mm in tracing helpers

From: Arnd Bergmann

Date: Wed Dec 02 2026 - 08:03:15 EST


On Wed, Dec 2, 2026, at 05:07, Alexei Starovoitov wrote:
> On Tue, Dec 01, 2026 at 06:39 PM James Houghton <jthoughton@xxxxxxxxxx> wrote:
>> + /*
>> + * Tracing programs may run in any context, including kernel threads
>> + * and exiting tasks, which have no user memory to read. That's not a
>> + * kernel bug, so fail before the user copy helpers warn about it.
>> + */
>> + if (unlikely(!current->mm))
>> + ret = -EFAULT;
>> + else
>> + ret = copy_from_user_nofault(dst, unsafe_ptr, size);
>
> The nofault helpers exist for callers that run in any context.
> v1 had the check inside the helpers. That was the right place.
> Nack to v2.

Looking through it all again, I agree with this now, as it simplifies
the rules. If {copy_from,strncpy_from,strnlen}_user_nofault()
silently fail on !current->mm, a couple of patches in this series
are no longer needed, and James has checked the remaining users
for correctness.

Arnd