aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2013-01-21 15:25:54 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2013-03-03 22:58:33 -0500
commit2cf0966683430b6468f36ca20515a33ca7f2403c (patch)
tree902080486ebd7988d1250914c3809c4de472a22b
parent22d1a35da0e247a006c286842a1846acb4ffed4f (diff)
make SYSCALL_DEFINE<n>-generated wrappers do asmlinkage_protect
... and switch i386 to HAVE_SYSCALL_WRAPPERS, killing open-coded uses of asmlinkage_protect() in a bunch of syscalls. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--arch/x86/include/asm/syscalls.h4
-rw-r--r--arch/x86/kernel/tls.c14
-rw-r--r--arch/x86/um/tls_32.c5
-rw-r--r--fs/aio.c2
-rw-r--r--fs/open.c24
-rw-r--r--include/linux/syscalls.h6
-rw-r--r--kernel/exit.c5
-rw-r--r--kernel/fork.c5
-rw-r--r--kernel/uid16.c55
9 files changed, 31 insertions, 89 deletions
diff --git a/arch/x86/include/asm/syscalls.h b/arch/x86/include/asm/syscalls.h
index 6cf0a9cc60cd..5f87b35fd2ef 100644
--- a/arch/x86/include/asm/syscalls.h
+++ b/arch/x86/include/asm/syscalls.h
@@ -27,8 +27,8 @@ asmlinkage int sys_modify_ldt(int, void __user *, unsigned long);
27long sys_rt_sigreturn(void); 27long sys_rt_sigreturn(void);
28 28
29/* kernel/tls.c */ 29/* kernel/tls.c */
30asmlinkage int sys_set_thread_area(struct user_desc __user *); 30asmlinkage long sys_set_thread_area(struct user_desc __user *);
31asmlinkage int sys_get_thread_area(struct user_desc __user *); 31asmlinkage long sys_get_thread_area(struct user_desc __user *);
32 32
33/* X86_32 only */ 33/* X86_32 only */
34#ifdef CONFIG_X86_32 34#ifdef CONFIG_X86_32
diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
index 9d9d2f9e77a5..f7fec09e3e3a 100644
--- a/arch/x86/kernel/tls.c
+++ b/arch/x86/kernel/tls.c
@@ -3,13 +3,13 @@
3#include <linux/sched.h> 3#include <linux/sched.h>
4#include <linux/user.h> 4#include <linux/user.h>
5#include <linux/regset.h> 5#include <linux/regset.h>
6#include <linux/syscalls.h>
6 7
7#include <asm/uaccess.h> 8#include <asm/uaccess.h>
8#include <asm/desc.h> 9#include <asm/desc.h>
9#include <asm/ldt.h> 10#include <asm/ldt.h>
10#include <asm/processor.h> 11#include <asm/processor.h>
11#include <asm/proto.h> 12#include <asm/proto.h>
12#include <asm/syscalls.h>
13 13
14#include "tls.h" 14#include "tls.h"
15 15
@@ -89,11 +89,9 @@ int do_set_thread_area(struct task_struct *p, int idx,
89 return 0; 89 return 0;
90} 90}
91 91
92asmlinkage int sys_set_thread_area(struct user_desc __user *u_info) 92SYSCALL_DEFINE1(set_thread_area, struct user_desc __user *, u_info)
93{ 93{
94 int ret = do_set_thread_area(current, -1, u_info, 1); 94 return do_set_thread_area(current, -1, u_info, 1);
95 asmlinkage_protect(1, ret, u_info);
96 return ret;
97} 95}
98 96
99 97
@@ -139,11 +137,9 @@ int do_get_thread_area(struct task_struct *p, int idx,
139 return 0; 137 return 0;
140} 138}
141 139
142asmlinkage int sys_get_thread_area(struct user_desc __user *u_info) 140SYSCALL_DEFINE1(get_thread_area, struct user_desc __user *, u_info)
143{ 141{
144 int ret = do_get_thread_area(current, -1, u_info); 142 return do_get_thread_area(current, -1, u_info);
145 asmlinkage_protect(1, ret, u_info);
146 return ret;
147} 143}
148 144
149int regset_tls_active(struct task_struct *target, 145int regset_tls_active(struct task_struct *target,
diff --git a/arch/x86/um/tls_32.c b/arch/x86/um/tls_32.c
index 5f5feff3d24c..80ffa5b9982d 100644
--- a/arch/x86/um/tls_32.c
+++ b/arch/x86/um/tls_32.c
@@ -5,6 +5,7 @@
5 5
6#include <linux/percpu.h> 6#include <linux/percpu.h>
7#include <linux/sched.h> 7#include <linux/sched.h>
8#include <linux/syscalls.h>
8#include <asm/uaccess.h> 9#include <asm/uaccess.h>
9#include <os.h> 10#include <os.h>
10#include <skas.h> 11#include <skas.h>
@@ -274,7 +275,7 @@ clear:
274 goto out; 275 goto out;
275} 276}
276 277
277int sys_set_thread_area(struct user_desc __user *user_desc) 278SYSCALL_DEFINE1(set_thread_area, struct user_desc __user *, user_desc)
278{ 279{
279 struct user_desc info; 280 struct user_desc info;
280 int idx, ret; 281 int idx, ret;
@@ -322,7 +323,7 @@ int ptrace_set_thread_area(struct task_struct *child, int idx,
322 return set_tls_entry(child, &info, idx, 0); 323 return set_tls_entry(child, &info, idx, 0);
323} 324}
324 325
325int sys_get_thread_area(struct user_desc __user *user_desc) 326SYSCALL_DEFINE1(get_thread_area, struct user_desc __user *, user_desc)
326{ 327{
327 struct user_desc info; 328 struct user_desc info;
328 int idx, ret; 329 int idx, ret;
diff --git a/fs/aio.c b/fs/aio.c
index 3f941f2a3059..c3ebb98a527b 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -1790,7 +1790,5 @@ SYSCALL_DEFINE5(io_getevents, aio_context_t, ctx_id,
1790 ret = read_events(ioctx, min_nr, nr, events, timeout); 1790 ret = read_events(ioctx, min_nr, nr, events, timeout);
1791 put_ioctx(ioctx); 1791 put_ioctx(ioctx);
1792 } 1792 }
1793
1794 asmlinkage_protect(5, ret, ctx_id, min_nr, nr, events, timeout);
1795 return ret; 1793 return ret;
1796} 1794}
diff --git a/fs/open.c b/fs/open.c
index a53922450448..8c741002f947 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -197,10 +197,7 @@ out:
197 197
198SYSCALL_DEFINE2(ftruncate, unsigned int, fd, unsigned long, length) 198SYSCALL_DEFINE2(ftruncate, unsigned int, fd, unsigned long, length)
199{ 199{
200 long ret = do_sys_ftruncate(fd, length, 1); 200 return do_sys_ftruncate(fd, length, 1);
201 /* avoid REGPARM breakage on x86: */
202 asmlinkage_protect(2, ret, fd, length);
203 return ret;
204} 201}
205 202
206#ifdef CONFIG_COMPAT 203#ifdef CONFIG_COMPAT
@@ -219,10 +216,7 @@ SYSCALL_DEFINE2(truncate64, const char __user *, path, loff_t, length)
219 216
220SYSCALL_DEFINE2(ftruncate64, unsigned int, fd, loff_t, length) 217SYSCALL_DEFINE2(ftruncate64, unsigned int, fd, loff_t, length)
221{ 218{
222 long ret = do_sys_ftruncate(fd, length, 0); 219 return do_sys_ftruncate(fd, length, 0);
223 /* avoid REGPARM breakage on x86: */
224 asmlinkage_protect(2, ret, fd, length);
225 return ret;
226} 220}
227#endif /* BITS_PER_LONG == 32 */ 221#endif /* BITS_PER_LONG == 32 */
228 222
@@ -961,29 +955,19 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
961 955
962SYSCALL_DEFINE3(open, const char __user *, filename, int, flags, umode_t, mode) 956SYSCALL_DEFINE3(open, const char __user *, filename, int, flags, umode_t, mode)
963{ 957{
964 long ret;
965
966 if (force_o_largefile()) 958 if (force_o_largefile())
967 flags |= O_LARGEFILE; 959 flags |= O_LARGEFILE;
968 960
969 ret = do_sys_open(AT_FDCWD, filename, flags, mode); 961 return do_sys_open(AT_FDCWD, filename, flags, mode);
970 /* avoid REGPARM breakage on x86: */
971 asmlinkage_protect(3, ret, filename, flags, mode);
972 return ret;
973} 962}
974 963
975SYSCALL_DEFINE4(openat, int, dfd, const char __user *, filename, int, flags, 964SYSCALL_DEFINE4(openat, int, dfd, const char __user *, filename, int, flags,
976 umode_t, mode) 965 umode_t, mode)
977{ 966{
978 long ret;
979
980 if (force_o_largefile()) 967 if (force_o_largefile())
981 flags |= O_LARGEFILE; 968 flags |= O_LARGEFILE;
982 969
983 ret = do_sys_open(dfd, filename, flags, mode); 970 return do_sys_open(dfd, filename, flags, mode);
984 /* avoid REGPARM breakage on x86: */
985 asmlinkage_protect(4, ret, dfd, filename, flags, mode);
986 return ret;
987} 971}
988 972
989#ifndef __alpha__ 973#ifndef __alpha__
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 3b6fc13cb46a..9660a8bdcbbe 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -99,6 +99,7 @@ struct sigaltstack;
99#define __TYPE_IS_LL(t) (__same_type((t)0, 0LL) || __same_type((t)0, 0ULL)) 99#define __TYPE_IS_LL(t) (__same_type((t)0, 0LL) || __same_type((t)0, 0ULL))
100#define __SC_LONG(t, a) __typeof(__builtin_choose_expr(__TYPE_IS_LL(t), 0LL, 0L)) a 100#define __SC_LONG(t, a) __typeof(__builtin_choose_expr(__TYPE_IS_LL(t), 0LL, 0L)) a
101#define __SC_CAST(t, a) (t) a 101#define __SC_CAST(t, a) (t) a
102#define __SC_ARGS(t, a) a
102#define __SC_TEST(t, a) (void)BUILD_BUG_ON_ZERO(!__TYPE_IS_LL(t) && sizeof(t) > sizeof(long)) 103#define __SC_TEST(t, a) (void)BUILD_BUG_ON_ZERO(!__TYPE_IS_LL(t) && sizeof(t) > sizeof(long))
103 104
104#ifdef CONFIG_FTRACE_SYSCALLS 105#ifdef CONFIG_FTRACE_SYSCALLS
@@ -200,13 +201,16 @@ extern struct trace_event_functions exit_syscall_print_funcs;
200 201
201#define SYSCALL_DEFINE(name) static inline long SYSC_##name 202#define SYSCALL_DEFINE(name) static inline long SYSC_##name
202 203
204#define __PROTECT(...) asmlinkage_protect(__VA_ARGS__)
203#define __SYSCALL_DEFINEx(x, name, ...) \ 205#define __SYSCALL_DEFINEx(x, name, ...) \
204 asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)); \ 206 asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)); \
205 static inline long SYSC##name(__MAP(x,__SC_DECL,__VA_ARGS__)); \ 207 static inline long SYSC##name(__MAP(x,__SC_DECL,__VA_ARGS__)); \
206 asmlinkage long SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \ 208 asmlinkage long SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \
207 { \ 209 { \
210 long ret = SYSC##name(__MAP(x,__SC_CAST,__VA_ARGS__)); \
208 __MAP(x,__SC_TEST,__VA_ARGS__); \ 211 __MAP(x,__SC_TEST,__VA_ARGS__); \
209 return SYSC##name(__MAP(x,__SC_CAST,__VA_ARGS__)); \ 212 __PROTECT(x, ret,__MAP(x,__SC_ARGS,__VA_ARGS__)); \
213 return ret; \
210 } \ 214 } \
211 SYSCALL_ALIAS(sys##name, SyS##name); \ 215 SYSCALL_ALIAS(sys##name, SyS##name); \
212 static inline long SYSC##name(__MAP(x,__SC_DECL,__VA_ARGS__)) 216 static inline long SYSC##name(__MAP(x,__SC_DECL,__VA_ARGS__))
diff --git a/kernel/exit.c b/kernel/exit.c
index 51e485ca9935..25d0108d7452 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -1629,9 +1629,6 @@ SYSCALL_DEFINE5(waitid, int, which, pid_t, upid, struct siginfo __user *,
1629 } 1629 }
1630 1630
1631 put_pid(pid); 1631 put_pid(pid);
1632
1633 /* avoid REGPARM breakage on x86: */
1634 asmlinkage_protect(5, ret, which, upid, infop, options, ru);
1635 return ret; 1632 return ret;
1636} 1633}
1637 1634
@@ -1669,8 +1666,6 @@ SYSCALL_DEFINE4(wait4, pid_t, upid, int __user *, stat_addr,
1669 ret = do_wait(&wo); 1666 ret = do_wait(&wo);
1670 put_pid(pid); 1667 put_pid(pid);
1671 1668
1672 /* avoid REGPARM breakage on x86: */
1673 asmlinkage_protect(4, ret, upid, stat_addr, options, ru);
1674 return ret; 1669 return ret;
1675} 1670}
1676 1671
diff --git a/kernel/fork.c b/kernel/fork.c
index 8d932b1c9056..e1f34abe5887 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1674,10 +1674,7 @@ SYSCALL_DEFINE5(clone, unsigned long, clone_flags, unsigned long, newsp,
1674 int, tls_val) 1674 int, tls_val)
1675#endif 1675#endif
1676{ 1676{
1677 long ret = do_fork(clone_flags, newsp, 0, parent_tidptr, child_tidptr); 1677 return do_fork(clone_flags, newsp, 0, parent_tidptr, child_tidptr);
1678 asmlinkage_protect(5, ret, clone_flags, newsp,
1679 parent_tidptr, child_tidptr, tls_val);
1680 return ret;
1681} 1678}
1682#endif 1679#endif
1683 1680
diff --git a/kernel/uid16.c b/kernel/uid16.c
index d7948eb10225..f6c83d7ef000 100644
--- a/kernel/uid16.c
+++ b/kernel/uid16.c
@@ -18,67 +18,43 @@
18 18
19SYSCALL_DEFINE3(chown16, const char __user *, filename, old_uid_t, user, old_gid_t, group) 19SYSCALL_DEFINE3(chown16, const char __user *, filename, old_uid_t, user, old_gid_t, group)
20{ 20{
21 long ret = sys_chown(filename, low2highuid(user), low2highgid(group)); 21 return sys_chown(filename, low2highuid(user), low2highgid(group));
22 /* avoid REGPARM breakage on x86: */
23 asmlinkage_protect(3, ret, filename, user, group);
24 return ret;
25} 22}
26 23
27SYSCALL_DEFINE3(lchown16, const char __user *, filename, old_uid_t, user, old_gid_t, group) 24SYSCALL_DEFINE3(lchown16, const char __user *, filename, old_uid_t, user, old_gid_t, group)
28{ 25{
29 long ret = sys_lchown(filename, low2highuid(user), low2highgid(group)); 26 return sys_lchown(filename, low2highuid(user), low2highgid(group));
30 /* avoid REGPARM breakage on x86: */
31 asmlinkage_protect(3, ret, filename, user, group);
32 return ret;
33} 27}
34 28
35SYSCALL_DEFINE3(fchown16, unsigned int, fd, old_uid_t, user, old_gid_t, group) 29SYSCALL_DEFINE3(fchown16, unsigned int, fd, old_uid_t, user, old_gid_t, group)
36{ 30{
37 long ret = sys_fchown(fd, low2highuid(user), low2highgid(group)); 31 return sys_fchown(fd, low2highuid(user), low2highgid(group));
38 /* avoid REGPARM breakage on x86: */
39 asmlinkage_protect(3, ret, fd, user, group);
40 return ret;
41} 32}
42 33
43SYSCALL_DEFINE2(setregid16, old_gid_t, rgid, old_gid_t, egid) 34SYSCALL_DEFINE2(setregid16, old_gid_t, rgid, old_gid_t, egid)
44{ 35{
45 long ret = sys_setregid(low2highgid(rgid), low2highgid(egid)); 36 return sys_setregid(low2highgid(rgid), low2highgid(egid));
46 /* avoid REGPARM breakage on x86: */
47 asmlinkage_protect(2, ret, rgid, egid);
48 return ret;
49} 37}
50 38
51SYSCALL_DEFINE1(setgid16, old_gid_t, gid) 39SYSCALL_DEFINE1(setgid16, old_gid_t, gid)
52{ 40{
53 long ret = sys_setgid(low2highgid(gid)); 41 return sys_setgid(low2highgid(gid));
54 /* avoid REGPARM breakage on x86: */
55 asmlinkage_protect(1, ret, gid);
56 return ret;
57} 42}
58 43
59SYSCALL_DEFINE2(setreuid16, old_uid_t, ruid, old_uid_t, euid) 44SYSCALL_DEFINE2(setreuid16, old_uid_t, ruid, old_uid_t, euid)
60{ 45{
61 long ret = sys_setreuid(low2highuid(ruid), low2highuid(euid)); 46 return sys_setreuid(low2highuid(ruid), low2highuid(euid));
62 /* avoid REGPARM breakage on x86: */
63 asmlinkage_protect(2, ret, ruid, euid);
64 return ret;
65} 47}
66 48
67SYSCALL_DEFINE1(setuid16, old_uid_t, uid) 49SYSCALL_DEFINE1(setuid16, old_uid_t, uid)
68{ 50{
69 long ret = sys_setuid(low2highuid(uid)); 51 return sys_setuid(low2highuid(uid));
70 /* avoid REGPARM breakage on x86: */
71 asmlinkage_protect(1, ret, uid);
72 return ret;
73} 52}
74 53
75SYSCALL_DEFINE3(setresuid16, old_uid_t, ruid, old_uid_t, euid, old_uid_t, suid) 54SYSCALL_DEFINE3(setresuid16, old_uid_t, ruid, old_uid_t, euid, old_uid_t, suid)
76{ 55{
77 long ret = sys_setresuid(low2highuid(ruid), low2highuid(euid), 56 return sys_setresuid(low2highuid(ruid), low2highuid(euid),
78 low2highuid(suid)); 57 low2highuid(suid));
79 /* avoid REGPARM breakage on x86: */
80 asmlinkage_protect(3, ret, ruid, euid, suid);
81 return ret;
82} 58}
83 59
84SYSCALL_DEFINE3(getresuid16, old_uid_t __user *, ruidp, old_uid_t __user *, euidp, old_uid_t __user *, suidp) 60SYSCALL_DEFINE3(getresuid16, old_uid_t __user *, ruidp, old_uid_t __user *, euidp, old_uid_t __user *, suidp)
@@ -100,11 +76,8 @@ SYSCALL_DEFINE3(getresuid16, old_uid_t __user *, ruidp, old_uid_t __user *, euid
100 76
101SYSCALL_DEFINE3(setresgid16, old_gid_t, rgid, old_gid_t, egid, old_gid_t, sgid) 77SYSCALL_DEFINE3(setresgid16, old_gid_t, rgid, old_gid_t, egid, old_gid_t, sgid)
102{ 78{
103 long ret = sys_setresgid(low2highgid(rgid), low2highgid(egid), 79 return sys_setresgid(low2highgid(rgid), low2highgid(egid),
104 low2highgid(sgid)); 80 low2highgid(sgid));
105 /* avoid REGPARM breakage on x86: */
106 asmlinkage_protect(3, ret, rgid, egid, sgid);
107 return ret;
108} 81}
109 82
110 83
@@ -127,18 +100,12 @@ SYSCALL_DEFINE3(getresgid16, old_gid_t __user *, rgidp, old_gid_t __user *, egid
127 100
128SYSCALL_DEFINE1(setfsuid16, old_uid_t, uid) 101SYSCALL_DEFINE1(setfsuid16, old_uid_t, uid)
129{ 102{
130 long ret = sys_setfsuid(low2highuid(uid)); 103 return sys_setfsuid(low2highuid(uid));
131 /* avoid REGPARM breakage on x86: */
132 asmlinkage_protect(1, ret, uid);
133 return ret;
134} 104}
135 105
136SYSCALL_DEFINE1(setfsgid16, old_gid_t, gid) 106SYSCALL_DEFINE1(setfsgid16, old_gid_t, gid)
137{ 107{
138 long ret = sys_setfsgid(low2highgid(gid)); 108 return sys_setfsgid(low2highgid(gid));
139 /* avoid REGPARM breakage on x86: */
140 asmlinkage_protect(1, ret, gid);
141 return ret;
142} 109}
143 110
144static int groups16_to_user(old_gid_t __user *grouplist, 111static int groups16_to_user(old_gid_t __user *grouplist,