aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Ellerman <mpe@ellerman.id.au>2015-07-23 06:21:01 -0400
committerMichael Ellerman <mpe@ellerman.id.au>2015-07-28 21:56:11 -0400
commitc3525940cca53cf3568fefd35d169fea4f107f0a (patch)
treeba6968be2c8b3914157f52ac05961c1e723913d6
parentf0322f7f1e2165fbf83530a424ef6ebeacbf4bca (diff)
powerpc/kernel: Switch to using MAX_ERRNO
Currently on powerpc we have our own #define for the highest (negative) errno value, called _LAST_ERRNO. This is defined to be 516, for reasons which are not clear. The generic code, and x86, use MAX_ERRNO, which is defined to be 4095. In particular seccomp uses MAX_ERRNO to restrict the value that a seccomp filter can return. Currently with the mismatch between _LAST_ERRNO and MAX_ERRNO, a seccomp tracer wanting to return 600, expecting it to be seen as an error, would instead find on powerpc that userspace sees a successful syscall with a return value of 600. To avoid this inconsistency, switch powerpc to use MAX_ERRNO. We are somewhat confident that generic syscalls that can return a non-error value above negative MAX_ERRNO have already been updated to use force_successful_syscall_return(). I have also checked all the powerpc specific syscalls, and believe that none of them expect to return a non-error value between -MAX_ERRNO and -516. So this change should be safe ... Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Reviewed-by: Kees Cook <keescook@chromium.org>
-rw-r--r--arch/powerpc/include/uapi/asm/errno.h2
-rw-r--r--arch/powerpc/kernel/entry_32.S3
-rw-r--r--arch/powerpc/kernel/entry_64.S5
3 files changed, 5 insertions, 5 deletions
diff --git a/arch/powerpc/include/uapi/asm/errno.h b/arch/powerpc/include/uapi/asm/errno.h
index 8c145fd17d86..e8b6b5f7de7c 100644
--- a/arch/powerpc/include/uapi/asm/errno.h
+++ b/arch/powerpc/include/uapi/asm/errno.h
@@ -6,6 +6,4 @@
6#undef EDEADLOCK 6#undef EDEADLOCK
7#define EDEADLOCK 58 /* File locking deadlock error */ 7#define EDEADLOCK 58 /* File locking deadlock error */
8 8
9#define _LAST_ERRNO 516
10
11#endif /* _ASM_POWERPC_ERRNO_H */ 9#endif /* _ASM_POWERPC_ERRNO_H */
diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S
index 46fc0f4d8982..67ecdf61f4e3 100644
--- a/arch/powerpc/kernel/entry_32.S
+++ b/arch/powerpc/kernel/entry_32.S
@@ -20,6 +20,7 @@
20 */ 20 */
21 21
22#include <linux/errno.h> 22#include <linux/errno.h>
23#include <linux/err.h>
23#include <linux/sys.h> 24#include <linux/sys.h>
24#include <linux/threads.h> 25#include <linux/threads.h>
25#include <asm/reg.h> 26#include <asm/reg.h>
@@ -354,7 +355,7 @@ ret_from_syscall:
354 SYNC 355 SYNC
355 MTMSRD(r10) 356 MTMSRD(r10)
356 lwz r9,TI_FLAGS(r12) 357 lwz r9,TI_FLAGS(r12)
357 li r8,-_LAST_ERRNO 358 li r8,-MAX_ERRNO
358 andi. r0,r9,(_TIF_SYSCALL_DOTRACE|_TIF_SINGLESTEP|_TIF_USER_WORK_MASK|_TIF_PERSYSCALL_MASK) 359 andi. r0,r9,(_TIF_SYSCALL_DOTRACE|_TIF_SINGLESTEP|_TIF_USER_WORK_MASK|_TIF_PERSYSCALL_MASK)
359 bne- syscall_exit_work 360 bne- syscall_exit_work
360 cmplw 0,r3,r8 361 cmplw 0,r3,r8
diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index 579e0f9a2d57..ee15d3c62e26 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -19,6 +19,7 @@
19 */ 19 */
20 20
21#include <linux/errno.h> 21#include <linux/errno.h>
22#include <linux/err.h>
22#include <asm/unistd.h> 23#include <asm/unistd.h>
23#include <asm/processor.h> 24#include <asm/processor.h>
24#include <asm/page.h> 25#include <asm/page.h>
@@ -207,7 +208,7 @@ system_call: /* label this so stack traces look sane */
207#endif /* CONFIG_PPC_BOOK3E */ 208#endif /* CONFIG_PPC_BOOK3E */
208 209
209 ld r9,TI_FLAGS(r12) 210 ld r9,TI_FLAGS(r12)
210 li r11,-_LAST_ERRNO 211 li r11,-MAX_ERRNO
211 andi. r0,r9,(_TIF_SYSCALL_DOTRACE|_TIF_SINGLESTEP|_TIF_USER_WORK_MASK|_TIF_PERSYSCALL_MASK) 212 andi. r0,r9,(_TIF_SYSCALL_DOTRACE|_TIF_SINGLESTEP|_TIF_USER_WORK_MASK|_TIF_PERSYSCALL_MASK)
212 bne- syscall_exit_work 213 bne- syscall_exit_work
213 cmpld r3,r11 214 cmpld r3,r11
@@ -277,7 +278,7 @@ syscall_exit_work:
277 beq+ 0f 278 beq+ 0f
278 REST_NVGPRS(r1) 279 REST_NVGPRS(r1)
279 b 2f 280 b 2f
2800: cmpld r3,r11 /* r10 is -LAST_ERRNO */ 2810: cmpld r3,r11 /* r11 is -MAX_ERRNO */
281 blt+ 1f 282 blt+ 1f
282 andi. r0,r9,_TIF_NOERROR 283 andi. r0,r9,_TIF_NOERROR
283 bne- 1f 284 bne- 1f