diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-05-01 10:21:43 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-05-01 10:21:43 -0400 |
| commit | 08d76760832993050ad8c25e63b56773ef2ca303 (patch) | |
| tree | abdcf148dfe43cd49f30f204f1dac6978107a508 /fs | |
| 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 'fs')
| -rw-r--r-- | fs/aio.c | 2 | ||||
| -rw-r--r-- | fs/compat.c | 121 | ||||
| -rw-r--r-- | fs/dcookies.c | 15 | ||||
| -rw-r--r-- | fs/eventpoll.c | 47 | ||||
| -rw-r--r-- | fs/notify/fanotify/fanotify_user.c | 17 | ||||
| -rw-r--r-- | fs/open.c | 52 | ||||
| -rw-r--r-- | fs/read_write.c | 68 | ||||
| -rw-r--r-- | fs/read_write.h | 2 | ||||
| -rw-r--r-- | fs/signalfd.c | 31 | ||||
| -rw-r--r-- | fs/splice.c | 22 | ||||
| -rw-r--r-- | fs/sync.c | 26 |
11 files changed, 170 insertions, 233 deletions
| @@ -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/compat.c b/fs/compat.c index d487985dd0ea..5f83ffa42115 100644 --- a/fs/compat.c +++ b/fs/compat.c | |||
| @@ -44,7 +44,6 @@ | |||
| 44 | #include <linux/signal.h> | 44 | #include <linux/signal.h> |
| 45 | #include <linux/poll.h> | 45 | #include <linux/poll.h> |
| 46 | #include <linux/mm.h> | 46 | #include <linux/mm.h> |
| 47 | #include <linux/eventpoll.h> | ||
| 48 | #include <linux/fs_struct.h> | 47 | #include <linux/fs_struct.h> |
| 49 | #include <linux/slab.h> | 48 | #include <linux/slab.h> |
| 50 | #include <linux/pagemap.h> | 49 | #include <linux/pagemap.h> |
| @@ -1253,26 +1252,6 @@ compat_sys_pwritev(unsigned long fd, const struct compat_iovec __user *vec, | |||
| 1253 | return compat_sys_pwritev64(fd, vec, vlen, pos); | 1252 | return compat_sys_pwritev64(fd, vec, vlen, pos); |
| 1254 | } | 1253 | } |
| 1255 | 1254 | ||
| 1256 | asmlinkage long | ||
| 1257 | compat_sys_vmsplice(int fd, const struct compat_iovec __user *iov32, | ||
| 1258 | unsigned int nr_segs, unsigned int flags) | ||
| 1259 | { | ||
| 1260 | unsigned i; | ||
| 1261 | struct iovec __user *iov; | ||
| 1262 | if (nr_segs > UIO_MAXIOV) | ||
| 1263 | return -EINVAL; | ||
| 1264 | iov = compat_alloc_user_space(nr_segs * sizeof(struct iovec)); | ||
| 1265 | for (i = 0; i < nr_segs; i++) { | ||
| 1266 | struct compat_iovec v; | ||
| 1267 | if (get_user(v.iov_base, &iov32[i].iov_base) || | ||
| 1268 | get_user(v.iov_len, &iov32[i].iov_len) || | ||
| 1269 | put_user(compat_ptr(v.iov_base), &iov[i].iov_base) || | ||
| 1270 | put_user(v.iov_len, &iov[i].iov_len)) | ||
| 1271 | return -EFAULT; | ||
| 1272 | } | ||
| 1273 | return sys_vmsplice(fd, iov, nr_segs, flags); | ||
| 1274 | } | ||
| 1275 | |||
| 1276 | /* | 1255 | /* |
| 1277 | * Exactly like fs/open.c:sys_open(), except that it doesn't set the | 1256 | * Exactly like fs/open.c:sys_open(), except that it doesn't set the |
| 1278 | * O_LARGEFILE flag. | 1257 | * O_LARGEFILE flag. |
| @@ -1658,84 +1637,6 @@ asmlinkage long compat_sys_ppoll(struct pollfd __user *ufds, | |||
| 1658 | return ret; | 1637 | return ret; |
| 1659 | } | 1638 | } |
| 1660 | 1639 | ||
| 1661 | #ifdef CONFIG_EPOLL | ||
| 1662 | |||
| 1663 | asmlinkage long compat_sys_epoll_pwait(int epfd, | ||
| 1664 | struct compat_epoll_event __user *events, | ||
| 1665 | int maxevents, int timeout, | ||
| 1666 | const compat_sigset_t __user *sigmask, | ||
| 1667 | compat_size_t sigsetsize) | ||
| 1668 | { | ||
| 1669 | long err; | ||
| 1670 | compat_sigset_t csigmask; | ||
| 1671 | sigset_t ksigmask, sigsaved; | ||
| 1672 | |||
| 1673 | /* | ||
| 1674 | * If the caller wants a certain signal mask to be set during the wait, | ||
| 1675 | * we apply it here. | ||
| 1676 | */ | ||
| 1677 | if (sigmask) { | ||
| 1678 | if (sigsetsize != sizeof(compat_sigset_t)) | ||
| 1679 | return -EINVAL; | ||
| 1680 | if (copy_from_user(&csigmask, sigmask, sizeof(csigmask))) | ||
| 1681 | return -EFAULT; | ||
| 1682 | sigset_from_compat(&ksigmask, &csigmask); | ||
| 1683 | sigdelsetmask(&ksigmask, sigmask(SIGKILL) | sigmask(SIGSTOP)); | ||
| 1684 | sigprocmask(SIG_SETMASK, &ksigmask, &sigsaved); | ||
| 1685 | } | ||
| 1686 | |||
| 1687 | err = sys_epoll_wait(epfd, events, maxevents, timeout); | ||
| 1688 | |||
| 1689 | /* | ||
| 1690 | * If we changed the signal mask, we need to restore the original one. | ||
| 1691 | * In case we've got a signal while waiting, we do not restore the | ||
| 1692 | * signal mask yet, and we allow do_signal() to deliver the signal on | ||
| 1693 | * the way back to userspace, before the signal mask is restored. | ||
| 1694 | */ | ||
| 1695 | if (sigmask) { | ||
| 1696 | if (err == -EINTR) { | ||
| 1697 | memcpy(¤t->saved_sigmask, &sigsaved, | ||
| 1698 | sizeof(sigsaved)); | ||
| 1699 | set_restore_sigmask(); | ||
| 1700 | } else | ||
| 1701 | sigprocmask(SIG_SETMASK, &sigsaved, NULL); | ||
| 1702 | } | ||
| 1703 | |||
| 1704 | return err; | ||
| 1705 | } | ||
| 1706 | |||
| 1707 | #endif /* CONFIG_EPOLL */ | ||
| 1708 | |||
| 1709 | #ifdef CONFIG_SIGNALFD | ||
| 1710 | |||
| 1711 | asmlinkage long compat_sys_signalfd4(int ufd, | ||
| 1712 | const compat_sigset_t __user *sigmask, | ||
| 1713 | compat_size_t sigsetsize, int flags) | ||
| 1714 | { | ||
| 1715 | compat_sigset_t ss32; | ||
| 1716 | sigset_t tmp; | ||
| 1717 | sigset_t __user *ksigmask; | ||
| 1718 | |||
| 1719 | if (sigsetsize != sizeof(compat_sigset_t)) | ||
| 1720 | return -EINVAL; | ||
| 1721 | if (copy_from_user(&ss32, sigmask, sizeof(ss32))) | ||
| 1722 | return -EFAULT; | ||
| 1723 | sigset_from_compat(&tmp, &ss32); | ||
| 1724 | ksigmask = compat_alloc_user_space(sizeof(sigset_t)); | ||
| 1725 | if (copy_to_user(ksigmask, &tmp, sizeof(sigset_t))) | ||
| 1726 | return -EFAULT; | ||
| 1727 | |||
| 1728 | return sys_signalfd4(ufd, ksigmask, sizeof(sigset_t), flags); | ||
| 1729 | } | ||
| 1730 | |||
| 1731 | asmlinkage long compat_sys_signalfd(int ufd, | ||
| 1732 | const compat_sigset_t __user *sigmask, | ||
| 1733 | compat_size_t sigsetsize) | ||
| 1734 | { | ||
| 1735 | return compat_sys_signalfd4(ufd, sigmask, sigsetsize, 0); | ||
| 1736 | } | ||
| 1737 | #endif /* CONFIG_SIGNALFD */ | ||
| 1738 | |||
| 1739 | #ifdef CONFIG_FHANDLE | 1640 | #ifdef CONFIG_FHANDLE |
| 1740 | /* | 1641 | /* |
| 1741 | * Exactly like fs/open.c:sys_open_by_handle_at(), except that it | 1642 | * Exactly like fs/open.c:sys_open_by_handle_at(), except that it |
| @@ -1747,25 +1648,3 @@ COMPAT_SYSCALL_DEFINE3(open_by_handle_at, int, mountdirfd, | |||
| 1747 | return do_handle_open(mountdirfd, handle, flags); | 1648 | return do_handle_open(mountdirfd, handle, flags); |
| 1748 | } | 1649 | } |
| 1749 | #endif | 1650 | #endif |
| 1750 | |||
| 1751 | #ifdef __ARCH_WANT_COMPAT_SYS_SENDFILE | ||
| 1752 | asmlinkage long compat_sys_sendfile(int out_fd, int in_fd, | ||
| 1753 | compat_off_t __user *offset, compat_size_t count) | ||
| 1754 | { | ||
| 1755 | loff_t pos; | ||
| 1756 | off_t off; | ||
| 1757 | ssize_t ret; | ||
| 1758 | |||
| 1759 | if (offset) { | ||
| 1760 | if (unlikely(get_user(off, offset))) | ||
| 1761 | return -EFAULT; | ||
| 1762 | pos = off; | ||
| 1763 | ret = do_sendfile(out_fd, in_fd, &pos, count, MAX_NON_LFS); | ||
| 1764 | if (unlikely(put_user(pos, offset))) | ||
| 1765 | return -EFAULT; | ||
| 1766 | return ret; | ||
| 1767 | } | ||
| 1768 | |||
| 1769 | return do_sendfile(out_fd, in_fd, NULL, count, 0); | ||
| 1770 | } | ||
| 1771 | #endif /* __ARCH_WANT_COMPAT_SYS_SENDFILE */ | ||
diff --git a/fs/dcookies.c b/fs/dcookies.c index 17c779967828..ab5954b50267 100644 --- a/fs/dcookies.c +++ b/fs/dcookies.c | |||
| @@ -25,6 +25,7 @@ | |||
| 25 | #include <linux/dcookies.h> | 25 | #include <linux/dcookies.h> |
| 26 | #include <linux/mutex.h> | 26 | #include <linux/mutex.h> |
| 27 | #include <linux/path.h> | 27 | #include <linux/path.h> |
| 28 | #include <linux/compat.h> | ||
| 28 | #include <asm/uaccess.h> | 29 | #include <asm/uaccess.h> |
| 29 | 30 | ||
| 30 | /* The dcookies are allocated from a kmem_cache and | 31 | /* The dcookies are allocated from a kmem_cache and |
| @@ -145,7 +146,7 @@ out: | |||
| 145 | /* And here is where the userspace process can look up the cookie value | 146 | /* And here is where the userspace process can look up the cookie value |
| 146 | * to retrieve the path. | 147 | * to retrieve the path. |
| 147 | */ | 148 | */ |
| 148 | SYSCALL_DEFINE(lookup_dcookie)(u64 cookie64, char __user * buf, size_t len) | 149 | SYSCALL_DEFINE3(lookup_dcookie, u64, cookie64, char __user *, buf, size_t, len) |
| 149 | { | 150 | { |
| 150 | unsigned long cookie = (unsigned long)cookie64; | 151 | unsigned long cookie = (unsigned long)cookie64; |
| 151 | int err = -EINVAL; | 152 | int err = -EINVAL; |
| @@ -201,12 +202,16 @@ out: | |||
| 201 | mutex_unlock(&dcookie_mutex); | 202 | mutex_unlock(&dcookie_mutex); |
| 202 | return err; | 203 | return err; |
| 203 | } | 204 | } |
| 204 | #ifdef CONFIG_HAVE_SYSCALL_WRAPPERS | 205 | |
| 205 | asmlinkage long SyS_lookup_dcookie(u64 cookie64, long buf, long len) | 206 | #ifdef CONFIG_COMPAT |
| 207 | COMPAT_SYSCALL_DEFINE4(lookup_dcookie, u32, w0, u32, w1, char __user *, buf, size_t, len) | ||
| 206 | { | 208 | { |
| 207 | return SYSC_lookup_dcookie(cookie64, (char __user *) buf, (size_t) len); | 209 | #ifdef __BIG_ENDIAN |
| 210 | return sys_lookup_dcookie(((u64)w0 << 32) | w1, buf, len); | ||
| 211 | #else | ||
| 212 | return sys_lookup_dcookie(((u64)w1 << 32) | w0, buf, len); | ||
| 213 | #endif | ||
| 208 | } | 214 | } |
| 209 | SYSCALL_ALIAS(sys_lookup_dcookie, SyS_lookup_dcookie); | ||
| 210 | #endif | 215 | #endif |
| 211 | 216 | ||
| 212 | static int dcookie_init(void) | 217 | static int dcookie_init(void) |
diff --git a/fs/eventpoll.c b/fs/eventpoll.c index 277cc38aeda5..deecc7294a67 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c | |||
| @@ -40,6 +40,7 @@ | |||
| 40 | #include <linux/atomic.h> | 40 | #include <linux/atomic.h> |
| 41 | #include <linux/proc_fs.h> | 41 | #include <linux/proc_fs.h> |
| 42 | #include <linux/seq_file.h> | 42 | #include <linux/seq_file.h> |
| 43 | #include <linux/compat.h> | ||
| 43 | 44 | ||
| 44 | /* | 45 | /* |
| 45 | * LOCKING: | 46 | * LOCKING: |
| @@ -1998,6 +1999,52 @@ SYSCALL_DEFINE6(epoll_pwait, int, epfd, struct epoll_event __user *, events, | |||
| 1998 | return error; | 1999 | return error; |
| 1999 | } | 2000 | } |
| 2000 | 2001 | ||
| 2002 | #ifdef CONFIG_COMPAT | ||
| 2003 | COMPAT_SYSCALL_DEFINE6(epoll_pwait, int, epfd, | ||
| 2004 | struct epoll_event __user *, events, | ||
| 2005 | int, maxevents, int, timeout, | ||
| 2006 | const compat_sigset_t __user *, sigmask, | ||
| 2007 | compat_size_t, sigsetsize) | ||
| 2008 | { | ||
| 2009 | long err; | ||
| 2010 | compat_sigset_t csigmask; | ||
| 2011 | sigset_t ksigmask, sigsaved; | ||
| 2012 | |||
| 2013 | /* | ||
| 2014 | * If the caller wants a certain signal mask to be set during the wait, | ||
| 2015 | * we apply it here. | ||
| 2016 | */ | ||
| 2017 | if (sigmask) { | ||
| 2018 | if (sigsetsize != sizeof(compat_sigset_t)) | ||
| 2019 | return -EINVAL; | ||
| 2020 | if (copy_from_user(&csigmask, sigmask, sizeof(csigmask))) | ||
| 2021 | return -EFAULT; | ||
| 2022 | sigset_from_compat(&ksigmask, &csigmask); | ||
| 2023 | sigdelsetmask(&ksigmask, sigmask(SIGKILL) | sigmask(SIGSTOP)); | ||
| 2024 | sigprocmask(SIG_SETMASK, &ksigmask, &sigsaved); | ||
| 2025 | } | ||
| 2026 | |||
| 2027 | err = sys_epoll_wait(epfd, events, maxevents, timeout); | ||
| 2028 | |||
| 2029 | /* | ||
| 2030 | * If we changed the signal mask, we need to restore the original one. | ||
| 2031 | * In case we've got a signal while waiting, we do not restore the | ||
| 2032 | * signal mask yet, and we allow do_signal() to deliver the signal on | ||
| 2033 | * the way back to userspace, before the signal mask is restored. | ||
| 2034 | */ | ||
| 2035 | if (sigmask) { | ||
| 2036 | if (err == -EINTR) { | ||
| 2037 | memcpy(¤t->saved_sigmask, &sigsaved, | ||
| 2038 | sizeof(sigsaved)); | ||
| 2039 | set_restore_sigmask(); | ||
| 2040 | } else | ||
| 2041 | sigprocmask(SIG_SETMASK, &sigsaved, NULL); | ||
| 2042 | } | ||
| 2043 | |||
| 2044 | return err; | ||
| 2045 | } | ||
| 2046 | #endif | ||
| 2047 | |||
| 2001 | static int __init eventpoll_init(void) | 2048 | static int __init eventpoll_init(void) |
| 2002 | { | 2049 | { |
| 2003 | struct sysinfo si; | 2050 | struct sysinfo si; |
diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c index 5d8444268a16..d0be29fa94cf 100644 --- a/fs/notify/fanotify/fanotify_user.c +++ b/fs/notify/fanotify/fanotify_user.c | |||
| @@ -755,9 +755,9 @@ out_destroy_group: | |||
| 755 | return fd; | 755 | return fd; |
| 756 | } | 756 | } |
| 757 | 757 | ||
| 758 | SYSCALL_DEFINE(fanotify_mark)(int fanotify_fd, unsigned int flags, | 758 | SYSCALL_DEFINE5(fanotify_mark, int, fanotify_fd, unsigned int, flags, |
| 759 | __u64 mask, int dfd, | 759 | __u64, mask, int, dfd, |
| 760 | const char __user * pathname) | 760 | const char __user *, pathname) |
| 761 | { | 761 | { |
| 762 | struct inode *inode = NULL; | 762 | struct inode *inode = NULL; |
| 763 | struct vfsmount *mnt = NULL; | 763 | struct vfsmount *mnt = NULL; |
| @@ -857,17 +857,6 @@ fput_and_out: | |||
| 857 | return ret; | 857 | return ret; |
| 858 | } | 858 | } |
| 859 | 859 | ||
| 860 | #ifdef CONFIG_HAVE_SYSCALL_WRAPPERS | ||
| 861 | asmlinkage long SyS_fanotify_mark(long fanotify_fd, long flags, __u64 mask, | ||
| 862 | long dfd, long pathname) | ||
| 863 | { | ||
| 864 | return SYSC_fanotify_mark((int) fanotify_fd, (unsigned int) flags, | ||
| 865 | mask, (int) dfd, | ||
| 866 | (const char __user *) pathname); | ||
| 867 | } | ||
| 868 | SYSCALL_ALIAS(sys_fanotify_mark, SyS_fanotify_mark); | ||
| 869 | #endif | ||
| 870 | |||
| 871 | /* | 860 | /* |
| 872 | * fanotify_user_setup - Our initialization function. Note that we cannot return | 861 | * fanotify_user_setup - Our initialization function. Note that we cannot return |
| 873 | * error because we have compiled-in VFS hooks. So an (unlikely) failure here | 862 | * error because we have compiled-in VFS hooks. So an (unlikely) failure here |
| @@ -197,10 +197,7 @@ out: | |||
| 197 | 197 | ||
| 198 | SYSCALL_DEFINE2(ftruncate, unsigned int, fd, unsigned long, length) | 198 | SYSCALL_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 |
| @@ -212,32 +209,15 @@ COMPAT_SYSCALL_DEFINE2(ftruncate, unsigned int, fd, compat_ulong_t, length) | |||
| 212 | 209 | ||
| 213 | /* LFS versions of truncate are only needed on 32 bit machines */ | 210 | /* LFS versions of truncate are only needed on 32 bit machines */ |
| 214 | #if BITS_PER_LONG == 32 | 211 | #if BITS_PER_LONG == 32 |
| 215 | SYSCALL_DEFINE(truncate64)(const char __user * path, loff_t length) | 212 | SYSCALL_DEFINE2(truncate64, const char __user *, path, loff_t, length) |
| 216 | { | 213 | { |
| 217 | return do_sys_truncate(path, length); | 214 | return do_sys_truncate(path, length); |
| 218 | } | 215 | } |
| 219 | #ifdef CONFIG_HAVE_SYSCALL_WRAPPERS | ||
| 220 | asmlinkage long SyS_truncate64(long path, loff_t length) | ||
| 221 | { | ||
| 222 | return SYSC_truncate64((const char __user *) path, length); | ||
| 223 | } | ||
| 224 | SYSCALL_ALIAS(sys_truncate64, SyS_truncate64); | ||
| 225 | #endif | ||
| 226 | 216 | ||
| 227 | SYSCALL_DEFINE(ftruncate64)(unsigned int fd, loff_t length) | 217 | SYSCALL_DEFINE2(ftruncate64, unsigned int, fd, loff_t, length) |
| 228 | { | 218 | { |
| 229 | long ret = do_sys_ftruncate(fd, length, 0); | 219 | return do_sys_ftruncate(fd, length, 0); |
| 230 | /* avoid REGPARM breakage on x86: */ | ||
| 231 | asmlinkage_protect(2, ret, fd, length); | ||
| 232 | return ret; | ||
| 233 | } | ||
| 234 | #ifdef CONFIG_HAVE_SYSCALL_WRAPPERS | ||
| 235 | asmlinkage long SyS_ftruncate64(long fd, loff_t length) | ||
| 236 | { | ||
| 237 | return SYSC_ftruncate64((unsigned int) fd, length); | ||
| 238 | } | 220 | } |
| 239 | SYSCALL_ALIAS(sys_ftruncate64, SyS_ftruncate64); | ||
| 240 | #endif | ||
| 241 | #endif /* BITS_PER_LONG == 32 */ | 221 | #endif /* BITS_PER_LONG == 32 */ |
| 242 | 222 | ||
| 243 | 223 | ||
| @@ -299,7 +279,7 @@ int do_fallocate(struct file *file, int mode, loff_t offset, loff_t len) | |||
| 299 | return ret; | 279 | return ret; |
| 300 | } | 280 | } |
| 301 | 281 | ||
| 302 | SYSCALL_DEFINE(fallocate)(int fd, int mode, loff_t offset, loff_t len) | 282 | SYSCALL_DEFINE4(fallocate, int, fd, int, mode, loff_t, offset, loff_t, len) |
| 303 | { | 283 | { |
| 304 | struct fd f = fdget(fd); | 284 | struct fd f = fdget(fd); |
| 305 | int error = -EBADF; | 285 | int error = -EBADF; |
| @@ -311,14 +291,6 @@ SYSCALL_DEFINE(fallocate)(int fd, int mode, loff_t offset, loff_t len) | |||
| 311 | return error; | 291 | return error; |
| 312 | } | 292 | } |
| 313 | 293 | ||
| 314 | #ifdef CONFIG_HAVE_SYSCALL_WRAPPERS | ||
| 315 | asmlinkage long SyS_fallocate(long fd, long mode, loff_t offset, loff_t len) | ||
| 316 | { | ||
| 317 | return SYSC_fallocate((int)fd, (int)mode, offset, len); | ||
| 318 | } | ||
| 319 | SYSCALL_ALIAS(sys_fallocate, SyS_fallocate); | ||
| 320 | #endif | ||
| 321 | |||
| 322 | /* | 294 | /* |
| 323 | * access() needs to use the real uid/gid, not the effective uid/gid. | 295 | * access() needs to use the real uid/gid, not the effective uid/gid. |
| 324 | * We do this by temporarily clearing all FS-related capabilities and | 296 | * We do this by temporarily clearing all FS-related capabilities and |
| @@ -983,29 +955,19 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode) | |||
| 983 | 955 | ||
| 984 | SYSCALL_DEFINE3(open, const char __user *, filename, int, flags, umode_t, mode) | 956 | SYSCALL_DEFINE3(open, const char __user *, filename, int, flags, umode_t, mode) |
| 985 | { | 957 | { |
| 986 | long ret; | ||
| 987 | |||
| 988 | if (force_o_largefile()) | 958 | if (force_o_largefile()) |
| 989 | flags |= O_LARGEFILE; | 959 | flags |= O_LARGEFILE; |
| 990 | 960 | ||
| 991 | ret = do_sys_open(AT_FDCWD, filename, flags, mode); | 961 | return do_sys_open(AT_FDCWD, filename, flags, mode); |
| 992 | /* avoid REGPARM breakage on x86: */ | ||
| 993 | asmlinkage_protect(3, ret, filename, flags, mode); | ||
| 994 | return ret; | ||
| 995 | } | 962 | } |
| 996 | 963 | ||
| 997 | SYSCALL_DEFINE4(openat, int, dfd, const char __user *, filename, int, flags, | 964 | SYSCALL_DEFINE4(openat, int, dfd, const char __user *, filename, int, flags, |
| 998 | umode_t, mode) | 965 | umode_t, mode) |
| 999 | { | 966 | { |
| 1000 | long ret; | ||
| 1001 | |||
| 1002 | if (force_o_largefile()) | 967 | if (force_o_largefile()) |
| 1003 | flags |= O_LARGEFILE; | 968 | flags |= O_LARGEFILE; |
| 1004 | 969 | ||
| 1005 | ret = do_sys_open(dfd, filename, flags, mode); | 970 | return do_sys_open(dfd, filename, flags, mode); |
| 1006 | /* avoid REGPARM breakage on x86: */ | ||
| 1007 | asmlinkage_protect(4, ret, dfd, filename, flags, mode); | ||
| 1008 | return ret; | ||
| 1009 | } | 971 | } |
| 1010 | 972 | ||
| 1011 | #ifndef __alpha__ | 973 | #ifndef __alpha__ |
diff --git a/fs/read_write.c b/fs/read_write.c index 7a648911246b..8274a794253b 100644 --- a/fs/read_write.c +++ b/fs/read_write.c | |||
| @@ -515,8 +515,8 @@ SYSCALL_DEFINE3(write, unsigned int, fd, const char __user *, buf, | |||
| 515 | return ret; | 515 | return ret; |
| 516 | } | 516 | } |
| 517 | 517 | ||
| 518 | SYSCALL_DEFINE(pread64)(unsigned int fd, char __user *buf, | 518 | SYSCALL_DEFINE4(pread64, unsigned int, fd, char __user *, buf, |
| 519 | size_t count, loff_t pos) | 519 | size_t, count, loff_t, pos) |
| 520 | { | 520 | { |
| 521 | struct fd f; | 521 | struct fd f; |
| 522 | ssize_t ret = -EBADF; | 522 | ssize_t ret = -EBADF; |
| @@ -534,17 +534,9 @@ SYSCALL_DEFINE(pread64)(unsigned int fd, char __user *buf, | |||
| 534 | 534 | ||
| 535 | return ret; | 535 | return ret; |
| 536 | } | 536 | } |
| 537 | #ifdef CONFIG_HAVE_SYSCALL_WRAPPERS | ||
| 538 | asmlinkage long SyS_pread64(long fd, long buf, long count, loff_t pos) | ||
| 539 | { | ||
| 540 | return SYSC_pread64((unsigned int) fd, (char __user *) buf, | ||
| 541 | (size_t) count, pos); | ||
| 542 | } | ||
| 543 | SYSCALL_ALIAS(sys_pread64, SyS_pread64); | ||
| 544 | #endif | ||
| 545 | 537 | ||
| 546 | SYSCALL_DEFINE(pwrite64)(unsigned int fd, const char __user *buf, | 538 | SYSCALL_DEFINE4(pwrite64, unsigned int, fd, const char __user *, buf, |
| 547 | size_t count, loff_t pos) | 539 | size_t, count, loff_t, pos) |
| 548 | { | 540 | { |
| 549 | struct fd f; | 541 | struct fd f; |
| 550 | ssize_t ret = -EBADF; | 542 | ssize_t ret = -EBADF; |
| @@ -562,14 +554,6 @@ SYSCALL_DEFINE(pwrite64)(unsigned int fd, const char __user *buf, | |||
| 562 | 554 | ||
| 563 | return ret; | 555 | return ret; |
| 564 | } | 556 | } |
| 565 | #ifdef CONFIG_HAVE_SYSCALL_WRAPPERS | ||
| 566 | asmlinkage long SyS_pwrite64(long fd, long buf, long count, loff_t pos) | ||
| 567 | { | ||
| 568 | return SYSC_pwrite64((unsigned int) fd, (const char __user *) buf, | ||
| 569 | (size_t) count, pos); | ||
| 570 | } | ||
| 571 | SYSCALL_ALIAS(sys_pwrite64, SyS_pwrite64); | ||
| 572 | #endif | ||
| 573 | 557 | ||
| 574 | /* | 558 | /* |
| 575 | * Reduce an iovec's length in-place. Return the resulting number of segments | 559 | * Reduce an iovec's length in-place. Return the resulting number of segments |
| @@ -897,8 +881,8 @@ SYSCALL_DEFINE5(pwritev, unsigned long, fd, const struct iovec __user *, vec, | |||
| 897 | return ret; | 881 | return ret; |
| 898 | } | 882 | } |
| 899 | 883 | ||
| 900 | ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos, size_t count, | 884 | static ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos, |
| 901 | loff_t max) | 885 | size_t count, loff_t max) |
| 902 | { | 886 | { |
| 903 | struct fd in, out; | 887 | struct fd in, out; |
| 904 | struct inode *in_inode, *out_inode; | 888 | struct inode *in_inode, *out_inode; |
| @@ -1022,3 +1006,43 @@ SYSCALL_DEFINE4(sendfile64, int, out_fd, int, in_fd, loff_t __user *, offset, si | |||
| 1022 | 1006 | ||
| 1023 | return do_sendfile(out_fd, in_fd, NULL, count, 0); | 1007 | return do_sendfile(out_fd, in_fd, NULL, count, 0); |
| 1024 | } | 1008 | } |
| 1009 | |||
| 1010 | #ifdef CONFIG_COMPAT | ||
| 1011 | COMPAT_SYSCALL_DEFINE4(sendfile, int, out_fd, int, in_fd, | ||
| 1012 | compat_off_t __user *, offset, compat_size_t, count) | ||
| 1013 | { | ||
| 1014 | loff_t pos; | ||
| 1015 | off_t off; | ||
| 1016 | ssize_t ret; | ||
| 1017 | |||
| 1018 | if (offset) { | ||
| 1019 | if (unlikely(get_user(off, offset))) | ||
| 1020 | return -EFAULT; | ||
| 1021 | pos = off; | ||
| 1022 | ret = do_sendfile(out_fd, in_fd, &pos, count, MAX_NON_LFS); | ||
| 1023 | if (unlikely(put_user(pos, offset))) | ||
| 1024 | return -EFAULT; | ||
| 1025 | return ret; | ||
| 1026 | } | ||
| 1027 | |||
| 1028 | return do_sendfile(out_fd, in_fd, NULL, count, 0); | ||
| 1029 | } | ||
| 1030 | |||
| 1031 | COMPAT_SYSCALL_DEFINE4(sendfile64, int, out_fd, int, in_fd, | ||
| 1032 | compat_loff_t __user *, offset, compat_size_t, count) | ||
| 1033 | { | ||
| 1034 | loff_t pos; | ||
| 1035 | ssize_t ret; | ||
| 1036 | |||
| 1037 | if (offset) { | ||
| 1038 | if (unlikely(copy_from_user(&pos, offset, sizeof(loff_t)))) | ||
| 1039 | return -EFAULT; | ||
| 1040 | ret = do_sendfile(out_fd, in_fd, &pos, count, 0); | ||
| 1041 | if (unlikely(put_user(pos, offset))) | ||
| 1042 | return -EFAULT; | ||
| 1043 | return ret; | ||
| 1044 | } | ||
| 1045 | |||
| 1046 | return do_sendfile(out_fd, in_fd, NULL, count, 0); | ||
| 1047 | } | ||
| 1048 | #endif | ||
diff --git a/fs/read_write.h b/fs/read_write.h index d3e00ef67420..d07b954c6e0c 100644 --- a/fs/read_write.h +++ b/fs/read_write.h | |||
| @@ -12,5 +12,3 @@ ssize_t do_sync_readv_writev(struct file *filp, const struct iovec *iov, | |||
| 12 | unsigned long nr_segs, size_t len, loff_t *ppos, iov_fn_t fn); | 12 | unsigned long nr_segs, size_t len, loff_t *ppos, iov_fn_t fn); |
| 13 | ssize_t do_loop_readv_writev(struct file *filp, struct iovec *iov, | 13 | ssize_t do_loop_readv_writev(struct file *filp, struct iovec *iov, |
| 14 | unsigned long nr_segs, loff_t *ppos, io_fn_t fn); | 14 | unsigned long nr_segs, loff_t *ppos, io_fn_t fn); |
| 15 | ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos, size_t count, | ||
| 16 | loff_t max); | ||
diff --git a/fs/signalfd.c b/fs/signalfd.c index b53486961735..424b7b65321f 100644 --- a/fs/signalfd.c +++ b/fs/signalfd.c | |||
| @@ -30,6 +30,7 @@ | |||
| 30 | #include <linux/signalfd.h> | 30 | #include <linux/signalfd.h> |
| 31 | #include <linux/syscalls.h> | 31 | #include <linux/syscalls.h> |
| 32 | #include <linux/proc_fs.h> | 32 | #include <linux/proc_fs.h> |
| 33 | #include <linux/compat.h> | ||
| 33 | 34 | ||
| 34 | void signalfd_cleanup(struct sighand_struct *sighand) | 35 | void signalfd_cleanup(struct sighand_struct *sighand) |
| 35 | { | 36 | { |
| @@ -311,3 +312,33 @@ SYSCALL_DEFINE3(signalfd, int, ufd, sigset_t __user *, user_mask, | |||
| 311 | { | 312 | { |
| 312 | return sys_signalfd4(ufd, user_mask, sizemask, 0); | 313 | return sys_signalfd4(ufd, user_mask, sizemask, 0); |
| 313 | } | 314 | } |
| 315 | |||
| 316 | #ifdef CONFIG_COMPAT | ||
| 317 | COMPAT_SYSCALL_DEFINE4(signalfd4, int, ufd, | ||
| 318 | const compat_sigset_t __user *,sigmask, | ||
| 319 | compat_size_t, sigsetsize, | ||
| 320 | int, flags) | ||
| 321 | { | ||
| 322 | compat_sigset_t ss32; | ||
| 323 | sigset_t tmp; | ||
| 324 | sigset_t __user *ksigmask; | ||
| 325 | |||
| 326 | if (sigsetsize != sizeof(compat_sigset_t)) | ||
| 327 | return -EINVAL; | ||
| 328 | if (copy_from_user(&ss32, sigmask, sizeof(ss32))) | ||
| 329 | return -EFAULT; | ||
| 330 | sigset_from_compat(&tmp, &ss32); | ||
| 331 | ksigmask = compat_alloc_user_space(sizeof(sigset_t)); | ||
| 332 | if (copy_to_user(ksigmask, &tmp, sizeof(sigset_t))) | ||
| 333 | return -EFAULT; | ||
| 334 | |||
| 335 | return sys_signalfd4(ufd, ksigmask, sizeof(sigset_t), flags); | ||
| 336 | } | ||
| 337 | |||
| 338 | COMPAT_SYSCALL_DEFINE3(signalfd, int, ufd, | ||
| 339 | const compat_sigset_t __user *,sigmask, | ||
| 340 | compat_size_t, sigsetsize) | ||
| 341 | { | ||
| 342 | return compat_sys_signalfd4(ufd, sigmask, sigsetsize, 0); | ||
| 343 | } | ||
| 344 | #endif | ||
diff --git a/fs/splice.c b/fs/splice.c index 29e394e49ddd..6b485b8753bd 100644 --- a/fs/splice.c +++ b/fs/splice.c | |||
| @@ -31,6 +31,7 @@ | |||
| 31 | #include <linux/security.h> | 31 | #include <linux/security.h> |
| 32 | #include <linux/gfp.h> | 32 | #include <linux/gfp.h> |
| 33 | #include <linux/socket.h> | 33 | #include <linux/socket.h> |
| 34 | #include <linux/compat.h> | ||
| 34 | #include "internal.h" | 35 | #include "internal.h" |
| 35 | 36 | ||
| 36 | /* | 37 | /* |
| @@ -1690,6 +1691,27 @@ SYSCALL_DEFINE4(vmsplice, int, fd, const struct iovec __user *, iov, | |||
| 1690 | return error; | 1691 | return error; |
| 1691 | } | 1692 | } |
| 1692 | 1693 | ||
| 1694 | #ifdef CONFIG_COMPAT | ||
| 1695 | COMPAT_SYSCALL_DEFINE4(vmsplice, int, fd, const struct compat_iovec __user *, iov32, | ||
| 1696 | unsigned int, nr_segs, unsigned int, flags) | ||
| 1697 | { | ||
| 1698 | unsigned i; | ||
| 1699 | struct iovec __user *iov; | ||
| 1700 | if (nr_segs > UIO_MAXIOV) | ||
| 1701 | return -EINVAL; | ||
| 1702 | iov = compat_alloc_user_space(nr_segs * sizeof(struct iovec)); | ||
| 1703 | for (i = 0; i < nr_segs; i++) { | ||
| 1704 | struct compat_iovec v; | ||
| 1705 | if (get_user(v.iov_base, &iov32[i].iov_base) || | ||
| 1706 | get_user(v.iov_len, &iov32[i].iov_len) || | ||
| 1707 | put_user(compat_ptr(v.iov_base), &iov[i].iov_base) || | ||
| 1708 | put_user(v.iov_len, &iov[i].iov_len)) | ||
| 1709 | return -EFAULT; | ||
| 1710 | } | ||
| 1711 | return sys_vmsplice(fd, iov, nr_segs, flags); | ||
| 1712 | } | ||
| 1713 | #endif | ||
| 1714 | |||
| 1693 | SYSCALL_DEFINE6(splice, int, fd_in, loff_t __user *, off_in, | 1715 | SYSCALL_DEFINE6(splice, int, fd_in, loff_t __user *, off_in, |
| 1694 | int, fd_out, loff_t __user *, off_out, | 1716 | int, fd_out, loff_t __user *, off_out, |
| 1695 | size_t, len, unsigned int, flags) | 1717 | size_t, len, unsigned int, flags) |
| @@ -283,8 +283,8 @@ EXPORT_SYMBOL(generic_write_sync); | |||
| 283 | * already-instantiated disk blocks, there are no guarantees here that the data | 283 | * already-instantiated disk blocks, there are no guarantees here that the data |
| 284 | * will be available after a crash. | 284 | * will be available after a crash. |
| 285 | */ | 285 | */ |
| 286 | SYSCALL_DEFINE(sync_file_range)(int fd, loff_t offset, loff_t nbytes, | 286 | SYSCALL_DEFINE4(sync_file_range, int, fd, loff_t, offset, loff_t, nbytes, |
| 287 | unsigned int flags) | 287 | unsigned int, flags) |
| 288 | { | 288 | { |
| 289 | int ret; | 289 | int ret; |
| 290 | struct fd f; | 290 | struct fd f; |
| @@ -365,29 +365,11 @@ out_put: | |||
| 365 | out: | 365 | out: |
| 366 | return ret; | 366 | return ret; |
| 367 | } | 367 | } |
| 368 | #ifdef CONFIG_HAVE_SYSCALL_WRAPPERS | ||
| 369 | asmlinkage long SyS_sync_file_range(long fd, loff_t offset, loff_t nbytes, | ||
| 370 | long flags) | ||
| 371 | { | ||
| 372 | return SYSC_sync_file_range((int) fd, offset, nbytes, | ||
| 373 | (unsigned int) flags); | ||
| 374 | } | ||
| 375 | SYSCALL_ALIAS(sys_sync_file_range, SyS_sync_file_range); | ||
| 376 | #endif | ||
| 377 | 368 | ||
| 378 | /* It would be nice if people remember that not all the world's an i386 | 369 | /* It would be nice if people remember that not all the world's an i386 |
| 379 | when they introduce new system calls */ | 370 | when they introduce new system calls */ |
| 380 | SYSCALL_DEFINE(sync_file_range2)(int fd, unsigned int flags, | 371 | SYSCALL_DEFINE4(sync_file_range2, int, fd, unsigned int, flags, |
| 381 | loff_t offset, loff_t nbytes) | 372 | loff_t, offset, loff_t, nbytes) |
| 382 | { | 373 | { |
| 383 | return sys_sync_file_range(fd, offset, nbytes, flags); | 374 | return sys_sync_file_range(fd, offset, nbytes, flags); |
| 384 | } | 375 | } |
| 385 | #ifdef CONFIG_HAVE_SYSCALL_WRAPPERS | ||
| 386 | asmlinkage long SyS_sync_file_range2(long fd, long flags, | ||
| 387 | loff_t offset, loff_t nbytes) | ||
| 388 | { | ||
| 389 | return SYSC_sync_file_range2((int) fd, (unsigned int) flags, | ||
| 390 | offset, nbytes); | ||
| 391 | } | ||
| 392 | SYSCALL_ALIAS(sys_sync_file_range2, SyS_sync_file_range2); | ||
| 393 | #endif | ||
