diff options
| author | Andrew Morton <akpm@digeo.com> | 2002-11-10 02:01:28 -0800 |
|---|---|---|
| committer | David S. Miller <davem@nuts.ninka.net> | 2002-11-10 02:01:28 -0800 |
| commit | 33f9ef1c778bfd16bc2f7ac0c1470c3984961660 (patch) | |
| tree | 2fedaa38e490c3ff4d6c4e5575b0a6e9e032db2f | |
| parent | e300f70b13ec4c9bafa638f40da81676966efacb (diff) | |
[PATCH] Fix readv/writev return value
A patch from Janet Morgan <janetmor@us.ibm.com>
If you feed an iovec with a bad address not at the zeroeth segment into
readv or writev, it returns the wrong value.
iovec 1: base is 8050b20 len is 64
iovec 2: base is ffffffff len is 64
iovec 3: base is 8050ba0 len is 64
The writev should return 64 bytes but is returning 128
This is because we've added the new segment's length into `count'
before running access_ok().
The patch changes it to fix that up on the slow path, if access_ok() fails.
| -rw-r--r-- | mm/filemap.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/mm/filemap.c b/mm/filemap.c index 4dcbc344f2d2..421b8597995a 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -791,6 +791,7 @@ __generic_file_aio_read(struct kiocb *iocb, const struct iovec *iov, if (seg == 0) return -EFAULT; nr_segs = seg; + count -= iv->iov_len; /* This segment is no good */ break; } @@ -1578,6 +1579,7 @@ generic_file_write_nolock(struct file *file, const struct iovec *iov, if (seg == 0) return -EFAULT; nr_segs = seg; + ocount -= iv->iov_len; /* This segment is no good */ break; } count = ocount; |
