Commit 75e1c70fc31490ef8a373ea2a4bea2524099b478
Committed by
Linus Torvalds
1 parent
bfa88ea7ee
Exists in
master
and in
20 other branches
aio: check for multiplication overflow in do_io_submit
Tavis Ormandy pointed out that do_io_submit does not do proper bounds checking on the passed-in iocb array: if (unlikely(nr < 0)) return -EINVAL; if (unlikely(!access_ok(VERIFY_READ, iocbpp, (nr*sizeof(iocbpp))))) return -EFAULT; ^^^^^^^^^^^^^^^^^^ The attached patch checks for overflow, and if it is detected, the number of iocbs submitted is scaled down to a number that will fit in the long. This is an ok thing to do, as sys_io_submit is documented as returning the number of iocbs submitted, so callers should handle a return value of less than the 'nr' argument passed in. Reported-by: Tavis Ormandy <taviso@cmpxchg8b.com> Signed-off-by: Jeff Moyer <jmoyer@redhat.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 1 changed file with 3 additions and 0 deletions Side-by-side Diff
fs/aio.c
... | ... | @@ -1659,6 +1659,9 @@ |
1659 | 1659 | if (unlikely(nr < 0)) |
1660 | 1660 | return -EINVAL; |
1661 | 1661 | |
1662 | + if (unlikely(nr > LONG_MAX/sizeof(*iocbpp))) | |
1663 | + nr = LONG_MAX/sizeof(*iocbpp); | |
1664 | + | |
1662 | 1665 | if (unlikely(!access_ok(VERIFY_READ, iocbpp, (nr*sizeof(*iocbpp))))) |
1663 | 1666 | return -EFAULT; |
1664 | 1667 |