summaryrefslogtreecommitdiff
path: root/include/linux/workqueue_api.h
diff options
context:
space:
mode:
authorChristian Brauner <brauner@kernel.org>2026-10-30 17:15:21 +0100
committerChristian Brauner <brauner@kernel.org>2026-11-06 14:25:49 +0100
commitac4b449b39e605123c12ea10042cafc9b6f39603 (patch)
treea24eb571961268d88a1914d4fbb32657fffae5a9 /include/linux/workqueue_api.h
parentdaac2c45354df894aab749efc11a92ca9efd68f1 (diff)
aio: don't let exit_aio() return before complete() is done
exit_aio() kills all contexts in one go and waits for them with a single on-stack struct ctx_rq_wait. The count starts at table->nr, each killed context drops one count in free_ioctx_reqs() and exit_aio() subtracts the empty slots afterwards. Whoever drops the last count either calls complete() or, if it is exit_aio(), skips the wait. With a full table skipped is zero and atomic_sub_and_test(0, ...) only tells us whether the count already hit zero. free_ioctx_reqs() runs from the percpu_ref RCU callback, so if exit_aio() is off the CPU long enough the last callback can have done its atomic_dec_and_test() but not yet called complete(): free_ioctx_reqs() exit_aio() atomic_dec_and_test() // 1 -> 0 atomic_sub_and_test(0) // true kfree(table) return complete(&wait.comp) complete() then locks and writes a completion on a stack frame that is gone. So hold an extra count for exit_aio() itself. Then the last count is always dropped by exit_aio() after it waited, or by a callback while exit_aio() waits for it. An unprivileged user gets there with four io_setup() calls and an exit without io_destroy(). Reported-by: Kyle Zeng <kylebot@openai.com> Fixes: dc48e56d7616 ("aio: fix serial draining in exit_aio()") Cc: stable@vger.kernel.org Link: https://patch.msgid.link/20261030-work-aio-exit_aio-v1-1-83942022a4c4@kernel.org Reviewed-by: Jan Kara <jack@suse.cz> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Diffstat (limited to 'include/linux/workqueue_api.h')
0 files changed, 0 insertions, 0 deletions