diff options
author | Heiko Carstens <heiko.carstens@de.ibm.com> | 2014-03-04 04:53:50 -0500 |
---|---|---|
committer | Heiko Carstens <heiko.carstens@de.ibm.com> | 2014-03-06 10:30:43 -0500 |
commit | 625b1d7e812d55df8d42253a134002c006de7468 (patch) | |
tree | 12a632957dac90ba9fe4da7c854a3c967b84d961 | |
parent | 875ec3da4c50571906dcd23952f1dfcdd92ae3f1 (diff) |
fs/compat: convert to COMPAT_SYSCALL_DEFINE
Convert all compat system call functions where all parameter types
have a size of four or less than four bytes, or are pointer types
to COMPAT_SYSCALL_DEFINE.
The implicit casts within COMPAT_SYSCALL_DEFINE will perform proper
zero and sign extension to 64 bit of all parameters if needed.
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
-rw-r--r-- | fs/compat.c | 73 | ||||
-rw-r--r-- | fs/exec.c | 6 |
2 files changed, 39 insertions, 40 deletions
diff --git a/fs/compat.c b/fs/compat.c index 0095a6978eef..6d8312b7a51d 100644 --- a/fs/compat.c +++ b/fs/compat.c | |||
@@ -72,8 +72,8 @@ int compat_printk(const char *fmt, ...) | |||
72 | * Not all architectures have sys_utime, so implement this in terms | 72 | * Not all architectures have sys_utime, so implement this in terms |
73 | * of sys_utimes. | 73 | * of sys_utimes. |
74 | */ | 74 | */ |
75 | asmlinkage long compat_sys_utime(const char __user *filename, | 75 | COMPAT_SYSCALL_DEFINE2(utime, const char __user *, filename, |
76 | struct compat_utimbuf __user *t) | 76 | struct compat_utimbuf __user *, t) |
77 | { | 77 | { |
78 | struct timespec tv[2]; | 78 | struct timespec tv[2]; |
79 | 79 | ||
@@ -87,7 +87,7 @@ asmlinkage long compat_sys_utime(const char __user *filename, | |||
87 | return do_utimes(AT_FDCWD, filename, t ? tv : NULL, 0); | 87 | return do_utimes(AT_FDCWD, filename, t ? tv : NULL, 0); |
88 | } | 88 | } |
89 | 89 | ||
90 | asmlinkage long compat_sys_utimensat(unsigned int dfd, const char __user *filename, struct compat_timespec __user *t, int flags) | 90 | COMPAT_SYSCALL_DEFINE4(utimensat, unsigned int, dfd, const char __user *, filename, struct compat_timespec __user *, t, int, flags) |
91 | { | 91 | { |
92 | struct timespec tv[2]; | 92 | struct timespec tv[2]; |
93 | 93 | ||
@@ -102,7 +102,7 @@ asmlinkage long compat_sys_utimensat(unsigned int dfd, const char __user *filena | |||
102 | return do_utimes(dfd, filename, t ? tv : NULL, flags); | 102 | return do_utimes(dfd, filename, t ? tv : NULL, flags); |
103 | } | 103 | } |
104 | 104 | ||
105 | asmlinkage long compat_sys_futimesat(unsigned int dfd, const char __user *filename, struct compat_timeval __user *t) | 105 | COMPAT_SYSCALL_DEFINE3(futimesat, unsigned int, dfd, const char __user *, filename, struct compat_timeval __user *, t) |
106 | { | 106 | { |
107 | struct timespec tv[2]; | 107 | struct timespec tv[2]; |
108 | 108 | ||
@@ -121,7 +121,7 @@ asmlinkage long compat_sys_futimesat(unsigned int dfd, const char __user *filena | |||
121 | return do_utimes(dfd, filename, t ? tv : NULL, 0); | 121 | return do_utimes(dfd, filename, t ? tv : NULL, 0); |
122 | } | 122 | } |
123 | 123 | ||
124 | asmlinkage long compat_sys_utimes(const char __user *filename, struct compat_timeval __user *t) | 124 | COMPAT_SYSCALL_DEFINE2(utimes, const char __user *, filename, struct compat_timeval __user *, t) |
125 | { | 125 | { |
126 | return compat_sys_futimesat(AT_FDCWD, filename, t); | 126 | return compat_sys_futimesat(AT_FDCWD, filename, t); |
127 | } | 127 | } |
@@ -159,8 +159,8 @@ static int cp_compat_stat(struct kstat *stat, struct compat_stat __user *ubuf) | |||
159 | return copy_to_user(ubuf, &tmp, sizeof(tmp)) ? -EFAULT : 0; | 159 | return copy_to_user(ubuf, &tmp, sizeof(tmp)) ? -EFAULT : 0; |
160 | } | 160 | } |
161 | 161 | ||
162 | asmlinkage long compat_sys_newstat(const char __user * filename, | 162 | COMPAT_SYSCALL_DEFINE2(newstat, const char __user *, filename, |
163 | struct compat_stat __user *statbuf) | 163 | struct compat_stat __user *, statbuf) |
164 | { | 164 | { |
165 | struct kstat stat; | 165 | struct kstat stat; |
166 | int error; | 166 | int error; |
@@ -171,8 +171,8 @@ asmlinkage long compat_sys_newstat(const char __user * filename, | |||
171 | return cp_compat_stat(&stat, statbuf); | 171 | return cp_compat_stat(&stat, statbuf); |
172 | } | 172 | } |
173 | 173 | ||
174 | asmlinkage long compat_sys_newlstat(const char __user * filename, | 174 | COMPAT_SYSCALL_DEFINE2(newlstat, const char __user *, filename, |
175 | struct compat_stat __user *statbuf) | 175 | struct compat_stat __user *, statbuf) |
176 | { | 176 | { |
177 | struct kstat stat; | 177 | struct kstat stat; |
178 | int error; | 178 | int error; |
@@ -184,9 +184,9 @@ asmlinkage long compat_sys_newlstat(const char __user * filename, | |||
184 | } | 184 | } |
185 | 185 | ||
186 | #ifndef __ARCH_WANT_STAT64 | 186 | #ifndef __ARCH_WANT_STAT64 |
187 | asmlinkage long compat_sys_newfstatat(unsigned int dfd, | 187 | COMPAT_SYSCALL_DEFINE4(newfstatat, unsigned int, dfd, |
188 | const char __user *filename, | 188 | const char __user *, filename, |
189 | struct compat_stat __user *statbuf, int flag) | 189 | struct compat_stat __user *, statbuf, int, flag) |
190 | { | 190 | { |
191 | struct kstat stat; | 191 | struct kstat stat; |
192 | int error; | 192 | int error; |
@@ -198,8 +198,8 @@ asmlinkage long compat_sys_newfstatat(unsigned int dfd, | |||
198 | } | 198 | } |
199 | #endif | 199 | #endif |
200 | 200 | ||
201 | asmlinkage long compat_sys_newfstat(unsigned int fd, | 201 | COMPAT_SYSCALL_DEFINE2(newfstat, unsigned int, fd, |
202 | struct compat_stat __user * statbuf) | 202 | struct compat_stat __user *, statbuf) |
203 | { | 203 | { |
204 | struct kstat stat; | 204 | struct kstat stat; |
205 | int error = vfs_fstat(fd, &stat); | 205 | int error = vfs_fstat(fd, &stat); |
@@ -247,7 +247,7 @@ static int put_compat_statfs(struct compat_statfs __user *ubuf, struct kstatfs * | |||
247 | * The following statfs calls are copies of code from fs/statfs.c and | 247 | * The following statfs calls are copies of code from fs/statfs.c and |
248 | * should be checked against those from time to time | 248 | * should be checked against those from time to time |
249 | */ | 249 | */ |
250 | asmlinkage long compat_sys_statfs(const char __user *pathname, struct compat_statfs __user *buf) | 250 | COMPAT_SYSCALL_DEFINE2(statfs, const char __user *, pathname, struct compat_statfs __user *, buf) |
251 | { | 251 | { |
252 | struct kstatfs tmp; | 252 | struct kstatfs tmp; |
253 | int error = user_statfs(pathname, &tmp); | 253 | int error = user_statfs(pathname, &tmp); |
@@ -256,7 +256,7 @@ asmlinkage long compat_sys_statfs(const char __user *pathname, struct compat_sta | |||
256 | return error; | 256 | return error; |
257 | } | 257 | } |
258 | 258 | ||
259 | asmlinkage long compat_sys_fstatfs(unsigned int fd, struct compat_statfs __user *buf) | 259 | COMPAT_SYSCALL_DEFINE2(fstatfs, unsigned int, fd, struct compat_statfs __user *, buf) |
260 | { | 260 | { |
261 | struct kstatfs tmp; | 261 | struct kstatfs tmp; |
262 | int error = fd_statfs(fd, &tmp); | 262 | int error = fd_statfs(fd, &tmp); |
@@ -298,7 +298,7 @@ static int put_compat_statfs64(struct compat_statfs64 __user *ubuf, struct kstat | |||
298 | return 0; | 298 | return 0; |
299 | } | 299 | } |
300 | 300 | ||
301 | asmlinkage long compat_sys_statfs64(const char __user *pathname, compat_size_t sz, struct compat_statfs64 __user *buf) | 301 | COMPAT_SYSCALL_DEFINE3(statfs64, const char __user *, pathname, compat_size_t, sz, struct compat_statfs64 __user *, buf) |
302 | { | 302 | { |
303 | struct kstatfs tmp; | 303 | struct kstatfs tmp; |
304 | int error; | 304 | int error; |
@@ -312,7 +312,7 @@ asmlinkage long compat_sys_statfs64(const char __user *pathname, compat_size_t s | |||
312 | return error; | 312 | return error; |
313 | } | 313 | } |
314 | 314 | ||
315 | asmlinkage long compat_sys_fstatfs64(unsigned int fd, compat_size_t sz, struct compat_statfs64 __user *buf) | 315 | COMPAT_SYSCALL_DEFINE3(fstatfs64, unsigned int, fd, compat_size_t, sz, struct compat_statfs64 __user *, buf) |
316 | { | 316 | { |
317 | struct kstatfs tmp; | 317 | struct kstatfs tmp; |
318 | int error; | 318 | int error; |
@@ -331,7 +331,7 @@ asmlinkage long compat_sys_fstatfs64(unsigned int fd, compat_size_t sz, struct c | |||
331 | * Given how simple this syscall is that apporach is more maintainable | 331 | * Given how simple this syscall is that apporach is more maintainable |
332 | * than the various conversion hacks. | 332 | * than the various conversion hacks. |
333 | */ | 333 | */ |
334 | asmlinkage long compat_sys_ustat(unsigned dev, struct compat_ustat __user *u) | 334 | COMPAT_SYSCALL_DEFINE2(ustat, unsigned, dev, struct compat_ustat __user *, u) |
335 | { | 335 | { |
336 | struct compat_ustat tmp; | 336 | struct compat_ustat tmp; |
337 | struct kstatfs sbuf; | 337 | struct kstatfs sbuf; |
@@ -476,8 +476,7 @@ asmlinkage long compat_sys_fcntl(unsigned int fd, unsigned int cmd, | |||
476 | return compat_sys_fcntl64(fd, cmd, arg); | 476 | return compat_sys_fcntl64(fd, cmd, arg); |
477 | } | 477 | } |
478 | 478 | ||
479 | asmlinkage long | 479 | COMPAT_SYSCALL_DEFINE2(io_setup, unsigned, nr_reqs, u32 __user *, ctx32p) |
480 | compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p) | ||
481 | { | 480 | { |
482 | long ret; | 481 | long ret; |
483 | aio_context_t ctx64; | 482 | aio_context_t ctx64; |
@@ -869,8 +868,8 @@ efault: | |||
869 | return -EFAULT; | 868 | return -EFAULT; |
870 | } | 869 | } |
871 | 870 | ||
872 | asmlinkage long compat_sys_old_readdir(unsigned int fd, | 871 | COMPAT_SYSCALL_DEFINE3(old_readdir, unsigned int, fd, |
873 | struct compat_old_linux_dirent __user *dirent, unsigned int count) | 872 | struct compat_old_linux_dirent __user *, dirent, unsigned int, count) |
874 | { | 873 | { |
875 | int error; | 874 | int error; |
876 | struct fd f = fdget(fd); | 875 | struct fd f = fdget(fd); |
@@ -948,8 +947,8 @@ efault: | |||
948 | return -EFAULT; | 947 | return -EFAULT; |
949 | } | 948 | } |
950 | 949 | ||
951 | asmlinkage long compat_sys_getdents(unsigned int fd, | 950 | COMPAT_SYSCALL_DEFINE3(getdents, unsigned int, fd, |
952 | struct compat_linux_dirent __user *dirent, unsigned int count) | 951 | struct compat_linux_dirent __user *, dirent, unsigned int, count) |
953 | { | 952 | { |
954 | struct fd f; | 953 | struct fd f; |
955 | struct compat_linux_dirent __user * lastdirent; | 954 | struct compat_linux_dirent __user * lastdirent; |
@@ -1033,8 +1032,8 @@ efault: | |||
1033 | return -EFAULT; | 1032 | return -EFAULT; |
1034 | } | 1033 | } |
1035 | 1034 | ||
1036 | asmlinkage long compat_sys_getdents64(unsigned int fd, | 1035 | COMPAT_SYSCALL_DEFINE3(getdents64, unsigned int, fd, |
1037 | struct linux_dirent64 __user * dirent, unsigned int count) | 1036 | struct linux_dirent64 __user *, dirent, unsigned int, count) |
1038 | { | 1037 | { |
1039 | struct fd f; | 1038 | struct fd f; |
1040 | struct linux_dirent64 __user * lastdirent; | 1039 | struct linux_dirent64 __user * lastdirent; |
@@ -1287,9 +1286,9 @@ out_nofds: | |||
1287 | return ret; | 1286 | return ret; |
1288 | } | 1287 | } |
1289 | 1288 | ||
1290 | asmlinkage long compat_sys_select(int n, compat_ulong_t __user *inp, | 1289 | COMPAT_SYSCALL_DEFINE5(select, int, n, compat_ulong_t __user *, inp, |
1291 | compat_ulong_t __user *outp, compat_ulong_t __user *exp, | 1290 | compat_ulong_t __user *, outp, compat_ulong_t __user *, exp, |
1292 | struct compat_timeval __user *tvp) | 1291 | struct compat_timeval __user *, tvp) |
1293 | { | 1292 | { |
1294 | struct timespec end_time, *to = NULL; | 1293 | struct timespec end_time, *to = NULL; |
1295 | struct compat_timeval tv; | 1294 | struct compat_timeval tv; |
@@ -1320,7 +1319,7 @@ struct compat_sel_arg_struct { | |||
1320 | compat_uptr_t tvp; | 1319 | compat_uptr_t tvp; |
1321 | }; | 1320 | }; |
1322 | 1321 | ||
1323 | asmlinkage long compat_sys_old_select(struct compat_sel_arg_struct __user *arg) | 1322 | COMPAT_SYSCALL_DEFINE1(old_select, struct compat_sel_arg_struct __user *, arg) |
1324 | { | 1323 | { |
1325 | struct compat_sel_arg_struct a; | 1324 | struct compat_sel_arg_struct a; |
1326 | 1325 | ||
@@ -1381,9 +1380,9 @@ static long do_compat_pselect(int n, compat_ulong_t __user *inp, | |||
1381 | return ret; | 1380 | return ret; |
1382 | } | 1381 | } |
1383 | 1382 | ||
1384 | asmlinkage long compat_sys_pselect6(int n, compat_ulong_t __user *inp, | 1383 | COMPAT_SYSCALL_DEFINE6(pselect6, int, n, compat_ulong_t __user *, inp, |
1385 | compat_ulong_t __user *outp, compat_ulong_t __user *exp, | 1384 | compat_ulong_t __user *, outp, compat_ulong_t __user *, exp, |
1386 | struct compat_timespec __user *tsp, void __user *sig) | 1385 | struct compat_timespec __user *, tsp, void __user *, sig) |
1387 | { | 1386 | { |
1388 | compat_size_t sigsetsize = 0; | 1387 | compat_size_t sigsetsize = 0; |
1389 | compat_uptr_t up = 0; | 1388 | compat_uptr_t up = 0; |
@@ -1400,9 +1399,9 @@ asmlinkage long compat_sys_pselect6(int n, compat_ulong_t __user *inp, | |||
1400 | sigsetsize); | 1399 | sigsetsize); |
1401 | } | 1400 | } |
1402 | 1401 | ||
1403 | asmlinkage long compat_sys_ppoll(struct pollfd __user *ufds, | 1402 | COMPAT_SYSCALL_DEFINE5(ppoll, struct pollfd __user *, ufds, |
1404 | unsigned int nfds, struct compat_timespec __user *tsp, | 1403 | unsigned int, nfds, struct compat_timespec __user *, tsp, |
1405 | const compat_sigset_t __user *sigmask, compat_size_t sigsetsize) | 1404 | const compat_sigset_t __user *, sigmask, compat_size_t, sigsetsize) |
1406 | { | 1405 | { |
1407 | compat_sigset_t ss32; | 1406 | compat_sigset_t ss32; |
1408 | sigset_t ksigmask, sigsaved; | 1407 | sigset_t ksigmask, sigsaved; |
@@ -1619,9 +1619,9 @@ SYSCALL_DEFINE3(execve, | |||
1619 | return do_execve(getname(filename), argv, envp); | 1619 | return do_execve(getname(filename), argv, envp); |
1620 | } | 1620 | } |
1621 | #ifdef CONFIG_COMPAT | 1621 | #ifdef CONFIG_COMPAT |
1622 | asmlinkage long compat_sys_execve(const char __user * filename, | 1622 | COMPAT_SYSCALL_DEFINE3(execve, const char __user *, filename, |
1623 | const compat_uptr_t __user * argv, | 1623 | const compat_uptr_t __user *, argv, |
1624 | const compat_uptr_t __user * envp) | 1624 | const compat_uptr_t __user *, envp) |
1625 | { | 1625 | { |
1626 | return compat_do_execve(getname(filename), argv, envp); | 1626 | return compat_do_execve(getname(filename), argv, envp); |
1627 | } | 1627 | } |