Linux Trace Kernel
 help / color / mirror / Atom feed
From: "Arnd Bergmann" <arnd@arndb.de>
To: "James Houghton" <jthoughton@google.com>
Cc: "James E . J . Bottomley" <James.Bottomley@hansenpartnership.com>,
	"Arnaldo Carvalho de Melo" <acme@kernel.org>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"Pavel Begunkov" <asml.silence@gmail.com>,
	"Alexei Starovoitov" <ast@kernel.org>,
	"Jens Axboe" <axboe@kernel.dk>,
	bpf@vger.kernel.org, "Daniel Borkmann" <daniel@iogearbox.net>,
	"David Hildenbrand (Red Hat)" <david@kernel.org>,
	"David Sterba" <dsterba@suse.com>,
	io-uring@vger.kernel.org, "Jim Mattson" <jmattson@google.com>,
	"John Fastabend" <john.fastabend@gmail.com>,
	"Josh Poimboeuf" <jpoimboe@kernel.org>,
	"Kees Cook" <kees@kernel.org>,
	kvm@vger.kernel.org, "Liam R. Howlett" <liam@infradead.org>,
	linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	linux-perf-users@vger.kernel.org, linux-scsi@vger.kernel.org,
	linux-trace-kernel@vger.kernel.org,
	"Lorenzo Stoakes" <ljs@kernel.org>,
	"Chris Mason" <mason@kernel.org>,
	"Mathieu Desnoyers" <mathieu.desnoyers@efficios.com>,
	"Masami Hiramatsu" <mhiramat@kernel.org>,
	"Michal Hocko" <mhocko@suse.com>,
	"Ingo Molnar" <mingo@redhat.com>,
	"Martin K. Petersen" <mkp@kernel.org>,
	"Namhyung Kim" <namhyung@kernel.org>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Peter Zijlstra" <peterz@infradead.org>,
	"Steven Rostedt" <rostedt@goodmis.org>,
	"Mike Rapoport" <rppt@kernel.org>,
	"Sean Christopherson" <seanjc@google.com>,
	"Suren Baghdasaryan" <surenb@google.com>,
	"Thomas Gleixner" <tglx@kernel.org>,
	"Vlastimil Babka (SUSE)" <vbabka@kernel.org>,
	"Alexander Viro" <viro@zeniv.linux.org.uk>
Subject: Re: [RFC PATCH 00/10] uaccess: Refuse and warn on user accesses when current->mm is NULL
Date: Tue, 24 Nov 2026 23:01:51 +0100	[thread overview]
Message-ID: <1a99e5fc-129e-41e3-8420-101bcf04b366@app.fastmail.com> (raw)
In-Reply-To: <CADrL8HX5vb1PGDpWzp-eR0rNfsMCVUhFa9vp_WZZx2eJZ+dfXQ@mail.gmail.com>

On Tue, Nov 24, 2026, at 22:10, James Houghton wrote:
> On Wed, Oct 28, 2026 at 7:14 PM Arnd Bergmann <arnd@arndb.de> wrote:
>> On Wed, Oct 28, 2026, at 00:17, James Houghton wrote:

> So now in v2, the _nofault() helpers themselves do not check current->mm.
>
> I've uploaded a draft version of v2 here, in case you want to take a look:
>   https://github.com/48ca/linux uaccess-v2-wip

I read through this now and it all looks good to me so far.

>> Since in principle every user access should go through both
>> access_ok/mask_user_address and current->mm check at some point,
>> so combining the two as much as possible should help long-term
>> maintainability.
>
> You're right, and v2 has been restructured like this.
>
> - The check is in access_ok() itself: the generic version, plus the
> arm64 and riscv versions. __access_ok() remains a plain range check.
> - The callers of mask_user_address()/masked_user_*_access_begin()
> check current->mm explicitly. There are about a dozen such callers.
> - The unchecked accessors, __copy_{from,to}_user()
> and__copy_{from,to}_user_inatomic() (and arm64's
> copy_from_user_flushcache(), which also relies on an earlier
> access_ok()), keep an explicit check for now. Once their users are
> converted to the checked versions, those checks can be dropped.

Ok, sounds all good. If we get more than handful of mask_user_address()
and masked_user_*_access_begin(), we can always revisit that interface
to make sure the check can't be skipped, but for now this seems
like a good tradeoff.

