diff options
author | Michael Ellerman <mpe@ellerman.id.au> | 2015-07-23 06:21:06 -0400 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2015-07-28 21:56:13 -0400 |
commit | 1cb9839b73e7f2b006a1cc9452c30f15ff8b1748 (patch) | |
tree | 6e508e8421b0e55e3c7417e670ec7aa4a19a9bb6 | |
parent | a7657844296e796bf33922192743ddeacbcd4d7a (diff) |
powerpc: Use orig_gpr3 in syscall_get_arguments()
Currently syscall_get_arguments() is used by syscall tracepoints, and
collect_syscall() which is used in some debugging as well as
/proc/pid/syscall.
The current implementation just copies regs->gpr[3 .. 5] out, which is
fine for all the current use cases.
When we enable seccomp filter, that will also start using
syscall_get_arguments(). However for seccomp filter we want to use r3
as the return value of the syscall, and orig_gpr3 as the first
parameter. This will allow seccomp to modify the return value in r3.
To support this we need to modify syscall_get_arguments() to return
orig_gpr3 instead of r3. This is safe for all uses because orig_gpr3
always contains the r3 value that was passed to the syscall. We store it
in the syscall entry path and never modify it.
Update syscall_set_arguments() while we're here, even though it's never
used.
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Reviewed-by: Kees Cook <keescook@chromium.org>
-rw-r--r-- | arch/powerpc/include/asm/syscall.h | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/arch/powerpc/include/asm/syscall.h b/arch/powerpc/include/asm/syscall.h index 403e2303fe18..8d79a87c0511 100644 --- a/arch/powerpc/include/asm/syscall.h +++ b/arch/powerpc/include/asm/syscall.h | |||
@@ -64,7 +64,7 @@ static inline void syscall_get_arguments(struct task_struct *task, | |||
64 | unsigned int i, unsigned int n, | 64 | unsigned int i, unsigned int n, |
65 | unsigned long *args) | 65 | unsigned long *args) |
66 | { | 66 | { |
67 | unsigned long mask = -1UL; | 67 | unsigned long val, mask = -1UL; |
68 | 68 | ||
69 | BUG_ON(i + n > 6); | 69 | BUG_ON(i + n > 6); |
70 | 70 | ||
@@ -72,8 +72,14 @@ static inline void syscall_get_arguments(struct task_struct *task, | |||
72 | if (test_tsk_thread_flag(task, TIF_32BIT)) | 72 | if (test_tsk_thread_flag(task, TIF_32BIT)) |
73 | mask = 0xffffffff; | 73 | mask = 0xffffffff; |
74 | #endif | 74 | #endif |
75 | while (n--) | 75 | while (n--) { |
76 | args[n] = regs->gpr[3 + i + n] & mask; | 76 | if (n == 0 && i == 0) |
77 | val = regs->orig_gpr3; | ||
78 | else | ||
79 | val = regs->gpr[3 + i + n]; | ||
80 | |||
81 | args[n] = val & mask; | ||
82 | } | ||
77 | } | 83 | } |
78 | 84 | ||
79 | static inline void syscall_set_arguments(struct task_struct *task, | 85 | static inline void syscall_set_arguments(struct task_struct *task, |
@@ -83,6 +89,10 @@ static inline void syscall_set_arguments(struct task_struct *task, | |||
83 | { | 89 | { |
84 | BUG_ON(i + n > 6); | 90 | BUG_ON(i + n > 6); |
85 | memcpy(®s->gpr[3 + i], args, n * sizeof(args[0])); | 91 | memcpy(®s->gpr[3 + i], args, n * sizeof(args[0])); |
92 | |||
93 | /* Also copy the first argument into orig_gpr3 */ | ||
94 | if (i == 0 && n > 0) | ||
95 | regs->orig_gpr3 = args[0]; | ||
86 | } | 96 | } |
87 | 97 | ||
88 | static inline int syscall_get_arch(void) | 98 | static inline int syscall_get_arch(void) |