aio: fix io_setup/io_destroy race
authorAl Viro <viro@ZenIV.linux.org.uk>
Wed, 7 Mar 2012 05:16:35 +0000 (05:16 +0000)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 10 Mar 2012 02:59:59 +0000 (18:59 -0800)
Have ioctx_alloc() return an extra reference, so that caller would drop it
on success and not bother with re-grabbing it on failure exit.  The current
code is obviously broken - io_destroy() from another thread that managed
to guess the address io_setup() would've returned would free ioctx right
under us; gets especially interesting if aio_context_t * we pass to
io_setup() points to PROT_READ mapping, so put_user() fails and we end
up doing io_destroy() on kioctx another thread has just got freed...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Acked-by: Benjamin LaHaise <bcrl@kvack.org>
Reviewed-by: Jeff Moyer <jmoyer@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

No differences found