Commit b1b4fad5 authored by Matt Redfearn's avatar Matt Redfearn Committed by Ralf Baechle

MIPS: seccomp: Support compat with both O32 and N32

Previously the seccomp would only support strict mode on O32 userland
programs when the kernel had support for both O32 and N32 ABIs. Remove
kludge and support both ABIs.

With this patch in place, the seccomp_bpf self test now passes
global.mode_strict_support with N32 userland.
Suggested-by: default avatarPaul Burton <paul.burton@imgtec.com>
Signed-off-by: default avatarMatt Redfearn <matt.redfearn@imgtec.com>
Acked-by: default avatarKees Cook <keescook@chromium.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: IMG-MIPSLinuxKerneldevelopers@imgtec.com
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/12917/Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
parent c983f0e8
...@@ -2,27 +2,32 @@ ...@@ -2,27 +2,32 @@
#include <linux/unistd.h> #include <linux/unistd.h>
/* #ifdef CONFIG_COMPAT
* Kludge alert: static inline const int *get_compat_mode1_syscalls(void)
* {
* The generic seccomp code currently allows only a single compat ABI. Until static const int syscalls_O32[] = {
* this is fixed we priorize O32 as the compat ABI over N32. __NR_O32_Linux + 3, __NR_O32_Linux + 4,
*/ __NR_O32_Linux + 1, __NR_O32_Linux + 193,
#ifdef CONFIG_MIPS32_O32 0, /* null terminated */
};
#define __NR_seccomp_read_32 4003 static const int syscalls_N32[] = {
#define __NR_seccomp_write_32 4004 __NR_N32_Linux + 0, __NR_N32_Linux + 1,
#define __NR_seccomp_exit_32 4001 __NR_N32_Linux + 58, __NR_N32_Linux + 211,
#define __NR_seccomp_sigreturn_32 4193 /* rt_sigreturn */ 0, /* null terminated */
};
#elif defined(CONFIG_MIPS32_N32)
if (config_enabled(CONFIG_MIPS32_O32) && test_thread_flag(TIF_32BIT_REGS))
#define __NR_seccomp_read_32 6000 return syscalls_O32;
#define __NR_seccomp_write_32 6001
#define __NR_seccomp_exit_32 6058 if (config_enabled(CONFIG_MIPS32_N32))
#define __NR_seccomp_sigreturn_32 6211 /* rt_sigreturn */ return syscalls_N32;
#endif /* CONFIG_MIPS32_O32 */ BUG();
}
#define get_compat_mode1_syscalls get_compat_mode1_syscalls
#endif /* CONFIG_COMPAT */
#include <asm-generic/seccomp.h> #include <asm-generic/seccomp.h>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment