* [PATCH 1/2] vfs: Get rid of duplicate offset checks in p{read,write}*
@ 2013-09-29 9:37 Namhyung Kim
2013-09-29 9:37 ` [PATCH 2/2] vfs: Get rid of duplicate file_ops check in do_readv_writev() Namhyung Kim
0 siblings, 1 reply; 3+ messages in thread
From: Namhyung Kim @ 2013-09-29 9:37 UTC (permalink / raw)
To: Alexander Viro; +Cc: linux-fsdevel, linux-kernel
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.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
fs/read_write.c | 16 ----------------
1 file changed, 16 deletions(-)
diff --git a/fs/read_write.c b/fs/read_write.c
index e3cd280b158c..878f40e50451 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -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;
--
1.7.9.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] vfs: Get rid of duplicate file_ops check in do_readv_writev()
2013-09-29 9:37 [PATCH 1/2] vfs: Get rid of duplicate offset checks in p{read,write}* Namhyung Kim
@ 2013-09-29 9:37 ` Namhyung Kim
2013-09-29 22:24 ` Al Viro
0 siblings, 1 reply; 3+ messages in thread
From: Namhyung Kim @ 2013-09-29 9:37 UTC (permalink / raw)
To: Alexander Viro; +Cc: linux-fsdevel, linux-kernel
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().
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
fs/read_write.c | 9 ---------
1 file changed, 9 deletions(-)
diff --git a/fs/read_write.c b/fs/read_write.c
index 878f40e50451..a8bcdd26b16e 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -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;
--
1.7.9.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 2/2] vfs: Get rid of duplicate file_ops check in do_readv_writev()
2013-09-29 9:37 ` [PATCH 2/2] vfs: Get rid of duplicate file_ops check in do_readv_writev() Namhyung Kim
@ 2013-09-29 22:24 ` Al Viro
0 siblings, 0 replies; 3+ messages in thread
From: Al Viro @ 2013-09-29 22:24 UTC (permalink / raw)
To: Namhyung Kim; +Cc: linux-fsdevel, linux-kernel
On Sun, Sep 29, 2013 at 06:37:50PM +0900, Namhyung Kim wrote:
> 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().
... 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.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-09-29 22:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-29 9:37 [PATCH 1/2] vfs: Get rid of duplicate offset checks in p{read,write}* Namhyung Kim
2013-09-29 9:37 ` [PATCH 2/2] vfs: Get rid of duplicate file_ops check in do_readv_writev() Namhyung Kim
2013-09-29 22:24 ` Al Viro
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).