Skip to content

Commit

Permalink
MIPS: ptrace: Fix regs_return_value for kernel context
Browse files Browse the repository at this point in the history
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: d7e7528 ("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
Cc: stable@vger.kernel.org # 3.3+
Patchwork: https://patchwork.linux-mips.org/patch/14381/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
  • Loading branch information
Marcin Nowakowski authored and Ralf Baechle committed Oct 12, 2016
1 parent 9445622 commit 74f1077
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion arch/mips/include/asm/ptrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,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];
Expand Down

0 comments on commit 74f1077

Please sign in to comment.