Commit 625b1d7e authored by Heiko Carstens's avatar Heiko Carstens

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: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
parent 875ec3da
...@@ -72,8 +72,8 @@ int compat_printk(const char *fmt, ...) ...@@ -72,8 +72,8 @@ int compat_printk(const char *fmt, ...)
* Not all architectures have sys_utime, so implement this in terms * Not all architectures have sys_utime, so implement this in terms
* of sys_utimes. * of sys_utimes.
*/ */
asmlinkage long compat_sys_utime(const char __user *filename, COMPAT_SYSCALL_DEFINE2(utime, const char __user *, filename,
struct compat_utimbuf __user *t) struct compat_utimbuf __user *, t)
{ {
struct timespec tv[2]; struct timespec tv[2];
...@@ -87,7 +87,7 @@ asmlinkage long compat_sys_utime(const char __user *filename, ...@@ -87,7 +87,7 @@ asmlinkage long compat_sys_utime(const char __user *filename,
return do_utimes(AT_FDCWD, filename, t ? tv : NULL, 0); return do_utimes(AT_FDCWD, filename, t ? tv : NULL, 0);
} }
asmlinkage long compat_sys_utimensat(unsigned int dfd, const char __user *filename, struct compat_timespec __user *t, int flags) COMPAT_SYSCALL_DEFINE4(utimensat, unsigned int, dfd, const char __user *, filename, struct compat_timespec __user *, t, int, flags)
{ {
struct timespec tv[2]; struct timespec tv[2];
...@@ -102,7 +102,7 @@ asmlinkage long compat_sys_utimensat(unsigned int dfd, const char __user *filena ...@@ -102,7 +102,7 @@ asmlinkage long compat_sys_utimensat(unsigned int dfd, const char __user *filena
return do_utimes(dfd, filename, t ? tv : NULL, flags); return do_utimes(dfd, filename, t ? tv : NULL, flags);
} }
asmlinkage long compat_sys_futimesat(unsigned int dfd, const char __user *filename, struct compat_timeval __user *t) COMPAT_SYSCALL_DEFINE3(futimesat, unsigned int, dfd, const char __user *, filename, struct compat_timeval __user *, t)
{ {
struct timespec tv[2]; struct timespec tv[2];
...@@ -121,7 +121,7 @@ asmlinkage long compat_sys_futimesat(unsigned int dfd, const char __user *filena ...@@ -121,7 +121,7 @@ asmlinkage long compat_sys_futimesat(unsigned int dfd, const char __user *filena
return do_utimes(dfd, filename, t ? tv : NULL, 0); return do_utimes(dfd, filename, t ? tv : NULL, 0);
} }
asmlinkage long compat_sys_utimes(const char __user *filename, struct compat_timeval __user *t) COMPAT_SYSCALL_DEFINE2(utimes, const char __user *, filename, struct compat_timeval __user *, t)
{ {
return compat_sys_futimesat(AT_FDCWD, filename, t); return compat_sys_futimesat(AT_FDCWD, filename, t);
} }
...@@ -159,8 +159,8 @@ static int cp_compat_stat(struct kstat *stat, struct compat_stat __user *ubuf) ...@@ -159,8 +159,8 @@ static int cp_compat_stat(struct kstat *stat, struct compat_stat __user *ubuf)
return copy_to_user(ubuf, &tmp, sizeof(tmp)) ? -EFAULT : 0; return copy_to_user(ubuf, &tmp, sizeof(tmp)) ? -EFAULT : 0;
} }
asmlinkage long compat_sys_newstat(const char __user * filename, COMPAT_SYSCALL_DEFINE2(newstat, const char __user *, filename,
struct compat_stat __user *statbuf) struct compat_stat __user *, statbuf)
{ {
struct kstat stat; struct kstat stat;
int error; int error;
...@@ -171,8 +171,8 @@ asmlinkage long compat_sys_newstat(const char __user * filename, ...@@ -171,8 +171,8 @@ asmlinkage long compat_sys_newstat(const char __user * filename,
return cp_compat_stat(&stat, statbuf); return cp_compat_stat(&stat, statbuf);
} }
asmlinkage long compat_sys_newlstat(const char __user * filename, COMPAT_SYSCALL_DEFINE2(newlstat, const char __user *, filename,
struct compat_stat __user *statbuf) struct compat_stat __user *, statbuf)
{ {
struct kstat stat; struct kstat stat;
int error; int error;
...@@ -184,9 +184,9 @@ asmlinkage long compat_sys_newlstat(const char __user * filename, ...@@ -184,9 +184,9 @@ asmlinkage long compat_sys_newlstat(const char __user * filename,
} }
#ifndef __ARCH_WANT_STAT64 #ifndef __ARCH_WANT_STAT64
asmlinkage long compat_sys_newfstatat(unsigned int dfd, COMPAT_SYSCALL_DEFINE4(newfstatat, unsigned int, dfd,
const char __user *filename, const char __user *, filename,
struct compat_stat __user *statbuf, int flag) struct compat_stat __user *, statbuf, int, flag)
{ {
struct kstat stat; struct kstat stat;
int error; int error;
...@@ -198,8 +198,8 @@ asmlinkage long compat_sys_newfstatat(unsigned int dfd, ...@@ -198,8 +198,8 @@ asmlinkage long compat_sys_newfstatat(unsigned int dfd,
} }
#endif #endif
asmlinkage long compat_sys_newfstat(unsigned int fd, COMPAT_SYSCALL_DEFINE2(newfstat, unsigned int, fd,
struct compat_stat __user * statbuf) struct compat_stat __user *, statbuf)
{ {
struct kstat stat; struct kstat stat;
int error = vfs_fstat(fd, &stat); int error = vfs_fstat(fd, &stat);
...@@ -247,7 +247,7 @@ static int put_compat_statfs(struct compat_statfs __user *ubuf, struct kstatfs * ...@@ -247,7 +247,7 @@ static int put_compat_statfs(struct compat_statfs __user *ubuf, struct kstatfs *
* The following statfs calls are copies of code from fs/statfs.c and * The following statfs calls are copies of code from fs/statfs.c and
* should be checked against those from time to time * should be checked against those from time to time
*/ */
asmlinkage long compat_sys_statfs(const char __user *pathname, struct compat_statfs __user *buf) COMPAT_SYSCALL_DEFINE2(statfs, const char __user *, pathname, struct compat_statfs __user *, buf)
{ {
struct kstatfs tmp; struct kstatfs tmp;
int error = user_statfs(pathname, &tmp); int error = user_statfs(pathname, &tmp);
...@@ -256,7 +256,7 @@ asmlinkage long compat_sys_statfs(const char __user *pathname, struct compat_sta ...@@ -256,7 +256,7 @@ asmlinkage long compat_sys_statfs(const char __user *pathname, struct compat_sta
return error; return error;
} }
asmlinkage long compat_sys_fstatfs(unsigned int fd, struct compat_statfs __user *buf) COMPAT_SYSCALL_DEFINE2(fstatfs, unsigned int, fd, struct compat_statfs __user *, buf)
{ {
struct kstatfs tmp; struct kstatfs tmp;
int error = fd_statfs(fd, &tmp); int error = fd_statfs(fd, &tmp);
...@@ -298,7 +298,7 @@ static int put_compat_statfs64(struct compat_statfs64 __user *ubuf, struct kstat ...@@ -298,7 +298,7 @@ static int put_compat_statfs64(struct compat_statfs64 __user *ubuf, struct kstat
return 0; return 0;
} }
asmlinkage long compat_sys_statfs64(const char __user *pathname, compat_size_t sz, struct compat_statfs64 __user *buf) COMPAT_SYSCALL_DEFINE3(statfs64, const char __user *, pathname, compat_size_t, sz, struct compat_statfs64 __user *, buf)
{ {
struct kstatfs tmp; struct kstatfs tmp;
int error; int error;
...@@ -312,7 +312,7 @@ asmlinkage long compat_sys_statfs64(const char __user *pathname, compat_size_t s ...@@ -312,7 +312,7 @@ asmlinkage long compat_sys_statfs64(const char __user *pathname, compat_size_t s
return error; return error;
} }
asmlinkage long compat_sys_fstatfs64(unsigned int fd, compat_size_t sz, struct compat_statfs64 __user *buf) COMPAT_SYSCALL_DEFINE3(fstatfs64, unsigned int, fd, compat_size_t, sz, struct compat_statfs64 __user *, buf)
{ {
struct kstatfs tmp; struct kstatfs tmp;
int error; int error;
...@@ -331,7 +331,7 @@ asmlinkage long compat_sys_fstatfs64(unsigned int fd, compat_size_t sz, struct c ...@@ -331,7 +331,7 @@ asmlinkage long compat_sys_fstatfs64(unsigned int fd, compat_size_t sz, struct c
* Given how simple this syscall is that apporach is more maintainable * Given how simple this syscall is that apporach is more maintainable
* than the various conversion hacks. * than the various conversion hacks.
*/ */
asmlinkage long compat_sys_ustat(unsigned dev, struct compat_ustat __user *u) COMPAT_SYSCALL_DEFINE2(ustat, unsigned, dev, struct compat_ustat __user *, u)
{ {
struct compat_ustat tmp; struct compat_ustat tmp;
struct kstatfs sbuf; struct kstatfs sbuf;
...@@ -476,8 +476,7 @@ asmlinkage long compat_sys_fcntl(unsigned int fd, unsigned int cmd, ...@@ -476,8 +476,7 @@ asmlinkage long compat_sys_fcntl(unsigned int fd, unsigned int cmd,
return compat_sys_fcntl64(fd, cmd, arg); return compat_sys_fcntl64(fd, cmd, arg);
} }
asmlinkage long COMPAT_SYSCALL_DEFINE2(io_setup, unsigned, nr_reqs, u32 __user *, ctx32p)
compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
{ {
long ret; long ret;
aio_context_t ctx64; aio_context_t ctx64;
...@@ -869,8 +868,8 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen, ...@@ -869,8 +868,8 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
return -EFAULT; return -EFAULT;
} }
asmlinkage long compat_sys_old_readdir(unsigned int fd, COMPAT_SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
struct compat_old_linux_dirent __user *dirent, unsigned int count) struct compat_old_linux_dirent __user *, dirent, unsigned int, count)
{ {
int error; int error;
struct fd f = fdget(fd); struct fd f = fdget(fd);
...@@ -948,8 +947,8 @@ static int compat_filldir(void *__buf, const char *name, int namlen, ...@@ -948,8 +947,8 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
return -EFAULT; return -EFAULT;
} }
asmlinkage long compat_sys_getdents(unsigned int fd, COMPAT_SYSCALL_DEFINE3(getdents, unsigned int, fd,
struct compat_linux_dirent __user *dirent, unsigned int count) struct compat_linux_dirent __user *, dirent, unsigned int, count)
{ {
struct fd f; struct fd f;
struct compat_linux_dirent __user * lastdirent; struct compat_linux_dirent __user * lastdirent;
...@@ -1033,8 +1032,8 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t ...@@ -1033,8 +1032,8 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
return -EFAULT; return -EFAULT;
} }
asmlinkage long compat_sys_getdents64(unsigned int fd, COMPAT_SYSCALL_DEFINE3(getdents64, unsigned int, fd,
struct linux_dirent64 __user * dirent, unsigned int count) struct linux_dirent64 __user *, dirent, unsigned int, count)
{ {
struct fd f; struct fd f;
struct linux_dirent64 __user * lastdirent; struct linux_dirent64 __user * lastdirent;
...@@ -1287,9 +1286,9 @@ int compat_core_sys_select(int n, compat_ulong_t __user *inp, ...@@ -1287,9 +1286,9 @@ int compat_core_sys_select(int n, compat_ulong_t __user *inp,
return ret; return ret;
} }
asmlinkage long compat_sys_select(int n, compat_ulong_t __user *inp, COMPAT_SYSCALL_DEFINE5(select, int, n, compat_ulong_t __user *, inp,
compat_ulong_t __user *outp, compat_ulong_t __user *exp, compat_ulong_t __user *, outp, compat_ulong_t __user *, exp,
struct compat_timeval __user *tvp) struct compat_timeval __user *, tvp)
{ {
struct timespec end_time, *to = NULL; struct timespec end_time, *to = NULL;
struct compat_timeval tv; struct compat_timeval tv;
...@@ -1320,7 +1319,7 @@ struct compat_sel_arg_struct { ...@@ -1320,7 +1319,7 @@ struct compat_sel_arg_struct {
compat_uptr_t tvp; compat_uptr_t tvp;
}; };
asmlinkage long compat_sys_old_select(struct compat_sel_arg_struct __user *arg) COMPAT_SYSCALL_DEFINE1(old_select, struct compat_sel_arg_struct __user *, arg)
{ {
struct compat_sel_arg_struct a; struct compat_sel_arg_struct a;
...@@ -1381,9 +1380,9 @@ static long do_compat_pselect(int n, compat_ulong_t __user *inp, ...@@ -1381,9 +1380,9 @@ static long do_compat_pselect(int n, compat_ulong_t __user *inp,
return ret; return ret;
} }
asmlinkage long compat_sys_pselect6(int n, compat_ulong_t __user *inp, COMPAT_SYSCALL_DEFINE6(pselect6, int, n, compat_ulong_t __user *, inp,
compat_ulong_t __user *outp, compat_ulong_t __user *exp, compat_ulong_t __user *, outp, compat_ulong_t __user *, exp,
struct compat_timespec __user *tsp, void __user *sig) struct compat_timespec __user *, tsp, void __user *, sig)
{ {
compat_size_t sigsetsize = 0; compat_size_t sigsetsize = 0;
compat_uptr_t up = 0; compat_uptr_t up = 0;
...@@ -1400,9 +1399,9 @@ asmlinkage long compat_sys_pselect6(int n, compat_ulong_t __user *inp, ...@@ -1400,9 +1399,9 @@ asmlinkage long compat_sys_pselect6(int n, compat_ulong_t __user *inp,
sigsetsize); sigsetsize);
} }
asmlinkage long compat_sys_ppoll(struct pollfd __user *ufds, COMPAT_SYSCALL_DEFINE5(ppoll, struct pollfd __user *, ufds,
unsigned int nfds, struct compat_timespec __user *tsp, unsigned int, nfds, struct compat_timespec __user *, tsp,
const compat_sigset_t __user *sigmask, compat_size_t sigsetsize) const compat_sigset_t __user *, sigmask, compat_size_t, sigsetsize)
{ {
compat_sigset_t ss32; compat_sigset_t ss32;
sigset_t ksigmask, sigsaved; sigset_t ksigmask, sigsaved;
......
...@@ -1619,9 +1619,9 @@ SYSCALL_DEFINE3(execve, ...@@ -1619,9 +1619,9 @@ SYSCALL_DEFINE3(execve,
return do_execve(getname(filename), argv, envp); return do_execve(getname(filename), argv, envp);
} }
#ifdef CONFIG_COMPAT #ifdef CONFIG_COMPAT
asmlinkage long compat_sys_execve(const char __user * filename, COMPAT_SYSCALL_DEFINE3(execve, const char __user *, filename,
const compat_uptr_t __user * argv, const compat_uptr_t __user *, argv,
const compat_uptr_t __user * envp) const compat_uptr_t __user *, envp)
{ {
return compat_do_execve(getname(filename), argv, envp); return compat_do_execve(getname(filename), argv, envp);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment