diff options
-rw-r--r-- | fs/read_write.c | 22 | ||||
-rw-r--r-- | include/linux/compat.h | 3 |
2 files changed, 25 insertions, 0 deletions
diff --git a/fs/read_write.c b/fs/read_write.c index 1adfb691e4f..91b91c4a9ed 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1007,3 +1007,25 @@ SYSCALL_DEFINE4(sendfile64, int, out_fd, int, in_fd, loff_t __user *, offset, si return do_sendfile(out_fd, in_fd, NULL, count, 0); } + +#ifdef __ARCH_WANT_COMPAT_SYS_SENDFILE +asmlinkage int compat_sys_sendfile(int out_fd, int in_fd, + compat_off_t __user *offset, compat_size_t count) +{ + loff_t pos; + off_t off; + ssize_t ret; + + if (offset) { + if (unlikely(get_user(off, offset))) + return -EFAULT; + pos = off; + ret = do_sendfile(out_fd, in_fd, &pos, count, MAX_NON_LFS); + if (unlikely(put_user(pos, offset))) + return -EFAULT; + return ret; + } + + return do_sendfile(out_fd, in_fd, NULL, count, 0); +} +#endif /* __ARCH_WANT_COMPAT_SYS_SENDFILE */ diff --git a/include/linux/compat.h b/include/linux/compat.h index 09b28b7369d..5f2d2ccf8db 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h @@ -590,6 +590,9 @@ asmlinkage ssize_t compat_sys_process_vm_writev(compat_pid_t pid, unsigned long liovcnt, const struct compat_iovec __user *rvec, unsigned long riovcnt, unsigned long flags); +asmlinkage int compat_sys_sendfile(int out_fd, int in_fd, + compat_off_t __user *offset, s32 count); + #else #define is_compat_task() (0) |