fs/aio: Add explicit RCU grace period when freeing kioctx
authorTejun Heo <tj@kernel.org>
Wed, 14 Mar 2018 19:10:17 +0000 (12:10 -0700)
committerTejun Heo <tj@kernel.org>
Wed, 14 Mar 2018 19:10:17 +0000 (12:10 -0700)
commita6d7cff472eea87d96899a20fa718d2bab7109f3
treeeb61b607a6fb3b77781c3e526ca33e0f885eb8b1
parent3032f8c504d2b15d58e4c96060a96b47e215573c
fs/aio: Add explicit RCU grace period when freeing kioctx

While fixing refcounting, e34ecee2ae79 ("aio: Fix a trinity splat")
incorrectly removed explicit RCU grace period before freeing kioctx.
The intention seems to be depending on the internal RCU grace periods
of percpu_ref; however, percpu_ref uses a different flavor of RCU,
sched-RCU.  This can lead to kioctx being freed while RCU read
protected dereferences are still in progress.

Fix it by updating free_ioctx() to go through call_rcu() explicitly.

v2: Comment added to explain double bouncing.

Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: Jann Horn <jannh@google.com>
Fixes: e34ecee2ae79 ("aio: Fix a trinity splat")
Cc: Kent Overstreet <kent.overstreet@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: stable@vger.kernel.org # v3.13+
fs/aio.c