Patch "KVM: arm64: vgic-v2: Check for non-NULL vCPU in vgic_v2_parse_attr()" has been added to the 6.1-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    KVM: arm64: vgic-v2: Check for non-NULL vCPU in vgic_v2_parse_attr()

to the 6.1-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     kvm-arm64-vgic-v2-check-for-non-null-vcpu-in-vgic_v2.patch
and it can be found in the queue-6.1 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 2fc0f80a773da0594d81651ad83b9bce35aa518e
Author: Oliver Upton <oliver.upton@xxxxxxxxx>
Date:   Wed Apr 24 17:39:58 2024 +0000

    KVM: arm64: vgic-v2: Check for non-NULL vCPU in vgic_v2_parse_attr()
    
    [ Upstream commit 6ddb4f372fc63210034b903d96ebbeb3c7195adb ]
    
    vgic_v2_parse_attr() is responsible for finding the vCPU that matches
    the user-provided CPUID, which (of course) may not be valid. If the ID
    is invalid, kvm_get_vcpu_by_id() returns NULL, which isn't handled
    gracefully.
    
    Similar to the GICv3 uaccess flow, check that kvm_get_vcpu_by_id()
    actually returns something and fail the ioctl if not.
    
    Cc: stable@xxxxxxxxxxxxxxx
    Fixes: 7d450e282171 ("KVM: arm/arm64: vgic-new: Add userland access to VGIC dist registers")
    Reported-by: Alexander Potapenko <glider@xxxxxxxxxx>
    Tested-by: Alexander Potapenko <glider@xxxxxxxxxx>
    Reviewed-by: Alexander Potapenko <glider@xxxxxxxxxx>
    Reviewed-by: Marc Zyngier <maz@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20240424173959.3776798-2-oliver.upton@xxxxxxxxx
    Signed-off-by: Oliver Upton <oliver.upton@xxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/arch/arm64/kvm/vgic/vgic-kvm-device.c b/arch/arm64/kvm/vgic/vgic-kvm-device.c
index 97ead28f81425..63731fb3d8f63 100644
--- a/arch/arm64/kvm/vgic/vgic-kvm-device.c
+++ b/arch/arm64/kvm/vgic/vgic-kvm-device.c
@@ -337,12 +337,12 @@ int kvm_register_vgic_device(unsigned long type)
 int vgic_v2_parse_attr(struct kvm_device *dev, struct kvm_device_attr *attr,
 		       struct vgic_reg_attr *reg_attr)
 {
-	int cpuid;
+	int cpuid = FIELD_GET(KVM_DEV_ARM_VGIC_CPUID_MASK, attr->attr);
 
-	cpuid = FIELD_GET(KVM_DEV_ARM_VGIC_CPUID_MASK, attr->attr);
-
-	reg_attr->vcpu = kvm_get_vcpu_by_id(dev->kvm, cpuid);
 	reg_attr->addr = attr->attr & KVM_DEV_ARM_VGIC_OFFSET_MASK;
+	reg_attr->vcpu = kvm_get_vcpu_by_id(dev->kvm, cpuid);
+	if (!reg_attr->vcpu)
+		return -EINVAL;
 
 	return 0;
 }




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux