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 genpddebug_remove() 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.