In the Linux kernel, the following vulnerability has been resolved:
bpf, cpumap: Make sure kthread is running before map update returns
The following warning was reported when running stress-mode enabled xdpredirectcpu with some RT threads:
------------[ cut here ]------------ WARNING: CPU: 4 PID: 65 at kernel/bpf/cpumap.c:135 CPU: 4 PID: 65 Comm: kworker/4:1 Not tainted 6.5.0-rc2+ #1 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996) Workqueue: events cpumapkthreadstop RIP: 0010:putcpumapentry+0xda/0x220 ...... Call Trace: <TASK> ? showregs+0x65/0x70 ? _warn+0xa5/0x240 ...... ? putcpumapentry+0xda/0x220 cpumapkthreadstop+0x41/0x60 processonework+0x6b0/0xb80 workerthread+0x96/0x720 kthread+0x1a5/0x1f0 retfromfork+0x3a/0x70 retfromforkasm+0x1b/0x30 </TASK>
The root cause is the same as commit 436901649731 ("bpf: cpumap: Fix memory leak in cpumapupdateelem"). The kthread is stopped prematurely by kthreadstop() in cpumapkthreadstop(), and kthread() doesn't call cpumapkthreadrun() at all but XDP program has already queued some frames or skbs into ptrring. So when _cpumapringcleanup() checks the ptrring, it will find it was not emptied and report a warning.
An alternative fix is to use _cpumapringcleanup() to drop these pending frames or skbs when kthreadstop() returns -EINTR, but it may confuse the user, because these frames or skbs have been handled correctly by XDP program. So instead of dropping these frames or skbs, just make sure the per-cpu kthread is running before _cpumapentry_alloc() returns.
After apply the fix, the error handle for kthread_stop() will be unnecessary because it will always return 0, so just remove it.
{
"cna_assigner": "Linux",
"osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2023/53xxx/CVE-2023-53577.json"
}"https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2023-53577.json"
[
{
"id": "CVE-2023-53577-011e5c27",
"target": {
"function": "cpu_map_kthread_run",
"file": "kernel/bpf/cpumap.c"
},
"signature_version": "v1",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@b44d28b98f185d2f2348aa3c3636838c316f889e",
"digest": {
"function_hash": "59328108497823361401599838441249974719",
"length": 1572.0
},
"signature_type": "Function"
},
{
"id": "CVE-2023-53577-26fd5439",
"target": {
"function": "__cpu_map_entry_alloc",
"file": "kernel/bpf/cpumap.c"
},
"signature_version": "v1",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@7a1178a3671b40746830d355836b72e47ceb2490",
"digest": {
"function_hash": "245861764595931031864701377584476915121",
"length": 1424.0
},
"signature_type": "Function"
},
{
"id": "CVE-2023-53577-3820d928",
"target": {
"function": "__cpu_map_entry_alloc",
"file": "kernel/bpf/cpumap.c"
},
"signature_version": "v1",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@640a604585aa30f93e39b17d4d6ba69fcb1e66c9",
"digest": {
"function_hash": "245861764595931031864701377584476915121",
"length": 1424.0
},
"signature_type": "Function"
},
{
"id": "CVE-2023-53577-5ad6c54b",
"target": {
"function": "cpu_map_kthread_stop",
"file": "kernel/bpf/cpumap.c"
},
"signature_version": "v1",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@b44d28b98f185d2f2348aa3c3636838c316f889e",
"digest": {
"function_hash": "144335344264484137632153086552784220162",
"length": 211.0
},
"signature_type": "Function"
},
{
"id": "CVE-2023-53577-6402453a",
"target": {
"function": "cpu_map_kthread_stop",
"file": "kernel/bpf/cpumap.c"
},
"signature_version": "v1",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@ecb45b852af5e88257020b88bea5ff0798d72aca",
"digest": {
"function_hash": "144335344264484137632153086552784220162",
"length": 211.0
},
"signature_type": "Function"
},
{
"id": "CVE-2023-53577-76f47430",
"target": {
"file": "kernel/bpf/cpumap.c"
},
"signature_version": "v1",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@640a604585aa30f93e39b17d4d6ba69fcb1e66c9",
"digest": {
"threshold": 0.9,
"line_hashes": [
"143438376298442273920926464802654990414",
"250771888575949518523275674243928571782",
"303757949268044798089672956859187323036",
"265743565993017108498042715382169596201",
"10180334402934129591783230633104027711",
"157015782765516536576679792778283995201",
"59501919835773192338161811586144766201",
"113709665641243981283763825978951238647",
"325972872204104486376820041827965104256",
"67081723231749901790387236844454909958",
"6304905941425533914673567932832807845",
"110162913310688347596362697753078138444",
"183741779348057090285139692868771297631",
"302306194468357866488824726889657628627",
"201147909139658975426762557161426227030",
"24944682068804800165373135039932874705",
"55909221691383211074674447975641021516",
"65755660034969066084273626766704169226",
"257076868399015462300796849971009078594",
"49326886230236955399633341462155949151",
"229861443575873711011138732098803860895",
"42872310553560809291948004536962916238",
"313516021413463993687771576377936403326",
"38605075665589829548241315755496364302",
"163876881819410860100233051565001162413",
"128047395418713422891953530647034002953",
"44585040642333322479646870248382220264",
"219256666154436913529750288694148741527",
"176299639361397656866298840852311923670",
"17821537593699931483827345263907344583"
]
},
"signature_type": "Line"
},
{
"id": "CVE-2023-53577-8db1beba",
"target": {
"file": "kernel/bpf/cpumap.c"
},
"signature_version": "v1",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@7a1178a3671b40746830d355836b72e47ceb2490",
"digest": {
"threshold": 0.9,
"line_hashes": [
"31418575802945226983292607567543349729",
"226169139402218453455532113807964533807",
"269583873111867603089090266157061141055",
"107259744828248273615128507994301091469",
"10180334402934129591783230633104027711",
"157015782765516536576679792778283995201",
"59501919835773192338161811586144766201",
"113709665641243981283763825978951238647",
"325972872204104486376820041827965104256",
"67081723231749901790387236844454909958",
"6304905941425533914673567932832807845",
"110162913310688347596362697753078138444",
"183741779348057090285139692868771297631",
"302306194468357866488824726889657628627",
"201147909139658975426762557161426227030",
"24944682068804800165373135039932874705",
"55909221691383211074674447975641021516",
"65755660034969066084273626766704169226",
"257076868399015462300796849971009078594",
"49326886230236955399633341462155949151",
"229861443575873711011138732098803860895",
"42872310553560809291948004536962916238",
"313516021413463993687771576377936403326",
"38605075665589829548241315755496364302",
"163876881819410860100233051565001162413",
"128047395418713422891953530647034002953",
"44585040642333322479646870248382220264",
"219256666154436913529750288694148741527",
"176299639361397656866298840852311923670",
"17821537593699931483827345263907344583"
]
},
"signature_type": "Line"
},
{
"id": "CVE-2023-53577-988963b9",
"target": {
"file": "kernel/bpf/cpumap.c"
},
"signature_version": "v1",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@b44d28b98f185d2f2348aa3c3636838c316f889e",
"digest": {
"threshold": 0.9,
"line_hashes": [
"31418575802945226983292607567543349729",
"226169139402218453455532113807964533807",
"175735885896960302668492591831838947826",
"83517906903142381303911037822382678751",
"10180334402934129591783230633104027711",
"157015782765516536576679792778283995201",
"59501919835773192338161811586144766201",
"113709665641243981283763825978951238647",
"325972872204104486376820041827965104256",
"67081723231749901790387236844454909958",
"6304905941425533914673567932832807845",
"110162913310688347596362697753078138444",
"183741779348057090285139692868771297631",
"302306194468357866488824726889657628627",
"201147909139658975426762557161426227030",
"24944682068804800165373135039932874705",
"55909221691383211074674447975641021516",
"65755660034969066084273626766704169226",
"257076868399015462300796849971009078594",
"49326886230236955399633341462155949151",
"229861443575873711011138732098803860895",
"42872310553560809291948004536962916238",
"313516021413463993687771576377936403326",
"38605075665589829548241315755496364302",
"94841480697798446392178440980333610273",
"134006582155979900373010443398748329357",
"44585040642333322479646870248382220264",
"219256666154436913529750288694148741527",
"176299639361397656866298840852311923670",
"17821537593699931483827345263907344583"
]
},
"signature_type": "Line"
},
{
"id": "CVE-2023-53577-b06b6ac3",
"target": {
"function": "cpu_map_kthread_stop",
"file": "kernel/bpf/cpumap.c"
},
"signature_version": "v1",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@640a604585aa30f93e39b17d4d6ba69fcb1e66c9",
"digest": {
"function_hash": "144335344264484137632153086552784220162",
"length": 211.0
},
"signature_type": "Function"
},
{
"id": "CVE-2023-53577-b5d1c1c3",
"target": {
"function": "cpu_map_kthread_run",
"file": "kernel/bpf/cpumap.c"
},
"signature_version": "v1",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@7a1178a3671b40746830d355836b72e47ceb2490",
"digest": {
"function_hash": "59328108497823361401599838441249974719",
"length": 1572.0
},
"signature_type": "Function"
},
{
"id": "CVE-2023-53577-c33ead4f",
"target": {
"file": "kernel/bpf/cpumap.c"
},
"signature_version": "v1",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@ecb45b852af5e88257020b88bea5ff0798d72aca",
"digest": {
"threshold": 0.9,
"line_hashes": [
"143438376298442273920926464802654990414",
"250771888575949518523275674243928571782",
"303757949268044798089672956859187323036",
"265743565993017108498042715382169596201",
"10180334402934129591783230633104027711",
"157015782765516536576679792778283995201",
"59501919835773192338161811586144766201",
"113709665641243981283763825978951238647",
"325972872204104486376820041827965104256",
"67081723231749901790387236844454909958",
"6304905941425533914673567932832807845",
"110162913310688347596362697753078138444",
"183741779348057090285139692868771297631",
"302306194468357866488824726889657628627",
"201147909139658975426762557161426227030",
"24944682068804800165373135039932874705",
"55909221691383211074674447975641021516",
"65755660034969066084273626766704169226",
"257076868399015462300796849971009078594",
"49326886230236955399633341462155949151",
"229861443575873711011138732098803860895",
"42872310553560809291948004536962916238",
"313516021413463993687771576377936403326",
"38605075665589829548241315755496364302",
"163876881819410860100233051565001162413",
"128047395418713422891953530647034002953",
"44585040642333322479646870248382220264",
"219256666154436913529750288694148741527",
"176299639361397656866298840852311923670",
"17821537593699931483827345263907344583"
]
},
"signature_type": "Line"
},
{
"id": "CVE-2023-53577-c3a31a1e",
"target": {
"function": "__cpu_map_entry_alloc",
"file": "kernel/bpf/cpumap.c"
},
"signature_version": "v1",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@b44d28b98f185d2f2348aa3c3636838c316f889e",
"digest": {
"function_hash": "61414893430206803631026512124113699505",
"length": 1416.0
},
"signature_type": "Function"
},
{
"id": "CVE-2023-53577-c8316e26",
"target": {
"function": "cpu_map_kthread_stop",
"file": "kernel/bpf/cpumap.c"
},
"signature_version": "v1",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@7a1178a3671b40746830d355836b72e47ceb2490",
"digest": {
"function_hash": "144335344264484137632153086552784220162",
"length": 211.0
},
"signature_type": "Function"
},
{
"id": "CVE-2023-53577-cc5c4bab",
"target": {
"function": "__cpu_map_entry_alloc",
"file": "kernel/bpf/cpumap.c"
},
"signature_version": "v1",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@ecb45b852af5e88257020b88bea5ff0798d72aca",
"digest": {
"function_hash": "245861764595931031864701377584476915121",
"length": 1424.0
},
"signature_type": "Function"
},
{
"id": "CVE-2023-53577-d08bd968",
"target": {
"function": "cpu_map_kthread_run",
"file": "kernel/bpf/cpumap.c"
},
"signature_version": "v1",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@ecb45b852af5e88257020b88bea5ff0798d72aca",
"digest": {
"function_hash": "15642097272404235098973166296759969808",
"length": 1567.0
},
"signature_type": "Function"
},
{
"id": "CVE-2023-53577-d454de27",
"target": {
"function": "cpu_map_kthread_run",
"file": "kernel/bpf/cpumap.c"
},
"signature_version": "v1",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@640a604585aa30f93e39b17d4d6ba69fcb1e66c9",
"digest": {
"function_hash": "15642097272404235098973166296759969808",
"length": 1567.0
},
"signature_type": "Function"
}
]