kvm: check dev parameter when updating msi route
PATCH 1/1 kvm: check dev parameter when updating msi route
From: Prasad J Pandit <[email protected]>
When updating message signalled interrupt(MSI) route in routine kvm_irqchip_update_msi_route, device parameter could be null. Add check to avoid null dereference.
--- accel/kvm/kvm-all.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
accel/kvm/kvm-all.c +2 -2
@@ -1167,7 +1167,7 @@ int kvm_irqchip_add_msi_route(KVMState *s, int vector, PCIDevice *dev) kroute.u.msi.address_lo = (uint32_t )msg.address; kroute.u.msi.address_hi = msg.address >>32 ; kroute.u.msi.data =le32_to_cpu (msg.data); -if (pci_available &&kvm_msi_devid_required ()) { +if (pci_available && dev &&kvm_msi_devid_required ()) { kroute.flags =KVM_MSI_VALID_DEVID ; kroute.u.msi.devid =pci_requester_id (dev); }
@@ -1205,7 +1205,7 @@ int kvm_irqchip_update_msi_route(KVMState *s, int virq, MSIMessage msg, kroute.u.msi.address_lo = (uint32_t )msg.address; kroute.u.msi.address_hi = msg.address >>32 ; kroute.u.msi.data =le32_to_cpu (msg.data); -if (pci_available &&kvm_msi_devid_required ()) { +if (pci_available && dev &&kvm_msi_devid_required ()) { kroute.flags =KVM_MSI_VALID_DEVID ; kroute.u.msi.devid =pci_requester_id (dev); }
Signature · 1 line
2.14.3
This should primarily go to the qemu devel list. I've Cc'd it, but reposting would be safer, thanks.
2018-02-02 10:21+0530, P J P:
Quoted 37 lines
From: Prasad J Pandit <[email protected]>
When updating message signalled interrupt(MSI) route in routine
kvm_irqchip_update_msi_route, device parameter could be null. Add check to avoid null dereference.Reported-by Guoxiang Niu <[email protected]>Signed-off-by Prasad J Pandit <[email protected]>--- accel/kvm/kvm-all.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)accel/kvm/kvm-all.c +2
-2@@ -1167,7 +1167,7 @@ int kvm_irqchip_add_msi_route(KVMState *s, int vector, PCIDevice *dev) kroute.u.msi.address_lo = (uint32_t )msg.address; kroute.u.msi.address_hi = msg.address >>32 ; kroute.u.msi.data =le32_to_cpu (msg.data); -if (pci_available &&kvm_msi_devid_required ()) { +if (pci_available && dev &&kvm_msi_devid_required ()) { kroute.flags =KVM_MSI_VALID_DEVID ; kroute.u.msi.devid =pci_requester_id (dev); }@@ -1205,7 +1205,7 @@ int kvm_irqchip_update_msi_route(KVMState *s, int virq, MSIMessage msg, kroute.u.msi.address_lo = (uint32_t )msg.address; kroute.u.msi.address_hi = msg.address >>32 ; kroute.u.msi.data =le32_to_cpu (msg.data); -if (pci_available &&kvm_msi_devid_required ()) { +if (pci_available && dev &&kvm_msi_devid_required ()) { kroute.flags =KVM_MSI_VALID_DEVID ; kroute.u.msi.devid =pci_requester_id (dev); }Signature · 1 line
2.14.3
Hello Radim,
+-- On Fri, 2 Feb 2018, Radim Krčmář wrote --+ | This should primarily go to the qemu devel list. I've Cc'd it, but | reposting would be safer, thanks.
Ah, Okay. I did think qemu-devel would be better, but MAINTAINERS file lists
[email protected] address for accel/kvm/.
Thank you.
--
Prasad J Pandit / Red Hat Product Security Team
47AF CE69 3A90 54AA 9045 1053 DD13 3D32 FE5B 041F