Skip to content

Commit

Permalink
aio: negative offset should return -EINVAL
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Rusty Russell authored and Linus Torvalds committed Feb 8, 2008
1 parent 7adfa2f commit c2ec668
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fs/aio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit c2ec668

Please sign in to comment.