In the Linux kernel, the following vulnerability has been resolved: iouring/io-wq: Use setbit() and testbit() at worker->flags Utilize setbit() and testbit() on worker->flags within iouring/io-wq to address potential data races. The structure ioworker->flags may be accessed through various data paths, leading to concurrency issues. When KCSAN is enabled, it reveals data races occurring in ioworkerhandlework and iowqactivatefreeworker functions. BUG: KCSAN: data-race in ioworkerhandlework / iowqactivatefreeworker write to 0xffff8885c4246404 of 4 bytes by task 49071 on cpu 28: ioworkerhandlework (iouring/io-wq.c:434 iouring/io-wq.c:569) iowqworker (iouring/io-wq.c:?) <snip> read to 0xffff8885c4246404 of 4 bytes by task 49024 on cpu 5: iowqactivatefreeworker (iouring/io-wq.c:? iouring/io-wq.c:285) iowqenqueue (iouring/io-wq.c:947) ioqueueiowq (iouring/iouring.c:524) ioreqtasksubmit (iouring/iouring.c:1511) iohandletwlist (iouring/iouring.c:1198) <snip> Line numbers against commit 18daea77cca6 ("Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm"). These races involve writes and reads to the same memory location by different tasks running on different CPUs. To mitigate this, refactor the code to use atomic operations such as setbit(), testbit(), and clear_bit() instead of basic "and" and "or" operations. This ensures thread-safe manipulation of worker flags. Also, move create_index
to avoid holes in the structure.