Skip to contentSkip to conversation

kvm: s390: Reject setting flic pfault attributes on ucontrol VMs

PATCH Hariharan Mari 1 participant 1 message Dec 18, 2024

Subsystems (3)
lore
Share & tools
lore

Hariharan Mari

author Tested-by
#0 lore raw
Quoted 7 lines · Christoph Schlameuss

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")
Quoted 49 lines
---
 Documentation/virt/kvm/devices/s390_flic.rst | 4 ++++
 arch/s390/kvm/interrupt.c                    | 4 ++++
 2 files changed, 8 insertions(+)
Documentation/virt/kvm/devices/s390_flic.rst +0 -0
index ea96559ba501..b784f8016748 100644
@@ -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.

Documentation/virt/kvm/devices/s390_flic.rst +2 -0
+    -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.

Documentation/virt/kvm/devices/s390_flic.rst +2 -0
+    -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::

arch/s390/kvm/interrupt.c +4 -0
index ea8dce299954..22d73c13e555 100644
@@ -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