MIPS: ptrace: Fix regs_return_value for kernel context
authorMarcin Nowakowski <marcin.nowakowski@imgtec.com>
Wed, 12 Oct 2016 07:32:56 +0000 (09:32 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 6 Feb 2017 22:32:55 +0000 (23:32 +0100)
commit 74f1077b5b783e7bf4fa3007cefdc8dbd6c07518 upstream.

Currently regs_return_value always negates reg[2] if it determines
the syscall has failed, but when called in kernel context this check is
invalid and may result in returning a wrong value.

This fixes errors reported by CONFIG_KPROBES_SANITY_TEST

Fixes: d7e7528bcd45 ("Audit: push audit success and retcode into arch ptrace.h")
Signed-off-by: Marcin Nowakowski <marcin.nowakowski@imgtec.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/14381/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Willy Tarreau <w@1wt.eu>
arch/mips/include/asm/ptrace.h

index 5e6cd0947393295ea87cba5191c5a6fbf728c527..a288de2199d8e4a419ef0a83d5edc4aad5358196 100644 (file)
@@ -73,7 +73,7 @@ static inline int is_syscall_success(struct pt_regs *regs)
 
 static inline long regs_return_value(struct pt_regs *regs)
 {
-       if (is_syscall_success(regs))
+       if (is_syscall_success(regs) || !user_mode(regs))
                return regs->regs[2];
        else
                return -regs->regs[2];