From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: Thomas Gleixner <tglx@linutronix.de>,
LKML <linux-kernel@vger.kernel.org>
Cc: "Linus Torvalds" <torvalds@linux-foundation.org>,
"Mathieu Desnoyers" <mathieu.desnoyers@efficios.com>,
x86@kernel.org, "Peter Zijlstra" <peterz@infradead.org>,
"Darren Hart" <dvhart@infradead.org>,
"Davidlohr Bueso" <dave@stgolabs.net>,
"André Almeida" <andrealmeid@igalia.com>,
"Alexander Viro" <viro@zeniv.linux.org.uk>,
"Christian Brauner" <brauner@kernel.org>,
"Jan Kara" <jack@suse.cz>,
linux-fsdevel@vger.kernel.org
Subject: Re: [patch 3/4] x86/futex: Use user_*_masked_begin()
Date: Tue, 26 Aug 2025 09:09:08 +0200 [thread overview]
Message-ID: <288844da-400f-46f8-aa12-e0309424fb14@csgroup.eu> (raw)
In-Reply-To: <20250813151939.729465198@linutronix.de>
Le 13/08/2025 à 17:57, Thomas Gleixner a écrit :
> Replace the can_do_masked_user_access() conditional with the generic macro.
>
> No functional change.
>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: x86@kernel.org
> ---
> arch/x86/include/asm/futex.h | 12 ++++--------
> 1 file changed, 4 insertions(+), 8 deletions(-)
>
> --- a/arch/x86/include/asm/futex.h
> +++ b/arch/x86/include/asm/futex.h
> @@ -48,9 +48,7 @@ do { \
> static __always_inline int arch_futex_atomic_op_inuser(int op, int oparg, int *oval,
> u32 __user *uaddr)
> {
> - if (can_do_masked_user_access())
> - uaddr = masked_user_access_begin(uaddr);
> - else if (!user_access_begin(uaddr, sizeof(u32)))
> + if (!user_write_masked_begin(uaddr))
You are replacing a user_access_begin() by a macro that calls
user_write_access_begin(). I means that reads will not be allowed,
allthough arch_futex_atomic_op_inuser() performs read-then-write, so it
requires a full read-write user access.
> return -EFAULT;
>
> switch (op) {
> @@ -74,7 +72,7 @@ static __always_inline int arch_futex_at
> user_access_end();
> return -ENOSYS;
> }
> - user_access_end();
> + user_write_access_end();
Same, can't be changed to write-only, read permission is required as well.
> return 0;
> Efault:
> user_access_end();
> @@ -86,9 +84,7 @@ static inline int futex_atomic_cmpxchg_i
> {
> int ret = 0;
>
> - if (can_do_masked_user_access())
> - uaddr = masked_user_access_begin(uaddr);
> - else if (!user_access_begin(uaddr, sizeof(u32)))
> + if (!user_write_masked_begin(uaddr))
Same, read access is also needed.
> return -EFAULT;
> asm volatile("\n"
> "1:\t" LOCK_PREFIX "cmpxchgl %3, %2\n"
> @@ -98,7 +94,7 @@ static inline int futex_atomic_cmpxchg_i
> : "r" (newval), "1" (oldval)
> : "memory"
> );
> - user_access_end();
> + user_write_access_end();
Same, read access is also needed.
> *uval = oldval;
> return ret;
> }
>
>
next prev parent reply other threads:[~2025-08-26 7:20 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-13 15:57 [patch 0/4] uaccess: Provide and use helpers for user masked access Thomas Gleixner
2025-08-13 15:57 ` [patch 1/4] uaccess: Provide common helpers for masked user access Thomas Gleixner
2025-08-26 7:04 ` Christophe Leroy
2025-09-13 18:01 ` Thomas Gleixner
2025-08-13 15:57 ` [patch 2/4] futex: Convert to get/put_user_masked_u32() Thomas Gleixner
2025-08-13 15:57 ` [patch 3/4] x86/futex: Use user_*_masked_begin() Thomas Gleixner
2025-08-26 7:09 ` Christophe Leroy [this message]
2025-08-13 15:57 ` [patch 4/4] select: Use user_read_masked_begin() Thomas Gleixner
2025-08-17 13:49 ` [patch 0/4] uaccess: Provide and use helpers for user masked access David Laight
2025-08-17 14:00 ` Linus Torvalds
2025-08-17 15:29 ` David Laight
2025-08-17 15:36 ` Linus Torvalds
2025-08-18 11:59 ` David Laight
2025-08-18 21:21 ` David Laight
2025-08-18 21:36 ` Linus Torvalds
2025-08-18 22:21 ` Al Viro
2025-08-18 23:00 ` Linus Torvalds
2025-08-19 0:39 ` Al Viro
2025-08-20 23:48 ` Al Viro
2025-08-21 7:45 ` Christian Brauner
2025-08-21 22:49 ` Al Viro
2025-08-19 2:39 ` Matthew Wilcox
2025-08-19 21:33 ` David Laight
2025-08-19 4:44 ` Thomas Weißschuh
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=288844da-400f-46f8-aa12-e0309424fb14@csgroup.eu \
--to=christophe.leroy@csgroup.eu \
--cc=andrealmeid@igalia.com \
--cc=brauner@kernel.org \
--cc=dave@stgolabs.net \
--cc=dvhart@infradead.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=viro@zeniv.linux.org.uk \
--cc=x86@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®