fix compat truncate/ftruncate
authorAl Viro <viro@zeniv.linux.org.uk>
Sun, 24 Feb 2013 18:49:08 +0000 (13:49 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Mon, 25 Feb 2013 14:24:55 +0000 (09:24 -0500)
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
arch/arm64/include/asm/unistd32.h
arch/mips/kernel/scall64-o32.S
arch/parisc/kernel/syscall_table.S
arch/powerpc/kernel/sys_ppc32.c
arch/s390/kernel/compat_wrapper.S
arch/s390/kernel/syscalls.S
arch/sparc/kernel/sys32.S
arch/sparc/kernel/systbls_64.S
arch/x86/syscalls/syscall_32.tbl
fs/open.c
include/linux/compat.h

index 8153f1a43f0a519c5262d1b1fa90091d10c94473..12f22492df4ced64e6268449a80598a2ae5676f2 100644 (file)
@@ -113,8 +113,8 @@ __SYSCALL(88,  sys_reboot)
 __SYSCALL(89,  sys_ni_syscall)                 /* 89 was sys_readdir */
 __SYSCALL(90,  sys_ni_syscall)                 /* 90 was sys_mmap */
 __SYSCALL(91,  sys_munmap)
-__SYSCALL(92,  sys_truncate)
-__SYSCALL(93,  sys_ftruncate)
+__SYSCALL(92,  compat_sys_truncate)
+__SYSCALL(93,  compat_sys_ftruncate)
 __SYSCALL(94,  sys_fchmod)
 __SYSCALL(95,  sys_fchown16)
 __SYSCALL(96,  sys_getpriority)
index 063cd0d6ddd22c1a87adba66be35ed279f144662..20b100f9d3601ce5c850b691e2791b43c49f1bd3 100644 (file)
@@ -284,8 +284,8 @@ sys_call_table:
        PTR     compat_sys_old_readdir
        PTR     sys_mips_mmap                   /* 4090 */
        PTR     sys_munmap
-       PTR     sys_truncate
-       PTR     sys_ftruncate
+       PTR     compat_sys_truncate
+       PTR     compat_sys_ftruncate
        PTR     sys_fchmod
        PTR     sys_fchown                      /* 4095 */
        PTR     sys_getpriority
index d0efc0aeb6125fcd4e84f6c280baf5f1040ae812..884b91b028f01c72ef637efacf7e44c7ede28f60 100644 (file)
        ENTRY_SAME(mmap2)
        ENTRY_SAME(mmap)                /* 90 */
        ENTRY_SAME(munmap)
-       ENTRY_SAME(truncate)
-       ENTRY_SAME(ftruncate)
+       ENTRY_COMP(truncate)
+       ENTRY_COMP(ftruncate)
        ENTRY_SAME(fchmod)
        ENTRY_SAME(fchown)              /* 95 */
        ENTRY_SAME(getpriority)
index 5677a36f450b1807f12cd09a61b827cc5c18a45b..d0bafc0cdf069d91c58eb112113497a5ab256f76 100644 (file)
@@ -146,18 +146,6 @@ asmlinkage long compat_sys_sendfile64_wrapper(u32 out_fd, u32 in_fd,
                            (off_t __user *)offset, count);
 }
 
-long compat_sys_truncate(const char __user * path, u32 length)
-{
-       /* sign extend length */
-       return sys_truncate(path, (int)length);
-}
-
-long compat_sys_ftruncate(int fd, u32 length)
-{
-       /* sign extend length */
-       return sys_ftruncate(fd, (int)length);
-}
-
 unsigned long compat_sys_mmap2(unsigned long addr, size_t len,
                          unsigned long prot, unsigned long flags,
                          unsigned long fd, unsigned long pgoff)
index 2b1a3a03244f87e9b211bc25e12f09c0a41de0b5..3c98c4dc5aca5be0eae8aa2c98a829d589132913 100644 (file)
@@ -325,16 +325,6 @@ ENTRY(sys32_munmap_wrapper)
        llgfr   %r3,%r3                 # size_t
        jg      sys_munmap              # branch to system call
 
-ENTRY(sys32_truncate_wrapper)
-       llgtr   %r2,%r2                 # const char *
-       lgfr    %r3,%r3                 # long
-       jg      sys_truncate            # branch to system call
-
-ENTRY(sys32_ftruncate_wrapper)
-       llgfr   %r2,%r2                 # unsigned int
-       llgfr   %r3,%r3                 # unsigned long
-       jg      sys_ftruncate           # branch to system call
-
 ENTRY(sys32_fchmod_wrapper)
        llgfr   %r2,%r2                 # unsigned int
        llgfr   %r3,%r3                 # mode_t
index 0e5262f01007ac3136e1a09fa8f79675936b2fe6..630b935d128465fc9c2eacc76364c6e1398562f6 100644 (file)
@@ -100,8 +100,8 @@ SYSCALL(sys_reboot,sys_reboot,sys32_reboot_wrapper)
 SYSCALL(sys_ni_syscall,sys_ni_syscall,old32_readdir_wrapper)   /* old readdir syscall */
 SYSCALL(sys_old_mmap,sys_old_mmap,old32_mmap_wrapper)          /* 90 */
 SYSCALL(sys_munmap,sys_munmap,sys32_munmap_wrapper)
