CVE-2022-49265: PM: domains: Fix sleep-in-atomic bug caused by genpd_debug_remove()
In the Linux kernel, the following vulnerability has been resolved:
PM: domains: Fix sleep-in-atomic bug caused by genpddebugremove()
When a genpd with GENPDFLAGIRQSAFE gets removed, the following sleep-in-atomic bug will be seen, as genpddebugremove() will be called with a spinlock being held.
[ 0.029183] BUG: sleeping function called from invalid context at kernel/locking/rwsem.c:1460 [ 0.029204] inatomic(): 1, irqsdisabled(): 128, nonblock: 0, pid: 1, name: swapper/0 [ 0.029219] preemptcount: 1, expected: 0 [ 0.029230] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 5.17.0-rc4+ #489 [ 0.029245] Hardware name: Thundercomm TurboX CM2290 (DT) [ 0.029256] Call trace: [ 0.029265] dumpbacktrace.part.0+0xbc/0xd0 [ 0.029285] showstack+0x3c/0xa0 [ 0.029298] dumpstacklvl+0x7c/0xa0 [ 0.029311] dumpstack+0x18/0x34 [ 0.029323] mightresched+0x10c/0x13c [ 0.029338] mightsleep+0x4c/0x80 [ 0.029351] downread+0x24/0xd0 [ 0.029363] lookuponelenunlocked+0x9c/0xcc [ 0.029379] lookuppositiveunlocked+0x10/0x50 [ 0.029392] debugfslookup+0x68/0xac [ 0.029406] genpdremove.part.0+0x12c/0x1b4 [ 0.029419] ofgenpdremovelast+0xa8/0xd4 [ 0.029434] pscicpuidledomainprobe+0x174/0x53c [ 0.029449] platformprobe+0x68/0xe0 [ 0.029462] reallyprobe+0x190/0x430 [ 0.029473] driverprobedevice+0x90/0x18c [ 0.029485] driverprobedevice+0x40/0xe0 [ 0.029497] driverattach+0xf4/0x1d0 [ 0.029508] busforeachdev+0x70/0xd0 [ 0.029523] driverattach+0x24/0x30 [ 0.029534] busadddriver+0x164/0x22c [ 0.029545] driverregister+0x78/0x130 [ 0.029556] platformdriverregister+0x28/0x34 [ 0.029569] psciidleinitdomains+0x1c/0x28 [ 0.029583] dooneinitcall+0x50/0x1b0 [ 0.029595] kernelinitfreeable+0x214/0x280 [ 0.029609] kernelinit+0x2c/0x13c [ 0.029622] retfromfork+0x10/0x20
It doesn't seem necessary to call genpddebugremove() with the lock, so move it out from locking to fix the problem.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
debian/linuxto a version that resolves this vulnerability.Fixed in 5.17.3-1 - Upgrade
Upgrade
debian/linuxto a version that resolves this vulnerability.Fixed in 6.1.176-1Fixed in 6.1.192-2Fixed in 6.12.107-1Fixed in 6.12.117-1Fixed in 7.3.4-1Fixed in 7.3.5-1 - Compensating control
Move the genpd_debug_remove() call outside the spinlock-held locking section so it is not called while a spinlock is held, preventing the sleep-in-atomic bug for genpds with GENPD_FLAG_IRQ_SAFE.