]> git.baikalelectronics.ru Git - kernel.git/commit
aio: Fix a trinity splat
authorKent Overstreet <kmo@daterainc.com>
Fri, 11 Oct 2013 02:31:47 +0000 (19:31 -0700)
committerKent Overstreet <kmo@daterainc.com>
Fri, 11 Oct 2013 02:31:47 +0000 (19:31 -0700)
commit41ce451659769b20f2696377bbef0338515b342f
tree0ce1c1ad368f8e0562f0b656142dcfd5c070d66c
parentbc25b6c102b413f911b5083264004c34f7e58e6c
aio: Fix a trinity splat

aio kiocb refcounting was broken - it was relying on keeping track of
the number of available ring buffer entries, which it needs to do
anyways; then at shutdown time it'd wait for completions to be delivered
until the # of available ring buffer entries equalled what it was
initialized to.

Problem with  that is that the ring buffer is mapped writable into
userspace, so userspace could futz with the head and tail pointers to
cause the kernel to see extra completions, and cause free_ioctx() to
return while there were still outstanding kiocbs. Which would be bad.

Fix is just to directly refcount the kiocbs - which is more
straightforward, and with the new percpu refcounting code doesn't cost
us any cacheline bouncing which was the whole point of the original
scheme.

Also clean up ioctx_alloc()'s error path and fix a bug where it wasn't
subtracting from aio_nr if ioctx_add_table() failed.

Signed-off-by: Kent Overstreet <kmo@daterainc.com>
fs/aio.c