Skip to contentSkip to conversation

virtio-pci: Fix the use of an uninitialized irqfd

PATCH Superseded Cindy Lu 2 participants 4 messages Jul 19, 2024 – Jul 23, 2024

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Cindy Lu

author
#0 lore raw

PATCH v5 1/1 virtio-pci: Fix the use of an uninitialized irqfd

The crash was reported in MAC OS and NixOS, here is the link for this bug
https://gitlab.com/qemu-project/qemu/-/issues/2334
https://gitlab.com/qemu-project/qemu/-/issues/2321

In this bug, they are using the virtio_input device. The guest notifier was not supported for this device, The function virtio_pci_set_guest_notifiers() was not called, and the vector_irqfd was not initialized.

So the fix is adding the check for vector_irqfd in virtio_pci_get_notifier()

But The function virtio_pci_get_notifier(),it can also be used in all kinds of device. If the vector_irqfd still didn't initial after the VIRTIO_CONFIG_S_DRIVER_OK is set means this device is not using guest notifier. We can let the check fail here

This fix is verified in vyatta,MacOS,NixOS,fedora system.

The bt tree for this bug is:
Thread 6 "CPU 0/KVM" received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x7c817be006c0 (LWP 1269146)] kvm_virtio_pci_vq_vector_use () at ../qemu-9.0.0/hw/virtio/virtio-pci.c:817
817 if (irqfd->users == 0) {
(gdb) thread apply all bt
...
Thread 6 (Thread 0x7c817be006c0 (LWP 1269146) "CPU 0/KVM"):

0  kvm_virtio_pci_vq_vector_use () at ../qemu-9.0.0/hw/virtio/virtio-pci.c:817
1  kvm_virtio_pci_vector_use_one () at ../qemu-9.0.0/hw/virtio/virtio-pci.c:893
2  0x00005983657045e2 in memory_region_write_accessor () at ../qemu-9.0.0/system/memory.c:497
3  0x0000598365704ba6 in access_with_adjusted_size () at ../qemu-9.0.0/system/memory.c:573
4  0x0000598365705059 in memory_region_dispatch_write () at ../qemu-9.0.0/system/memory.c:1528
5  0x00005983659b8e1f in flatview_write_continue_step.isra.0 () at ../qemu-9.0.0/system/physmem.c:2713
6  0x000059836570ba7d in flatview_write_continue () at ../qemu-9.0.0/system/physmem.c:2743
7  flatview_write () at ../qemu-9.0.0/system/physmem.c:2774
8  0x000059836570bb76 in address_space_write () at ../qemu-9.0.0/system/physmem.c:2894
9  0x0000598365763afe in address_space_rw () at ../qemu-9.0.0/system/physmem.c:2904

10 kvm_cpu_exec () at ../qemu-9.0.0/accel/kvm/kvm-all.c:2917
11 0x000059836576656e in kvm_vcpu_thread_fn () at ../qemu-9.0.0/accel/kvm/kvm-accel-ops.c:50 12 0x0000598365926ca8 in qemu_thread_start () at ../qemu-9.0.0/util/qemu-thread-posix.c:541 13 0x00007c8185bcd1cf in ??? () at /usr/lib/libc.so.6
14 0x00007c8185c4e504 in clone () at /usr/lib/libc.so.6

Fixes 2ce6cff94d ("virtio-pci: fix use of a released vector")
---
 hw/virtio/virtio-pci.c | 3 +++
 1 file changed, 3 insertions(+)
hw/virtio/virtio-pci.c +3 -0
index 592fdaa10f..dc31a37ec0 100644
@@ -860,6 +860,9 @@ static int virtio_pci_get_notifier(VirtIOPCIProxy *proxy, int queue_no,
     VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
     VirtQueue *vq;
 
+    if (!proxy->vector_irqfd && vdev->status & VIRTIO_CONFIG_S_DRIVER_OK)
+        return -1;
+
     if (queue_no == VIRTIO_CONFIG_IRQ_IDX) {
         *n = virtio_config_get_guest_notifier(vdev);
         *vector = vdev->config_vector;
Signature · 1 line
2.45.0
#1 lore raw

Hi Cindy

Quoted 53 lines · Cindy Lu

The crash was reported in MAC OS and NixOS, here is the link for this bug
https://gitlab.com/qemu-project/qemu/-/issues/2334
https://gitlab.com/qemu-project/qemu/-/issues/2321

In this bug, they are using the virtio_input device. The guest notifier was not supported for this device, The function virtio_pci_set_guest_notifiers() was not called, and the vector_irqfd was not initialized.

So the fix is adding the check for vector_irqfd in virtio_pci_get_notifier()

But The function virtio_pci_get_notifier(),it can also be used in all kinds of device. If the vector_irqfd still didn't initial after the VIRTIO_CONFIG_S_DRIVER_OK is set means this device is not using guest notifier. We can let the check fail here

This fix is verified in vyatta,MacOS,NixOS,fedora system.

The bt tree for this bug is:
Thread 6 "CPU 0/KVM" received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x7c817be006c0 (LWP 1269146)] kvm_virtio_pci_vq_vector_use () at ../qemu-9.0.0/hw/virtio/virtio-pci.c:817
817 if (irqfd->users == 0) {
(gdb) thread apply all bt
...
Thread 6 (Thread 0x7c817be006c0 (LWP 1269146) "CPU 0/KVM"):

0  kvm_virtio_pci_vq_vector_use () at ../qemu-9.0.0/hw/virtio/virtio-pci.c:817
1  kvm_virtio_pci_vector_use_one () at ../qemu-9.0.0/hw/virtio/virtio-pci.c:893
2  0x00005983657045e2 in memory_region_write_accessor () at ../qemu-9.0.0/system/memory.c:497
3  0x0000598365704ba6 in access_with_adjusted_size () at ../qemu-9.0.0/system/memory.c:573
4  0x0000598365705059 in memory_region_dispatch_write () at ../qemu-9.0.0/system/memory.c:1528
5  0x00005983659b8e1f in flatview_write_continue_step.isra.0 () at ../qemu-9.0.0/system/physmem.c:2713
6  0x000059836570ba7d in flatview_write_continue () at ../qemu-9.0.0/system/physmem.c:2743
7  flatview_write () at ../qemu-9.0.0/system/physmem.c:2774
8  0x000059836570bb76 in address_space_write () at ../qemu-9.0.0/system/physmem.c:2894
9  0x0000598365763afe in address_space_rw () at ../qemu-9.0.0/system/physmem.c:2904

10 kvm_cpu_exec () at ../qemu-9.0.0/accel/kvm/kvm-all.c:2917
11 0x000059836576656e in kvm_vcpu_thread_fn () at ../qemu-9.0.0/accel/kvm/kvm-accel-ops.c:50 12 0x0000598365926ca8 in qemu_thread_start () at ../qemu-9.0.0/util/qemu-thread-posix.c:541 13 0x00007c8185bcd1cf in ??? () at /usr/lib/libc.so.6
14 0x00007c8185c4e504 in clone () at /usr/lib/libc.so.6

Fixes 2ce6cff94d ("virtio-pci: fix use of a released vector")
---
 hw/virtio/virtio-pci.c | 3 +++
 1 file changed, 3 insertions(+)
hw/virtio/virtio-pci.c +0 -0
index 592fdaa10f..dc31a37ec0 100644

hw/virtio/virtio-pci.c static int virtio_pci_get_notifier(VirtIOPCIProxy *proxy, int queue_no, · line 865

Quoted 6 lines
hw/virtio/virtio-pci.c +3 -0
@@ -860,6 +860,9 @@ static int virtio_pci_get_notifier(VirtIOPCIProxy *proxy, int queue_no,
     VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
     VirtQueue *vq;
 
+    if (!proxy->vector_irqfd && vdev->status & VIRTIO_CONFIG_S_DRIVER_OK)
+        return -1;
+

Did this mean !proxy->vector_irqfd && !(vdev->status & VIRTIO_CONFIG_S_DRIVER_OK)) is legal?

Thanks

Quoted 6 lines
hw/virtio/virtio-pci.c +0 -1
     if (queue_no == VIRTIO_CONFIG_IRQ_IDX) {
         *n = virtio_config_get_guest_notifier(vdev);
         *vector = vdev->config_vector;
--

2.45.0

author
#2 lore raw
Quoted 6 lines · Jason Wang

Hi Cindy

Quoted 2 lines · Cindy Lu

The crash was reported in MAC OS and NixOS, here is the link for this

bug

Quoted 4 lines
Quoted 4 lines

https://gitlab.com/qemu-project/qemu/-/issues/2334
https://gitlab.com/qemu-project/qemu/-/issues/2321

In this bug, they are using the virtio_input device. The guest notifier

was

Quoted 1 line
Quoted 1 line

not supported for this device, The function

virtio_pci_set_guest_notifiers()

Quoted 3 lines
Quoted 3 lines

was not called, and the vector_irqfd was not initialized.

So the fix is adding the check for vector_irqfd in

virtio_pci_get_notifier()

Quoted 2 lines
Quoted 2 lines

But The function virtio_pci_get_notifier(),it can also be used in all

kinds of device.

Quoted 1 line
Quoted 1 line

If the vector_irqfd still didn't initial after the

VIRTIO_CONFIG_S_DRIVER_OK is set

Quoted 1 line
Quoted 1 line

means this device is not using guest notifier. We can let the check

fail here

Quoted 7 lines
Quoted 7 lines

This fix is verified in vyatta,MacOS,NixOS,fedora system.

The bt tree for this bug is:
Thread 6 "CPU 0/KVM" received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x7c817be006c0 (LWP 1269146)] kvm_virtio_pci_vq_vector_use () at

../qemu-9.0.0/hw/virtio/virtio-pci.c:817

Quoted 5 lines
Quoted 5 lines

817 if (irqfd->users == 0) {
(gdb) thread apply all bt
...
Thread 6 (Thread 0x7c817be006c0 (LWP 1269146) "CPU 0/KVM"):
0 kvm_virtio_pci_vq_vector_use () at

../qemu-9.0.0/hw/virtio/virtio-pci.c:817

Quoted 1 line
Quoted 1 line

1 kvm_virtio_pci_vector_use_one () at

../qemu-9.0.0/hw/virtio/virtio-pci.c:893

Quoted 1 line
Quoted 1 line

2 0x00005983657045e2 in memory_region_write_accessor () at

../qemu-9.0.0/system/memory.c:497

Quoted 1 line
Quoted 1 line

3 0x0000598365704ba6 in access_with_adjusted_size () at

../qemu-9.0.0/system/memory.c:573

Quoted 1 line
Quoted 1 line

4 0x0000598365705059 in memory_region_dispatch_write () at

../qemu-9.0.0/system/memory.c:1528

Quoted 1 line
Quoted 1 line

5 0x00005983659b8e1f in flatview_write_continue_step.isra.0 () at

../qemu-9.0.0/system/physmem.c:2713

Quoted 1 line
Quoted 1 line

6 0x000059836570ba7d in flatview_write_continue () at

../qemu-9.0.0/system/physmem.c:2743

Quoted 2 lines
Quoted 2 lines

7 flatview_write () at ../qemu-9.0.0/system/physmem.c:2774 8 0x000059836570bb76 in address_space_write () at

../qemu-9.0.0/system/physmem.c:2894

Quoted 1 line
Quoted 1 line

9 0x0000598365763afe in address_space_rw () at

../qemu-9.0.0/system/physmem.c:2904

Quoted 2 lines
Quoted 2 lines

10 kvm_cpu_exec () at ../qemu-9.0.0/accel/kvm/kvm-all.c:2917 11 0x000059836576656e in kvm_vcpu_thread_fn () at

../qemu-9.0.0/accel/kvm/kvm-accel-ops.c:50

Quoted 1 line
Quoted 1 line

12 0x0000598365926ca8 in qemu_thread_start () at

../qemu-9.0.0/util/qemu-thread-posix.c:541

Quoted 10 lines
Quoted 10 lines

13 0x00007c8185bcd1cf in ??? () at /usr/lib/libc.so.6 14 0x00007c8185c4e504 in clone () at /usr/lib/libc.so.6

Fixes 2ce6cff94d ("virtio-pci: fix use of a released vector")
---
 hw/virtio/virtio-pci.c | 3 +++
 1 file changed, 3 insertions(+)
Quoted 5 lines

hw/virtio/virtio-pci.c static int virtio_pci_get_notifier(VirtIOPCIProxy

Quoted 5 lines
hw/virtio/virtio-pci.c +0 -0
index 592fdaa10f..dc31a37ec0 100644
@@ -860,6 +860,9 @@ static int virtio_pci_get_notifier(VirtIOPCIProxy

*proxy, int queue_no,

Quoted 4 lines

hw/virtio/virtio-pci.c static int virtio_pci_get_notifier(VirtIOPCIProxy *proxy, int queue_no,

Quoted 4 lines
hw/virtio/virtio-pci.c +1 -0
     VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
     VirtQueue *vq;
 
+    if (!proxy->vector_irqfd && vdev->status &

VIRTIO_CONFIG_S_DRIVER_OK)

Quoted 8 lines

hw/virtio/virtio-pci.c static int virtio_pci_get_notifier(VirtIOPCIProxy *proxy, int queue_no, · line 865

Quoted 2 lines
hw/virtio/virtio-pci.c +2 -0
+        return -1;
+

Did this mean !proxy->vector_irqfd && !(vdev->status & VIRTIO_CONFIG_S_DRIVER_OK)) is legal?

Thanks

yes, for my test, I didn't meet this kind of environment. However, since this function is used widely in many environments, I cannot cover all devices for testing.

I think we can change the patch back to the first version, which is to check the proxy->vector_irqfd in virtio_pci_set_vector(). This will have a lower risk and make more sense
thanks
cindy

Quoted 96 lines · Jason Wang

Hi Cindy

Quoted 6 lines · Cindy Lu

The crash was reported in MAC OS and NixOS, here is the link for this bug
https://gitlab.com/qemu-project/qemu/-/issues/2334
https://gitlab.com/qemu-project/qemu/-/issues/2321

In this bug, they are using the virtio_input device. The guest notifier

was

Quoted 1 line

not supported for this device, The function

virtio_pci_set_guest_notifiers()

Quoted 3 lines

was not called, and the vector_irqfd was not initialized.

So the fix is adding the check for vector_irqfd in

virtio_pci_get_notifier()

Quoted 2 lines

But The function virtio_pci_get_notifier(),it can also be used in all

kinds of device.

Quoted 1 line

If the vector_irqfd still didn't initial after the

VIRTIO_CONFIG_S_DRIVER_OK is set

Quoted 1 line

means this device is not using guest notifier. We can let the check fail

here

Quoted 7 lines

This fix is verified in vyatta,MacOS,NixOS,fedora system.

The bt tree for this bug is:
Thread 6 "CPU 0/KVM" received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x7c817be006c0 (LWP 1269146)] kvm_virtio_pci_vq_vector_use () at

../qemu-9.0.0/hw/virtio/virtio-pci.c:817

Quoted 5 lines

817 if (irqfd->users == 0) {
(gdb) thread apply all bt
...
Thread 6 (Thread 0x7c817be006c0 (LWP 1269146) "CPU 0/KVM"):
0 kvm_virtio_pci_vq_vector_use () at

../qemu-9.0.0/hw/virtio/virtio-pci.c:817

Quoted 1 line

1 kvm_virtio_pci_vector_use_one () at

../qemu-9.0.0/hw/virtio/virtio-pci.c:893

Quoted 1 line

2 0x00005983657045e2 in memory_region_write_accessor () at

../qemu-9.0.0/system/memory.c:497

Quoted 1 line

3 0x0000598365704ba6 in access_with_adjusted_size () at

../qemu-9.0.0/system/memory.c:573

Quoted 1 line

4 0x0000598365705059 in memory_region_dispatch_write () at

../qemu-9.0.0/system/memory.c:1528

Quoted 1 line

5 0x00005983659b8e1f in flatview_write_continue_step.isra.0 () at

../qemu-9.0.0/system/physmem.c:2713

Quoted 1 line

6 0x000059836570ba7d in flatview_write_continue () at

../qemu-9.0.0/system/physmem.c:2743

Quoted 2 lines

7 flatview_write () at ../qemu-9.0.0/system/physmem.c:2774 8 0x000059836570bb76 in address_space_write () at

../qemu-9.0.0/system/physmem.c:2894

Quoted 1 line

9 0x0000598365763afe in address_space_rw () at

../qemu-9.0.0/system/physmem.c:2904

Quoted 2 lines

10 kvm_cpu_exec () at ../qemu-9.0.0/accel/kvm/kvm-all.c:2917 11 0x000059836576656e in kvm_vcpu_thread_fn () at

../qemu-9.0.0/accel/kvm/kvm-accel-ops.c:50

Quoted 1 line

12 0x0000598365926ca8 in qemu_thread_start () at

../qemu-9.0.0/util/qemu-thread-posix.c:541

hw/virtio/virtio-pci.c static int virtio_pci_get_notifier(VirtIOPCIProxy

Quoted 15 lines

13 0x00007c8185bcd1cf in ??? () at /usr/lib/libc.so.6 14 0x00007c8185c4e504 in clone () at /usr/lib/libc.so.6

Fixes 2ce6cff94d ("virtio-pci: fix use of a released vector")
---
 hw/virtio/virtio-pci.c | 3 +++
 1 file changed, 3 insertions(+)
hw/virtio/virtio-pci.c +0 -0
index 592fdaa10f..dc31a37ec0 100644
@@ -860,6 +860,9 @@ static int virtio_pci_get_notifier(VirtIOPCIProxy

*proxy, int queue_no,

hw/virtio/virtio-pci.c static int virtio_pci_get_notifier(VirtIOPCIProxy *proxy, int queue_no,

Quoted 4 lines
hw/virtio/virtio-pci.c +1 -0
     VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
     VirtQueue *vq;
 
+    if (!proxy->vector_irqfd && vdev->status &

VIRTIO_CONFIG_S_DRIVER_OK)

hw/virtio/virtio-pci.c static int virtio_pci_get_notifier(VirtIOPCIProxy *proxy, int queue_no, · line 865

Quoted 2 lines
hw/virtio/virtio-pci.c +2 -0
+        return -1;
+

Did this mean !proxy->vector_irqfd && !(vdev->status & VIRTIO_CONFIG_S_DRIVER_OK)) is legal?

Thanks

Quoted 6 lines
hw/virtio/virtio-pci.c +0 -1
     if (queue_no == VIRTIO_CONFIG_IRQ_IDX) {
         *n = virtio_config_get_guest_notifier(vdev);
         *vector = vdev->config_vector;
--

2.45.0

#3 lore raw
Quoted 71 lines · Cindy Lu
Quoted 67 lines · Jason Wang

Hi Cindy

Quoted 53 lines · Cindy Lu

The crash was reported in MAC OS and NixOS, here is the link for this bug
https://gitlab.com/qemu-project/qemu/-/issues/2334
https://gitlab.com/qemu-project/qemu/-/issues/2321

In this bug, they are using the virtio_input device. The guest notifier was not supported for this device, The function virtio_pci_set_guest_notifiers() was not called, and the vector_irqfd was not initialized.

So the fix is adding the check for vector_irqfd in virtio_pci_get_notifier()

But The function virtio_pci_get_notifier(),it can also be used in all kinds of device. If the vector_irqfd still didn't initial after the VIRTIO_CONFIG_S_DRIVER_OK is set means this device is not using guest notifier. We can let the check fail here

This fix is verified in vyatta,MacOS,NixOS,fedora system.

The bt tree for this bug is:
Thread 6 "CPU 0/KVM" received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x7c817be006c0 (LWP 1269146)] kvm_virtio_pci_vq_vector_use () at ../qemu-9.0.0/hw/virtio/virtio-pci.c:817
817 if (irqfd->users == 0) {
(gdb) thread apply all bt
...
Thread 6 (Thread 0x7c817be006c0 (LWP 1269146) "CPU 0/KVM"):

0  kvm_virtio_pci_vq_vector_use () at ../qemu-9.0.0/hw/virtio/virtio-pci.c:817
1  kvm_virtio_pci_vector_use_one () at ../qemu-9.0.0/hw/virtio/virtio-pci.c:893
2  0x00005983657045e2 in memory_region_write_accessor () at ../qemu-9.0.0/system/memory.c:497
3  0x0000598365704ba6 in access_with_adjusted_size () at ../qemu-9.0.0/system/memory.c:573
4  0x0000598365705059 in memory_region_dispatch_write () at ../qemu-9.0.0/system/memory.c:1528
5  0x00005983659b8e1f in flatview_write_continue_step.isra.0 () at ../qemu-9.0.0/system/physmem.c:2713
6  0x000059836570ba7d in flatview_write_continue () at ../qemu-9.0.0/system/physmem.c:2743
7  flatview_write () at ../qemu-9.0.0/system/physmem.c:2774
8  0x000059836570bb76 in address_space_write () at ../qemu-9.0.0/system/physmem.c:2894
9  0x0000598365763afe in address_space_rw () at ../qemu-9.0.0/system/physmem.c:2904

10 kvm_cpu_exec () at ../qemu-9.0.0/accel/kvm/kvm-all.c:2917
11 0x000059836576656e in kvm_vcpu_thread_fn () at ../qemu-9.0.0/accel/kvm/kvm-accel-ops.c:50 12 0x0000598365926ca8 in qemu_thread_start () at ../qemu-9.0.0/util/qemu-thread-posix.c:541 13 0x00007c8185bcd1cf in ??? () at /usr/lib/libc.so.6
14 0x00007c8185c4e504 in clone () at /usr/lib/libc.so.6

Fixes 2ce6cff94d ("virtio-pci: fix use of a released vector")
---
 hw/virtio/virtio-pci.c | 3 +++
 1 file changed, 3 insertions(+)
hw/virtio/virtio-pci.c +0 -0
index 592fdaa10f..dc31a37ec0 100644

hw/virtio/virtio-pci.c static int virtio_pci_get_notifier(VirtIOPCIProxy *proxy, int queue_no, · line 865

Quoted 6 lines
hw/virtio/virtio-pci.c +3 -0
@@ -860,6 +860,9 @@ static int virtio_pci_get_notifier(VirtIOPCIProxy *proxy, int queue_no,
     VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
     VirtQueue *vq;
 
+    if (!proxy->vector_irqfd && vdev->status & VIRTIO_CONFIG_S_DRIVER_OK)
+        return -1;
+

Did this mean !proxy->vector_irqfd && !(vdev->status & VIRTIO_CONFIG_S_DRIVER_OK)) is legal?

Quoted 3 lines
Quoted 2 lines

Thanks

yes, for my test, I didn't meet this kind of environment.

This needs to be checked, we can use qtest to poc this condition if you wish.

But I meant we need to explain why there is a check for DRIVER_OK here. For example, did the current Qemu guarantee that?

Quoted 5 lines

However, since this function is used widely in many environments, I cannot cover all devices for testing.

I think we can change the patch back to the first version, which is to check the proxy->vector_irqfd in virtio_pci_set_vector(). This will have a lower risk and make more sense thanks
cindy

Thanks

Quoted 79 lines · Jason Wang
Quoted 76 lines

Hi Cindy

Quoted 53 lines · Cindy Lu

The crash was reported in MAC OS and NixOS, here is the link for this bug
https://gitlab.com/qemu-project/qemu/-/issues/2334
https://gitlab.com/qemu-project/qemu/-/issues/2321

In this bug, they are using the virtio_input device. The guest notifier was not supported for this device, The function virtio_pci_set_guest_notifiers() was not called, and the vector_irqfd was not initialized.

So the fix is adding the check for vector_irqfd in virtio_pci_get_notifier()

But The function virtio_pci_get_notifier(),it can also be used in all kinds of device. If the vector_irqfd still didn't initial after the VIRTIO_CONFIG_S_DRIVER_OK is set means this device is not using guest notifier. We can let the check fail here

This fix is verified in vyatta,MacOS,NixOS,fedora system.

The bt tree for this bug is:
Thread 6 "CPU 0/KVM" received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x7c817be006c0 (LWP 1269146)] kvm_virtio_pci_vq_vector_use () at ../qemu-9.0.0/hw/virtio/virtio-pci.c:817
817 if (irqfd->users == 0) {
(gdb) thread apply all bt
...
Thread 6 (Thread 0x7c817be006c0 (LWP 1269146) "CPU 0/KVM"):

0  kvm_virtio_pci_vq_vector_use () at ../qemu-9.0.0/hw/virtio/virtio-pci.c:817
1  kvm_virtio_pci_vector_use_one () at ../qemu-9.0.0/hw/virtio/virtio-pci.c:893
2  0x00005983657045e2 in memory_region_write_accessor () at ../qemu-9.0.0/system/memory.c:497
3  0x0000598365704ba6 in access_with_adjusted_size () at ../qemu-9.0.0/system/memory.c:573
4  0x0000598365705059 in memory_region_dispatch_write () at ../qemu-9.0.0/system/memory.c:1528
5  0x00005983659b8e1f in flatview_write_continue_step.isra.0 () at ../qemu-9.0.0/system/physmem.c:2713
6  0x000059836570ba7d in flatview_write_continue () at ../qemu-9.0.0/system/physmem.c:2743
7  flatview_write () at ../qemu-9.0.0/system/physmem.c:2774
8  0x000059836570bb76 in address_space_write () at ../qemu-9.0.0/system/physmem.c:2894
9  0x0000598365763afe in address_space_rw () at ../qemu-9.0.0/system/physmem.c:2904

10 kvm_cpu_exec () at ../qemu-9.0.0/accel/kvm/kvm-all.c:2917
11 0x000059836576656e in kvm_vcpu_thread_fn () at ../qemu-9.0.0/accel/kvm/kvm-accel-ops.c:50 12 0x0000598365926ca8 in qemu_thread_start () at ../qemu-9.0.0/util/qemu-thread-posix.c:541 13 0x00007c8185bcd1cf in ??? () at /usr/lib/libc.so.6
14 0x00007c8185c4e504 in clone () at /usr/lib/libc.so.6

Fixes 2ce6cff94d ("virtio-pci: fix use of a released vector")
---
 hw/virtio/virtio-pci.c | 3 +++
 1 file changed, 3 insertions(+)
hw/virtio/virtio-pci.c +0 -0
index 592fdaa10f..dc31a37ec0 100644

hw/virtio/virtio-pci.c static int virtio_pci_get_notifier(VirtIOPCIProxy *proxy, int queue_no, · line 865

Quoted 6 lines
hw/virtio/virtio-pci.c +3 -0
@@ -860,6 +860,9 @@ static int virtio_pci_get_notifier(VirtIOPCIProxy *proxy, int queue_no,
     VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
     VirtQueue *vq;
 
+    if (!proxy->vector_irqfd && vdev->status & VIRTIO_CONFIG_S_DRIVER_OK)
+        return -1;
+

Did this mean !proxy->vector_irqfd && !(vdev->status & VIRTIO_CONFIG_S_DRIVER_OK)) is legal?

Thanks

Quoted 6 lines
hw/virtio/virtio-pci.c +0 -1
     if (queue_no == VIRTIO_CONFIG_IRQ_IDX) {
         *n = virtio_config_get_guest_notifier(vdev);
         *vector = vdev->config_vector;
--

2.45.0