From: Steven Rostedt <rostedt@goodmis.org>
To: David Laight <david.laight.linux@gmail.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
Linux Trace Kernel <linux-trace-kernel@vger.kernel.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
linux-mm@kvack.org, Kees Cook <keescook@chromium.org>,
Aleksa Sarai <cyphar@cyphar.com>,
Al Viro <viro@ZenIV.linux.org.uk>
Subject: Re: [PATCH] uaccess: Comment that copy to/from inatomic requires page fault disabled
Date: Mon, 15 Sep 2025 19:37:16 -0400 [thread overview]
Message-ID: <20250915193716.5357b448@gandalf.local.home> (raw)
In-Reply-To: <20250915164313.42644914@pumpkin>
On Mon, 15 Sep 2025 16:43:13 +0100
David Laight <david.laight.linux@gmail.com> wrote:
> > @@ -124,7 +130,8 @@ __copy_from_user(void *to, const void __user *from, unsigned long n)
> > * Copy data from kernel space to user space. Caller must check
> > * the specified block with access_ok() before calling this function.
> > * The caller should also make sure he pins the user space address
> > - * so that we don't result in page fault and sleep.
> > + * or call page_fault_disable() so that we don't result in a page fault
> > + * and sleep.
>
> It is worse than that - it must avoid a COW fault as well.
> I suspect the comment should really be that these are not the functions you
> are looking for, you probably want the 'nofault' variants.
>
> Even if the code thinks it has pinned the user buffer it has to be better
> to use the 'nofault' variant.
>
> The only exception might be in code that already has page faults disabled.
> But even then it would have to be pretty performance critical for normal code.
OK, perhaps just change the comments to state that this is an internal
version and should be avoided unless you know what you are doing. Otherwise
use the _nofault() versions.
-- Steve
prev parent reply other threads:[~2025-09-15 23:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-10 20:18 Steven Rostedt
2025-09-12 1:07 ` Masami Hiramatsu
2025-09-15 15:43 ` David Laight
2025-09-15 23:37 ` Steven Rostedt [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=20250915193716.5357b448@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=cyphar@cyphar.com \
--cc=david.laight.linux@gmail.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.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