[PATCH] powerpc/signal32: Fix erroneous SIGSEGV on RT signal return

From: Christophe Leroy
Date: Fri Apr 23 2021 - 09:52:15 EST


Return of user_read_access_begin() is tested the wrong way,
leading to a SIGSEGV when the user address is valid and likely
an Oops when the user address is bad.

Fix the test.

Fixes: 887f3ceb51cd ("powerpc/signal32: Convert do_setcontext[_tm]() to user access block")
Signed-off-by: Christophe Leroy <christophe.leroy@xxxxxxxxxx>
---
arch/powerpc/kernel/signal_32.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
index fc41c58f0cbb..8f05ed0da292 100644
--- a/arch/powerpc/kernel/signal_32.c
+++ b/arch/powerpc/kernel/signal_32.c
@@ -967,7 +967,7 @@ static int do_setcontext(struct ucontext __user *ucp, struct pt_regs *regs, int
sigset_t set;
struct mcontext __user *mcp;

- if (user_read_access_begin(ucp, sizeof(*ucp)))
+ if (!user_read_access_begin(ucp, sizeof(*ucp)))
return -EFAULT;

unsafe_get_sigset_t(&set, &ucp->uc_sigmask, failed);
@@ -1005,7 +1005,7 @@ static int do_setcontext_tm(struct ucontext __user *ucp,
u32 cmcp;
u32 tm_cmcp;

- if (user_read_access_begin(ucp, sizeof(*ucp)))
+ if (!user_read_access_begin(ucp, sizeof(*ucp)))
return -EFAULT;

unsafe_get_sigset_t(&set, &ucp->uc_sigmask, failed);
--
2.25.0