2019-05-22 09:51:24 +02:00
|
|
|
|
2007-11-12 21:30:26 -06:00
|
|
|
|
2014-12-08 12:31:02 +02:00
|
|
|
|
2007-11-12 21:30:26 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-12-08 12:31:02 +02:00
|
|
|
|
2007-11-12 21:30:26 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-12-08 12:31:02 +02:00
|
|
|
|
|
|
|
|
|
2007-11-12 21:30:26 -06:00
|
|
|
|
|
|
|
|
|
2014-12-08 16:39:45 +02:00
|
|
|
|
2007-11-12 21:30:26 -06:00
|
|
|
|
2015-01-15 17:54:13 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-10-24 09:54:06 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-03-23 11:15:24 +08:00
|
|
|
|
|
|
|
|
|
2011-11-17 17:41:15 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-03-23 11:15:23 +08:00
|
|
|
|
2017-04-04 21:15:41 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-03-23 11:15:24 +08:00
|
|
|
|
2011-11-17 17:41:15 +02:00
|
|
|
|
|
|
|
|
|
2007-11-12 21:30:26 -06:00
|
|
|
|
2014-12-07 18:41:16 +02:00
|
|
|
|
2007-11-12 21:30:26 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-12-03 18:01:58 +02:00
|
|
|
|
2013-10-29 09:38:50 +10:30
|
|
|
|
2007-11-12 21:30:26 -06:00
|
|
|
|
|
|
|
|
|
2024-07-16 13:35:44 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-05-14 13:55:31 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-10-14 10:40:34 +10:30
|
|
|
|
2024-07-16 13:35:44 +02:00
|
|
|
|
2009-05-14 13:55:31 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-04-04 21:44:44 +03:00
|
|
|
|
2009-05-14 13:55:31 +03:00
|
|
|
|
2017-04-04 21:44:44 +03:00
|
|
|
|
2009-05-14 13:55:31 +03:00
|
|
|
|
2017-04-04 21:44:44 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-05-14 13:55:31 +03:00
|
|
|
|
|
|
|
|
|
2017-04-04 21:44:44 +03:00
|
|
|
|
2009-05-14 13:55:31 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-11-12 21:30:26 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-12-02 14:35:27 +02:00
|
|
|
|
2007-11-12 21:30:26 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-05-14 13:55:31 +03:00
|
|
|
|
|
|
|
|
|
2007-11-12 21:30:26 -06:00
|
|
|
|
2009-05-14 13:55:31 +03:00
|
|
|
|
2007-11-12 21:30:26 -06:00
|
|
|
|
|
|
|
|
|
2017-04-04 21:15:41 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-04-18 02:54:35 +00:00
|
|
|
|
|
|
|
|
|
2017-04-04 21:15:41 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-02-21 20:03:00 -08:00
|
|
|
|
2017-04-04 21:15:41 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-02-21 20:03:00 -08:00
|
|
|
|
2017-04-04 21:15:41 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-07-16 13:35:41 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-08-24 18:07:02 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-04-04 21:15:41 +03:00
|
|
|
|
2017-08-24 18:07:02 +02:00
|
|
|
|
2017-04-04 21:15:41 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-03-23 11:15:24 +08:00
|
|
|
|
2017-04-04 21:15:41 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-03-23 11:15:24 +08:00
|
|
|
|
2017-04-04 21:15:41 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-07-16 13:35:44 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-04-18 02:54:35 +00:00
|
|
|
|
2017-04-04 21:44:44 +03:00
|
|
|
|
|
|
|
|
|
2017-03-06 18:32:29 +02:00
|
|
|
|
2024-07-16 13:35:47 +02:00
|
|
|
|
|
|
|
|
|
2017-04-04 21:44:44 +03:00
|
|
|
|
|
|
|
|
|
2026-02-21 16:37:42 -08:00
|
|
|
|
2017-04-04 21:44:44 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-08-16 01:36:40 -04:00
|
|
|
|
2017-04-04 21:44:44 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-07-16 13:35:44 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-04-04 21:44:44 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-07-16 13:35:47 +02:00
|
|
|
|
2017-04-04 21:44:44 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-10-24 09:54:06 -04:00
|
|
|
|
2017-04-04 21:44:44 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-08-01 14:38:52 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-04-04 21:44:44 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-04-04 21:15:41 +03:00
|
|
|
|
|
|
|
|
|
2009-06-12 22:16:36 -06:00
|
|
|
|
2009-07-26 15:48:08 +03:00
|
|
|
|
2024-10-24 09:54:06 -04:00
|
|
|
|
2009-06-12 22:16:36 -06:00
|
|
|
|
2017-04-04 21:15:41 +03:00
|
|
|
|
2009-06-12 22:16:36 -06:00
|
|
|
|
2009-07-26 15:48:08 +03:00
|
|
|
|
2024-10-24 09:54:06 -04:00
|
|
|
|
|
|
|
|
|
2016-11-17 11:43:13 +01:00
|
|
|
|
2024-10-24 09:54:06 -04:00
|
|
|
|
|
|
|
|
|
2024-07-16 13:35:44 +02:00
|
|
|
|
|
|
|
|
|
2017-03-08 08:09:27 +00:00
|
|
|
|
|
|
|
|
|
2023-10-25 16:53:19 +02:00
|
|
|
|
2017-03-08 08:09:27 +00:00
|
|
|
|
|
|
|
|
|
2016-11-17 11:43:13 +01:00
|
|
|
|
2024-10-24 09:54:06 -04:00
|
|
|
|
2009-07-26 15:48:08 +03:00
|
|
|
|
2017-04-04 21:44:44 +03:00
|
|
|
|
2009-05-14 13:55:41 +03:00
|
|
|
|
2017-04-04 21:15:41 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-11-17 11:43:15 +01:00
|
|
|
|
2017-04-04 21:15:41 +03:00
|
|
|
|
|
|
|
|
|
2016-11-17 11:43:15 +01:00
|
|
|
|
2019-03-09 15:17:40 +08:00
|
|
|
|
|
|
|
|
|
2022-04-14 23:30:02 -03:00
|
|
|
|
2019-03-09 15:17:40 +08:00
|
|
|
|
2017-02-05 18:15:19 +01:00
|
|
|
|
2017-04-04 21:15:41 +03:00
|
|
|
|
2016-11-17 11:43:15 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-04-04 21:15:41 +03:00
|
|
|
|
|
|
|
|
|
2016-11-17 11:43:15 +01:00
|
|
|
|
|
|
|
|
|
2017-04-04 21:15:41 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-04-04 21:44:44 +03:00
|
|
|
|
|
|
|
|
|
2009-06-12 22:16:36 -06:00
|
|
|
|
|
|
|
|
|
2024-07-16 13:35:42 +02:00
|
|
|
|
|
|
|
|
|
2024-07-16 13:35:44 +02:00
|
|
|
|
2024-07-16 13:35:42 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-07-16 13:35:43 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-07-16 13:35:44 +02:00
|
|
|
|
2024-07-16 13:35:47 +02:00
|
|
|
|
|
|
|
|
|
2024-07-16 13:35:40 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-07-16 13:35:44 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-07-16 13:35:40 +02:00
|
|
|
|
2024-07-16 13:35:44 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-07-16 13:35:40 +02:00
|
|
|
|
|
|
|
|
|
2024-07-16 13:35:47 +02:00
|
|
|
|
|
|
|
|
|
2024-07-16 13:35:40 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-07-16 13:35:43 +02:00
|
|
|
|
2024-07-16 13:35:44 +02:00
|
|
|
|
|
|
|
|
|
2024-07-16 13:35:40 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-10-24 09:54:06 -04:00
|
|
|
|
2024-07-16 13:35:40 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-04-18 02:54:35 +00:00
|
|
|
|
2024-07-08 09:48:00 +02:00
|
|
|
|
|
|
|
|
|
2024-07-16 13:35:42 +02:00
|
|
|
|
2024-07-08 09:48:00 +02:00
|
|
|
|
2009-07-26 15:48:08 +03:00
|
|
|
|
|
|
|
|
|
2024-07-16 13:35:48 +02:00
|
|
|
|
2024-07-08 09:48:00 +02:00
|
|
|
|
2018-12-28 10:26:25 +08:00
|
|
|
|
2024-07-16 13:35:48 +02:00
|
|
|
|
2024-07-16 13:35:42 +02:00
|
|
|
|
2024-07-16 13:35:48 +02:00
|
|
|
|
2009-07-26 15:48:08 +03:00
|
|
|
|
2026-02-21 16:37:42 -08:00
|
|
|
|
2017-04-04 21:44:44 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-07-16 13:35:48 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-07-16 13:35:42 +02:00
|
|
|
|
|
|
|
|
|
2017-04-04 21:08:54 +03:00
|
|
|
|
2017-04-04 21:15:41 +03:00
|
|
|
|
|
|
|
|
|
2024-07-08 09:48:00 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-04-04 21:15:41 +03:00
|
|
|
|
2024-07-08 09:48:00 +02:00
|
|
|
|
2024-07-16 13:35:51 +02:00
|
|
|
|
|
|
|
|
|
2017-04-04 21:08:54 +03:00
|
|
|
|
2017-04-04 21:15:41 +03:00
|
|
|
|
|
|
|
|
|
2009-09-23 22:26:29 -06:00
|
|
|
|
2009-07-26 15:48:08 +03:00
|
|
|
|
2024-07-16 13:35:41 +02:00
|
|
|
|
2016-11-17 11:43:16 +01:00
|
|
|
|
2017-04-04 21:15:41 +03:00
|
|
|
|
2016-11-17 11:43:16 +01:00
|
|
|
|
2017-04-04 21:44:44 +03:00
|
|
|
|
2017-04-04 21:15:41 +03:00
|
|
|
|
2009-07-26 15:48:08 +03:00
|
|
|
|
2024-07-08 09:48:00 +02:00
|
|
|
|
|
|
|
|
|
2012-09-05 21:47:45 +03:00
|
|
|
|
|
|
|
|
|
2016-11-17 11:43:16 +01:00
|
|
|
|
virtio_pci: fix vq info pointer lookup via wrong index
Unbinding a virtio balloon device:
echo virtio0 > /sys/bus/virtio/drivers/virtio_balloon/unbind
triggers a NULL pointer dereference. The dmesg says:
BUG: kernel NULL pointer dereference, address: 0000000000000008
[...]
RIP: 0010:__list_del_entry_valid_or_report+0x5/0xf0
Call Trace:
<TASK>
vp_del_vqs+0x121/0x230
remove_common+0x135/0x150
virtballoon_remove+0xee/0x100
virtio_dev_remove+0x3b/0x80
device_release_driver_internal+0x187/0x2c0
unbind_store+0xb9/0xe0
kernfs_fop_write_iter.llvm.11660790530567441834+0xf6/0x180
vfs_write+0x2a9/0x3b0
ksys_write+0x5c/0xd0
do_syscall_64+0x54/0x230
entry_SYSCALL_64_after_hwframe+0x29/0x31
[...]
</TASK>
The virtio_balloon device registers 5 queues (inflate, deflate, stats,
free_page, reporting) but only the first two are unconditional. The
stats, free_page and reporting queues are each conditional on their
respective feature bits. When any of these features are absent, the
corresponding vqs_info entry has name == NULL, creating holes in the
array.
The root cause is an indexing mismatch introduced when vq info storage
was changed to be passed as an argument. vp_find_vqs_msix() and
vp_find_vqs_intx() store the info pointer at vp_dev->vqs[i], where 'i'
is the caller's sparse array index. However, the virtqueue itself gets
vq->index assigned from queue_idx, a dense index that skips NULL
entries. When holes exist, 'i' and queue_idx diverge. Later,
vp_del_vqs() looks up info via vp_dev->vqs[vq->index] using the dense
index into the sparsely-populated array, and hits NULL.
Fix this by storing info at vp_dev->vqs[queue_idx] instead of
vp_dev->vqs[i], so the store index matches the lookup index
(vq->index). Apply the fix to both the MSIX and INTX paths.
Cc: Yichun Zhang <yichun@openresty.com>
Cc: Jiri Pirko <jiri@nvidia.com>
Cc: stable@vger.kernel.org # v6.11+
Tested-by: Yuka <yuka@umeyashiki.org>
Fixes: 89a1c435aec2 ("virtio_pci: pass vq info as an argument to vp_setup_vq()")
Signed-off-by: Ammar Faizi <ammarfaizi2@openresty.com>
Message-Id: <20260315141808.547081-1-ammarfaizi2@openresty.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2026-03-15 21:18:08 +07:00
|
|
|
|
2024-07-16 13:35:44 +02:00
|
|
|
|
2024-07-16 13:35:47 +02:00
|
|
|
|
virtio_pci: fix vq info pointer lookup via wrong index
Unbinding a virtio balloon device:
echo virtio0 > /sys/bus/virtio/drivers/virtio_balloon/unbind
triggers a NULL pointer dereference. The dmesg says:
BUG: kernel NULL pointer dereference, address: 0000000000000008
[...]
RIP: 0010:__list_del_entry_valid_or_report+0x5/0xf0
Call Trace:
<TASK>
vp_del_vqs+0x121/0x230
remove_common+0x135/0x150
virtballoon_remove+0xee/0x100
virtio_dev_remove+0x3b/0x80
device_release_driver_internal+0x187/0x2c0
unbind_store+0xb9/0xe0
kernfs_fop_write_iter.llvm.11660790530567441834+0xf6/0x180
vfs_write+0x2a9/0x3b0
ksys_write+0x5c/0xd0
do_syscall_64+0x54/0x230
entry_SYSCALL_64_after_hwframe+0x29/0x31
[...]
</TASK>
The virtio_balloon device registers 5 queues (inflate, deflate, stats,
free_page, reporting) but only the first two are unconditional. The
stats, free_page and reporting queues are each conditional on their
respective feature bits. When any of these features are absent, the
corresponding vqs_info entry has name == NULL, creating holes in the
array.
The root cause is an indexing mismatch introduced when vq info storage
was changed to be passed as an argument. vp_find_vqs_msix() and
vp_find_vqs_intx() store the info pointer at vp_dev->vqs[i], where 'i'
is the caller's sparse array index. However, the virtqueue itself gets
vq->index assigned from queue_idx, a dense index that skips NULL
entries. When holes exist, 'i' and queue_idx diverge. Later,
vp_del_vqs() looks up info via vp_dev->vqs[vq->index] using the dense
index into the sparsely-populated array, and hits NULL.
Fix this by storing info at vp_dev->vqs[queue_idx] instead of
vp_dev->vqs[i], so the store index matches the lookup index
(vq->index). Apply the fix to both the MSIX and INTX paths.
Cc: Yichun Zhang <yichun@openresty.com>
Cc: Jiri Pirko <jiri@nvidia.com>
Cc: stable@vger.kernel.org # v6.11+
Tested-by: Yuka <yuka@umeyashiki.org>
Fixes: 89a1c435aec2 ("virtio_pci: pass vq info as an argument to vp_setup_vq()")
Signed-off-by: Ammar Faizi <ammarfaizi2@openresty.com>
Message-Id: <20260315141808.547081-1-ammarfaizi2@openresty.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2026-03-15 21:18:08 +07:00
|
|
|
|
|
|
|
|
|
2009-07-26 15:48:08 +03:00
|
|
|
|
|
|
|
|
|
2017-04-04 21:15:41 +03:00
|
|
|
|
2009-07-26 15:48:08 +03:00
|
|
|
|
|
|
|
|
|
2024-07-16 13:35:48 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-07-16 13:35:51 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-07-16 13:35:48 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-07-26 15:48:08 +03:00
|
|
|
|
|
|
|
|
|
2017-04-04 21:15:41 +03:00
|
|
|
|
|
|
|
|
|
2009-07-26 15:48:08 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-04-18 02:54:35 +00:00
|
|
|
|
2024-07-08 09:48:00 +02:00
|
|
|
|
|
|
|
|
|
2016-11-17 11:43:16 +01:00
|
|
|
|
|
|
|
|
|
2024-07-16 13:35:48 +02:00
|
|
|
|
2018-12-28 10:26:25 +08:00
|
|
|
|
2024-07-16 13:35:48 +02:00
|
|
|
|
|
|
|
|
|
2016-11-17 11:43:16 +01:00
|
|
|
|
2026-02-21 16:37:42 -08:00
|
|
|
|
2017-04-04 21:44:44 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-07-16 13:35:48 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-11-17 11:43:16 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-04-04 21:15:41 +03:00
|
|
|
|
2016-11-17 11:43:16 +01:00
|
|
|
|
2017-04-04 21:15:41 +03:00
|
|
|
|
2017-04-04 21:44:44 +03:00
|
|
|
|
2016-11-17 11:43:16 +01:00
|
|
|
|
2024-07-08 09:48:00 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-11-17 11:43:16 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
virtio_pci: fix vq info pointer lookup via wrong index
Unbinding a virtio balloon device:
echo virtio0 > /sys/bus/virtio/drivers/virtio_balloon/unbind
triggers a NULL pointer dereference. The dmesg says:
BUG: kernel NULL pointer dereference, address: 0000000000000008
[...]
RIP: 0010:__list_del_entry_valid_or_report+0x5/0xf0
Call Trace:
<TASK>
vp_del_vqs+0x121/0x230
remove_common+0x135/0x150
virtballoon_remove+0xee/0x100
virtio_dev_remove+0x3b/0x80
device_release_driver_internal+0x187/0x2c0
unbind_store+0xb9/0xe0
kernfs_fop_write_iter.llvm.11660790530567441834+0xf6/0x180
vfs_write+0x2a9/0x3b0
ksys_write+0x5c/0xd0
do_syscall_64+0x54/0x230
entry_SYSCALL_64_after_hwframe+0x29/0x31
[...]
</TASK>
The virtio_balloon device registers 5 queues (inflate, deflate, stats,
free_page, reporting) but only the first two are unconditional. The
stats, free_page and reporting queues are each conditional on their
respective feature bits. When any of these features are absent, the
corresponding vqs_info entry has name == NULL, creating holes in the
array.
The root cause is an indexing mismatch introduced when vq info storage
was changed to be passed as an argument. vp_find_vqs_msix() and
vp_find_vqs_intx() store the info pointer at vp_dev->vqs[i], where 'i'
is the caller's sparse array index. However, the virtqueue itself gets
vq->index assigned from queue_idx, a dense index that skips NULL
entries. When holes exist, 'i' and queue_idx diverge. Later,
vp_del_vqs() looks up info via vp_dev->vqs[vq->index] using the dense
index into the sparsely-populated array, and hits NULL.
Fix this by storing info at vp_dev->vqs[queue_idx] instead of
vp_dev->vqs[i], so the store index matches the lookup index
(vq->index). Apply the fix to both the MSIX and INTX paths.
Cc: Yichun Zhang <yichun@openresty.com>
Cc: Jiri Pirko <jiri@nvidia.com>
Cc: stable@vger.kernel.org # v6.11+
Tested-by: Yuka <yuka@umeyashiki.org>
Fixes: 89a1c435aec2 ("virtio_pci: pass vq info as an argument to vp_setup_vq()")
Signed-off-by: Ammar Faizi <ammarfaizi2@openresty.com>
Message-Id: <20260315141808.547081-1-ammarfaizi2@openresty.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2026-03-15 21:18:08 +07:00
|
|
|
|
2024-07-08 09:48:00 +02:00
|
|
|
|
virtio_pci: fix vq info pointer lookup via wrong index
Unbinding a virtio balloon device:
echo virtio0 > /sys/bus/virtio/drivers/virtio_balloon/unbind
triggers a NULL pointer dereference. The dmesg says:
BUG: kernel NULL pointer dereference, address: 0000000000000008
[...]
RIP: 0010:__list_del_entry_valid_or_report+0x5/0xf0
Call Trace:
<TASK>
vp_del_vqs+0x121/0x230
remove_common+0x135/0x150
virtballoon_remove+0xee/0x100
virtio_dev_remove+0x3b/0x80
device_release_driver_internal+0x187/0x2c0
unbind_store+0xb9/0xe0
kernfs_fop_write_iter.llvm.11660790530567441834+0xf6/0x180
vfs_write+0x2a9/0x3b0
ksys_write+0x5c/0xd0
do_syscall_64+0x54/0x230
entry_SYSCALL_64_after_hwframe+0x29/0x31
[...]
</TASK>
The virtio_balloon device registers 5 queues (inflate, deflate, stats,
free_page, reporting) but only the first two are unconditional. The
stats, free_page and reporting queues are each conditional on their
respective feature bits. When any of these features are absent, the
corresponding vqs_info entry has name == NULL, creating holes in the
array.
The root cause is an indexing mismatch introduced when vq info storage
was changed to be passed as an argument. vp_find_vqs_msix() and
vp_find_vqs_intx() store the info pointer at vp_dev->vqs[i], where 'i'
is the caller's sparse array index. However, the virtqueue itself gets
vq->index assigned from queue_idx, a dense index that skips NULL
entries. When holes exist, 'i' and queue_idx diverge. Later,
vp_del_vqs() looks up info via vp_dev->vqs[vq->index] using the dense
index into the sparsely-populated array, and hits NULL.
Fix this by storing info at vp_dev->vqs[queue_idx] instead of
vp_dev->vqs[i], so the store index matches the lookup index
(vq->index). Apply the fix to both the MSIX and INTX paths.
Cc: Yichun Zhang <yichun@openresty.com>
Cc: Jiri Pirko <jiri@nvidia.com>
Cc: stable@vger.kernel.org # v6.11+
Tested-by: Yuka <yuka@umeyashiki.org>
Fixes: 89a1c435aec2 ("virtio_pci: pass vq info as an argument to vp_setup_vq()")
Signed-off-by: Ammar Faizi <ammarfaizi2@openresty.com>
Message-Id: <20260315141808.547081-1-ammarfaizi2@openresty.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2026-03-15 21:18:08 +07:00
|
|
|
|
|
|
|
|
|
2016-11-17 11:43:16 +01:00
|
|
|
|
|
|
|
|
|
2017-04-04 21:15:41 +03:00
|
|
|
|
2016-11-17 11:43:16 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-07-16 13:35:48 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-07-16 13:35:51 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-07-16 13:35:48 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-11-17 11:43:16 +01:00
|
|
|
|
2017-04-04 21:15:41 +03:00
|
|
|
|
|
|
|
|
|
2016-11-17 11:43:16 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-05-14 13:55:41 +03:00
|
|
|
|
2022-04-18 02:54:35 +00:00
|
|
|
|
2024-07-08 09:48:00 +02:00
|
|
|
|
2017-03-06 18:32:29 +02:00
|
|
|
|
2009-06-12 22:16:36 -06:00
|
|
|
|
2009-09-23 22:26:29 -06:00
|
|
|
|
2009-05-14 13:55:41 +03:00
|
|
|
|
2017-04-04 21:08:54 +03:00
|
|
|
|
2024-07-16 13:35:42 +02:00
|
|
|
|
|
|
|
|
|
2009-07-26 15:48:08 +03:00
|
|
|
|
|
|
|
|
|
2024-07-16 13:35:44 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-04-04 21:08:54 +03:00
|
|
|
|
2024-07-16 13:35:42 +02:00
|
|
|
|
|
|
|
|
|
2017-04-04 21:08:54 +03:00
|
|
|
|
|
|
|
|
|
2022-10-12 17:58:28 -04:00
|
|
|
|
|
|
|
|
|
virtio_pci: don't try to use intxif pin is zero
The background is that we use dpu in cloud computing,the arch is x86,80
cores. We will have a lots of virtio devices,like 512 or more.
When we probe about 200 virtio_blk devices,it will fail and
the stack is printed as follows:
[25338.485128] virtio-pci 0000:b3:00.0: virtio_pci: leaving for legacy driver
[25338.496174] genirq: Flags mismatch irq 0. 00000080 (virtio418) vs. 00015a00 (timer)
[25338.503822] CPU: 20 PID: 5431 Comm: kworker/20:0 Kdump: loaded Tainted: G OE --------- - - 4.18.0-305.30.1.el8.x86_64
[25338.516403] Hardware name: Inspur NF5280M5/YZMB-00882-10E, BIOS 4.1.21 08/25/2021
[25338.523881] Workqueue: events work_for_cpu_fn
[25338.528235] Call Trace:
[25338.530687] dump_stack+0x5c/0x80
[25338.534000] __setup_irq.cold.53+0x7c/0xd3
[25338.538098] request_threaded_irq+0xf5/0x160
[25338.542371] vp_find_vqs+0xc7/0x190
[25338.545866] init_vq+0x17c/0x2e0 [virtio_blk]
[25338.550223] ? ncpus_cmp_func+0x10/0x10
[25338.554061] virtblk_probe+0xe6/0x8a0 [virtio_blk]
[25338.558846] virtio_dev_probe+0x158/0x1f0
[25338.562861] really_probe+0x255/0x4a0
[25338.566524] ? __driver_attach_async_helper+0x90/0x90
[25338.571567] driver_probe_device+0x49/0xc0
[25338.575660] bus_for_each_drv+0x79/0xc0
[25338.579499] __device_attach+0xdc/0x160
[25338.583337] bus_probe_device+0x9d/0xb0
[25338.587167] device_add+0x418/0x780
[25338.590654] register_virtio_device+0x9e/0xe0
[25338.595011] virtio_pci_probe+0xb3/0x140
[25338.598941] local_pci_probe+0x41/0x90
[25338.602689] work_for_cpu_fn+0x16/0x20
[25338.606443] process_one_work+0x1a7/0x360
[25338.610456] ? create_worker+0x1a0/0x1a0
[25338.614381] worker_thread+0x1cf/0x390
[25338.618132] ? create_worker+0x1a0/0x1a0
[25338.622051] kthread+0x116/0x130
[25338.625283] ? kthread_flush_work_fn+0x10/0x10
[25338.629731] ret_from_fork+0x1f/0x40
[25338.633395] virtio_blk: probe of virtio418 failed with error -16
The log :
"genirq: Flags mismatch irq 0. 00000080 (virtio418) vs. 00015a00 (timer)"
was printed because of the irq 0 is used by timer exclusive,and when
vp_find_vqs call vp_find_vqs_msix and returns false twice (for
whatever reason), then it will call vp_find_vqs_intx as a fallback.
Because vp_dev->pci_dev->irq is zero, we request irq 0 with
flag IRQF_SHARED, and get a backtrace like above.
According to PCI spec about "Interrupt Pin" Register (Offset 3Dh):
"The Interrupt Pin register is a read-only register that identifies the
legacy interrupt Message(s) the Function uses. Valid values are 01h, 02h,
03h, and 04h that map to legacy interrupt Messages for INTA,
INTB, INTC, and INTD respectively. A value of 00h indicates that the
Function uses no legacy interrupt Message(s)."
So if vp_dev->pci_dev->pin is zero, we should not request legacy
interrupt.
Signed-off-by: Angus Chen <angus.chen@jaguarmicro.com>
Suggested-by: Michael S. Tsirkin <mst@redhat.com>
Message-Id: <20220930000915.548-1-angus.chen@jaguarmicro.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2022-09-30 08:09:15 +08:00
|
|
|
|
2017-04-04 21:08:54 +03:00
|
|
|
|
2024-07-08 09:48:00 +02:00
|
|
|
|
2009-06-12 22:16:36 -06:00
|
|
|
|
|
|
|
|
|
2014-12-07 18:41:16 +02:00
|
|
|
|
2011-11-14 14:17:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-08-28 13:54:14 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-08-09 18:18:28 -07:00
|
|
|
|
2012-08-28 13:54:14 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-04-04 21:44:44 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-08-28 13:54:14 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-04-04 21:09:20 +03:00
|
|
|
|
2017-04-04 21:44:44 +03:00
|
|
|
|
|
|
|
|
|
2018-08-09 18:18:28 -07:00
|
|
|
|
2023-10-25 16:53:19 +02:00
|
|
|
|
2012-08-28 13:54:14 +02:00
|
|
|
|
2018-08-09 18:18:28 -07:00
|
|
|
|
2023-10-25 16:53:19 +02:00
|
|
|
|
2012-08-28 13:54:14 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-02-05 18:15:23 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-04-04 21:44:44 +03:00
|
|
|
|
2024-07-16 13:35:44 +02:00
|
|
|
|
|
|
|
|
|
2017-02-05 18:15:23 +01:00
|
|
|
|
|
|
|
|
|
2017-04-04 21:44:44 +03:00
|
|
|
|
|
|
|
|
|
2017-02-05 18:15:23 +01:00
|
|
|
|
|
|
|
|
|
2013-09-09 09:57:12 +09:30
|
|
|
|
2011-12-22 16:58:26 +05:30
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-10-14 10:40:35 +10:30
|
|
|
|
2011-12-22 16:58:26 +05:30
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-03-29 12:54:43 +05:30
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-10-14 10:40:35 +10:30
|
|
|
|
2011-12-22 16:58:26 +05:30
|
|
|
|
|
|
|
|
|
2023-12-08 16:07:54 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-12-11 21:47:49 +02:00
|
|
|
|
2023-12-08 16:07:54 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-12-22 16:58:25 +05:30
|
|
|
|
2007-11-12 21:30:26 -06:00
|
|
|
|
2014-12-11 21:47:49 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-03-06 22:02:30 +00:00
|
|
|
|
2014-12-11 21:47:49 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-01-13 11:23:32 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-12-11 21:47:49 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-12-21 20:40:24 +08:00
|
|
|
|
2015-01-13 11:23:32 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-02-21 16:37:42 -08:00
|
|
|
|
2015-01-13 11:23:32 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-04-04 21:44:44 +03:00
|
|
|
|
2024-07-16 13:35:44 +02:00
|
|
|
|
2017-04-04 21:44:44 +03:00
|
|
|
|
2015-01-13 11:23:32 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-01-15 17:54:13 +02:00
|
|
|
|
2014-12-11 13:59:51 +02:00
|
|
|
|
2015-01-15 17:54:13 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-01-13 11:23:32 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-12-21 20:40:24 +08:00
|
|
|
|
2015-01-13 11:23:32 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-10-29 17:14:42 +08:00
|
|
|
|
|
|
|
|
|
2014-12-11 13:59:51 +02:00
|
|
|
|
2021-10-29 17:14:42 +08:00
|
|
|
|
2015-01-13 11:23:32 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-12-21 20:40:24 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-01-13 11:23:32 +02:00
|
|
|
|
2014-12-11 21:47:49 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-01-13 11:23:32 +02:00
|
|
|
|
2016-01-14 16:00:41 +02:00
|
|
|
|
2015-01-13 11:23:32 +02:00
|
|
|
|
2021-07-21 17:26:48 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-06-01 12:02:39 +08:00
|
|
|
|
|
|
|
|
|
2015-01-13 11:23:32 +02:00
|
|
|
|
|
|
|
|
|
2021-10-29 17:14:42 +08:00
|
|
|
|
2014-12-11 13:59:51 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-01-13 11:23:32 +02:00
|
|
|
|
|
|
|
|
|
2016-01-14 16:00:41 +02:00
|
|
|
|
2014-12-11 21:47:49 +02:00
|
|
|
|
|
|
|
|
|
2018-06-01 12:02:39 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-11-27 08:57:31 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-12-11 21:47:49 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-06-01 12:02:39 +08:00
|
|
|
|
2024-11-27 08:57:31 +02:00
|
|
|
|
2014-12-11 21:47:49 +02:00
|
|
|
|
|
|
|
|
|
2023-12-19 11:32:44 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-12-11 21:47:49 +02:00
|
|
|
|
2014-12-17 00:54:03 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|