[PATCH -mm 3/7][AIO] - Fix access_ok() checks

Sébastien Dugué
2007-02-01T09:40:16Z

Fix access_ok() checks in sys_io_submit() and
compat_sys_io_submit()

sys_io_submit() and compat_sys_io_submit() check for the number of
requests (nr) being positive, but the following access_ok() call uses
nr * sizeof(ptr) which can overlow to a negative number.

Just make sure that nr * sizeof(ptr) is positive in the first place.

aio.c | 2 +-
compat.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

Signed-off-by: Sébastien Dugué <sebastien.dugue@bull.net>

Index: linux-2.6.20-rc6-mm3/fs/aio.c
===================================================================
--- linux-2.6.20-rc6-mm3.orig/fs/aio.c 2007-01-30 11:28:56.000000000 +0100
+++ linux-2.6.20-rc6-mm3/fs/aio.c 2007-01-30 11:32:42.000000000 +0100
@@ -1630,7 +1630,7 @@ asmlinkage long sys_io_submit(aio_contex
long ret = 0;
int i;

- if (unlikely(nr < 0))
+ if (unlikely((nr*sizeof(*iocbpp)) < 0))
return -EINVAL;

if (unlikely(!access_ok(VERIFY_READ, iocbpp, (nr*sizeof(*iocbpp)))))
Index: linux-2.6.20-rc6-mm3/fs/compat.c
===================================================================
--- linux-2.6.20-rc6-mm3.orig/fs/compat.c 2007-01-30 11:30:29.000000000 +0100
+++ linux-2.6.20-rc6-mm3/fs/compat.c 2007-01-30 11:31:55.000000000 +0100
@@ -651,7 +651,7 @@ compat_sys_io_submit(aio_context_t ctx_i
long ret = 0;
int i;

- if (unlikely(nr < 0))
+ if (unlikely((nr * sizeof(u32)) < 0))
return -EINVAL;

if (unlikely(!access_ok(VERIFY_READ, iocb, (nr * sizeof(u32)))))