diff options
| author | Dominik Brodowski <linux@dominikbrodowski.net> | 2018-04-05 05:53:03 -0400 |
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2018-04-05 10:59:38 -0400 |
| commit | 7303e30ec1d8fb5ca1f07c92d069241c32b2ee1b (patch) | |
| tree | 9bf0343c73e0f5562bd8972c25bf8ffa280e8845 /kernel | |
| parent | fa697140f9a20119a9ec8fd7460cc4314fbdaff3 (diff) | |
syscalls/core: Prepare CONFIG_ARCH_HAS_SYSCALL_WRAPPER=y for compat syscalls
It may be useful for an architecture to override the definitions of the
COMPAT_SYSCALL_DEFINE0() and __COMPAT_SYSCALL_DEFINEx() macros in
<linux/compat.h>, in particular to use a different calling convention
for syscalls. This patch provides a mechanism to do so, based on the
previously introduced CONFIG_ARCH_HAS_SYSCALL_WRAPPER. If it is enabled,
<asm/sycall_wrapper.h> is included in <linux/compat.h> and may be used
to define the macros mentioned above. Moreover, as the syscall calling
convention may be different if CONFIG_ARCH_HAS_SYSCALL_WRAPPER is set,
the compat syscall function prototypes in <linux/compat.h> are #ifndef'd
out in that case.
As some of the syscalls and/or compat syscalls may not be present,
the COND_SYSCALL() and COND_SYSCALL_COMPAT() macros in kernel/sys_ni.c
as well as the SYS_NI() and COMPAT_SYS_NI() macros in
kernel/time/posix-stubs.c can be re-defined in <asm/syscall_wrapper.h> iff
CONFIG_ARCH_HAS_SYSCALL_WRAPPER is enabled.
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20180405095307.3730-5-linux@dominikbrodowski.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/sys_ni.c | 10 | ||||
| -rw-r--r-- | kernel/time/posix-stubs.c | 10 |
2 files changed, 20 insertions, 0 deletions
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 */ |
| 10 | asmlinkage long sys_ni_syscall(void); | 15 | asmlinkage 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 | |||
| 22 | asmlinkage long sys_ni_posix_timers(void) | 27 | asmlinkage 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 | ||
| 33 | SYS_NI(timer_create); | 43 | SYS_NI(timer_create); |
| 34 | SYS_NI(timer_gettime); | 44 | SYS_NI(timer_gettime); |
