arm64: use the correct function type for __arm64_sys_ni_syscall
authorSami Tolvanen <samitolvanen@google.com>
Fri, 24 May 2019 22:11:18 +0000 (15:11 -0700)
committerWill Deacon <will.deacon@arm.com>
Wed, 29 May 2019 12:46:00 +0000 (13:46 +0100)
Calling sys_ni_syscall through a syscall_fn_t pointer trips indirect
call Control-Flow Integrity checking due to a function type
mismatch. Use SYSCALL_DEFINE0 for __arm64_sys_ni_syscall instead and
remove the now unnecessary casts.

Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
arch/arm64/kernel/sys.c
arch/arm64/kernel/sys32.c

index 162a95ed088138d8d4f114dc1e56df467ce82089..fe20c461582a1ecdc9d60224e5f8fae37a3aaf33 100644 (file)
@@ -47,22 +47,26 @@ SYSCALL_DEFINE1(arm64_personality, unsigned int, personality)
        return ksys_personality(personality);
 }
 
+asmlinkage long sys_ni_syscall(void);
+
+asmlinkage long __arm64_sys_ni_syscall(const struct pt_regs *__unused)
+{
+       return sys_ni_syscall();
+}
+
 /*
  * Wrappers to pass the pt_regs argument.
  */
 #define __arm64_sys_personality                __arm64_sys_arm64_personality
 
-asmlinkage long sys_ni_syscall(const struct pt_regs *);
-#define __arm64_sys_ni_syscall sys_ni_syscall
-
 #undef __SYSCALL
 #define __SYSCALL(nr, sym)     asmlinkage long __arm64_##sym(const struct pt_regs *);
 #include <asm/unistd.h>
 
 #undef __SYSCALL
-#define __SYSCALL(nr, sym)     [nr] = (syscall_fn_t)__arm64_##sym,
+#define __SYSCALL(nr, sym)     [nr] = __arm64_##sym,
 
 const syscall_fn_t sys_call_table[__NR_syscalls] = {
-       [0 ... __NR_syscalls - 1] = (syscall_fn_t)sys_ni_syscall,
+       [0 ... __NR_syscalls - 1] = __arm64_sys_ni_syscall,
 #include <asm/unistd.h>
 };
index 0f8bcb7de70086edecc3da67b70b8a126f28ded7..3c80a40c1c9d6d1a8e933e842fdec45d55d2d959 100644 (file)
@@ -133,17 +133,14 @@ COMPAT_SYSCALL_DEFINE6(aarch32_fallocate, int, fd, int, mode,
        return ksys_fallocate(fd, mode, arg_u64(offset), arg_u64(len));
 }
 
-asmlinkage long sys_ni_syscall(const struct pt_regs *);
-#define __arm64_sys_ni_syscall sys_ni_syscall
-
 #undef __SYSCALL
 #define __SYSCALL(nr, sym)     asmlinkage long __arm64_##sym(const struct pt_regs *);
 #include <asm/unistd32.h>
 
 #undef __SYSCALL
-#define __SYSCALL(nr, sym)     [nr] = (syscall_fn_t)__arm64_##sym,
+#define __SYSCALL(nr, sym)     [nr] = __arm64_##sym,
 
 const syscall_fn_t compat_sys_call_table[__NR_compat_syscalls] = {
-       [0 ... __NR_compat_syscalls - 1] = (syscall_fn_t)sys_ni_syscall,
+       [0 ... __NR_compat_syscalls - 1] = __arm64_sys_ni_syscall,
 #include <asm/unistd32.h>
 };