Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

parisc: sendfile and sendfile64 syscall cleanups

Utilize the existing compat_sys_sendfile function for 64bit kernel and add
wrappers for sendfile and sendfile64 to correctly handle the 32/64 bit sign
extension.

Signed-off-by: Helge Deller <deller@gmx.de>

+15 -33
+1
arch/parisc/include/asm/unistd.h
··· 167 167 #define __ARCH_WANT_SYS_FORK 168 168 #define __ARCH_WANT_SYS_VFORK 169 169 #define __ARCH_WANT_SYS_CLONE 170 + #define __ARCH_WANT_COMPAT_SYS_SENDFILE 170 171 171 172 #endif /* __ASSEMBLY__ */ 172 173
+13 -32
arch/parisc/kernel/sys_parisc32.c
··· 60 60 return -ENOSYS; 61 61 } 62 62 63 - asmlinkage int sys32_sendfile(int out_fd, int in_fd, compat_off_t __user *offset, s32 count) 63 + /* Note: it is necessary to treat out_fd and in_fd as unsigned ints, with the 64 + * corresponding cast to a signed int to insure that the proper conversion 65 + * (sign extension) between the register representation of a signed int (msr in 66 + * 32-bit mode) and the register representation of a signed int (msr in 64-bit 67 + * mode) is performed. 68 + */ 69 + asmlinkage long sys32_sendfile(u32 out_fd, u32 in_fd, 70 + compat_off_t __user *offset, compat_size_t count) 64 71 { 65 - mm_segment_t old_fs = get_fs(); 66 - int ret; 67 - off_t of; 68 - 69 - if (offset && get_user(of, offset)) 70 - return -EFAULT; 71 - 72 - set_fs(KERNEL_DS); 73 - ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __user *)&of : NULL, count); 74 - set_fs(old_fs); 75 - 76 - if (offset && put_user(of, offset)) 77 - return -EFAULT; 78 - 79 - return ret; 72 + return compat_sys_sendfile((int)out_fd, (int)in_fd, offset, count); 80 73 } 81 74 82 - asmlinkage int sys32_sendfile64(int out_fd, int in_fd, compat_loff_t __user *offset, s32 count) 75 + asmlinkage long sys32_sendfile64(u32 out_fd, u32 in_fd, 76 + compat_loff_t __user *offset, compat_size_t count) 83 77 { 84 - mm_segment_t old_fs = get_fs(); 85 - int ret; 86 - loff_t lof; 87 - 88 - if (offset && get_user(lof, offset)) 89 - return -EFAULT; 90 - 91 - set_fs(KERNEL_DS); 92 - ret = sys_sendfile64(out_fd, in_fd, offset ? (loff_t __user *)&lof : NULL, count); 93 - set_fs(old_fs); 94 - 95 - if (offset && put_user(lof, offset)) 96 - return -EFAULT; 97 - 98 - return ret; 78 + return sys_sendfile64((int)out_fd, (int)in_fd, 79 + (loff_t __user *)offset, count); 99 80 } 100 81 101 82
+1 -1
arch/parisc/kernel/syscall_table.S
··· 304 304 ENTRY_SAME(gettid) 305 305 ENTRY_OURS(readahead) 306 306 ENTRY_SAME(tkill) 307 - ENTRY_SAME(sendfile64) 307 + ENTRY_DIFF(sendfile64) 308 308 ENTRY_COMP(futex) /* 210 */ 309 309 ENTRY_COMP(sched_setaffinity) 310 310 ENTRY_COMP(sched_getaffinity)