aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Ellerman <mpe@ellerman.id.au>2015-07-23 06:21:07 -0400
committerMichael Ellerman <mpe@ellerman.id.au>2015-07-28 21:56:13 -0400
commite9fbe6863281b942d7eea44c6ccabc30f46ab44f (patch)
tree396596458f5ebfbbd4905117027920a2dfda3ee7
parent1cb9839b73e7f2b006a1cc9452c30f15ff8b1748 (diff)
powerpc: Change syscall_get_nr() to return int
The documentation for syscall_get_nr() in asm-generic says: Note this returns int even on 64-bit machines. Only 32 bits of system call number can be meaningful. If the actual arch value is 64 bits, this truncates to 32 bits so 0xffffffff means -1. However our implementation was never updated to reflect this. Generally it's not important, but there is once case where it matters. For seccomp filter with SECCOMP_RET_TRACE, the tracer will set regs->gpr[0] to -1 to reject the syscall. When the task is a compat task, this means we end up with 0xffffffff in r0 because ptrace will zero extend the 32-bit value. If syscall_get_nr() returns an unsigned long, then a 64-bit kernel will see a positive value in r0 and will incorrectly allow the syscall through seccomp. Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Reviewed-by: Kees Cook <keescook@chromium.org>
-rw-r--r--arch/powerpc/include/asm/syscall.h11
1 files changed, 8 insertions, 3 deletions
diff --git a/arch/powerpc/include/asm/syscall.h b/arch/powerpc/include/asm/syscall.h
index 8d79a87c0511..ab9f3f0a8637 100644
--- a/arch/powerpc/include/asm/syscall.h
+++ b/arch/powerpc/include/asm/syscall.h
@@ -22,10 +22,15 @@
22extern const unsigned long sys_call_table[]; 22extern const unsigned long sys_call_table[];
23#endif /* CONFIG_FTRACE_SYSCALLS */ 23#endif /* CONFIG_FTRACE_SYSCALLS */
24 24
25static inline long syscall_get_nr(struct task_struct *task, 25static inline int syscall_get_nr(struct task_struct *task, struct pt_regs *regs)
26 struct pt_regs *regs)
27{ 26{
28 return TRAP(regs) == 0xc00 ? regs->gpr[0] : -1L; 27 /*
28 * Note that we are returning an int here. That means 0xffffffff, ie.
29 * 32-bit negative 1, will be interpreted as -1 on a 64-bit kernel.
30 * This is important for seccomp so that compat tasks can set r0 = -1
31 * to reject the syscall.
32 */
33 return TRAP(regs) == 0xc00 ? regs->gpr[0] : -1;
29} 34}
30 35
31static inline void syscall_rollback(struct task_struct *task, 36static inline void syscall_rollback(struct task_struct *task,