aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/compat.h22
-rw-r--r--init/Kconfig9
-rw-r--r--kernel/sys_ni.c10
-rw-r--r--kernel/time/posix-stubs.c10
4 files changed, 48 insertions, 3 deletions
diff --git a/include/linux/compat.h b/include/linux/compat.h
index 9847c5a013c3..2d85ec5cfda2 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -24,6 +24,17 @@
24#include <asm/siginfo.h> 24#include <asm/siginfo.h>
25#include <asm/signal.h> 25#include <asm/signal.h>
26 26
27#ifdef CONFIG_ARCH_HAS_SYSCALL_WRAPPER
28/*
29 * It may be useful for an architecture to override the definitions of the
30 * COMPAT_SYSCALL_DEFINE0 and COMPAT_SYSCALL_DEFINEx() macros, in particular
31 * to use a different calling convention for syscalls. To allow for that,
32 + the prototypes for the compat_sys_*() functions below will *not* be included
33 * if CONFIG_ARCH_HAS_SYSCALL_WRAPPER is enabled.
34 */
35#include <asm/syscall_wrapper.h>
36#endif /* CONFIG_ARCH_HAS_SYSCALL_WRAPPER */
37
27#ifndef COMPAT_USE_64BIT_TIME 38#ifndef COMPAT_USE_64BIT_TIME
28#define COMPAT_USE_64BIT_TIME 0 39#define COMPAT_USE_64BIT_TIME 0
29#endif 40#endif
@@ -32,10 +43,12 @@
32#define __SC_DELOUSE(t,v) ((__force t)(unsigned long)(v)) 43#define __SC_DELOUSE(t,v) ((__force t)(unsigned long)(v))
33#endif 44#endif
34 45
46#ifndef COMPAT_SYSCALL_DEFINE0
35#define COMPAT_SYSCALL_DEFINE0(name) \ 47#define COMPAT_SYSCALL_DEFINE0(name) \
36 asmlinkage long compat_sys_##name(void); \ 48 asmlinkage long compat_sys_##name(void); \
37 ALLOW_ERROR_INJECTION(compat_sys_##name, ERRNO); \ 49 ALLOW_ERROR_INJECTION(compat_sys_##name, ERRNO); \
38 asmlinkage long compat_sys_##name(void) 50 asmlinkage long compat_sys_##name(void)
51#endif /* COMPAT_SYSCALL_DEFINE0 */
39 52
40#define COMPAT_SYSCALL_DEFINE1(name, ...) \ 53#define COMPAT_SYSCALL_DEFINE1(name, ...) \
41 COMPAT_SYSCALL_DEFINEx(1, _##name, __VA_ARGS__) 54 COMPAT_SYSCALL_DEFINEx(1, _##name, __VA_ARGS__)
@@ -50,6 +63,7 @@
50#define COMPAT_SYSCALL_DEFINE6(name, ...) \ 63#define COMPAT_SYSCALL_DEFINE6(name, ...) \
51 COMPAT_SYSCALL_DEFINEx(6, _##name, __VA_ARGS__) 64 COMPAT_SYSCALL_DEFINEx(6, _##name, __VA_ARGS__)
52 65
66#ifndef COMPAT_SYSCALL_DEFINEx
53#define COMPAT_SYSCALL_DEFINEx(x, name, ...) \ 67#define COMPAT_SYSCALL_DEFINEx(x, name, ...) \
54 asmlinkage long compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__));\ 68 asmlinkage long compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__));\
55 asmlinkage long compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))\ 69 asmlinkage long compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))\
@@ -62,6 +76,7 @@
62 return C_SYSC##name(__MAP(x,__SC_DELOUSE,__VA_ARGS__)); \ 76 return C_SYSC##name(__MAP(x,__SC_DELOUSE,__VA_ARGS__)); \
63 } \ 77 } \
64 static inline long C_SYSC##name(__MAP(x,__SC_DECL,__VA_ARGS__)) 78 static inline long C_SYSC##name(__MAP(x,__SC_DECL,__VA_ARGS__))
79#endif /* COMPAT_SYSCALL_DEFINEx */
65 80
66#ifndef compat_user_stack_pointer 81#ifndef compat_user_stack_pointer
67#define compat_user_stack_pointer() current_user_stack_pointer() 82#define compat_user_stack_pointer() current_user_stack_pointer()
@@ -517,7 +532,12 @@ int __compat_save_altstack(compat_stack_t __user *, unsigned long);
517 * Please note that these prototypes here are only provided for information 532 * Please note that these prototypes here are only provided for information
518 * purposes, for static analysis, and for linking from the syscall table. 533 * purposes, for static analysis, and for linking from the syscall table.
519 * These functions should not be called elsewhere from kernel code. 534 * These functions should not be called elsewhere from kernel code.
535 *
536 * As the syscall calling convention may be different from the default
537 * for architectures overriding the syscall calling convention, do not
538 * include the prototypes if CONFIG_ARCH_HAS_SYSCALL_WRAPPER is enabled.
520 */ 539 */
540#ifndef CONFIG_ARCH_HAS_SYSCALL_WRAPPER
521asmlinkage long compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p); 541asmlinkage long compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p);
522asmlinkage long compat_sys_io_submit(compat_aio_context_t ctx_id, int nr, 542asmlinkage long compat_sys_io_submit(compat_aio_context_t ctx_id, int nr,
523 u32 __user *iocb); 543 u32 __user *iocb);
@@ -955,6 +975,8 @@ asmlinkage long compat_sys_stime(compat_time_t __user *tptr);
955/* obsolete: net/socket.c */ 975/* obsolete: net/socket.c */
956asmlinkage long compat_sys_socketcall(int call, u32 __user *args); 976asmlinkage long compat_sys_socketcall(int call, u32 __user *args);
957 977
978#endif /* CONFIG_ARCH_HAS_SYSCALL_WRAPPER */
979
958 980
959/* 981/*
960 * For most but not all architectures, "am I in a compat syscall?" and 982 * For most but not all architectures, "am I in a compat syscall?" and
diff --git a/init/Kconfig b/init/Kconfig
index 068eb6c3bbf7..2dbc88051bde 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1925,8 +1925,11 @@ config ARCH_HAS_SYNC_CORE_BEFORE_USERMODE
1925 bool 1925 bool
1926 1926
1927# It may be useful for an architecture to override the definitions of the 1927# It may be useful for an architecture to override the definitions of the
1928# SYSCALL_DEFINE() and __SYSCALL_DEFINEx() macros in <linux/syscalls.h>, 1928# SYSCALL_DEFINE() and __SYSCALL_DEFINEx() macros in <linux/syscalls.h>
1929# in particular to use a different calling convention for syscalls. 1929# and the COMPAT_ variants in <linux/compat.h>, in particular to use a
1930# different calling convention for syscalls. They can also override the
1931# macros for not-implemented syscalls in kernel/sys_ni.c and
1932# kernel/time/posix-stubs.c. All these overrides need to be available in
1933# <asm/syscall_wrapper.h>.
1930config ARCH_HAS_SYSCALL_WRAPPER 1934config ARCH_HAS_SYSCALL_WRAPPER
1931 def_bool n 1935 def_bool n
1932 depends on !COMPAT
diff --git a/kernel/sys_ni.c b/kernel/sys_ni.c
index 6cafc008f6db..9791364925dc 100644
--- a/kernel/sys_ni.c
+++ b/kernel/sys_ni.c
@@ -5,6 +5,11 @@
5 5
6#include <asm/unistd.h> 6#include <asm/unistd.h>
7 7
8#ifdef CONFIG_ARCH_HAS_SYSCALL_WRAPPER
9/* Architectures may override COND_SYSCALL and COND_SYSCALL_COMPAT */
10#include <asm/syscall_wrapper.h>
11#endif /* CONFIG_ARCH_HAS_SYSCALL_WRAPPER */
12
8/* we can't #include <linux/syscalls.h> here, 13/* we can't #include <linux/syscalls.h> here,
9 but tell gcc to not warn with -Wmissing-prototypes */ 14 but tell gcc to not warn with -Wmissing-prototypes */
10asmlinkage long sys_ni_syscall(void); 15asmlinkage long sys_ni_syscall(void);
@@ -17,8 +22,13 @@ asmlinkage long sys_ni_syscall(void)
17 return -ENOSYS; 22 return -ENOSYS;
18} 23}
19 24
25#ifndef COND_SYSCALL
20#define COND_SYSCALL(name) cond_syscall(sys_##name) 26#define COND_SYSCALL(name) cond_syscall(sys_##name)
27#endif /* COND_SYSCALL */
28
29#ifndef COND_SYSCALL_COMPAT
21#define COND_SYSCALL_COMPAT(name) cond_syscall(compat_sys_##name) 30#define COND_SYSCALL_COMPAT(name) cond_syscall(compat_sys_##name)
31#endif /* COND_SYSCALL_COMPAT */
22 32
23/* 33/*
24 * This list is kept in the same order as include/uapi/asm-generic/unistd.h. 34 * This list is kept in the same order as include/uapi/asm-generic/unistd.h.
diff --git a/kernel/time/posix-stubs.c b/kernel/time/posix-stubs.c
index b258bee13b02..69a937c3cd81 100644
--- a/kernel/time/posix-stubs.c
+++ b/kernel/time/posix-stubs.c
@@ -19,6 +19,11 @@
19#include <linux/posix-timers.h> 19#include <linux/posix-timers.h>
20#include <linux/compat.h> 20#include <linux/compat.h>
21 21
22#ifdef CONFIG_ARCH_HAS_SYSCALL_WRAPPER
23/* Architectures may override SYS_NI and COMPAT_SYS_NI */
24#include <asm/syscall_wrapper.h>
25#endif
26
22asmlinkage long sys_ni_posix_timers(void) 27asmlinkage long sys_ni_posix_timers(void)
23{ 28{
24 pr_err_once("process %d (%s) attempted a POSIX timer syscall " 29 pr_err_once("process %d (%s) attempted a POSIX timer syscall "
@@ -27,8 +32,13 @@ asmlinkage long sys_ni_posix_timers(void)
27 return -ENOSYS; 32 return -ENOSYS;
28} 33}
29 34
35#ifndef SYS_NI
30#define SYS_NI(name) SYSCALL_ALIAS(sys_##name, sys_ni_posix_timers) 36#define SYS_NI(name) SYSCALL_ALIAS(sys_##name, sys_ni_posix_timers)
37#endif
38
39#ifndef COMPAT_SYS_NI
31#define COMPAT_SYS_NI(name) SYSCALL_ALIAS(compat_sys_##name, sys_ni_posix_timers) 40#define COMPAT_SYS_NI(name) SYSCALL_ALIAS(compat_sys_##name, sys_ni_posix_timers)
41#endif
32 42
33SYS_NI(timer_create); 43SYS_NI(timer_create);
34SYS_NI(timer_gettime); 44SYS_NI(timer_gettime);