Skip to main content

CVE-2025-21839: Vulnerability in Linux Linux

Medium
VulnerabilityCVE-2025-21839cvecve-2025-21839
Published: Fri Mar 07 2025 (03/07/2025, 09:09:58 UTC)
Source: CVE
Vendor/Project: Linux
Product: Linux

Description

In the Linux kernel, the following vulnerability has been resolved: KVM: x86: Load DR6 with guest value only before entering .vcpu_run() loop Move the conditional loading of hardware DR6 with the guest's DR6 value out of the core .vcpu_run() loop to fix a bug where KVM can load hardware with a stale vcpu->arch.dr6. When the guest accesses a DR and host userspace isn't debugging the guest, KVM disables DR interception and loads the guest's values into hardware on VM-Enter and saves them on VM-Exit. This allows the guest to access DRs at will, e.g. so that a sequence of DR accesses to configure a breakpoint only generates one VM-Exit. For DR0-DR3, the logic/behavior is identical between VMX and SVM, and also identical between KVM_DEBUGREG_BP_ENABLED (userspace debugging the guest) and KVM_DEBUGREG_WONT_EXIT (guest using DRs), and so KVM handles loading DR0-DR3 in common code, _outside_ of the core kvm_x86_ops.vcpu_run() loop. But for DR6, the guest's value doesn't need to be loaded into hardware for KVM_DEBUGREG_BP_ENABLED, and SVM provides a dedicated VMCB field whereas VMX requires software to manually load the guest value, and so loading the guest's value into DR6 is handled by {svm,vmx}_vcpu_run(), i.e. is done _inside_ the core run loop. Unfortunately, saving the guest values on VM-Exit is initiated by common x86, again outside of the core run loop. If the guest modifies DR6 (in hardware, when DR interception is disabled), and then the next VM-Exit is a fastpath VM-Exit, KVM will reload hardware DR6 with vcpu->arch.dr6 and clobber the guest's actual value. The bug shows up primarily with nested VMX because KVM handles the VMX preemption timer in the fastpath, and the window between hardware DR6 being modified (in guest context) and DR6 being read by guest software is orders of magnitude larger in a nested setup. E.g. in non-nested, the VMX preemption timer would need to fire precisely between #DB injection and the #DB handler's read of DR6, whereas with a KVM-on-KVM setup, the window where hardware DR6 is "dirty" extends all the way from L1 writing DR6 to VMRESUME (in L1). L1's view: ========== <L1 disables DR interception> CPU 0/KVM-7289 [023] d.... 2925.640961: kvm_entry: vcpu 0 A: L1 Writes DR6 CPU 0/KVM-7289 [023] d.... 2925.640963: <hack>: Set DRs, DR6 = 0xffff0ff1 B: CPU 0/KVM-7289 [023] d.... 2925.640967: kvm_exit: vcpu 0 reason EXTERNAL_INTERRUPT intr_info 0x800000ec D: L1 reads DR6, arch.dr6 = 0 CPU 0/KVM-7289 [023] d.... 2925.640969: <hack>: Sync DRs, DR6 = 0xffff0ff0 CPU 0/KVM-7289 [023] d.... 2925.640976: kvm_entry: vcpu 0 L2 reads DR6, L1 disables DR interception CPU 0/KVM-7289 [023] d.... 2925.640980: kvm_exit: vcpu 0 reason DR_ACCESS info1 0x0000000000000216 CPU 0/KVM-7289 [023] d.... 2925.640983: kvm_entry: vcpu 0 CPU 0/KVM-7289 [023] d.... 2925.640983: <hack>: Set DRs, DR6 = 0xffff0ff0 L2 detects failure CPU 0/KVM-7289 [023] d.... 2925.640987: kvm_exit: vcpu 0 reason HLT L1 reads DR6 (confirms failure) CPU 0/KVM-7289 [023] d.... 2925.640990: <hack>: Sync DRs, DR6 = 0xffff0ff0 L0's view: ========== L2 reads DR6, arch.dr6 = 0 CPU 23/KVM-5046 [001] d.... 3410.005610: kvm_exit: vcpu 23 reason DR_ACCESS info1 0x0000000000000216 CPU 23/KVM-5046 [001] ..... 3410.005610: kvm_nested_vmexit: vcpu 23 reason DR_ACCESS info1 0x0000000000000216 L2 => L1 nested VM-Exit CPU 23/KVM-5046 [001] ..... 3410.005610: kvm_nested_vmexit_inject: reason: DR_ACCESS ext_inf1: 0x0000000000000216 CPU 23/KVM-5046 [001] d.... 3410.005610: kvm_entry: vcpu 23 CPU 23/KVM-5046 [001] d.... 3410.005611: kvm_exit: vcpu 23 reason VMREAD CPU 23/KVM-5046 [001] d.... 3410.005611: kvm_entry: vcpu 23 CPU 23/KVM-5046 [001] d.... 3410. ---truncated---

