https://github.com/torvalds/linux
Revision 1d5f360dd1a3c04e00a52af74dd84fdb0e1d454b authored by Jens Axboe on 26 February 2021, 21:54:16 UTC, committed by Jens Axboe on 04 March 2021, 13:35:00 UTC
We clear the bit marking the ctx task_work as active after having run
the queued work, but we really should be clearing it before. Otherwise
we can hit a tiny race ala:

CPU0					CPU1
io_task_work_add()			tctx_task_work()
					run_work
	add_to_list
	test_and_set_bit
					clear_bit
		already set

and CPU0 will return thinking the task_work is queued, while in reality
it's already being run. If we hit the condition after __tctx_task_work()
found no more work, but before we've cleared the bit, then we'll end up
thinking it's queued and will be run. In reality it is queued, but we
didn't queue the ctx task_work to ensure that it gets run.

Fixes: 7cbf1722d5fc ("io_uring: provide FIFO ordering for task_work")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent afcc401
History
Tip revision: 1d5f360dd1a3c04e00a52af74dd84fdb0e1d454b authored by Jens Axboe on 26 February 2021, 21:54:16 UTC
io_uring: fix race condition in task_work add and clear
Tip revision: 1d5f360
File Mode Size
Documentation
LICENSES
arch
block
certs
crypto
drivers
fs
include
init
ipc
kernel
lib
mm
net
samples
scripts
security
sound
tools
usr
virt
.clang-format -rw-r--r-- 16.4 KB
.cocciconfig -rw-r--r-- 59 bytes
.get_maintainer.ignore -rw-r--r-- 71 bytes
.gitattributes -rw-r--r-- 62 bytes
.gitignore -rw-r--r-- 1.9 KB
.mailmap -rw-r--r-- 18.5 KB
COPYING -rw-r--r-- 496 bytes
CREDITS -rw-r--r-- 98.3 KB
Kbuild -rw-r--r-- 1.3 KB
Kconfig -rw-r--r-- 555 bytes
MAINTAINERS -rw-r--r-- 577.0 KB
Makefile -rw-r--r-- 64.6 KB
README -rw-r--r-- 727 bytes

README

back to top