Skip to content

Commit 1e29ab3

Browse files
samitolvanenwildea01
authored andcommitted
arm64: use the correct function type for __arm64_sys_ni_syscall
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 <[email protected]> Signed-off-by: Will Deacon <[email protected]>
1 parent 0e358bd commit 1e29ab3

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

arch/arm64/kernel/sys.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,26 @@ SYSCALL_DEFINE1(arm64_personality, unsigned int, personality)
4747
return ksys_personality(personality);
4848
}
4949

50+
asmlinkage long sys_ni_syscall(void);
51+
52+
asmlinkage long __arm64_sys_ni_syscall(const struct pt_regs *__unused)
53+
{
54+
return sys_ni_syscall();
55+
}
56+
5057
/*
5158
* Wrappers to pass the pt_regs argument.
5259
*/
5360
#define __arm64_sys_personality __arm64_sys_arm64_personality
5461

55-
asmlinkage long sys_ni_syscall(const struct pt_regs *);
56-
#define __arm64_sys_ni_syscall sys_ni_syscall
57-
5862
#undef __SYSCALL
5963
#define __SYSCALL(nr, sym) asmlinkage long __arm64_##sym(const struct pt_regs *);
6064
#include <asm/unistd.h>
6165

6266
#undef __SYSCALL
63-
#define __SYSCALL(nr, sym) [nr] = (syscall_fn_t)__arm64_##sym,
67+
#define __SYSCALL(nr, sym) [nr] = __arm64_##sym,
6468

6569
const syscall_fn_t sys_call_table[__NR_syscalls] = {
66-
[0 ... __NR_syscalls - 1] = (syscall_fn_t)sys_ni_syscall,
70+
[0 ... __NR_syscalls - 1] = __arm64_sys_ni_syscall,
6771
#include <asm/unistd.h>
6872
};

arch/arm64/kernel/sys32.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,17 +133,14 @@ COMPAT_SYSCALL_DEFINE6(aarch32_fallocate, int, fd, int, mode,
133133
return ksys_fallocate(fd, mode, arg_u64(offset), arg_u64(len));
134134
}
135135

136-
asmlinkage long sys_ni_syscall(const struct pt_regs *);
137-
#define __arm64_sys_ni_syscall sys_ni_syscall
138-
139136
#undef __SYSCALL
140137
#define __SYSCALL(nr, sym) asmlinkage long __arm64_##sym(const struct pt_regs *);
141138
#include <asm/unistd32.h>
142139

143140
#undef __SYSCALL
144-
#define __SYSCALL(nr, sym) [nr] = (syscall_fn_t)__arm64_##sym,
141+
#define __SYSCALL(nr, sym) [nr] = __arm64_##sym,
145142

146143
const syscall_fn_t compat_sys_call_table[__NR_compat_syscalls] = {
147-
[0 ... __NR_compat_syscalls - 1] = (syscall_fn_t)sys_ni_syscall,
144+
[0 ... __NR_compat_syscalls - 1] = __arm64_sys_ni_syscall,
148145
#include <asm/unistd32.h>
149146
};

0 commit comments

Comments
 (0)