aio: fix the compat vectored operations

The aio compat code was not converting the struct iovecs from 32bit to
64bit pointers, causing either EINVAL to be returned from io_getevents, or
EFAULT as the result of the I/O.  This patch passes a compat flag to
io_submit to signal that pointer conversion is necessary for a given iocb
array.

A variant of this was tested by Michael Tokarev.  I have also updated the
libaio test harness to exercise this code path with good success.
Further, I grabbed a copy of ltp and ran the
testcases/kernel/syscall/readv and writev tests there (compiled with -m32
on my 64bit system).  All seems happy, but extra eyes on this would be
welcome.

[[email protected]: coding-style fixes]
[[email protected]: fix CONFIG_COMPAT=n build]
Signed-off-by: Jeff Moyer <[email protected]>
Reported-by: Michael Tokarev <[email protected]>
Cc: Zach Brown <[email protected]>
Cc: <[email protected]>		[2.6.35.1]
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
Jeff Moyer 2010-05-26 14:44:26 -07:00 • committed by Linus Torvalds
commit 9d85cba718
3 changed files with 47 additions and 25 deletions

View file

@ -673,7 +673,7 @@ compat_sys_io_submit(aio_context_t ctx_id, int nr, u32 __user *iocb)
iocb64 = compat_alloc_user_space(nr * sizeof(*iocb64));
ret = copy_iocb(nr, iocb, iocb64);
if (!ret)
ret = sys_io_submit(ctx_id, nr, iocb64);
ret = do_io_submit(ctx_id, nr, iocb64, 1);
return ret;
}