diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-05-01 07:21:43 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-05-01 07:21:43 -0700 |
commit | 08d76760832993050ad8c25e63b56773ef2ca303 (patch) | |
tree | abdcf148dfe43cd49f30f204f1dac6978107a508 /include/linux | |
parent | 5f56886521d6ddd3648777fae44d82382dd8c87f (diff) | |
parent | 99e621f796d7f0341a51e8cdf32b81663b10b448 (diff) |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/signal
Pull compat cleanup from Al Viro:
"Mostly about syscall wrappers this time; there will be another pile
with patches in the same general area from various people, but I'd
rather push those after both that and vfs.git pile are in."
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/signal:
syscalls.h: slightly reduce the jungles of macros
get rid of union semop in sys_semctl(2) arguments
make do_mremap() static
sparc: no need to sign-extend in sync_file_range() wrapper
ppc compat wrappers for add_key(2) and request_key(2) are pointless
x86: trim sys_ia32.h
x86: sys32_kill and sys32_mprotect are pointless
get rid of compat_sys_semctl() and friends in case of ARCH_WANT_OLD_COMPAT_IPC
merge compat sys_ipc instances
consolidate compat lookup_dcookie()
convert vmsplice to COMPAT_SYSCALL_DEFINE
switch getrusage() to COMPAT_SYSCALL_DEFINE
switch epoll_pwait to COMPAT_SYSCALL_DEFINE
convert sendfile{,64} to COMPAT_SYSCALL_DEFINE
switch signalfd{,4}() to COMPAT_SYSCALL_DEFINE
make SYSCALL_DEFINE<n>-generated wrappers do asmlinkage_protect
make HAVE_SYSCALL_WRAPPERS unconditional
consolidate cond_syscall and SYSCALL_ALIAS declarations
teach SYSCALL_DEFINE<n> how to deal with long long/unsigned long long
get rid of duplicate logics in __SC_....[1-6] definitions
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/compat.h | 51 | ||||
-rw-r--r-- | include/linux/linkage.h | 21 | ||||
-rw-r--r-- | include/linux/mm.h | 3 | ||||
-rw-r--r-- | include/linux/syscalls.h | 156 |
4 files changed, 86 insertions, 145 deletions
diff --git a/include/linux/compat.h b/include/linux/compat.h index 377cd8c3395e..d53c35352ea9 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h @@ -27,12 +27,6 @@ #define __SC_DELOUSE(t,v) ((t)(unsigned long)(v)) #endif -#define __SC_CCAST1(t1, a1) __SC_DELOUSE(t1,a1) -#define __SC_CCAST2(t2, a2, ...) __SC_DELOUSE(t2,a2), __SC_CCAST1(__VA_ARGS__) -#define __SC_CCAST3(t3, a3, ...) __SC_DELOUSE(t3,a3), __SC_CCAST2(__VA_ARGS__) -#define __SC_CCAST4(t4, a4, ...) __SC_DELOUSE(t4,a4), __SC_CCAST3(__VA_ARGS__) -#define __SC_CCAST5(t5, a5, ...) __SC_DELOUSE(t5,a5), __SC_CCAST4(__VA_ARGS__) -#define __SC_CCAST6(t6, a6, ...) __SC_DELOUSE(t6,a6), __SC_CCAST5(__VA_ARGS__) #define COMPAT_SYSCALL_DEFINE1(name, ...) \ COMPAT_SYSCALL_DEFINEx(1, _##name, __VA_ARGS__) #define COMPAT_SYSCALL_DEFINE2(name, ...) \ @@ -46,24 +40,15 @@ #define COMPAT_SYSCALL_DEFINE6(name, ...) \ COMPAT_SYSCALL_DEFINEx(6, _##name, __VA_ARGS__) -#ifdef CONFIG_HAVE_SYSCALL_WRAPPERS - #define COMPAT_SYSCALL_DEFINEx(x, name, ...) \ - asmlinkage long compat_sys##name(__SC_DECL##x(__VA_ARGS__)); \ - static inline long C_SYSC##name(__SC_DECL##x(__VA_ARGS__)); \ - asmlinkage long compat_SyS##name(__SC_LONG##x(__VA_ARGS__)) \ + asmlinkage long compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__));\ + static inline long C_SYSC##name(__MAP(x,__SC_DECL,__VA_ARGS__));\ + asmlinkage long compat_SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__))\ { \ - return (long) C_SYSC##name(__SC_CCAST##x(__VA_ARGS__)); \ + return C_SYSC##name(__MAP(x,__SC_DELOUSE,__VA_ARGS__)); \ } \ SYSCALL_ALIAS(compat_sys##name, compat_SyS##name); \ - static inline long C_SYSC##name(__SC_DECL##x(__VA_ARGS__)) - -#else /* CONFIG_HAVE_SYSCALL_WRAPPERS */ - -#define COMPAT_SYSCALL_DEFINEx(x, name, ...) \ - asmlinkage long compat_sys##name(__SC_DECL##x(__VA_ARGS__)) - -#endif /* CONFIG_HAVE_SYSCALL_WRAPPERS */ + static inline long C_SYSC##name(__MAP(x,__SC_DECL,__VA_ARGS__)) #ifndef compat_user_stack_pointer #define compat_user_stack_pointer() current_user_stack_pointer() @@ -326,21 +311,13 @@ asmlinkage long compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr, compat_size_t __user *len_ptr); -#ifdef CONFIG_ARCH_WANT_OLD_COMPAT_IPC -long compat_sys_semctl(int first, int second, int third, void __user *uptr); -long compat_sys_msgsnd(int first, int second, int third, void __user *uptr); -long compat_sys_msgrcv(int first, int second, int msgtyp, int third, - int version, void __user *uptr); -long compat_sys_shmat(int first, int second, compat_uptr_t third, int version, - void __user *uptr); -#else -long compat_sys_semctl(int semid, int semnum, int cmd, int arg); -long compat_sys_msgsnd(int msqid, struct compat_msgbuf __user *msgp, +asmlinkage long compat_sys_ipc(u32, int, int, u32, compat_uptr_t, u32); +asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg); +asmlinkage long compat_sys_semctl(int semid, int semnum, int cmd, int arg); +asmlinkage long compat_sys_msgsnd(int msqid, compat_uptr_t msgp, compat_ssize_t msgsz, int msgflg); -long compat_sys_msgrcv(int msqid, struct compat_msgbuf __user *msgp, +asmlinkage long compat_sys_msgrcv(int msqid, compat_uptr_t msgp, compat_ssize_t msgsz, long msgtyp, int msgflg); -long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg); -#endif long compat_sys_msgctl(int first, int second, void __user *uptr); long compat_sys_shmctl(int first, int second, void __user *uptr); long compat_sys_semtimedop(int semid, struct sembuf __user *tsems, @@ -444,13 +421,13 @@ extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request, asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid, compat_long_t addr, compat_long_t data); +asmlinkage long compat_sys_lookup_dcookie(u32, u32, char __user *, size_t); /* * epoll (fs/eventpoll.c) compat bits follow ... */ -struct epoll_event; -#define compat_epoll_event epoll_event +struct epoll_event; /* fortunately, this one is fixed-layout */ asmlinkage long compat_sys_epoll_pwait(int epfd, - struct compat_epoll_event __user *events, + struct epoll_event __user *events, int maxevents, int timeout, const compat_sigset_t __user *sigmask, compat_size_t sigsetsize); @@ -685,6 +662,8 @@ asmlinkage ssize_t compat_sys_process_vm_writev(compat_pid_t pid, asmlinkage long compat_sys_sendfile(int out_fd, int in_fd, compat_off_t __user *offset, compat_size_t count); +asmlinkage long compat_sys_sendfile64(int out_fd, int in_fd, + compat_loff_t __user *offset, compat_size_t count); asmlinkage long compat_sys_sigaltstack(const compat_stack_t __user *uss_ptr, compat_stack_t __user *uoss_ptr); diff --git a/include/linux/linkage.h b/include/linux/linkage.h index 807f1e533226..829d66c67fc2 100644 --- a/include/linux/linkage.h +++ b/include/linux/linkage.h @@ -2,6 +2,7 @@ #define _LINUX_LINKAGE_H #include <linux/compiler.h> +#include <linux/stringify.h> #include <asm/linkage.h> #ifdef __cplusplus @@ -14,6 +15,26 @@ #define asmlinkage CPP_ASMLINKAGE #endif +#ifndef SYMBOL_NAME +#ifdef CONFIG_SYMBOL_PREFIX +#define SYMBOL_NAME(x) CONFIG_SYMBOL_PREFIX ## x +#else +#define SYMBOL_NAME(x) x +#endif +#endif +#define __SYMBOL_NAME(x) __stringify(SYMBOL_NAME(x)) + +#ifndef cond_syscall +#define cond_syscall(x) asm(".weak\t" __SYMBOL_NAME(x) \ + "\n\t.set\t" __SYMBOL_NAME(x) "," __SYMBOL_NAME(sys_ni_syscall)); +#endif + +#ifndef SYSCALL_ALIAS +#define SYSCALL_ALIAS(alias, name) \ + asm ("\t.globl " __SYMBOL_NAME(alias) \ + "\n\t.set\t" __SYMBOL_NAME(alias) "," __SYMBOL_NAME(name)) +#endif + #define __page_aligned_data __section(.data..page_aligned) __aligned(PAGE_SIZE) #define __page_aligned_bss __section(.bss..page_aligned) __aligned(PAGE_SIZE) diff --git a/include/linux/mm.h b/include/linux/mm.h index c05d7cfbb6b9..1a7f19e7f1a0 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1082,9 +1082,6 @@ extern unsigned long move_page_tables(struct vm_area_struct *vma, unsigned long old_addr, struct vm_area_struct *new_vma, unsigned long new_addr, unsigned long len, bool need_rmap_locks); -extern unsigned long do_mremap(unsigned long addr, - unsigned long old_len, unsigned long new_len, - unsigned long flags, unsigned long new_addr); extern unsigned long change_protection(struct vm_area_struct *vma, unsigned long start, unsigned long end, pgprot_t newprot, int dirty_accountable, int prot_numa); diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index 313a8e0a6553..4147d700a293 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h @@ -78,49 +78,34 @@ struct sigaltstack; #include <linux/key.h> #include <trace/syscall.h> -#define __SC_DECL1(t1, a1) t1 a1 -#define __SC_DECL2(t2, a2, ...) t2 a2, __SC_DECL1(__VA_ARGS__) -#define __SC_DECL3(t3, a3, ...) t3 a3, __SC_DECL2(__VA_ARGS__) -#define __SC_DECL4(t4, a4, ...) t4 a4, __SC_DECL3(__VA_ARGS__) -#define __SC_DECL5(t5, a5, ...) t5 a5, __SC_DECL4(__VA_ARGS__) -#define __SC_DECL6(t6, a6, ...) t6 a6, __SC_DECL5(__VA_ARGS__) - -#define __SC_LONG1(t1, a1) long a1 -#define __SC_LONG2(t2, a2, ...) long a2, __SC_LONG1(__VA_ARGS__) -#define __SC_LONG3(t3, a3, ...) long a3, __SC_LONG2(__VA_ARGS__) -#define __SC_LONG4(t4, a4, ...) long a4, __SC_LONG3(__VA_ARGS__) -#define __SC_LONG5(t5, a5, ...) long a5, __SC_LONG4(__VA_ARGS__) -#define __SC_LONG6(t6, a6, ...) long a6, __SC_LONG5(__VA_ARGS__) - -#define __SC_CAST1(t1, a1) (t1) a1 -#define __SC_CAST2(t2, a2, ...) (t2) a2, __SC_CAST1(__VA_ARGS__) -#define __SC_CAST3(t3, a3, ...) (t3) a3, __SC_CAST2(__VA_ARGS__) -#define __SC_CAST4(t4, a4, ...) (t4) a4, __SC_CAST3(__VA_ARGS__) -#define __SC_CAST5(t5, a5, ...) (t5) a5, __SC_CAST4(__VA_ARGS__) -#define __SC_CAST6(t6, a6, ...) (t6) a6, __SC_CAST5(__VA_ARGS__) - -#define __SC_TEST(type) BUILD_BUG_ON(sizeof(type) > sizeof(long)) -#define __SC_TEST1(t1, a1) __SC_TEST(t1) -#define __SC_TEST2(t2, a2, ...) __SC_TEST(t2); __SC_TEST1(__VA_ARGS__) -#define __SC_TEST3(t3, a3, ...) __SC_TEST(t3); __SC_TEST2(__VA_ARGS__) -#define __SC_TEST4(t4, a4, ...) __SC_TEST(t4); __SC_TEST3(__VA_ARGS__) -#define __SC_TEST5(t5, a5, ...) __SC_TEST(t5); __SC_TEST4(__VA_ARGS__) -#define __SC_TEST6(t6, a6, ...) __SC_TEST(t6); __SC_TEST5(__VA_ARGS__) +/* + * __MAP - apply a macro to syscall arguments + * __MAP(n, m, t1, a1, t2, a2, ..., tn, an) will expand to + * m(t1, a1), m(t2, a2), ..., m(tn, an) + * The first argument must be equal to the amount of type/name + * pairs given. Note that this list of pairs (i.e. the arguments + * of __MAP starting at the third one) is in the same format as + * for SYSCALL_DEFINE<n>/COMPAT_SYSCALL_DEFINE<n> + */ +#define __MAP0(m,...) +#define __MAP1(m,t,a) m(t,a) +#define __MAP2(m,t,a,...) m(t,a), __MAP1(m,__VA_ARGS__) +#define __MAP3(m,t,a,...) m(t,a), __MAP2(m,__VA_ARGS__) +#define __MAP4(m,t,a,...) m(t,a), __MAP3(m,__VA_ARGS__) +#define __MAP5(m,t,a,...) m(t,a), __MAP4(m,__VA_ARGS__) +#define __MAP6(m,t,a,...) m(t,a), __MAP5(m,__VA_ARGS__) +#define __MAP(n,...) __MAP##n(__VA_ARGS__) + +#define __SC_DECL(t, a) t a +#define __TYPE_IS_LL(t) (__same_type((t)0, 0LL) || __same_type((t)0, 0ULL)) +#define __SC_LONG(t, a) __typeof(__builtin_choose_expr(__TYPE_IS_LL(t), 0LL, 0L)) a +#define __SC_CAST(t, a) (t) a +#define __SC_ARGS(t, a) a +#define __SC_TEST(t, a) (void)BUILD_BUG_ON_ZERO(!__TYPE_IS_LL(t) && sizeof(t) > sizeof(long)) #ifdef CONFIG_FTRACE_SYSCALLS -#define __SC_STR_ADECL1(t, a) #a -#define __SC_STR_ADECL2(t, a, ...) #a, __SC_STR_ADECL1(__VA_ARGS__) -#define __SC_STR_ADECL3(t, a, ...) #a, __SC_STR_ADECL2(__VA_ARGS__) -#define __SC_STR_ADECL4(t, a, ...) #a, __SC_STR_ADECL3(__VA_ARGS__) -#define __SC_STR_ADECL5(t, a, ...) #a, __SC_STR_ADECL4(__VA_ARGS__) -#define __SC_STR_ADECL6(t, a, ...) #a, __SC_STR_ADECL5(__VA_ARGS__) - -#define __SC_STR_TDECL1(t, a) #t -#define __SC_STR_TDECL2(t, a, ...) #t, __SC_STR_TDECL1(__VA_ARGS__) -#define __SC_STR_TDECL3(t, a, ...) #t, __SC_STR_TDECL2(__VA_ARGS__) -#define __SC_STR_TDECL4(t, a, ...) #t, __SC_STR_TDECL3(__VA_ARGS__) -#define __SC_STR_TDECL5(t, a, ...) #t, __SC_STR_TDECL4(__VA_ARGS__) -#define __SC_STR_TDECL6(t, a, ...) #t, __SC_STR_TDECL5(__VA_ARGS__) +#define __SC_STR_ADECL(t, a) #a +#define __SC_STR_TDECL(t, a) #t extern struct ftrace_event_class event_class_syscall_enter; extern struct ftrace_event_class event_class_syscall_exit; @@ -155,7 +140,13 @@ extern struct trace_event_functions exit_syscall_print_funcs; __attribute__((section("_ftrace_events"))) \ *__event_exit_##sname = &event_exit_##sname; -#define SYSCALL_METADATA(sname, nb) \ +#define SYSCALL_METADATA(sname, nb, ...) \ + static const char *types_##sname[] = { \ + __MAP(nb,__SC_STR_TDECL,__VA_ARGS__) \ + }; \ + static const char *args_##sname[] = { \ + __MAP(nb,__SC_STR_ADECL,__VA_ARGS__) \ + }; \ SYSCALL_TRACE_ENTER_EVENT(sname); \ SYSCALL_TRACE_EXIT_EVENT(sname); \ static struct syscall_metadata __used \ @@ -163,8 +154,8 @@ extern struct trace_event_functions exit_syscall_print_funcs; .name = "sys"#sname, \ .syscall_nr = -1, /* Filled in at boot */ \ .nb_args = nb, \ - .types = types_##sname, \ - .args = args_##sname, \ + .types = nb ? types_##sname : NULL, \ + .args = nb ? args_##sname : NULL, \ .enter_event = &event_enter_##sname, \ .exit_event = &event_exit_##sname, \ .enter_fields = LIST_HEAD_INIT(__syscall_meta_##sname.enter_fields), \ @@ -172,26 +163,13 @@ extern struct trace_event_functions exit_syscall_print_funcs; static struct syscall_metadata __used \ __attribute__((section("__syscalls_metadata"))) \ *__p_syscall_meta_##sname = &__syscall_meta_##sname; +#else +#define SYSCALL_METADATA(sname, nb, ...) +#endif #define SYSCALL_DEFINE0(sname) \ - SYSCALL_TRACE_ENTER_EVENT(_##sname); \ - SYSCALL_TRACE_EXIT_EVENT(_##sname); \ - static struct syscall_metadata __used \ - __syscall_meta__##sname = { \ - .name = "sys_"#sname, \ - .syscall_nr = -1, /* Filled in at boot */ \ - .nb_args = 0, \ - .enter_event = &event_enter__##sname, \ - .exit_event = &event_exit__##sname, \ - .enter_fields = LIST_HEAD_INIT(__syscall_meta__##sname.enter_fields), \ - }; \ - static struct syscall_metadata __used \ - __attribute__((section("__syscalls_metadata"))) \ - *__p_syscall_meta_##sname = &__syscall_meta__##sname; \ + SYSCALL_METADATA(_##sname, 0); \ asmlinkage long sys_##sname(void) -#else -#define SYSCALL_DEFINE0(name) asmlinkage long sys_##name(void) -#endif #define SYSCALL_DEFINE1(name, ...) SYSCALL_DEFINEx(1, _##name, __VA_ARGS__) #define SYSCALL_DEFINE2(name, ...) SYSCALL_DEFINEx(2, _##name, __VA_ARGS__) @@ -200,57 +178,23 @@ extern struct trace_event_functions exit_syscall_print_funcs; #define SYSCALL_DEFINE5(name, ...) SYSCALL_DEFINEx(5, _##name, __VA_ARGS__) #define SYSCALL_DEFINE6(name, ...) SYSCALL_DEFINEx(6, _##name, __VA_ARGS__) -#ifdef CONFIG_PPC64 -#define SYSCALL_ALIAS(alias, name) \ - asm ("\t.globl " #alias "\n\t.set " #alias ", " #name "\n" \ - "\t.globl ." #alias "\n\t.set ." #alias ", ." #name) -#else -#if defined(CONFIG_ALPHA) || defined(CONFIG_MIPS) -#define SYSCALL_ALIAS(alias, name) \ - asm ( #alias " = " #name "\n\t.globl " #alias) -#else -#define SYSCALL_ALIAS(alias, name) \ - asm ("\t.globl " #alias "\n\t.set " #alias ", " #name) -#endif -#endif - -#ifdef CONFIG_FTRACE_SYSCALLS #define SYSCALL_DEFINEx(x, sname, ...) \ - static const char *types_##sname[] = { \ - __SC_STR_TDECL##x(__VA_ARGS__) \ - }; \ - static const char *args_##sname[] = { \ - __SC_STR_ADECL##x(__VA_ARGS__) \ - }; \ - SYSCALL_METADATA(sname, x); \ + SYSCALL_METADATA(sname, x, __VA_ARGS__) \ __SYSCALL_DEFINEx(x, sname, __VA_ARGS__) -#else -#define SYSCALL_DEFINEx(x, sname, ...) \ - __SYSCALL_DEFINEx(x, sname, __VA_ARGS__) -#endif - -#ifdef CONFIG_HAVE_SYSCALL_WRAPPERS - -#define SYSCALL_DEFINE(name) static inline long SYSC_##name +#define __PROTECT(...) asmlinkage_protect(__VA_ARGS__) #define __SYSCALL_DEFINEx(x, name, ...) \ - asmlinkage long sys##name(__SC_DECL##x(__VA_ARGS__)); \ - static inline long SYSC##name(__SC_DECL##x(__VA_ARGS__)); \ - asmlinkage long SyS##name(__SC_LONG##x(__VA_ARGS__)) \ + asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)); \ + static inline long SYSC##name(__MAP(x,__SC_DECL,__VA_ARGS__)); \ + asmlinkage long SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \ { \ - __SC_TEST##x(__VA_ARGS__); \ - return (long) SYSC##name(__SC_CAST##x(__VA_ARGS__)); \ + long ret = SYSC##name(__MAP(x,__SC_CAST,__VA_ARGS__)); \ + __MAP(x,__SC_TEST,__VA_ARGS__); \ + __PROTECT(x, ret,__MAP(x,__SC_ARGS,__VA_ARGS__)); \ + return ret; \ } \ SYSCALL_ALIAS(sys##name, SyS##name); \ - static inline long SYSC##name(__SC_DECL##x(__VA_ARGS__)) - -#else /* CONFIG_HAVE_SYSCALL_WRAPPERS */ - -#define SYSCALL_DEFINE(name) asmlinkage long sys_##name -#define __SYSCALL_DEFINEx(x, name, ...) \ - asmlinkage long sys##name(__SC_DECL##x(__VA_ARGS__)) - -#endif /* CONFIG_HAVE_SYSCALL_WRAPPERS */ + static inline long SYSC##name(__MAP(x,__SC_DECL,__VA_ARGS__)) asmlinkage long sys_time(time_t __user *tloc); asmlinkage long sys_stime(time_t __user *tptr); @@ -694,7 +638,7 @@ asmlinkage long sys_msgctl(int msqid, int cmd, struct msqid_ds __user *buf); asmlinkage long sys_semget(key_t key, int nsems, int semflg); asmlinkage long sys_semop(int semid, struct sembuf __user *sops, unsigned nsops); -asmlinkage long sys_semctl(int semid, int semnum, int cmd, union semun arg); +asmlinkage long sys_semctl(int semid, int semnum, int cmd, unsigned long arg); asmlinkage long sys_semtimedop(int semid, struct sembuf __user *sops, unsigned nsops, const struct timespec __user *timeout); |