[PATCH 1/2] vfs: Get rid of duplicate offset checks in p{read,write}*

From: Namhyung Kim
Date: Sun Sep 29 2013 - 05:38:25 EST


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@xxxxxxxxxx>
---
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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/