-SYSCALL(sys_truncate,sys_truncate,sys32_truncate_wrapper)
-SYSCALL(sys_ftruncate,sys_ftruncate,sys32_ftruncate_wrapper)
+SYSCALL(sys_truncate,sys_truncate,compat_sys_truncate)
+SYSCALL(sys_ftruncate,sys_ftruncate,compat_sys_ftruncate)
 SYSCALL(sys_fchmod,sys_fchmod,sys32_fchmod_wrapper)
 SYSCALL(sys_fchown16,sys_ni_syscall,sys32_fchown16_wrapper)    /* 95 old fchown16 syscall*/
 SYSCALL(sys_getpriority,sys_getpriority,sys32_getpriority_wrapper)
index be3d65a3c27084f72018b6528d37eeceb653cf46..240a3cecc11e620dccf6c941bcd6fd08fcd793be 100644 (file)
@@ -52,7 +52,6 @@ SIGN1(sys32_recvmsg, compat_sys_recvmsg, %o0)
 SIGN1(sys32_sendmsg, compat_sys_sendmsg, %o0)
 SIGN2(sys32_sync_file_range, compat_sync_file_range, %o0, %o5)
 SIGN1(sys32_vmsplice, compat_sys_vmsplice, %o0)
-SIGN1(sys32_truncate, sys_truncate, %o1)
 
        .globl          sys32_mmap2
 sys32_mmap2:
index 9ed517c5037b1df4a512d0a060f46892e4c5e31b..088134834dab4fd0da1293c8a3b20cb0c7a9813d 100644 (file)
@@ -43,8 +43,8 @@ sys_call_table32:
 /*110*/        .word sys_setresgid, sys_getresgid, sys_setregid, sys_nis_syscall, sys_nis_syscall
        .word sys_getgroups, compat_sys_gettimeofday, sys32_getrusage, sys_nis_syscall, sys_getcwd
 /*120*/        .word compat_sys_readv, compat_sys_writev, compat_sys_settimeofday, sys_fchown16, sys_fchmod
-       .word sys_nis_syscall, sys_setreuid16, sys_setregid16, sys_rename, sys32_truncate
-/*130*/        .word sys_ftruncate, sys_flock, compat_sys_lstat64, sys_nis_syscall, sys_nis_syscall
+       .word sys_nis_syscall, sys_setreuid16, sys_setregid16, sys_rename, compat_sys_truncate
+/*130*/        .word compat_sys_ftruncate, sys_flock, compat_sys_lstat64, sys_nis_syscall, sys_nis_syscall
        .word sys_nis_syscall, sys_mkdir, sys_rmdir, compat_sys_utimes, compat_sys_stat64
 /*140*/        .word sys_sendfile64, sys_nis_syscall, sys32_futex, sys_gettid, compat_sys_getrlimit
        .word compat_sys_setrlimit, sys_pivot_root, sys_prctl, sys_pciconfig_read, sys_pciconfig_write
index f51810be1a326d0b20fe684c30c06b829ab4f6e5..e6d55f0064dfd75c9c46f1d44a0b1a1ab1d1a8ca 100644 (file)
@@ -98,8 +98,8 @@
 89     i386    readdir                 sys_old_readdir                 compat_sys_old_readdir
 90     i386    mmap                    sys_old_mmap                    sys32_mmap
 91     i386    munmap                  sys_munmap
-92     i386    truncate                sys_truncate
-93     i386    ftruncate               sys_ftruncate
+92     i386    truncate                sys_truncate                    compat_sys_truncate
+93     i386    ftruncate               sys_ftruncate                   compat_sys_ftruncate
 94     i386    fchmod                  sys_fchmod
 95     i386    fchown                  sys_fchown16
 96     i386    getpriority             sys_getpriority
index 9b33c0cbfacf3dffc3f67df9247a838505aa0d6d..669ba0dd666701fae8f3853b613df8413367249a 100644 (file)
--- a/fs/open.c
+++ b/fs/open.c
@@ -30,6 +30,7 @@
 #include <linux/fs_struct.h>
 #include <linux/ima.h>
 #include <linux/dnotify.h>
+#include <linux/compat.h>
 
 #include "internal.h"
 
@@ -140,6 +141,13 @@ SYSCALL_DEFINE2(truncate, const char __user *, path, long, length)
        return do_sys_truncate(path, length);
 }
 
+#ifdef CONFIG_COMPAT
+COMPAT_SYSCALL_DEFINE2(truncate, const char __user *, path, compat_off_t, length)
+{
+       return do_sys_truncate(path, length);
+}
+#endif
+
 static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
 {
        struct inode *inode;
@@ -195,6 +203,13 @@ SYSCALL_DEFINE2(ftruncate, unsigned int, fd, unsigned long, length)
        return ret;
 }
 
+#ifdef CONFIG_COMPAT
+COMPAT_SYSCALL_DEFINE2(ftruncate, unsigned int, fd, compat_ulong_t, length)
+{
+       return do_sys_ftruncate(fd, length, 1);
+}
+#endif
+
 /* LFS versions of truncate are only needed on 32 bit machines */
 #if BITS_PER_LONG == 32
 SYSCALL_DEFINE(truncate64)(const char __user * path, loff_t length)
index 59c72048bf201a60806a9c61b1076635905174db..76a87fb57ac258c4f004cee14737d8570da048f0 100644 (file)
@@ -536,6 +536,8 @@ asmlinkage long compat_sys_openat(int dfd, const char __user *filename,
 asmlinkage long compat_sys_open_by_handle_at(int mountdirfd,
                                             struct file_handle __user *handle,
                                             int flags);
+asmlinkage long compat_sys_truncate(const char __user *, compat_off_t);
+asmlinkage long compat_sys_ftruncate(unsigned int, compat_ulong_t);
 asmlinkage long compat_sys_pselect6(int n, compat_ulong_t __user *inp,
                                    compat_ulong_t __user *outp,
                                    compat_ulong_t __user *exp,