Skip to content

Commit

Permalink
seccomp: Get compat syscalls from asm-generic header
Browse files Browse the repository at this point in the history
Move retrieval of compat syscall numbers into inline function defined in
asm-generic header so that arches may override it.

[[email protected]: Resolve merge conflict.]

Suggested-by: Paul Burton <[email protected]>
Signed-off-by: Matt Redfearn <[email protected]>
Acked-by: Kees Cook <[email protected]>
Cc: [email protected]
Cc: Arnd Bergmann <[email protected]>
Cc: Andy Lutomirski <[email protected]>
Cc: Will Drewry <[email protected]>
Cc: [email protected]
Cc: [email protected]
Patchwork: https://patchwork.linux-mips.org/patch/12978/
Signed-off-by: Ralf Baechle <[email protected]>
  • Loading branch information
mpredfearn authored and ralfbaechle committed May 13, 2016
1 parent a400bed commit c983f0e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
14 changes: 14 additions & 0 deletions include/asm-generic/seccomp.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,18 @@
#define __NR_seccomp_sigreturn __NR_rt_sigreturn
#endif

#ifdef CONFIG_COMPAT
#ifndef get_compat_mode1_syscalls
static inline const int *get_compat_mode1_syscalls(void)
{
static const int mode1_syscalls_32[] = {
__NR_seccomp_read_32, __NR_seccomp_write_32,
__NR_seccomp_exit_32, __NR_seccomp_sigreturn_32,
0, /* null terminated */
};
return mode1_syscalls_32;
}
#endif
#endif /* CONFIG_COMPAT */

#endif /* _ASM_GENERIC_SECCOMP_H */
9 changes: 1 addition & 8 deletions kernel/seccomp.c
Original file line number Diff line number Diff line change
Expand Up @@ -518,19 +518,12 @@ static int mode1_syscalls[] = {
0, /* null terminated */
};

#ifdef CONFIG_COMPAT
static int mode1_syscalls_32[] = {
__NR_seccomp_read_32, __NR_seccomp_write_32, __NR_seccomp_exit_32, __NR_seccomp_sigreturn_32,
0, /* null terminated */
};
#endif

static void __secure_computing_strict(int this_syscall)
{
int *syscall_whitelist = mode1_syscalls;
#ifdef CONFIG_COMPAT
if (in_compat_syscall())
syscall_whitelist = mode1_syscalls_32;
syscall_whitelist = get_compat_mode1_syscalls();
#endif
do {
if (*syscall_whitelist == this_syscall)
Expand Down

0 comments on commit c983f0e

Please sign in to comment.