Skip to content

Commit 6e48476

Browse files
samitolvanenIngo Molnar
authored andcommitted
syscalls/x86: Fix function types in COND_SYSCALL
Define a weak function in COND_SYSCALL instead of a weak alias to sys_ni_syscall(), which has an incompatible type. This fixes indirect call mismatches with Control-Flow Integrity (CFI) checking. Signed-off-by: Sami Tolvanen <[email protected]> Acked-by: Andy Lutomirski <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: H . Peter Anvin <[email protected]> Cc: Kees Cook <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent f48f01a commit 6e48476

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

arch/x86/include/asm/syscall_wrapper.h

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#ifndef _ASM_X86_SYSCALL_WRAPPER_H
77
#define _ASM_X86_SYSCALL_WRAPPER_H
88

9+
struct pt_regs;
10+
911
/* Mapping of registers to parameters for syscalls on x86-64 and x32 */
1012
#define SC_X86_64_REGS_TO_ARGS(x, ...) \
1113
__MAP(x,__SC_ARGS \
@@ -64,9 +66,15 @@
6466
SYSCALL_ALIAS(__ia32_sys_##sname, __x64_sys_##sname); \
6567
asmlinkage long __x64_sys_##sname(const struct pt_regs *__unused)
6668

67-
#define COND_SYSCALL(name) \
68-
cond_syscall(__x64_sys_##name); \
69-
cond_syscall(__ia32_sys_##name)
69+
#define COND_SYSCALL(name) \
70+
asmlinkage __weak long __x64_sys_##name(const struct pt_regs *__unused) \
71+
{ \
72+
return sys_ni_syscall(); \
73+
} \
74+
asmlinkage __weak long __ia32_sys_##name(const struct pt_regs *__unused)\
75+
{ \
76+
return sys_ni_syscall(); \
77+
}
7078

7179
#define SYS_NI(name) \
7280
SYSCALL_ALIAS(__x64_sys_##name, sys_ni_posix_timers); \
@@ -218,7 +226,11 @@
218226
#endif
219227

220228
#ifndef COND_SYSCALL
221-
#define COND_SYSCALL(name) cond_syscall(__x64_sys_##name)
229+
#define COND_SYSCALL(name) \
230+
asmlinkage __weak long __x64_sys_##name(const struct pt_regs *__unused) \
231+
{ \
232+
return sys_ni_syscall(); \
233+
}
222234
#endif
223235

224236
#ifndef SYS_NI
@@ -230,7 +242,6 @@
230242
* For VSYSCALLS, we need to declare these three syscalls with the new
231243
* pt_regs-based calling convention for in-kernel use.
232244
*/
233-
struct pt_regs;
234245
asmlinkage long __x64_sys_getcpu(const struct pt_regs *regs);
235246
asmlinkage long __x64_sys_gettimeofday(const struct pt_regs *regs);
236247
asmlinkage long __x64_sys_time(const struct pt_regs *regs);

0 commit comments

Comments
 (0)