]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: s390: Reject setting flic pfault attributes on ucontrol VMs
authorChristoph Schlameuss <schlameuss@linux.ibm.com>
Mon, 16 Dec 2024 09:21:35 +0000 (10:21 +0100)
committerClaudio Imbrenda <imbrenda@linux.ibm.com>
Tue, 7 Jan 2025 15:36:10 +0000 (16:36 +0100)
Prevent null pointer dereference when processing the
KVM_DEV_FLIC_APF_ENABLE and KVM_DEV_FLIC_APF_DISABLE_WAIT ioctls in the
interrupt controller.

Fixes: 3c038e6be0e2 ("KVM: async_pf: Async page fault support on s390")
Reported-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Signed-off-by: Christoph Schlameuss <schlameuss@linux.ibm.com>
Reviewed-by: Hariharan Mari <hari55@linux.ibm.com>
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Link: https://lore.kernel.org/r/20241216092140.329196-2-schlameuss@linux.ibm.com
Message-ID: <20241216092140.329196-2-schlameuss@linux.ibm.com>
Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Documentation/virt/kvm/devices/s390_flic.rst
arch/s390/kvm/interrupt.c

index ea96559ba5016595a77bc51bbe937a3d6b36e82f..b784f801674836c48f969a2f563b284871eb6f43 100644 (file)
@@ -58,11 +58,15 @@ Groups:
     Enables async page faults for the guest. So in case of a major page fault
     the host is allowed to handle this async and continues the guest.
 
+    -EINVAL is returned when called on the FLIC of a ucontrol VM.
+
   KVM_DEV_FLIC_APF_DISABLE_WAIT
     Disables async page faults for the guest and waits until already pending
     async page faults are done. This is necessary to trigger a completion interrupt
     for every init interrupt before migrating the interrupt list.
 
+    -EINVAL is returned when called on the FLIC of a ucontrol VM.
+
   KVM_DEV_FLIC_ADAPTER_REGISTER
     Register an I/O adapter interrupt source. Takes a kvm_s390_io_adapter
     describing the adapter to register::
index ea8dce299954a3ce2d291b6ca7c803e34bef5a6d..22d73c13e5557d17d9723f663cef6552dff75704 100644 (file)
@@ -2678,9 +2678,13 @@ static int flic_set_attr(struct kvm_device *dev, struct kvm_device_attr *attr)
                kvm_s390_clear_float_irqs(dev->kvm);
                break;
        case KVM_DEV_FLIC_APF_ENABLE:
+               if (kvm_is_ucontrol(dev->kvm))
+                       return -EINVAL;
                dev->kvm->arch.gmap->pfault_enabled = 1;
                break;
        case KVM_DEV_FLIC_APF_DISABLE_WAIT:
+               if (kvm_is_ucontrol(dev->kvm))
+                       return -EINVAL;
                dev->kvm->arch.gmap->pfault_enabled = 0;
                /*
                 * Make sure no async faults are in transition when