hw/virtio/virtio-pci: add defensive check for vector_irqfd
PATCH 1/1 hw/virtio/virtio-pci: add defensive check for vector_irqfd
From: Denis Rastyogin <[email protected]>
Add a NULL check for proxy->vector_irqfd in virtio_pci_one_vector_unmask() before taking the irqfd path. This prevents potential access to uninitialized state if vector_irqfd is absent.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- hw/virtio/virtio-pci.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
hw/virtio/virtio-pci.c +5 -1
@@ -1015,7 +1015,11 @@ static int virtio_pci_one_vector_unmask(VirtIOPCIProxy *proxy,event_notifier_set (n); } }else { - ret =kvm_virtio_pci_irqfd_use (proxy, n, vector); +if (proxy->vector_irqfd) { + ret =kvm_virtio_pci_irqfd_use (proxy, n, vector); + }else { + ret = -EFAULT ; + } }return ret; }
Signature · 1 line
2.42.2
Hi Denis,
Quoted 20 lines · On 14/8/25 13:08, [email protected] wrote:
From: Denis Rastyogin <[email protected]>
Add a NULL check for
proxy->vector_irqfdinvirtio_pci_one_vector_unmask()before taking the irqfd path. This prevents potential access to uninitialized state ifvector_irqfdis absent.Found by Linux Verification Center (linuxtesting.org) with SVACE.
Reported-by Alexey Appolonov <[email protected]>Signed-off-by Denis Rastyogin <[email protected]>--- hw/virtio/virtio-pci.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)hw/virtio/virtio-pci.c +0
-0
hw/virtio/virtio-pci.c static int virtio_pci_one_vector_unmask(VirtIOPCIProxy *proxy, · line 1018
Quoted 5 lines
hw/virtio/virtio-pci.c +1
-1@@ -1015,7 +1015,11 @@ static int virtio_pci_one_vector_unmask(VirtIOPCIProxy *proxy,event_notifier_set (n); } }else { - ret =kvm_virtio_pci_irqfd_use (proxy, n, vector); +if (proxy->vector_irqfd) {
Why check the callers and not once in the callee?
Quoted 7 lines
hw/virtio/virtio-pci.c +4
-0+ ret =kvm_virtio_pci_irqfd_use (proxy, n, vector); + }else { + ret = -EFAULT ; + } }return ret; }
Quoted 11 lines · On Thu, Aug 14, 2025 at 02:08:08PM +0300, [email protected] wrote:
From: Denis Rastyogin <[email protected]>
Add a NULL check for
proxy->vector_irqfdinvirtio_pci_one_vector_unmask()before taking the irqfd path. This prevents potential access to uninitialized state ifvector_irqfdis absent.Found by Linux Verification Center (linuxtesting.org) with SVACE.
Reported-by Alexey Appolonov <[email protected]>Signed-off-by Denis Rastyogin <[email protected]>
I don't really understand what this description means. defensive against what? found in what sense? what is the uninitialized state accessed? when is the potential for this access?
Quoted 23 lines
--- hw/virtio/virtio-pci.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)hw/virtio/virtio-pci.c +5
-1@@ -1015,7 +1015,11 @@ static int virtio_pci_one_vector_unmask(VirtIOPCIProxy *proxy,event_notifier_set (n); } }else { - ret =kvm_virtio_pci_irqfd_use (proxy, n, vector); +if (proxy->vector_irqfd) { + ret =kvm_virtio_pci_irqfd_use (proxy, n, vector); + }else { + ret = -EFAULT ; + } }return ret; }Signature · 1 line
2.42.2