Commit 3f6d078d4accfff8b114f968259a060bfdc7c682

Authored by Al Viro
1 parent 561c673197

fix compat truncate/ftruncate

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Showing 11 changed files with 29 additions and 35 deletions Side-by-side Diff

arch/arm64/include/asm/unistd32.h
... ... @@ -113,8 +113,8 @@
113 113 __SYSCALL(89, sys_ni_syscall) /* 89 was sys_readdir */
114 114 __SYSCALL(90, sys_ni_syscall) /* 90 was sys_mmap */
115 115 __SYSCALL(91, sys_munmap)
116   -__SYSCALL(92, sys_truncate)
117   -__SYSCALL(93, sys_ftruncate)
  116 +__SYSCALL(92, compat_sys_truncate)
  117 +__SYSCALL(93, compat_sys_ftruncate)
118 118 __SYSCALL(94, sys_fchmod)
119 119 __SYSCALL(95, sys_fchown16)
120 120 __SYSCALL(96, sys_getpriority)
arch/mips/kernel/scall64-o32.S
... ... @@ -284,8 +284,8 @@
284 284 PTR compat_sys_old_readdir
285 285 PTR sys_mips_mmap /* 4090 */
286 286 PTR sys_munmap
287   - PTR sys_truncate
288   - PTR sys_ftruncate
  287 + PTR compat_sys_truncate
  288 + PTR compat_sys_ftruncate
289 289 PTR sys_fchmod
290 290 PTR sys_fchown /* 4095 */
291 291 PTR sys_getpriority
arch/parisc/kernel/syscall_table.S
... ... @@ -165,8 +165,8 @@
165 165 ENTRY_SAME(mmap2)
166 166 ENTRY_SAME(mmap) /* 90 */
167 167 ENTRY_SAME(munmap)
168   - ENTRY_SAME(truncate)
169   - ENTRY_SAME(ftruncate)
  168 + ENTRY_COMP(truncate)
  169 + ENTRY_COMP(ftruncate)
170 170 ENTRY_SAME(fchmod)
171 171 ENTRY_SAME(fchown) /* 95 */
172 172 ENTRY_SAME(getpriority)
arch/powerpc/kernel/sys_ppc32.c
... ... @@ -146,18 +146,6 @@
146 146 (off_t __user *)offset, count);
147 147 }
148 148  
149   -long compat_sys_truncate(const char __user * path, u32 length)
150   -{
151   - /* sign extend length */
152   - return sys_truncate(path, (int)length);
153   -}
154   -
155   -long compat_sys_ftruncate(int fd, u32 length)
156   -{
157   - /* sign extend length */
158   - return sys_ftruncate(fd, (int)length);
159   -}
160   -
161 149 unsigned long compat_sys_mmap2(unsigned long addr, size_t len,
162 150 unsigned long prot, unsigned long flags,
163 151 unsigned long fd, unsigned long pgoff)
arch/s390/kernel/compat_wrapper.S
... ... @@ -325,16 +325,6 @@
325 325 llgfr %r3,%r3 # size_t
326 326 jg sys_munmap # branch to system call
327 327  
328   -ENTRY(sys32_truncate_wrapper)
329   - llgtr %r2,%r2 # const char *
330   - lgfr %r3,%r3 # long
331   - jg sys_truncate # branch to system call
332   -
333   -ENTRY(sys32_ftruncate_wrapper)
334   - llgfr %r2,%r2 # unsigned int
335   - llgfr %r3,%r3 # unsigned long
336   - jg sys_ftruncate # branch to system call
337   -
338 328 ENTRY(sys32_fchmod_wrapper)
339 329 llgfr %r2,%r2 # unsigned int
340 330 llgfr %r3,%r3 # mode_t
arch/s390/kernel/syscalls.S
... ... @@ -100,8 +100,8 @@
100 100 SYSCALL(sys_ni_syscall,sys_ni_syscall,old32_readdir_wrapper) /* old readdir syscall */
101 101 SYSCALL(sys_old_mmap,sys_old_mmap,old32_mmap_wrapper) /* 90 */
102 102 SYSCALL(sys_munmap,sys_munmap,sys32_munmap_wrapper)
103   -SYSCALL(sys_truncate,sys_truncate,sys32_truncate_wrapper)
104   -SYSCALL(sys_ftruncate,sys_ftruncate,sys32_ftruncate_wrapper)
  103 +SYSCALL(sys_truncate,sys_truncate,compat_sys_truncate)
  104 +SYSCALL(sys_ftruncate,sys_ftruncate,compat_sys_ftruncate)
