Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1186302
| From | Benjamin Herrenschmidt <benh@kernel.crashing.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [RFC PATCH 02/12] powerpc/kernel: Switch to using MAX_ERRNO |
| Date | 2015-07-17 00:50 +0200 |
| Message-ID | <pN08x-3AR-5@gated-at.bofh.it> (permalink) |
| References | <pMpsl-LG-3@gated-at.bofh.it> <pMpC2-X9-23@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Wed, 2015-07-15 at 17:37 +1000, Michael Ellerman wrote: > 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 ... > > Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> > --- > arch/powerpc/include/uapi/asm/errno.h | 2 -- > arch/powerpc/kernel/entry_32.S | 3 ++- > arch/powerpc/kernel/entry_64.S | 5 +++-- > 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 @@ > #undef EDEADLOCK > #define EDEADLOCK 58 /* File locking deadlock error */ > > -#define _LAST_ERRNO 516 > - > #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 @@ > */ > > #include <linux/errno.h> > +#include <linux/err.h> > #include <linux/sys.h> > #include <linux/threads.h> > #include <asm/reg.h> > @@ -354,7 +355,7 @@ ret_from_syscall: > SYNC > MTMSRD(r10) > lwz r9,TI_FLAGS(r12) > - li r8,-_LAST_ERRNO > + li r8,-MAX_ERRNO > andi. r0,r9,(_TIF_SYSCALL_DOTRACE|_TIF_SINGLESTEP|_TIF_USER_WORK_MASK|_TIF_PERSYSCALL_MASK) > bne- syscall_exit_work > cmplw 0,r3,r8 > diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S > index 0796c487d3db..8292581a42f1 100644 > --- a/arch/powerpc/kernel/entry_64.S > +++ b/arch/powerpc/kernel/entry_64.S > @@ -19,6 +19,7 @@ > */ > > #include <linux/errno.h> > +#include <linux/err.h> > #include <asm/unistd.h> > #include <asm/processor.h> > #include <asm/page.h> > @@ -207,7 +208,7 @@ system_call: /* label this so stack traces look sane */ > #endif /* CONFIG_PPC_BOOK3E */ > > ld r9,TI_FLAGS(r12) > - li r11,-_LAST_ERRNO > + li r11,-MAX_ERRNO > andi. r0,r9,(_TIF_SYSCALL_DOTRACE|_TIF_SINGLESTEP|_TIF_USER_WORK_MASK|_TIF_PERSYSCALL_MASK) > bne- syscall_exit_work > cmpld r3,r11 > @@ -279,7 +280,7 @@ syscall_exit_work: > beq+ 0f > REST_NVGPRS(r1) > b 2f > -0: cmpld r3,r11 /* r10 is -LAST_ERRNO */ > +0: cmpld r3,r11 /* r11 is -MAX_ERRNO */ > blt+ 1f > andi. r0,r9,_TIF_NOERROR > bne- 1f -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[RFC PATCH 01/12] powerpc/kernel: Get pt_regs from r9 before calling do_syscall_trace_enter() Michael Ellerman <mpe@ellerman.id.au> - 2015-07-15 09:40 +0200
[RFC PATCH 03/12] powerpc/kernel: Change the do_syscall_trace_enter() API Michael Ellerman <mpe@ellerman.id.au> - 2015-07-15 09:40 +0200
[RFC PATCH 11/12] selftests/seccomp: Make seccomp tests work on big endian Michael Ellerman <mpe@ellerman.id.au> - 2015-07-15 09:40 +0200
Re: [RFC PATCH 11/12] selftests/seccomp: Make seccomp tests work on big endian Kees Cook <keescook@chromium.org> - 2015-07-15 17:20 +0200
Re: [RFC PATCH 11/12] selftests/seccomp: Make seccomp tests work on big endian Michael Ellerman <mpe@ellerman.id.au> - 2015-07-16 05:50 +0200
[RFC PATCH 04/12] powerpc: Drop unused syscall_get_error() Michael Ellerman <mpe@ellerman.id.au> - 2015-07-15 09:40 +0200
[RFC PATCH 07/12] powerpc: Use orig_gpr3 in syscall_get_arguments() Michael Ellerman <mpe@ellerman.id.au> - 2015-07-15 09:40 +0200
[RFC PATCH 02/12] powerpc/kernel: Switch to using MAX_ERRNO Michael Ellerman <mpe@ellerman.id.au> - 2015-07-15 09:50 +0200
Re: [RFC PATCH 02/12] powerpc/kernel: Switch to using MAX_ERRNO Benjamin Herrenschmidt <benh@kernel.crashing.org> - 2015-07-17 00:50 +0200
Re: [RFC PATCH 01/12] powerpc/kernel: Get pt_regs from r9 before calling do_syscall_trace_enter() Benjamin Herrenschmidt <benh@kernel.crashing.org> - 2015-07-17 00:50 +0200
Re: [RFC PATCH 01/12] powerpc/kernel: Get pt_regs from r9 before calling do_syscall_trace_enter() Michael Ellerman <mpe@ellerman.id.au> - 2015-07-17 06:50 +0200
csiph-web