From: Linus Torvalds Date: Mon, 9 Dec 2024 18:00:25 +0000 (-0800) Subject: futex: fix user access on powerpc X-Git-Tag: v6.13-rc3~47 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=32913f348229c9f72dda45fc2c08c6d9dfcd3d6d;p=thirdparty%2Fkernel%2Flinux.git futex: fix user access on powerpc The powerpc user access code is special, and unlike other architectures distinguishes between user access for reading and writing. And commit 43a43faf5376 ("futex: improve user space accesses") messed that up. It went undetected elsewhere, but caused ppc32 to fail early during boot, because the user access had been started with user_read_access_begin(), but then finished off with just a plain "user_access_end()". Note that the address-masking user access helpers don't even have that read-vs-write distinction, so if powerpc ever wants to do address masking tricks, we'll have to do some extra work for it. [ Make sure to also do it for the EFAULT case, as pointed out by Christophe Leroy ] Reported-by: Andreas Schwab Cc: Christophe Leroy Link: https://lore.kernel.org/all/87bjxl6b0i.fsf@igel.home/ Signed-off-by: Linus Torvalds --- diff --git a/kernel/futex/futex.h b/kernel/futex/futex.h index 618ce1fe870e9..99b32e728c4ad 100644 --- a/kernel/futex/futex.h +++ b/kernel/futex/futex.h @@ -265,11 +265,11 @@ static __always_inline int futex_read_inatomic(u32 *dest, u32 __user *from) else if (!user_read_access_begin(from, sizeof(*from))) return -EFAULT; unsafe_get_user(val, from, Efault); - user_access_end(); + user_read_access_end(); *dest = val; return 0; Efault: - user_access_end(); + user_read_access_end(); return -EFAULT; }