Al Viro c7b2855505 aio: fix the "too late munmap()" race
Current code has put_ioctx() called asynchronously from aio_fput_routine();
that's done *after* we have killed the request that used to pin ioctx,
so there's nothing to stop io_destroy() waiting in wait_for_all_aios()
from progressing.  As the result, we can end up with async call of
put_ioctx() being the last one and possibly happening during exit_mmap()
or elf_core_dump(), neither of which expects stray munmap() being done
to them...

We do need to prevent _freeing_ ioctx until aio_fput_routine() is done
with that, but that's all we care about - neither io_destroy() nor
exit_aio() will progress past wait_for_all_aios() until aio_fput_routine()
does really_put_req(), so the ioctx teardown won't be done until then
and we don't care about the contents of ioctx past that point.

Since actual freeing of these suckers is RCU-delayed, we don't need to
bump ioctx refcount when request goes into list for async removal.
All we need is rcu_read_lock held just over the ->ctx_lock-protected
area in aio_fput_routine().

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Reviewed-by: Jeff Moyer <jmoyer@redhat.com>
Acked-by: Benjamin LaHaise <bcrl@kvack.org>
Cc: stable@vger.kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-03-09 18:59:59 -08:00
..
2012-01-03 22:55:04 -05:00
2012-01-03 22:54:53 -05:00
2012-01-03 22:54:53 -05:00
2012-01-03 22:54:07 -05:00
2012-01-03 22:54:57 -05:00
2012-01-03 22:55:10 -05:00
2012-02-28 09:52:39 +00:00
2012-01-03 22:54:54 -05:00
2012-01-09 10:48:11 -05:00
2012-02-17 17:34:03 -05:00
2012-01-03 22:55:01 -05:00
2012-02-02 12:55:17 -08:00
2012-01-03 22:55:07 -05:00
2012-01-10 13:45:22 -08:00
2012-03-09 18:59:59 -08:00
2012-01-03 22:55:11 -05:00
2012-01-03 22:54:54 -05:00
2012-02-08 22:07:18 +01:00
2012-01-03 22:54:07 -05:00
2012-01-03 22:52:39 -05:00
2012-01-05 15:40:12 -08:00
2012-01-03 22:54:07 -05:00
2012-01-03 22:52:40 -05:00
2012-01-03 22:54:07 -05:00
2012-01-03 22:53:07 -05:00
2012-01-03 22:54:07 -05:00
2012-01-03 22:52:40 -05:00