{"id":"CVE-2026-142916","sourceIdentifier":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","published":"2026-12-03T04:18:31.687","lastModified":"2026-12-03T04:18:31.687","vulnStatus":"Received","cveTags":[],"descriptions":[{"lang":"en","value":"In the Linux kernel, the following vulnerability has been resolved:\n\npowerpc: fix NMI exit ordering: restore soft masks after irqentry_nmi_exit()\n\nWhen running with CONFIG_PPC_IRQ_SOFT_MASK_DEBUG=y and LOCKDEP=y, an\nOops is triggered during NMI exit:\n\n  [  202.258332] Oops: Exception in kernel mode, sig: 4 [#1]\n  NIP [000000000003e178] 0x3e178\n  LR  [c00000000003e174] arch_local_irq_restore+0x2a4/0x328\n  TRAP: 0700  MSR: 0000000000081000 <ME>\n\nThe faulting instruction at NIP is a 'trap' (0fe00000) inside the\nrfi_flush_fallback trampoline at a userspace-looking low address, reached\nafter a bad rfid caused by an incorrect SRR0 value.\n\nRoot cause:\nDEFINE_INTERRUPT_HANDLER_NMI used to call arch_interrupt_nmi_exit_prepare()\n*before* irqentry_nmi_exit(), giving this sequence:\n\n  arch_interrupt_nmi_enter_prepare()   // saves irq_soft_mask, irq_happened\n  irqentry_nmi_enter()                 // __nmi_enter() -> nmi_count++, in_nmi()=true\n  ____func(regs)                       // NMI handler body\n  arch_interrupt_nmi_exit_prepare()    // RESTORES irq_soft_mask=0 (IRQS_ENABLED)\n                                       // RESTORES irq_happened with pending bits\n  irqentry_nmi_exit()                  // instrumentation block runs here...\n    trace_hardirqs_on_prepare()        //   ...with in_nmi()==true still\n    lockdep_hardirqs_on_prepare()      //   ...and irq_soft_mask already restored to 0\n      -> arch_local_irq_restore(0)     // mask=0 -> enable path entered\n           WARN_ON_ONCE(in_nmi())      // FIRES: __nmi_exit() hasn't run yet\n    __nmi_exit()                       // nmi_count-- (too late)\n\narch_interrupt_nmi_exit_prepare() restores irq_soft_mask to whatever\nthe interrupted thread had (IRQS_ENABLED / 0) and restores irq_happened\nwith any pending deferred-interrupt bits that were present when the NMI\nfired.  This is correct and necessary before rfid back to the interrupted\ncontext, but it must not happen until irqentry_nmi_exit() has fully\ncompleted.\n\nWith irq_soft_mask=0 and pending bits in irq_happened, the\ntrace_hardirqs_on_prepare() call inside irqentry_nmi_exit()'s\ninstrumentation block reaches lockdep_hardirqs_on_prepare() which\ncalls __trace_hardirqs_on_caller(), which eventually calls\narch_local_irq_restore(0) (the IRQS_ENABLED / enable path).\n\narch_local_irq_restore() with mask=0 hits the CONFIG_PPC_IRQ_SOFT_MASK_DEBUG\nguards at irq_64.c:217:\n\n  WARN_ON_ONCE(in_nmi());   // TRUE: __nmi_exit() not yet called\n\nThe WARN_ON_ONCE fires a 'trap' instruction (tw 31,0,0 / 0fe00000) in\nkernel mode with MSR_PR=0, MSR_IR=0 (real-mode).  The program check\nhandler (TRAP 0700) takes the sig:4 (SIGILL) path via do_program_check()\nand calls die(), producing the Oops.\n\nThe RESTART_TABLE mechanism in arch_local_irq_restore then causes the\nbad rfid that lands at the userspace-looking address visible in the NIP.\n\nThe bug is invisible with LOCKDEP=n because trace_hardirqs_on_prepare()\nis a no-op when CONFIG_TRACE_IRQFLAGS is not set (TRACE_IRQFLAGS is\nselected by PROVE_LOCKING which selects LOCKDEP).\n\nFix:\nMove arch_interrupt_nmi_exit_prepare() to after the irqentry_nmi_exit()\nblock, so that:\n\n  irqentry_nmi_exit()                 // __nmi_exit() -> nmi_count--, in_nmi()=false\n  arch_interrupt_nmi_exit_prepare()   // now safe to restore soft mask state\n\nThe instrumentation inside irqentry_nmi_exit() now executes while\nin_nmi() is still true (nmi_count not yet decremented), but\nirq_soft_mask is still IRQS_ALL_DISABLED (NMI-entry value), so\narch_local_irq_restore() is never called with mask=0 from that path.\nAfter __nmi_exit() returns, arch_interrupt_nmi_exit_prepare() restores\nthe pre-NMI soft mask and irq_happened, which is the correct state for\nthe rfid back to the interrupted context."}],"affected":[{"source":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","affectedData":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","programFiles":["arch/powerpc/include/asm/interrupt.h"],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","versions":[{"version":"bee25f97ad24641df55cb3887eb5bfcb2b9d8fbc","lessThan":"94bf70c51f3766222d83b86f911f04dd49897e61","versionType":"git","status":"affected"},{"version":"bee25f97ad24641df55cb3887eb5bfcb2b9d8fbc","lessThan":"8fa763bc3ee9bd215476ab91ee480c649eaa4b29","versionType":"git","status":"affected"}]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","programFiles":["arch/powerpc/include/asm/interrupt.h"],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","versions":[{"version":"7.2","status":"affected"},{"version":"0","lessThan":"7.2","versionType":"semver","status":"unaffected"},{"version":"7.3.6","lessThanOrEqual":"7.3.*","versionType":"semver","status":"unaffected"},{"version":"7.4-rc1","lessThanOrEqual":"*","versionType":"original_commit_for_fix","status":"unaffected"}]}]}],"metrics":{},"references":[{"url":"https://git.kernel.org/stable/c/8fa763bc3ee9bd215476ab91ee480c649eaa4b29","source":"416baaa9-dc9f-4396-8d5f-8c081fb06d67"},{"url":"https://git.kernel.org/stable/c/94bf70c51f3766222d83b86f911f04dd49897e61","source":"416baaa9-dc9f-4396-8d5f-8c081fb06d67"}]}