CVE-2024-42140 in Linuxinfo

Summary

by MITRE • 07/30/2024

In the Linux kernel, the following vulnerability has been resolved:

riscv: kexec: Avoid deadlock in kexec crash path

If the kexec crash code is called in the interrupt context, the machine_kexec_mask_interrupts() function will trigger a deadlock while trying to acquire the irqdesc spinlock and then deactivate irqchip in irq_set_irqchip_state() function.

Unlike arm64, riscv only requires irq_eoi handler to complete EOI and keeping irq_set_irqchip_state() will only leave this possible deadlock without any use. So we simply remove it.

Once again VulDB remains the best source for vulnerability data.

Analysis

by VulDB Data Team • 07/19/2025

The vulnerability identified as CVE-2024-42140 affects the Linux kernel's implementation of the kexec crash handling mechanism on RISC-V architecture systems. This issue represents a critical deadlock condition that can occur during system crash recovery operations, specifically when the kexec crash code executes within interrupt context. The problem manifests in the machine_kexec_mask_interrupts() function which attempts to acquire an irqdesc spinlock while simultaneously calling irq_set_irqchip_state() function, creating a circular dependency that results in system lockup. The vulnerability demonstrates a fundamental flaw in the interrupt handling architecture where the kernel's crash recovery mechanism becomes non-functional due to improper synchronization primitives.

The technical root cause of this vulnerability stems from the improper handling of interrupt chip state management during kexec crash scenarios on RISC-V platforms. Unlike other architectures such as arm64, the RISC-V implementation unnecessarily includes a call to irq_set_irqchip_state() function within the interrupt masking process. This function invocation creates a deadlock condition because it attempts to acquire the same spinlock that is already held by the calling context, while also attempting to deactivate the irqchip in a manner incompatible with the interrupt context execution. The flaw aligns with CWE-362, which describes concurrent execution issues including race conditions and deadlock conditions, specifically manifesting as improper locking mechanisms in kernel-level code. The vulnerability represents a classic case of resource contention where the same synchronization primitive is accessed in a manner that creates circular dependencies.

The operational impact of CVE-2024-42140 extends beyond simple system instability to potentially catastrophic failure scenarios during critical system recovery operations. When a system crash occurs and the kexec crash path is invoked in interrupt context, the deadlock condition prevents proper system shutdown or crash dump collection, effectively rendering the crash recovery mechanism unusable. This can result in complete system hangs, data loss, and the inability to perform forensic analysis of crash conditions. The vulnerability affects all Linux kernel versions that implement kexec functionality on RISC-V architectures, making it particularly concerning for embedded systems, servers, and any environment where reliable crash recovery is essential. From an ATT&CK framework perspective, this vulnerability could be leveraged to achieve system denial of service conditions and potentially provide an attacker with opportunities to exploit system instability for privilege escalation or information disclosure.

The resolution for this vulnerability involves removing the unnecessary irq_set_irqchip_state() function call from the machine_kexec_mask_interrupts() implementation on RISC-V platforms. This change eliminates the deadlock condition by removing the conflicting synchronization attempt that was causing the circular dependency. The fix aligns with best practices for interrupt handling in kernel code by ensuring that interrupt masking operations do not attempt to perform operations that could create synchronization conflicts. The solution is minimal and surgical, addressing only the problematic code path without affecting other system functionality. Security practitioners should prioritize applying this patch to all RISC-V systems running affected kernel versions, particularly those in production environments where system reliability and crash recovery are critical components of overall security posture. The vulnerability highlights the importance of architecture-specific considerations in kernel development and demonstrates how seemingly minor implementation details can have significant impacts on system stability and security.

Responsible

Linux

Reservation

07/29/2024

Disclosure

07/30/2024

Moderation

accepted

CPE

ready

EPSS

0.00199

KEV

no

Activities

very low

Sources

Do you need the next level of professionalism?

Upgrade your account now!