In the Linux kernel, the following vulnerability has been resolved:
iouring/io-wq: Use setbit() and test_bit() at worker->flags
Utilize setbit() and testbit() on worker->flags within io_uring/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 io_worker_handle_work / io_wq_activate_free_worker
write to 0xffff8885c4246404 of 4 bytes by task 49071 on cpu 28:
io_worker_handle_work (io_uring/io-wq.c:434 io_uring/io-wq.c:569)
io_wq_worker (io_uring/io-wq.c:?)
<snip>
read to 0xffff8885c4246404 of 4 bytes by task 49024 on cpu 5:
io_wq_activate_free_worker (io_uring/io-wq.c:? io_uring/io-wq.c:285)
io_wq_enqueue (io_uring/io-wq.c:947)
io_queue_iowq (io_uring/io_uring.c:524)
io_req_task_submit (io_uring/io_uring.c:1511)
io_handle_tw_list (io_uring/io_uring.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.
[
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@1cbb0affb15470a9621267fe0a8568007553a4bf",
"signature_version": "v1",
"deprecated": false,
"target": {
"function": "__io_worker_busy",
"file": "io_uring/io-wq.c"
},
"id": "CVE-2024-39508-042a0e3e",
"signature_type": "Function",
"digest": {
"length": 241.0,
"function_hash": "136394663678397634155209862535421318118"
}
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@1cbb0affb15470a9621267fe0a8568007553a4bf",
"signature_version": "v1",
"deprecated": false,
"target": {
"function": "io_wq_dec_running",
"file": "io_uring/io-wq.c"
},
"id": "CVE-2024-39508-0dc323b5",
"signature_type": "Function",
"digest": {
"length": 393.0,
"function_hash": "38689795226496298337753709906511013706"
}
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@1cbb0affb15470a9621267fe0a8568007553a4bf",
"signature_version": "v1",
"deprecated": false,
"target": {
"file": "io_uring/io-wq.c"
},
"id": "CVE-2024-39508-0f7f6df9",
"signature_type": "Line",
"digest": {
"threshold": 0.9,
"line_hashes": [
"83560745127964808827326041434964826461",
"219731488719266497391824225037153855875",
"82454857502573157080077620485200433869",
"158306993901012121852789785578421858684",
"47935985860086753400694934149815014418",
"182603809724086206094070722389977218389",
"171392563895149271300194539383500347246",
"310757415266972158488985925715617750730",
"233696677772424814322326337515878050325",
"37082624273690191537588427117909708622",
"208926805611283259024145601576873508336",
"45771388677011969491409374780831228523",
"263834559492815016579954920758449345078",
"266588189664082639550406952635496042693",
"225965177764829838985170387986601116320",
"166818572900683082137017982583889753466",
"206664301122271662754308982596724466223",
"142874570879390542617161211569132820869",
"259068063814361809949043244802739898703",
"169967912987381119321627116004689080400",
"1131193355168059976770866173823934080",
"196246505563488698566908366323221655807",
"151268329653128243676622949351819856171",
"122382563993746885467305307099426196233",
"71183580569487219408724943748776992714",
"3052926035013967270756134341652862181",
"93237864985259397279431570683043859261",
"3814297757903137277998470705543463737",
"99896758761389325275026983218253729604",
"154590283455154617396929005453874668418",
"200486348740472977369461480783741706671",
"95293077088815423641415408844551290356",
"65201444843906571590897899127469595055",
"267600510282206114531368575316821395623",
"115255104503725471782846474272108308373",
"108689399851482050332224696644037466961",
"220084757849372173773894047730209510334",
"339870400600146413415355706623134832192",
"127265068434185605782180701594384475056",
"304716161094637316965898202168841712913",
"233005251938277129186005805975468739124",
"214493233526575605482909676965851907430",
"136949235874125724734150555441401753541",
"53995348272647775618169057058906710242",
"107285489247996220508409653070580474717",
"241910840057302341605811194211905223322",
"152413114531238928104231389351588781840",
"131211557956788921116144546537155821466",
"304757907257306775844443218727864535206",
"214493233526575605482909676965851907430",
"136949235874125724734150555441401753541",
"252763859860191311554662312620496498209",
"206670304429671338566151325411428869123",
"27730644884251561620003268440914497108",
"37889003000839837939132157445366110086",
"317930380649198635469901101462908803795",
"100483046935350726767730767454785437850",
"186234892542462446440342817288995977151",
"138728424755417838779672602758537664228",
"313475879429092062105245363600925183825",
"186720194291346911452374380237157204285",
"310686069621693750147637592652325527286",
"177852584184235504558275172612008727365",
"261841797369661110052292742569309199262",
"92518257699200917923248134400837798685",
"216602579948494698155528844189853679841",
"115232949953288043573230606583913026410",
"309894506751429715124947323993690142191",
"42421447159480732046090323042099570315",
"40154089534236679419511755271122695268",
"91410421941393222009784283535755957672"
]
}
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@8a565304927fbd28c9f028c492b5c1714002cbab",
"signature_version": "v1",
"deprecated": false,
"target": {
"function": "io_worker_exit",
"file": "io_uring/io-wq.c"
},
"id": "CVE-2024-39508-1b99cac8",
"signature_type": "Function",
"digest": {
"length": 548.0,
"function_hash": "208220269445597987093478847256007384152"
}
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@8a565304927fbd28c9f028c492b5c1714002cbab",
"signature_version": "v1",
"deprecated": false,
"target": {
"function": "io_wq_worker",
"file": "io_uring/io-wq.c"
},
"id": "CVE-2024-39508-1ba476eb",
"signature_type": "Function",
"digest": {
"length": 1118.0,
"function_hash": "288446281372766424380164209901732474060"
}
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@1cbb0affb15470a9621267fe0a8568007553a4bf",
"signature_version": "v1",
"deprecated": false,
"target": {
"function": "create_io_worker",
"file": "io_uring/io-wq.c"
},
"id": "CVE-2024-39508-44177417",
"signature_type": "Function",
"digest": {
"length": 871.0,
"function_hash": "62426176360332389052613423741883458714"
}
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@8a565304927fbd28c9f028c492b5c1714002cbab",
"signature_version": "v1",
"deprecated": false,
"target": {
"file": "io_uring/io-wq.c"
},
"id": "CVE-2024-39508-475cfef4",
"signature_type": "Line",
"digest": {
"threshold": 0.9,
"line_hashes": [
"83560745127964808827326041434964826461",
"219731488719266497391824225037153855875",
"82454857502573157080077620485200433869",
"158306993901012121852789785578421858684",
"47935985860086753400694934149815014418",
"182603809724086206094070722389977218389",
"171392563895149271300194539383500347246",
"310757415266972158488985925715617750730",
"233696677772424814322326337515878050325",
"37082624273690191537588427117909708622",
"208926805611283259024145601576873508336",
"45771388677011969491409374780831228523",
"263834559492815016579954920758449345078",
"266588189664082639550406952635496042693",
"225965177764829838985170387986601116320",
"166818572900683082137017982583889753466",
"206664301122271662754308982596724466223",
"142874570879390542617161211569132820869",
"259068063814361809949043244802739898703",
"169967912987381119321627116004689080400",
"1131193355168059976770866173823934080",
"196246505563488698566908366323221655807",
"151268329653128243676622949351819856171",
"122382563993746885467305307099426196233",
"71183580569487219408724943748776992714",
"3052926035013967270756134341652862181",
"93237864985259397279431570683043859261",
"3814297757903137277998470705543463737",
"99896758761389325275026983218253729604",
"154590283455154617396929005453874668418",
"200486348740472977369461480783741706671",
"95293077088815423641415408844551290356",
"65201444843906571590897899127469595055",
"267600510282206114531368575316821395623",
"115255104503725471782846474272108308373",
"108689399851482050332224696644037466961",
"220084757849372173773894047730209510334",
"339870400600146413415355706623134832192",
"127265068434185605782180701594384475056",
"304716161094637316965898202168841712913",
"233005251938277129186005805975468739124",
"214493233526575605482909676965851907430",
"136949235874125724734150555441401753541",
"53995348272647775618169057058906710242",
"107285489247996220508409653070580474717",
"241910840057302341605811194211905223322",
"152413114531238928104231389351588781840",
"131211557956788921116144546537155821466",
"304757907257306775844443218727864535206",
"214493233526575605482909676965851907430",
"136949235874125724734150555441401753541",
"252763859860191311554662312620496498209",
"206670304429671338566151325411428869123",
"27730644884251561620003268440914497108",
"37889003000839837939132157445366110086",
"317930380649198635469901101462908803795",
"100483046935350726767730767454785437850",
"186234892542462446440342817288995977151",
"138728424755417838779672602758537664228",
"313475879429092062105245363600925183825",
"186720194291346911452374380237157204285",
"310686069621693750147637592652325527286",
"177852584184235504558275172612008727365",
"261841797369661110052292742569309199262",
"92518257699200917923248134400837798685",
"216602579948494698155528844189853679841",
"115232949953288043573230606583913026410",
"309894506751429715124947323993690142191",
"42421447159480732046090323042099570315",
"40154089534236679419511755271122695268",
"91410421941393222009784283535755957672"
]
}
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@8a565304927fbd28c9f028c492b5c1714002cbab",
"signature_version": "v1",
"deprecated": false,
"target": {
"function": "io_wq_enqueue",
"file": "io_uring/io-wq.c"
},
"id": "CVE-2024-39508-4df45c1f",
"signature_type": "Function",
"digest": {
"length": 918.0,
"function_hash": "209408798478637511693839544105393019234"
}
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@1cbb0affb15470a9621267fe0a8568007553a4bf",
"signature_version": "v1",
"deprecated": false,
"target": {
"function": "io_wq_worker_running",
"file": "io_uring/io-wq.c"
},
"id": "CVE-2024-39508-52ecc875",
"signature_type": "Function",
"digest": {
"length": 258.0,
"function_hash": "145407770488646410119064020472478097967"
}
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@8a565304927fbd28c9f028c492b5c1714002cbab",
"signature_version": "v1",
"deprecated": false,
"target": {
"function": "io_wq_dec_running",
"file": "io_uring/io-wq.c"
},
"id": "CVE-2024-39508-55044a4b",
"signature_type": "Function",
"digest": {
"length": 393.0,
"function_hash": "38689795226496298337753709906511013706"
}
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@1cbb0affb15470a9621267fe0a8568007553a4bf",
"signature_version": "v1",
"deprecated": false,
"target": {
"function": "io_worker_exit",
"file": "io_uring/io-wq.c"
},
"id": "CVE-2024-39508-56dddaee",
"signature_type": "Function",
"digest": {
"length": 548.0,
"function_hash": "208220269445597987093478847256007384152"
}
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@8a565304927fbd28c9f028c492b5c1714002cbab",
"signature_version": "v1",
"deprecated": false,
"target": {
"function": "io_wq_get_acct",
"file": "io_uring/io-wq.c"
},
"id": "CVE-2024-39508-5aa99a72",
"signature_type": "Function",
"digest": {
"length": 123.0,
"function_hash": "21452442085413161947482358786773521000"
}
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@8a565304927fbd28c9f028c492b5c1714002cbab",
"signature_version": "v1",
"deprecated": false,
"target": {
"function": "io_wq_worker_running",
"file": "io_uring/io-wq.c"
},
"id": "CVE-2024-39508-65509443",
"signature_type": "Function",
"digest": {
"length": 258.0,
"function_hash": "145407770488646410119064020472478097967"
}
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@8a565304927fbd28c9f028c492b5c1714002cbab",
"signature_version": "v1",
"deprecated": false,
"target": {
"function": "create_io_worker",
"file": "io_uring/io-wq.c"
},
"id": "CVE-2024-39508-6f3b6c23",
"signature_type": "Function",
"digest": {
"length": 871.0,
"function_hash": "62426176360332389052613423741883458714"
}
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@1cbb0affb15470a9621267fe0a8568007553a4bf",
"signature_version": "v1",
"deprecated": false,
"target": {
"function": "io_wq_get_acct",
"file": "io_uring/io-wq.c"
},
"id": "CVE-2024-39508-a66a773d",
"signature_type": "Function",
"digest": {
"length": 123.0,
"function_hash": "21452442085413161947482358786773521000"
}
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@1cbb0affb15470a9621267fe0a8568007553a4bf",
"signature_version": "v1",
"deprecated": false,
"target": {
"function": "io_wq_worker_sleeping",
"file": "io_uring/io-wq.c"
},
"id": "CVE-2024-39508-d06ef815",
"signature_type": "Function",
"digest": {
"length": 265.0,
"function_hash": "47313372506792566503373096174604712981"
}
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@1cbb0affb15470a9621267fe0a8568007553a4bf",
"signature_version": "v1",
"deprecated": false,
"target": {
"function": "io_wq_worker",
"file": "io_uring/io-wq.c"
},
"id": "CVE-2024-39508-dbb5d76f",
"signature_type": "Function",
"digest": {
"length": 1118.0,
"function_hash": "288446281372766424380164209901732474060"
}
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@1cbb0affb15470a9621267fe0a8568007553a4bf",
"signature_version": "v1",
"deprecated": false,
"target": {
"function": "io_wq_enqueue",
"file": "io_uring/io-wq.c"
},
"id": "CVE-2024-39508-df0c52d0",
"signature_type": "Function",
"digest": {
"length": 918.0,
"function_hash": "209408798478637511693839544105393019234"
}
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@1cbb0affb15470a9621267fe0a8568007553a4bf",
"signature_version": "v1",
"deprecated": false,
"target": {
"function": "io_init_new_worker",
"file": "io_uring/io-wq.c"
},
"id": "CVE-2024-39508-e994c9d3",
"signature_type": "Function",
"digest": {
"length": 411.0,
"function_hash": "221977645479161012377616646145890051935"
}
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@8a565304927fbd28c9f028c492b5c1714002cbab",
"signature_version": "v1",
"deprecated": false,
"target": {
"function": "io_init_new_worker",
"file": "io_uring/io-wq.c"
},
"id": "CVE-2024-39508-ecf455e8",
"signature_type": "Function",
"digest": {
"length": 411.0,
"function_hash": "221977645479161012377616646145890051935"
}
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@8a565304927fbd28c9f028c492b5c1714002cbab",
"signature_version": "v1",
"deprecated": false,
"target": {
"function": "io_wq_worker_sleeping",
"file": "io_uring/io-wq.c"
},
"id": "CVE-2024-39508-ef528f83",
"signature_type": "Function",
"digest": {
"length": 265.0,
"function_hash": "47313372506792566503373096174604712981"
}
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@8a565304927fbd28c9f028c492b5c1714002cbab",
"signature_version": "v1",
"deprecated": false,
"target": {
"function": "__io_worker_busy",
"file": "io_uring/io-wq.c"
},
"id": "CVE-2024-39508-fc866d1c",
"signature_type": "Function",
"digest": {
"length": 241.0,
"function_hash": "136394663678397634155209862535421318118"
}
}
]