]> git.karo-electronics.de Git - karo-tx-linux.git/commit
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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 19 Mar 2012 15:57:43 +0000 (08:57 -0700)
commit8ef749e355dfb8932d4ae6d4aa8eacf3b0ab4444
treeb29bb3b2466c150dfe13cb7d81bbbeec3a0f50b0
parent0d9de88703f09127c0902a6c24178adf4d1a29aa
aio: fix io_setup/io_destroy race

commit 86b62a2cb4fc09037bbce2959d2992962396fd7f upstream.

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>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/aio.c