vfs: Get rid of duplicate offset checks in p{read,write}*
PATCH 1/2 vfs: Get rid of duplicate offset checks in p{read,write}*
Current pread/pwrite functions simply checks whether offset is negative. Thus we couldn't use these functions for the large (negative) offsets although some files did allow that.
Checking it correctly requires a file pointer and we already did the check in rw_verify_area() so just remove the checks.
--- fs/read_write.c | 16 ---------------- 1 file changed, 16 deletions(-)
fs/read_write.c +0 -16
@@ -534,9 +534,6 @@ SYSCALL_DEFINE4(pread64, unsigned int, fd, char __user *, buf,struct fd f;ssize_t ret = -EBADF ; -if (pos <0 ) -return -EINVAL ; - f =fdget (fd);if (f.file) { ret = -ESPIPE ;
@@ -554,9 +551,6 @@ SYSCALL_DEFINE4(pwrite64, unsigned int, fd, const char __user *, buf,struct fd f;ssize_t ret = -EBADF ; -if (pos <0 ) -return -EINVAL ; - f =fdget (fd);if (f.file) { ret = -ESPIPE ;
@@ -852,9 +846,6 @@ SYSCALL_DEFINE5(preadv, unsigned long, fd, const struct iovec __user *, vec,struct fd f;ssize_t ret = -EBADF ; -if (pos <0 ) -return -EINVAL ; - f =fdget (fd);if (f.file) { ret = -ESPIPE ;
@@ -876,9 +867,6 @@ SYSCALL_DEFINE5(pwritev, unsigned long, fd, const struct iovec __user *, vec,struct fd f;ssize_t ret = -EBADF ; -if (pos <0 ) -return -EINVAL ; - f =fdget (fd);if (f.file) { ret = -ESPIPE ;
@@ -1002,8 +990,6 @@ COMPAT_SYSCALL_DEFINE4(preadv64, unsigned long, fd,struct fd f;ssize_t ret; -if (pos <0 ) -return -EINVAL ; f =fdget (fd);if (!f.file)return -EBADF ;
@@ -1069,8 +1055,6 @@ COMPAT_SYSCALL_DEFINE4(pwritev64, unsigned long, fd,struct fd f;ssize_t ret; -if (pos <0 ) -return -EINVAL ; f =fdget (fd);if (!f.file)return -EBADF ;
Signature · 1 line
1.7.9.2
PATCH 2/2 vfs: Get rid of duplicate file_ops check in do_readv_writev()
The file->f_op check in do_readv_writev() is redundant since all of its caller (vfs_readv and vfs_writev) already did the check. The same goes to compat_do_readv_writev().
--- fs/read_write.c | 9 --------- 1 file changed, 9 deletions(-)
fs/read_write.c +0 -9
@@ -721,11 +721,6 @@ static ssize_t do_readv_writev(int type, struct file *file,io_fn_t fn;iov_fn_t fnv; -if (!file->f_op) { - ret = -EINVAL ; - goto out; - } - ret =rw_copy_check_uvector (type, uvector, nr_segs,ARRAY_SIZE (iovstack), iovstack, &iov);if (ret <=0 )
@@ -894,10 +889,6 @@ static ssize_t compat_do_readv_writev(int type, struct file *file,io_fn_t fn;iov_fn_t fnv; - ret = -EINVAL ; -if (!file->f_op) - goto out; - ret = -EFAULT ;if (!access_ok (VERIFY_READ , uvector, nr_segs*sizeof (*uvector))) goto out;
Signature · 1 line
1.7.9.2
Al Viro
maintainerRe: [PATCH 2/2] vfs: Get rid of duplicate file_ops check in do_readv_writev()
Quoted 3 lines · Namhyung Kim
The
file->f_opcheck indo_readv_writev()is redundant since all of its caller (vfs_readvandvfs_writev) already did the check. The same goes tocompat_do_readv_writev().
... and the right fix is to kill all those checks completely. I have that done in local queue; will push to #for-next tonight. file->f_op should never be NULL, period.