]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
KVM: arm64: Tear down vGIC on failed vCPU creation
authorWill Deacon <will@kernel.org>
Fri, 14 Mar 2025 13:34:09 +0000 (13:34 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 25 Apr 2025 08:45:23 +0000 (10:45 +0200)
commit5085e02362b9948f82fceca979b8f8e12acb1cc5
tree6e866381d48ec2a9ab25194af8be6eb88be40fb7
parentdb8a657980e70224041796bd44232a868bd4cd87
KVM: arm64: Tear down vGIC on failed vCPU creation

commit 250f25367b58d8c65a1b060a2dda037eea09a672 upstream.

If kvm_arch_vcpu_create() fails to share the vCPU page with the
hypervisor, we propagate the error back to the ioctl but leave the
vGIC vCPU data initialised. Note only does this leak the corresponding
memory when the vCPU is destroyed but it can also lead to use-after-free
if the redistributor device handling tries to walk into the vCPU.

Add the missing cleanup to kvm_arch_vcpu_create(), ensuring that the
vGIC vCPU structures are destroyed on error.

Cc: <stable@vger.kernel.org>
Cc: Marc Zyngier <maz@kernel.org>
Cc: Oliver Upton <oliver.upton@linux.dev>
Cc: Quentin Perret <qperret@google.com>
Signed-off-by: Will Deacon <will@kernel.org>
Reviewed-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20250314133409.9123-1-will@kernel.org
Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/arm64/kvm/arm.c