CVE-2026-98719: KVM: SEV: Nullify "have run CPUs" mask pointer when freeing it
In the Linux kernel, the following vulnerability has been resolved:
KVM: SEV: Nullify "have run CPUs" mask pointer when freeing it
Nullify haveruncpus when freeing the mask, particularly in the error path of sevguestinit(), so that KVM doesn't have to subtly use sev->active to track whether or not the mask has been freed. As pointed out by Sashiko, blindly freeing the mask in sevvmdestroy() results in a double-free if the mask is freed if sevguestinit() fails.
Throw the logic in a helper as nullifying the pointer is frustratingly difficult and weird due to haveruncpus being a single-entry array when CPUMASKOFFSTACK=n. Deliberately don't use CPUMASKVARNULL, as it's not directly assignable when the cpumask is on-stack, e.g. requires using a local variable and a memcpy(), which is beyond ridiculous. Furthermore, while clearing the on-stack bitmask is an unnecessary and arguably unwanted side effect, KVM absolutely relies on '0' being the "null" value given that the struct is zero-allocated.
Opportunistically add an alloc() helper to pair with free(); there are just enough call sites to make doing so worthwhile.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Configuration
Set CPUMASK_OFFSTACK=n and do not use CPUMASK_VAR_NULL.
CPUMASK_OFFSTACK = n