In the Linux kernel, the following vulnerability has been resolved:
kcsan: Turn reportfilterlistlock into a raw_spinlock
Ran Xiaokai reports that with a KCSAN-enabled PREEMPT_RT kernel, we can see splats like:
| BUG: sleeping function called from invalid context at kernel/locking/spinlockrt.c:48 | inatomic(): 1, irqsdisabled(): 1, nonblock: 0, pid: 0, name: swapper/1 | preemptcount: 10002, expected: 0 | RCU nest depth: 0, expected: 0 | no locks held by swapper/1/0. | irq event stamp: 156674 | hardirqs last enabled at (156673): [<ffffffff81130bd9>] doidle+0x1f9/0x240 | hardirqs last disabled at (156674): [<ffffffff82254f84>] sysvecapictimerinterrupt+0x14/0xc0 | softirqs last enabled at (0): [<ffffffff81099f47>] copyprocess+0xfc7/0x4b60 | softirqs last disabled at (0): [<0000000000000000>] 0x0 | Preemption disabled at: | [<ffffffff814a3e2a>] paintptr+0x2a/0x90 | CPU: 1 UID: 0 PID: 0 Comm: swapper/1 Not tainted 6.11.0+ #3 | Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.0-0-ga698c8995f-prebuilt.qemu.org 04/01/2014 | Call Trace: | <IRQ> | dumpstacklvl+0x7e/0xc0 | dumpstack+0x1d/0x30 | _mightresched+0x1a2/0x270 | rtspinlock+0x68/0x170 | kcsanskipreportdebugfs+0x43/0xe0 | printreport+0xb5/0x590 | kcsanreportknownorigin+0x1b1/0x1d0 | kcsansetupwatchpoint+0x348/0x650 | _tsanunalignedwrite1+0x16d/0x1d0 | hrtimerinterrupt+0x3d6/0x430 | _sysvecapictimerinterrupt+0xe8/0x3a0 | sysvecapictimerinterrupt+0x97/0xc0 | </IRQ>
On a detected data race, KCSAN's reporting logic checks if it should filter the report. That list is protected by the reportfilterlistlock non-raw spinlock which may sleep on RT kernels.
Since KCSAN may report data races in any context, convert it to a raw_spinlock.
This requires being careful about when to allocate memory for the filter list itself which can be done via KCSAN's debugfs interface. Concurrent modification of the filter list via debugfs should be rare: the chosen strategy is to optimistically pre-allocate memory before the critical section and discard if unused.
[
{
"signature_type": "Line",
"digest": {
"line_hashes": [
"316981584917860753452464795090062755201",
"62273259750664077054514284170623962270",
"241202445473364390950674776024774942758",
"195660675336767494964351454098884972223",
"59542882611266322885346458735306410162",
"240486642656834486871856846524630629193",
"201314701235959562596841018956438299276",
"76234241947557501257279600546962808394",
"319300669125372544078088581595543382399",
"154737608646659745545894008629589723383",
"32493826442275764608597101375530276464",
"261065859914457802713274513623854612730",
"47693077210752701795149616308623945686",
"255132513481879789471515339660283930433",
"114211749310291863272779040072763792794",
"2887398285282255749464651232984748537",
"9615953405974826073385659811420932103",
"132561366043746860828551758542859046998",
"271770592539189925149731892844129620013",
"219208353415296464220704999083520492182",
"308310678573045895562355895545671376049",
"266909614245964046424305443930300180089",
"10207905111109545816352342057437274212",
"61154643699297606837514809508112941578",
"37090148271255925813974777896185865666",
"84813220836285581722463298099267242830",
"205772402875537304673728135397102035740",
"159508536029229201999279875110865995576",
"298670953239699821511463508404489659198",
"128632547082882688101644145326297693624",
"177774386993910044204077339241132736085",
"178299826661872494282624742285971276587",
"56512234971316682123451207191920295684",
"40563118597060250600211166213530980473",
"20308841010865266011728599503846436834",
"106758302438950382761173221487889332772",
"185643358965507123127058141023486786985",
"230400807882745672007193242613187284279",
"138550838647233801659399295890410408439",
"94885011348018356180070293984514895783",
"303785424501747539213884222131127733060",
"105726537507658300045128461308183001369",
"184028021010876188748617249399796972828",
"303709694703832769598564566460356396414",
"287016376951128155281003149045089729838",
"304607654905915934484443500613370879400",
"67748571382025012827694964346971862643",
"325670636597586423469990599555125142674",
"123462620934091418380723178661218772225",
"159191480368566809611236284689543525191",
"36615963441715168034229487309686058925",
"76520575528814007115775647164849588538",
"237718685928600186878460675281079384894",
"310787855726929360660281188986291725528",
"197937822015339407469446564729847072181",
"132561366043746860828551758542859046998",
"24063651677324057808737445239735534948",
"59291603865955897180503096023112336590",
"44850167316147361668150026539972653518",
"158437508054051137819832059917151706564",
"131668153682376946604148763234796772755",
"77306252922938591451406210987453369521",
"278500308965108046467626513710519704232",
"316434819492911514906640297957909279863",
"88270219460571504603866371789367663084",
"333393507362919988538450973184353430161",
"108360077732376176888129284137361005576"
],
"threshold": 0.9
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@dca4e74a918586913d251c0b359e8cc96a3883ea",
"deprecated": false,
"id": "CVE-2024-56610-0aaf9551",
"signature_version": "v1",
"target": {
"file": "kernel/kcsan/debugfs.c"
}
},
{
"signature_type": "Function",
"digest": {
"length": 1017.0,
"function_hash": "127035106294239380240403375921243551847"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@dca4e74a918586913d251c0b359e8cc96a3883ea",
"deprecated": false,
"id": "CVE-2024-56610-0ecffe09",
"signature_version": "v1",
"target": {
"function": "insert_report_filterlist",
"file": "kernel/kcsan/debugfs.c"
}
},
{
"signature_type": "Line",
"digest": {
"line_hashes": [
"316981584917860753452464795090062755201",
"62273259750664077054514284170623962270",
"241202445473364390950674776024774942758",
"195660675336767494964351454098884972223",
"59542882611266322885346458735306410162",
"240486642656834486871856846524630629193",
"201314701235959562596841018956438299276",
"76234241947557501257279600546962808394",
"319300669125372544078088581595543382399",
"154737608646659745545894008629589723383",
"32493826442275764608597101375530276464",
"261065859914457802713274513623854612730",
"47693077210752701795149616308623945686",
"255132513481879789471515339660283930433",
"114211749310291863272779040072763792794",
"2887398285282255749464651232984748537",
"9615953405974826073385659811420932103",
"132561366043746860828551758542859046998",
"271770592539189925149731892844129620013",
"219208353415296464220704999083520492182",
"308310678573045895562355895545671376049",
"266909614245964046424305443930300180089",
"10207905111109545816352342057437274212",
"61154643699297606837514809508112941578",
"37090148271255925813974777896185865666",
"84813220836285581722463298099267242830",
"205772402875537304673728135397102035740",
"159508536029229201999279875110865995576",
"298670953239699821511463508404489659198",
"128632547082882688101644145326297693624",
"177774386993910044204077339241132736085",
"178299826661872494282624742285971276587",
"56512234971316682123451207191920295684",
"40563118597060250600211166213530980473",
"20308841010865266011728599503846436834",
"106758302438950382761173221487889332772",
"185643358965507123127058141023486786985",
"230400807882745672007193242613187284279",
"138550838647233801659399295890410408439",
"94885011348018356180070293984514895783",
"303785424501747539213884222131127733060",
"105726537507658300045128461308183001369",
"184028021010876188748617249399796972828",
"303709694703832769598564566460356396414",
"287016376951128155281003149045089729838",
"304607654905915934484443500613370879400",
"67748571382025012827694964346971862643",
"325670636597586423469990599555125142674",
"123462620934091418380723178661218772225",
"159191480368566809611236284689543525191",
"36615963441715168034229487309686058925",
"76520575528814007115775647164849588538",
"237718685928600186878460675281079384894",
"310787855726929360660281188986291725528",
"197937822015339407469446564729847072181",
"132561366043746860828551758542859046998",
"24063651677324057808737445239735534948",
"59291603865955897180503096023112336590",
"44850167316147361668150026539972653518",
"158437508054051137819832059917151706564",
"131668153682376946604148763234796772755",
"77306252922938591451406210987453369521",
"278500308965108046467626513710519704232",
"316434819492911514906640297957909279863",
"88270219460571504603866371789367663084",
"333393507362919988538450973184353430161",
"108360077732376176888129284137361005576"
],
"threshold": 0.9
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@ea6588abcc15d68fdeae777ffe3dd74c02eab407",
"deprecated": false,
"id": "CVE-2024-56610-139fc5db",
"signature_version": "v1",
"target": {
"file": "kernel/kcsan/debugfs.c"
}
},
{
"signature_type": "Line",
"digest": {
"line_hashes": [
"316981584917860753452464795090062755201",
"62273259750664077054514284170623962270",
"241202445473364390950674776024774942758",
"195660675336767494964351454098884972223",
"59542882611266322885346458735306410162",
"240486642656834486871856846524630629193",
"201314701235959562596841018956438299276",
"76234241947557501257279600546962808394",
"319300669125372544078088581595543382399",
"154737608646659745545894008629589723383",
"32493826442275764608597101375530276464",
"261065859914457802713274513623854612730",
"47693077210752701795149616308623945686",
"255132513481879789471515339660283930433",
"114211749310291863272779040072763792794",
"2887398285282255749464651232984748537",
"9615953405974826073385659811420932103",
"132561366043746860828551758542859046998",
"271770592539189925149731892844129620013",
"219208353415296464220704999083520492182",
"308310678573045895562355895545671376049",
"266909614245964046424305443930300180089",
"10207905111109545816352342057437274212",
"61154643699297606837514809508112941578",
"37090148271255925813974777896185865666",
"84813220836285581722463298099267242830",
"205772402875537304673728135397102035740",
"159508536029229201999279875110865995576",
"298670953239699821511463508404489659198",
"128632547082882688101644145326297693624",
"177774386993910044204077339241132736085",
"178299826661872494282624742285971276587",
"56512234971316682123451207191920295684",
"40563118597060250600211166213530980473",
"20308841010865266011728599503846436834",
"106758302438950382761173221487889332772",
"185643358965507123127058141023486786985",
"230400807882745672007193242613187284279",
"138550838647233801659399295890410408439",
"94885011348018356180070293984514895783",
"303785424501747539213884222131127733060",
"105726537507658300045128461308183001369",
"184028021010876188748617249399796972828",
"303709694703832769598564566460356396414",
"287016376951128155281003149045089729838",
"304607654905915934484443500613370879400",
"67748571382025012827694964346971862643",
"325670636597586423469990599555125142674",
"123462620934091418380723178661218772225",
"159191480368566809611236284689543525191",
"36615963441715168034229487309686058925",
"76520575528814007115775647164849588538",
"237718685928600186878460675281079384894",
"310787855726929360660281188986291725528",
"197937822015339407469446564729847072181",
"132561366043746860828551758542859046998",
"24063651677324057808737445239735534948",
"59291603865955897180503096023112336590",
"44850167316147361668150026539972653518",
"158437508054051137819832059917151706564",
"131668153682376946604148763234796772755",
"77306252922938591451406210987453369521",
"278500308965108046467626513710519704232",
"316434819492911514906640297957909279863",
"88270219460571504603866371789367663084",
"333393507362919988538450973184353430161",
"108360077732376176888129284137361005576"
],
"threshold": 0.9
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@f4f2ef66d288ea796ddb8ecbdc2df074ab2d5f4d",
"deprecated": false,
"id": "CVE-2024-56610-3695265b",
"signature_version": "v1",
"target": {
"file": "kernel/kcsan/debugfs.c"
}
},
{
"signature_type": "Line",
"digest": {
"line_hashes": [
"316981584917860753452464795090062755201",
"62273259750664077054514284170623962270",
"241202445473364390950674776024774942758",
"195660675336767494964351454098884972223",
"59542882611266322885346458735306410162",
"240486642656834486871856846524630629193",
"201314701235959562596841018956438299276",
"76234241947557501257279600546962808394",
"319300669125372544078088581595543382399",
"154737608646659745545894008629589723383",
"32493826442275764608597101375530276464",
"261065859914457802713274513623854612730",
"47693077210752701795149616308623945686",
"255132513481879789471515339660283930433",
"114211749310291863272779040072763792794",
"2887398285282255749464651232984748537",
"9615953405974826073385659811420932103",
"132561366043746860828551758542859046998",
"271770592539189925149731892844129620013",
"219208353415296464220704999083520492182",
"308310678573045895562355895545671376049",
"266909614245964046424305443930300180089",
"10207905111109545816352342057437274212",
"61154643699297606837514809508112941578",
"37090148271255925813974777896185865666",
"84813220836285581722463298099267242830",
"205772402875537304673728135397102035740",
"159508536029229201999279875110865995576",
"298670953239699821511463508404489659198",
"128632547082882688101644145326297693624",
"177774386993910044204077339241132736085",
"178299826661872494282624742285971276587",
"56512234971316682123451207191920295684",
"40563118597060250600211166213530980473",
"20308841010865266011728599503846436834",
"106758302438950382761173221487889332772",
"185643358965507123127058141023486786985",
"230400807882745672007193242613187284279",
"138550838647233801659399295890410408439",
"94885011348018356180070293984514895783",
"303785424501747539213884222131127733060",
"105726537507658300045128461308183001369",
"184028021010876188748617249399796972828",
"303709694703832769598564566460356396414",
"287016376951128155281003149045089729838",
"304607654905915934484443500613370879400",
"67748571382025012827694964346971862643",
"325670636597586423469990599555125142674",
"123462620934091418380723178661218772225",
"159191480368566809611236284689543525191",
"36615963441715168034229487309686058925",
"76520575528814007115775647164849588538",
"237718685928600186878460675281079384894",
"310787855726929360660281188986291725528",
"197937822015339407469446564729847072181",
"132561366043746860828551758542859046998",
"24063651677324057808737445239735534948",
"59291603865955897180503096023112336590",
"44850167316147361668150026539972653518",
"158437508054051137819832059917151706564",
"131668153682376946604148763234796772755",
"77306252922938591451406210987453369521",
"278500308965108046467626513710519704232",
"316434819492911514906640297957909279863",
"88270219460571504603866371789367663084",
"333393507362919988538450973184353430161",
"108360077732376176888129284137361005576"
],
"threshold": 0.9
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@59458fa4ddb47e7891c61b4a928d13d5f5b00aa0",
"deprecated": false,
"id": "CVE-2024-56610-504e3d7b",
"signature_version": "v1",
"target": {
"file": "kernel/kcsan/debugfs.c"
}
},
{
"signature_type": "Function",
"digest": {
"length": 1017.0,
"function_hash": "127035106294239380240403375921243551847"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@59458fa4ddb47e7891c61b4a928d13d5f5b00aa0",
"deprecated": false,
"id": "CVE-2024-56610-6483e4fd",
"signature_version": "v1",
"target": {
"function": "insert_report_filterlist",
"file": "kernel/kcsan/debugfs.c"
}
},
{
"signature_type": "Function",
"digest": {
"length": 1017.0,
"function_hash": "127035106294239380240403375921243551847"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@f4f2ef66d288ea796ddb8ecbdc2df074ab2d5f4d",
"deprecated": false,
"id": "CVE-2024-56610-bba72f5b",
"signature_version": "v1",
"target": {
"function": "insert_report_filterlist",
"file": "kernel/kcsan/debugfs.c"
}
},
{
"signature_type": "Function",
"digest": {
"length": 1017.0,
"function_hash": "127035106294239380240403375921243551847"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@ea6588abcc15d68fdeae777ffe3dd74c02eab407",
"deprecated": false,
"id": "CVE-2024-56610-bf0c156b",
"signature_version": "v1",
"target": {
"function": "insert_report_filterlist",
"file": "kernel/kcsan/debugfs.c"
}
},
{
"signature_type": "Line",
"digest": {
"line_hashes": [
"316981584917860753452464795090062755201",
"62273259750664077054514284170623962270",
"241202445473364390950674776024774942758",
"195660675336767494964351454098884972223",
"59542882611266322885346458735306410162",
"240486642656834486871856846524630629193",
"201314701235959562596841018956438299276",
"76234241947557501257279600546962808394",
"319300669125372544078088581595543382399",
"154737608646659745545894008629589723383",
"32493826442275764608597101375530276464",
"261065859914457802713274513623854612730",
"47693077210752701795149616308623945686",
"255132513481879789471515339660283930433",
"114211749310291863272779040072763792794",
"2887398285282255749464651232984748537",
"9615953405974826073385659811420932103",
"132561366043746860828551758542859046998",
"271770592539189925149731892844129620013",
"219208353415296464220704999083520492182",
"308310678573045895562355895545671376049",
"266909614245964046424305443930300180089",
"10207905111109545816352342057437274212",
"61154643699297606837514809508112941578",
"37090148271255925813974777896185865666",
"84813220836285581722463298099267242830",
"205772402875537304673728135397102035740",
"159508536029229201999279875110865995576",
"298670953239699821511463508404489659198",
"128632547082882688101644145326297693624",
"177774386993910044204077339241132736085",
"178299826661872494282624742285971276587",
"56512234971316682123451207191920295684",
"40563118597060250600211166213530980473",
"20308841010865266011728599503846436834",
"106758302438950382761173221487889332772",
"185643358965507123127058141023486786985",
"230400807882745672007193242613187284279",
"138550838647233801659399295890410408439",
"94885011348018356180070293984514895783",
"303785424501747539213884222131127733060",
"105726537507658300045128461308183001369",
"184028021010876188748617249399796972828",
"303709694703832769598564566460356396414",
"287016376951128155281003149045089729838",
"304607654905915934484443500613370879400",
"67748571382025012827694964346971862643",
"325670636597586423469990599555125142674",
"123462620934091418380723178661218772225",
"159191480368566809611236284689543525191",
"36615963441715168034229487309686058925",
"76520575528814007115775647164849588538",
"237718685928600186878460675281079384894",
"310787855726929360660281188986291725528",
"197937822015339407469446564729847072181",
"132561366043746860828551758542859046998",
"24063651677324057808737445239735534948",
"59291603865955897180503096023112336590",
"44850167316147361668150026539972653518",
"158437508054051137819832059917151706564",
"131668153682376946604148763234796772755",
"77306252922938591451406210987453369521",
"278500308965108046467626513710519704232",
"316434819492911514906640297957909279863",
"88270219460571504603866371789367663084",
"333393507362919988538450973184353430161",
"108360077732376176888129284137361005576"
],
"threshold": 0.9
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@889a0d3a35fdedba1c5dcb6410c95c32421680ec",
"deprecated": false,
"id": "CVE-2024-56610-c13c60d0",
"signature_version": "v1",
"target": {
"file": "kernel/kcsan/debugfs.c"
}
},
{
"signature_type": "Function",
"digest": {
"length": 1017.0,
"function_hash": "127035106294239380240403375921243551847"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@889a0d3a35fdedba1c5dcb6410c95c32421680ec",
"deprecated": false,
"id": "CVE-2024-56610-c23b4daf",
"signature_version": "v1",
"target": {
"function": "insert_report_filterlist",
"file": "kernel/kcsan/debugfs.c"
}
},
{
"signature_type": "Line",
"digest": {
"line_hashes": [
"316981584917860753452464795090062755201",
"62273259750664077054514284170623962270",
"241202445473364390950674776024774942758",
"195660675336767494964351454098884972223",
"59542882611266322885346458735306410162",
"240486642656834486871856846524630629193",
"201314701235959562596841018956438299276",
"76234241947557501257279600546962808394",
"319300669125372544078088581595543382399",
"154737608646659745545894008629589723383",
"32493826442275764608597101375530276464",
"261065859914457802713274513623854612730",
"47693077210752701795149616308623945686",
"255132513481879789471515339660283930433",
"114211749310291863272779040072763792794",
"2887398285282255749464651232984748537",
"9615953405974826073385659811420932103",
"132561366043746860828551758542859046998",
"271770592539189925149731892844129620013",
"219208353415296464220704999083520492182",
"308310678573045895562355895545671376049",
"266909614245964046424305443930300180089",
"10207905111109545816352342057437274212",
"61154643699297606837514809508112941578",
"37090148271255925813974777896185865666",
"84813220836285581722463298099267242830",
"205772402875537304673728135397102035740",
"159508536029229201999279875110865995576",
"298670953239699821511463508404489659198",
"128632547082882688101644145326297693624",
"177774386993910044204077339241132736085",
"178299826661872494282624742285971276587",
"56512234971316682123451207191920295684",
"40563118597060250600211166213530980473",
"20308841010865266011728599503846436834",
"106758302438950382761173221487889332772",
"185643358965507123127058141023486786985",
"230400807882745672007193242613187284279",
"138550838647233801659399295890410408439",
"94885011348018356180070293984514895783",
"303785424501747539213884222131127733060",
"105726537507658300045128461308183001369",
"184028021010876188748617249399796972828",
"303709694703832769598564566460356396414",
"287016376951128155281003149045089729838",
"304607654905915934484443500613370879400",
"67748571382025012827694964346971862643",
"325670636597586423469990599555125142674",
"123462620934091418380723178661218772225",
"159191480368566809611236284689543525191",
"36615963441715168034229487309686058925",
"76520575528814007115775647164849588538",
"237718685928600186878460675281079384894",
"310787855726929360660281188986291725528",
"197937822015339407469446564729847072181",
"132561366043746860828551758542859046998",
"24063651677324057808737445239735534948",
"59291603865955897180503096023112336590",
"44850167316147361668150026539972653518",
"158437508054051137819832059917151706564",
"131668153682376946604148763234796772755",
"77306252922938591451406210987453369521",
"278500308965108046467626513710519704232",
"316434819492911514906640297957909279863",
"88270219460571504603866371789367663084",
"333393507362919988538450973184353430161",
"108360077732376176888129284137361005576"
],
"threshold": 0.9
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@0ab4951c1473c7d1ceaf1232eb927109cd1c4859",
"deprecated": false,
"id": "CVE-2024-56610-c5489df7",
"signature_version": "v1",
"target": {
"file": "kernel/kcsan/debugfs.c"
}
},
{
"signature_type": "Function",
"digest": {
"length": 1017.0,
"function_hash": "127035106294239380240403375921243551847"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@0ab4951c1473c7d1ceaf1232eb927109cd1c4859",
"deprecated": false,
"id": "CVE-2024-56610-c6b2e241",
"signature_version": "v1",
"target": {
"function": "insert_report_filterlist",
"file": "kernel/kcsan/debugfs.c"
}
}
]