> Compared to v1, this also covers get_user()/put_user()/clear_user() on
> arm64, powerpc, riscv and the asm-generic architectures, and arch code
> like signal frame setup that uses access_ok() followed by __put_user()
> or unsafe_*(). user_access_begin() no longer needs its own check.
>
> What's still not covered: x86's get_user()/put_user(), which do their
> own range check in asm, a few architecture-specific paths that call
> __access_ok() directly (e.g. on alpha and sparc32), and arch code that
> calls __get_user()/__put_user() without access_ok(), mostly trap
> handlers for user-mode faults. Probably best tackled later.

ok

>> There are probably few enough of these that we could address them
>> by either adding current->mm checks or converting them to use
>> the full versions instead where that is an obvious change like
>> that usb gadget driver.
>
> Sounds good. I'll send a separate series converting the obvious ones,
> starting with the usb gadget driver. I think that will be useful.
> Let's see how far I can get; hopefully I can drop
> __copy_{from,to}_user() completely.

Ok, perfect!

      Arnd

      reply	other threads:[~2026-11-24 22:02 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-26 21:52 [RFC PATCH 00/10] uaccess: Refuse and warn on user accesses when current->mm is NULL James Houghton
2026-10-26 21:52 ` [RFC PATCH 01/10] scsi: bsg: Don't copy sense data to user memory when canceled James Houghton
2026-10-27  2:41   ` Jens Axboe
2026-10-27 17:52     ` James Houghton
2026-11-04  3:39   ` Martin K. Petersen
2026-10-26 21:52 ` [RFC PATCH 02/10] btrfs: Don't copy encoded read " James Houghton
2026-10-27  2:42   ` Jens Axboe
2026-10-26 21:52 ` [RFC PATCH 03/10] bpf: Fail sleepable user copy helpers when current->mm is NULL James Houghton
2026-10-26 22:30   ` bot+bpf-ci
2026-10-27 18:50     ` James Houghton
2026-10-26 21:52 ` [RFC PATCH 04/10] stacktrace: Don't unwind the user stack without an mm James Houghton
2026-10-26 22:30   ` bot+bpf-ci
2026-10-26 22:55     ` James Houghton
2026-10-26 21:52 ` [RFC PATCH 05/10] perf/core: " James Houghton
2026-10-27 11:09   ` Peter Zijlstra
2026-10-27 17:45     ` James Houghton
2026-10-26 21:52 ` [RFC PATCH 06/10] uaccess: Refuse and warn on user copies when current->mm is NULL James Houghton
2026-10-26 22:42   ` bot+bpf-ci
2026-10-26 23:41     ` James Houghton
2026-10-26 21:52 ` [RFC PATCH 07/10] uaccess: Fail user nofault helpers quietly " James Houghton
2026-10-26 21:52 ` [RFC PATCH 08/10] uaccess: Refuse and warn on __copy_from_user_inatomic() without an mm James Houghton
2026-10-26 22:30   ` bot+bpf-ci
2026-10-26 22:41     ` James Houghton
2026-10-26 21:52 ` [RFC PATCH 09/10] uaccess: Refuse and warn on more user accesses " James Houghton
2026-10-26 21:52 ` [RFC PATCH 10/10] uaccess: Move the NULL mm warning out of line James Houghton
2026-10-26 23:02   ` Arnd Bergmann
2026-10-26 23:51     ` James Houghton
2026-10-27  0:12 ` [RFC PATCH 00/10] uaccess: Refuse and warn on user accesses when current->mm is NULL Arnd Bergmann
2026-10-27 10:33   ` Arnd Bergmann
2026-10-27 17:29   ` James Houghton
2026-10-27 18:32     ` Arnd Bergmann
2026-10-27 21:18       ` Sean Christopherson
2026-10-27 23:17       ` James Houghton
2026-10-28 23:13         ` Arnd Bergmann
2026-11-24 21:10           ` James Houghton
2026-11-24 22:01             ` Arnd Bergmann [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=1a99e5fc-129e-41e3-8420-101bcf04b366@app.fastmail.com \
    --to=arnd@arndb.de \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=acme@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=asml.silence@gmail.com \
    --cc=ast@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=david@kernel.org \
    --cc=dsterba@suse.com \
    --cc=io-uring@vger.kernel.org \
    --cc=jmattson@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jpoimboe@kernel.org \
    --cc=jthoughton@google.com \
    --cc=kees@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=liam@infradead.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=ljs@kernel.org \
    --cc=mason@kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=mhocko@suse.com \
    --cc=mingo@redhat.com \
    --cc=mkp@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=rppt@kernel.org \
    --cc=seanjc@google.com \
    --cc=surenb@google.com \
    --cc=tglx@kernel.org \
    --cc=vbabka@kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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