105 105 SYSCALL(sys_fchmod,sys_fchmod,sys32_fchmod_wrapper)
106 106 SYSCALL(sys_fchown16,sys_ni_syscall,sys32_fchown16_wrapper) /* 95 old fchown16 syscall*/
107 107 SYSCALL(sys_getpriority,sys_getpriority,sys32_getpriority_wrapper)
arch/sparc/kernel/sys32.S
... ... @@ -52,7 +52,6 @@
52 52 SIGN1(sys32_sendmsg, compat_sys_sendmsg, %o0)
53 53 SIGN2(sys32_sync_file_range, compat_sync_file_range, %o0, %o5)
54 54 SIGN1(sys32_vmsplice, compat_sys_vmsplice, %o0)
55   -SIGN1(sys32_truncate, sys_truncate, %o1)
56 55  
57 56 .globl sys32_mmap2
58 57 sys32_mmap2:
arch/sparc/kernel/systbls_64.S
... ... @@ -43,8 +43,8 @@
43 43 /*110*/ .word sys_setresgid, sys_getresgid, sys_setregid, sys_nis_syscall, sys_nis_syscall
44 44 .word sys_getgroups, compat_sys_gettimeofday, sys32_getrusage, sys_nis_syscall, sys_getcwd
45 45 /*120*/ .word compat_sys_readv, compat_sys_writev, compat_sys_settimeofday, sys_fchown16, sys_fchmod
46   - .word sys_nis_syscall, sys_setreuid16, sys_setregid16, sys_rename, sys32_truncate
47   -/*130*/ .word sys_ftruncate, sys_flock, compat_sys_lstat64, sys_nis_syscall, sys_nis_syscall
  46 + .word sys_nis_syscall, sys_setreuid16, sys_setregid16, sys_rename, compat_sys_truncate
  47 +/*130*/ .word compat_sys_ftruncate, sys_flock, compat_sys_lstat64, sys_nis_syscall, sys_nis_syscall
48 48 .word sys_nis_syscall, sys_mkdir, sys_rmdir, compat_sys_utimes, compat_sys_stat64
49 49 /*140*/ .word sys_sendfile64, sys_nis_syscall, sys32_futex, sys_gettid, compat_sys_getrlimit
50 50 .word compat_sys_setrlimit, sys_pivot_root, sys_prctl, sys_pciconfig_read, sys_pciconfig_write
arch/x86/syscalls/syscall_32.tbl
... ... @@ -98,8 +98,8 @@
98 98 89 i386 readdir sys_old_readdir compat_sys_old_readdir
99 99 90 i386 mmap sys_old_mmap sys32_mmap
100 100 91 i386 munmap sys_munmap
101   -92 i386 truncate sys_truncate
102   -93 i386 ftruncate sys_ftruncate
  101 +92 i386 truncate sys_truncate compat_sys_truncate
  102 +93 i386 ftruncate sys_ftruncate compat_sys_ftruncate
103 103 94 i386 fchmod sys_fchmod
104 104 95 i386 fchown sys_fchown16
105 105 96 i386 getpriority sys_getpriority
... ... @@ -30,6 +30,7 @@
30 30 #include <linux/fs_struct.h>
31 31 #include <linux/ima.h>
32 32 #include <linux/dnotify.h>
  33 +#include <linux/compat.h>
33 34  
34 35 #include "internal.h"
35 36  
... ... @@ -140,6 +141,13 @@
140 141 return do_sys_truncate(path, length);
141 142 }
142 143  
  144 +#ifdef CONFIG_COMPAT
  145 +COMPAT_SYSCALL_DEFINE2(truncate, const char __user *, path, compat_off_t, length)
  146 +{
  147 + return do_sys_truncate(path, length);
  148 +}
  149 +#endif
  150 +
143 151 static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
144 152 {
145 153 struct inode *inode;
... ... @@ -194,6 +202,13 @@
194 202 asmlinkage_protect(2, ret, fd, length);
195 203 return ret;
196 204 }
  205 +
  206 +#ifdef CONFIG_COMPAT
  207 +COMPAT_SYSCALL_DEFINE2(ftruncate, unsigned int, fd, compat_ulong_t, length)
  208 +{
  209 + return do_sys_ftruncate(fd, length, 1);
  210 +}
  211 +#endif
197 212  
198 213 /* LFS versions of truncate are only needed on 32 bit machines */
199 214 #if BITS_PER_LONG == 32
include/linux/compat.h
... ... @@ -536,6 +536,8 @@
536 536 asmlinkage long compat_sys_open_by_handle_at(int mountdirfd,
537 537 struct file_handle __user *handle,
538 538 int flags);
  539 +asmlinkage long compat_sys_truncate(const char __user *, compat_off_t);
  540 +asmlinkage long compat_sys_ftruncate(unsigned int, compat_ulong_t);
539 541 asmlinkage long compat_sys_pselect6(int n, compat_ulong_t __user *inp,
540 542 compat_ulong_t __user *outp,
541 543 compat_ulong_t __user *exp,