mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-06 05:13:18 +00:00
fe4bfff86e
The terminator for the mode 1 syscalls list was a 0, but that could be a valid syscall number (e.g. x86_64 __NR_read). By luck, __NR_read was listed first and the loop construct would not test it, so there was no bug. However, this is fragile. Replace the terminator with -1 instead, and make the variable name for mode 1 syscall lists more descriptive. Cc: Andy Lutomirski <luto@amacapital.net> Cc: Will Drewry <wad@chromium.org> Signed-off-by: Kees Cook <keescook@chromium.org>
36 lines
810 B
C
36 lines
810 B
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef __ASM_SECCOMP_H
|
|
|
|
#include <linux/unistd.h>
|
|
|
|
#ifdef CONFIG_COMPAT
|
|
static inline const int *get_compat_mode1_syscalls(void)
|
|
{
|
|
static const int syscalls_O32[] = {
|
|
__NR_O32_Linux + 3, __NR_O32_Linux + 4,
|
|
__NR_O32_Linux + 1, __NR_O32_Linux + 193,
|
|
-1, /* negative terminated */
|
|
};
|
|
static const int syscalls_N32[] = {
|
|
__NR_N32_Linux + 0, __NR_N32_Linux + 1,
|
|
__NR_N32_Linux + 58, __NR_N32_Linux + 211,
|
|
-1, /* negative terminated */
|
|
};
|
|
|
|
if (IS_ENABLED(CONFIG_MIPS32_O32) && test_thread_flag(TIF_32BIT_REGS))
|
|
return syscalls_O32;
|
|
|
|
if (IS_ENABLED(CONFIG_MIPS32_N32))
|
|
return syscalls_N32;
|
|
|
|
BUG();
|
|
}
|
|
|
|
#define get_compat_mode1_syscalls get_compat_mode1_syscalls
|
|
|
|
#endif /* CONFIG_COMPAT */
|
|
|
|
#include <asm-generic/seccomp.h>
|
|
|
|
#endif /* __ASM_SECCOMP_H */
|