Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 75e1c70f authored by Jeff Moyer's avatar Jeff Moyer Committed by Linus Torvalds
Browse files

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: default avatarTavis Ormandy <taviso@cmpxchg8b.com>
Signed-off-by: default avatarJeff Moyer <jmoyer@redhat.com>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent bfa88ea7
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -1659,6 +1659,9 @@ long do_io_submit(aio_context_t ctx_id, long nr,
	if (unlikely(nr < 0))
	if (unlikely(nr < 0))
		return -EINVAL;
		return -EINVAL;


	if (unlikely(nr > LONG_MAX/sizeof(*iocbpp)))
		nr = LONG_MAX/sizeof(*iocbpp);

	if (unlikely(!access_ok(VERIFY_READ, iocbpp, (nr*sizeof(*iocbpp)))))
	if (unlikely(!access_ok(VERIFY_READ, iocbpp, (nr*sizeof(*iocbpp)))))
		return -EFAULT;
		return -EFAULT;