AI-Powered Analysis

AILast updated: 07/05/2025, 03:11:21 UTC

Technical Analysis

CVE-2025-21839 is a vulnerability in the Linux kernel's Kernel-based Virtual Machine (KVM) subsystem affecting the handling of debug registers (DRs), specifically DR6, during nested virtualization scenarios on x86 architectures. The issue arises from improper synchronization and loading of the guest's DR6 register value into the hardware debug register during VM-Enter and VM-Exit transitions. KVM disables debug register interception when the guest accesses DRs without host userspace debugging, allowing the guest to modify DRs directly. However, due to a bug, the hardware DR6 register can be loaded with a stale or incorrect value from the virtual CPU's architecture state (vcpu->arch.dr6) during fastpath VM-Exits, overwriting the guest's actual DR6 value. This discrepancy primarily manifests in nested virtualization environments (KVM-on-KVM), where the timing window between DR6 modification by the guest and its reading is significantly extended, increasing the likelihood of the stale value being used. The vulnerability stems from the difference in handling DR6 between VMX and SVM virtualization extensions and the placement of DR6 loading code inside the core vcpu_run loop, while saving guest DR6 values occurs outside this loop. This leads to race conditions and inconsistent DR6 states, potentially causing guest software to observe incorrect debug register values. Although the vulnerability does not directly enable code execution or privilege escalation, it can cause incorrect behavior in guest debugging, potentially leading to denial of service or incorrect debugging outcomes in nested virtualized environments. The issue affects Linux kernel versions containing the specified commit hashes and has been resolved by moving the conditional loading of DR6 outside the core vcpu_run loop to ensure consistent synchronization of the guest's DR6 value with the hardware register. No known exploits are reported in the wild, and no CVSS score has been assigned yet.

Potential Impact

For European organizations, especially those relying on nested virtualization for cloud services, development, or testing environments, this vulnerability could disrupt debugging workflows and virtual machine stability. Organizations using KVM-based nested virtualization might experience inconsistent debug register states, leading to incorrect breakpoint handling or failure in debugging guest systems. This can impact development teams, security researchers, and operations relying on precise debugging and monitoring of virtual machines. While the vulnerability does not directly lead to privilege escalation or remote code execution, the potential for denial of service or debugging failures could affect critical infrastructure relying on nested virtualization, such as telecom providers, financial institutions, and research centers. Additionally, cloud service providers in Europe offering nested virtualization capabilities could see degraded service quality or increased support costs. The impact is more pronounced in environments with complex nested VM setups, which are common in advanced cloud and virtualization deployments.

Mitigation Recommendations

1. Apply the official Linux kernel patches that address CVE-2025-21839 as soon as they become available to ensure the correct handling of DR6 in nested virtualization scenarios. 2. Avoid or limit the use of nested virtualization where possible, especially in production environments, until patches are applied and verified. 3. For environments requiring nested virtualization, implement rigorous testing of debugging and breakpoint functionality post-patch to confirm resolution. 4. Monitor virtualization logs for unusual VM-Exit or DR access patterns that could indicate issues related to this vulnerability. 5. Update virtualization management tools and hypervisor configurations to the latest versions that incorporate fixes for this vulnerability. 6. Educate development and operations teams about potential debugging inconsistencies in nested VMs and encourage reporting of anomalies. 7. Consider isolating critical workloads from nested virtualization environments if debugging accuracy is paramount and patches cannot be immediately applied.

Need more detailed analysis?Get Pro

Technical Details

Data Version
5.1
Assigner Short Name
Linux
Date Reserved
2024-12-29T08:45:45.777Z
Cisa Enriched
false
Cvss Version
null
State
PUBLISHED

Threat ID: 682d9818c4522896dcbd7ba5

Added to database: 5/21/2025, 9:08:40 AM

Last enriched: 7/5/2025, 3:11:21 AM

Last updated: 8/13/2025, 2:49:17 PM

Views: 22

Actions

PRO

Updates to AI analysis are available only with a Pro account. Contact root@offseq.com for access.

Please log in to the Console to use AI analysis features.

Need enhanced features?

Contact root@offseq.com for Pro access with improved analysis and higher rate limits.

Latest Threats