FAILED: patch "[PATCH] KVM: SEV: Free have_run_cpus during VM destruction even if VM" failed to apply to 6.12-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 6.12-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.12.y
git checkout FETCH_HEAD
git cherry-pick -x 12c1f6e03f944e399bd2c88441dca5dc702b95a5
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026093024-dynasty-embolism-3c71@gregkh' --subject-prefix 'PATCH 6.12.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 12c1f6e03f944e399bd2c88441dca5dc702b95a5 Mon Sep 17 00:00:00 2001
From: Sean Christopherson <[email protected]>
Date: Wed, 23 Sep 2026 09:37:20 -0700
Subject: [PATCH] KVM: SEV: Free have_run_cpus during VM destruction even if VM
is no longer SEV
Unconditionally free SEV's "have run CPUs" cpumask in the VM destroy path, i.e. even for what appear to be non-SEV VMs, as an SEV VM becomes a non-SEV VM if its state is intra-host migrated. Alternatively, the mask could be freed in sev_migrate_from() when "converting" the source VM, but that gets annoying because ideally KVM would nullify the mask to guard against UAF, and nullifying the mask would need be conditioned on CPUMASK_OFFSTACK=y.
Freeing the mask during sev_migrate_from() is also not robust against other KVM bugs, though that's kind of a moot point since any such bugs would show up even if sev->active is never set. I.e. KVM must get that side of things correct. But, that's not a great reason to add more code just to make things marginally less robust.
Message-ID: <[email protected]>
arch/x86/kvm/svm/sev.c +6 -2
@@ -2980,13 +2980,17 @@ void sev_vm_destroy(struct kvm *kvm)struct list_head *head = &sev->regions_list;struct list_head *pos, *q; +/* +* Free the mask even if the VM is not *currently* an SEV VM, as it may +* have been an SEV VM prior to intra-host migration. +*/ +free_cpumask_var (sev->have_run_cpus); +if (!sev_guest (kvm))return ;WARN_ON (!list_empty (&sev->mirror_vms)); -free_cpumask_var (sev->have_run_cpus); -/* * If this is a mirror VM, remove it from the owner's list of a mirrors * and skip ASID cleanup (the ASID is tied to the lifetime of the owner).