Skip to content

Commit cf3b83e

Browse files
amlutoIngo Molnar
authored andcommitted
syscalls/x86: Wire up COMPAT_SYSCALL_DEFINE0
x86 has special handling for COMPAT_SYSCALL_DEFINEx, but there was no override for COMPAT_SYSCALL_DEFINE0. Wire it up so that we can use it for rt_sigreturn. Signed-off-by: Andy Lutomirski <[email protected]> Signed-off-by: Sami Tolvanen <[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 8661d76 commit cf3b83e

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

arch/x86/include/asm/syscall_wrapper.h

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,21 @@
2828
* kernel/sys_ni.c and SYS_NI in kernel/time/posix-stubs.c to cover this
2929
* case as well.
3030
*/
31+
#define __IA32_COMPAT_SYS_STUB0(x, name) \
32+
asmlinkage long __ia32_compat_sys_##name(const struct pt_regs *regs);\
33+
ALLOW_ERROR_INJECTION(__ia32_compat_sys_##name, ERRNO); \
34+
asmlinkage long __ia32_compat_sys_##name(const struct pt_regs *regs)\
35+
{ \
36+
return __se_compat_sys_##name(); \
37+
}
38+
3139
#define __IA32_COMPAT_SYS_STUBx(x, name, ...) \
3240
asmlinkage long __ia32_compat_sys##name(const struct pt_regs *regs);\
3341
ALLOW_ERROR_INJECTION(__ia32_compat_sys##name, ERRNO); \
3442
asmlinkage long __ia32_compat_sys##name(const struct pt_regs *regs)\
3543
{ \
3644
return __se_compat_sys##name(SC_IA32_REGS_TO_ARGS(x,__VA_ARGS__));\
37-
} \
45+
}
3846

3947
#define __IA32_SYS_STUBx(x, name, ...) \
4048
asmlinkage long __ia32_sys##name(const struct pt_regs *regs); \
@@ -76,15 +84,24 @@
7684
* of the x86-64-style parameter ordering of x32 syscalls. The syscalls common
7785
* with x86_64 obviously do not need such care.
7886
*/
87+
#define __X32_COMPAT_SYS_STUB0(x, name, ...) \
88+
asmlinkage long __x32_compat_sys_##name(const struct pt_regs *regs);\
89+
ALLOW_ERROR_INJECTION(__x32_compat_sys_##name, ERRNO); \
90+
asmlinkage long __x32_compat_sys_##name(const struct pt_regs *regs)\
91+
{ \
92+
return __se_compat_sys_##name();\
93+
}
94+
7995
#define __X32_COMPAT_SYS_STUBx(x, name, ...) \
8096
asmlinkage long __x32_compat_sys##name(const struct pt_regs *regs);\
8197
ALLOW_ERROR_INJECTION(__x32_compat_sys##name, ERRNO); \
8298
asmlinkage long __x32_compat_sys##name(const struct pt_regs *regs)\
8399
{ \
84100
return __se_compat_sys##name(SC_X86_64_REGS_TO_ARGS(x,__VA_ARGS__));\
85-
} \
101+
}
86102

87103
#else /* CONFIG_X86_X32 */
104+
#define __X32_COMPAT_SYS_STUB0(x, name)
88105
#define __X32_COMPAT_SYS_STUBx(x, name, ...)
89106
#endif /* CONFIG_X86_X32 */
90107

@@ -95,6 +112,17 @@
95112
* mapping of registers to parameters, we need to generate stubs for each
96113
* of them.
97114
*/
115+
#define COMPAT_SYSCALL_DEFINE0(name) \
116+
static long __se_compat_sys_##name(void); \
117+
static inline long __do_compat_sys_##name(void); \
118+
__IA32_COMPAT_SYS_STUB0(x, name) \
119+
__X32_COMPAT_SYS_STUB0(x, name) \
120+
static long __se_compat_sys_##name(void) \
121+
{ \
122+
return __do_compat_sys_##name(); \
123+
} \
124+
static inline long __do_compat_sys_##name(void)
125+
98126
#define COMPAT_SYSCALL_DEFINEx(x, name, ...) \
99127
static long __se_compat_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \
100128
static inline long __do_compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__));\

0 commit comments

Comments
 (0)