CVE-2026-142916: powerpc: fix NMI exit ordering: restore soft masks after irqentry_nmi_exit()
In the Linux kernel, the following vulnerability has been resolved:
powerpc: fix NMI exit ordering: restore soft masks after irqentrynmiexit()
When running with CONFIGPPCIRQSOFTMASKDEBUG=y and LOCKDEP=y, an Oops is triggered during NMI exit:
[ 202.258332] Oops: Exception in kernel mode, sig: 4 [#1] NIP [000000000003e178] 0x3e178 LR [c00000000003e174] archlocalirqrestore+0x2a4/0x328 TRAP: 0700 MSR: 0000000000081000 <ME>
The faulting instruction at NIP is a 'trap' (0fe00000) inside the rfiflushfallback trampoline at a userspace-looking low address, reached after a bad rfid caused by an incorrect SRR0 value.
Root cause: DEFINEINTERRUPTHANDLERNMI used to call archinterruptnmiexitprepare() before irqentrynmiexit(), giving this sequence:
archinterruptnmienterprepare() // saves irqsoftmask, irqhappened irqentrynmienter() // nmienter() -> nmicount++, innmi()=true func(regs) // NMI handler body archinterruptnmiexitprepare() // RESTORES irqsoftmask=0 (IRQSENABLED) // RESTORES irqhappened with pending bits irqentrynmiexit() // instrumentation block runs here... tracehardirqsonprepare() // ...with innmi()==true still lockdephardirqsonprepare() // ...and irqsoftmask already restored to 0 -> archlocalirqrestore(0) // mask=0 -> enable path entered WARNONONCE(innmi()) // FIRES: nmiexit() hasn't run yet nmiexit() // nmicount-- (too late)
archinterruptnmiexitprepare() restores irqsoftmask to whatever the interrupted thread had (IRQSENABLED / 0) and restores irqhappened with any pending deferred-interrupt bits that were present when the NMI fired. This is correct and necessary before rfid back to the interrupted context, but it must not happen until irqentrynmiexit() has fully completed.
With irqsoftmask=0 and pending bits in irqhappened, the tracehardirqsonprepare() call inside irqentrynmiexit()'s instrumentation block reaches lockdephardirqsonprepare() which calls tracehardirqsoncaller(), which eventually calls archlocalirqrestore(0) (the IRQSENABLED / enable path).
archlocalirqrestore() with mask=0 hits the CONFIGPPCIRQSOFTMASKDEBUG guards at irq64.c:217:
WARNONONCE(innmi()); // TRUE: nmiexit() not yet called
The WARNONONCE fires a 'trap' instruction (tw 31,0,0 / 0fe00000) in kernel mode with MSRPR=0, MSRIR=0 (real-mode). The program check handler (TRAP 0700) takes the sig:4 (SIGILL) path via doprogramcheck() and calls die(), producing the Oops.
The RESTARTTABLE mechanism in archlocalirqrestore then causes the bad rfid that lands at the userspace-looking address visible in the NIP.
The bug is invisible with LOCKDEP=n because tracehardirqsonprepare() is a no-op when CONFIGTRACEIRQFLAGS is not set (TRACEIRQFLAGS is selected by PROVELOCKING which selects LOCKDEP).
Fix: Move archinterruptnmiexitprepare() to after the irqentrynmiexit() block, so that:
irqentrynmiexit() // nmiexit() -> nmicount--, innmi()=false archinterruptnmiexitprepare() // now safe to restore soft mask state
The instrumentation inside irqentrynmiexit() now executes while innmi() is still true (nmicount not yet decremented), but irqsoftmask is still IRQSALLDISABLED (NMI-entry value), so archlocalirqrestore() is never called with mask=0 from that path. After nmiexit() returns, archinterruptnmiexitprepare() restores the pre-NMI soft mask and irqhappened, which is the correct state for the rfid back to the interrupted context.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 7.3.6 - Compensating control
In the PowerPC NMI exit path, move arch_interrupt_nmi_exit_prepare() to after irqentry_nmi_exit().
Event History
Frequently Asked Questions
Which systems are known to trigger the failure?
The reported Oops occurs when the kernel is built and run with both CONFIG_PPC_IRQ_SOFT_MASK_DEBUG=y and LOCKDEP=y, during NMI exit on powerpc.
What evidence indicates this issue has been encountered?
A kernel-mode Oops with signal 4 during NMI exit is reported. The trace includes arch_local_irq_restore and a trap in the rfi_flush_fallback trampoline at a low, userspace-looking address after an incorrect SRR0 value is used by rfid.
What is the relevant execution condition?
The failure occurs in NMI-exit instrumentation when soft interrupt masks and pending interrupt state are restored before irqentry_nmi_exit() completes. At that point, lockdep instrumentation can run while the kernel still considers itself in NMI context.