Commit 33f9ef1c authored by Andrew Morton's avatar Andrew Morton Committed by David S. Miller

[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.
parent e300f70b
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment