summaryrefslogtreecommitdiffstats
path: root/fs/aio.c
diff options
context:
space:
mode:
authorRusty Russell2008-02-08 13:20:15 +0100
committerLinus Torvalds2008-02-08 18:22:33 +0100
commitc2ec66828fd253802abb912668f4bf9597e3c898 (patch)
tree6d7dfe34b423b5bf32a5a5ae6b35207db4bb5d22 /fs/aio.c
parentaio: partial write should not return error code (diff)
downloadkernel-qcow2-linux-c2ec66828fd253802abb912668f4bf9597e3c898.tar.gz
kernel-qcow2-linux-c2ec66828fd253802abb912668f4bf9597e3c898.tar.xz
kernel-qcow2-linux-c2ec66828fd253802abb912668f4bf9597e3c898.zip
aio: negative offset should return -EINVAL
An AIO read or write should return -EINVAL if the offset is negative. This check matches the one in pread and pwrite. This was found by the libaio test suite. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Acked-by: Zach Brown <zach.brown@oracle.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/aio.c')
-rw-r--r--fs/aio.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/aio.c b/fs/aio.c
index 26c1930889fa..b74c567383bc 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -1329,6 +1329,10 @@ static ssize_t aio_rw_vect_retry(struct kiocb *iocb)
opcode = IOCB_CMD_PWRITEV;
}
+ /* This matches the pread()/pwrite() logic */
+ if (iocb->ki_pos < 0)
+ return -EINVAL;
+
do {
ret = rw_op(iocb, &iocb->ki_iovec[iocb->ki_cur_seg],
iocb->ki_nr_segs - iocb->ki_cur_seg,