KernelScan.io

HIGH Introduced in 6.13

kvm NaclHfence Race

CVE-2026-98639

CVSS 7.0 / 10.0 KernelScan AI

CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H

01

In the Linux kernel, the following vulnerability has been resolved: KVM: riscv: Fix NACL hfence entry update order The SBI v3.0 specification (section 15.1.2) requires a nested HFENCE entry to be populated as follows: 1) find an unused entry with Config.Pending == 0 2) update the Page_Number and Page_Count words 3) update the Config word with Config.Pending set __kvm_riscv_nacl_hfence() writes the Config word first, so the SBI implementation (or NACL hardware) can observe a pending entry with pnum/pcount values left over from the previous use of that entry, resulting in incorrect TLB flush ranges. Write pnum and pcount first and the Config word last. Since the consumer is an external agent on coherent shared memory, use WRITE_ONCE() to stop the compiler from reordering the stores and smp_wmb() to make the parameter words globally visible before the Pending bit is set.

02

Engine v0.9.0

Risk summary

A race condition in the RISC-V KVM nested acceleration (NACL) code allows a nested guest (L2) to cause incorrect TLB flush ranges by exploiting a memory ordering violation. This can lead to memory corruption, information disclosure, or host kernel crashes. The vulnerability requires a RISC-V system with NACL hardware support and nested virtualization enabled.

Affectedarch/riscv/kvm/nacl.c (KVM RISC-V nested acceleration)

Vulnerability analysis

The KVM RISC-V NACL implementation writes the HFENCE entry's Config word (with the Pending bit set) before writing the Page_Number and Page_Count fields, violating the SBI v3.0 specification which requires the parameter words to be visible before the Pending bit. An external agent — the SBI firmware or NACL hardware — can observe the entry as pending while it still contains stale page number and count values from a previous use, resulting in incorrect TLB flush ranges. The fix reorders the stores so that Page_Number and Page_Count are written first using WRITE_ONCE(), followed by a smp_wmb() barrier to ensure global visibility, and only then writes the Config word with the Pending bit. This vulnerability is reachable only on RISC-V systems with NACL hardware support where nested virtualization is configured and an attacker can control a nested guest (L2).

03

BranchIntroducedFixed inPatch commit
6.186.136.18.55d6de766d8d26
7.26.137.2.96da466502621
mainline6.137.3b3d346838ec6