All of lore.kernel.org
 help / color / mirror / Atom feed
* PATCH] hw/s390x/s390-hypercall: fix potential NULL dereference in handle_virtio_ccw_notify
@ 2026-09-15 16:17 Николай Зорин
  2026-09-15 16:32 ` Thomas Huth
  2026-09-15 16:53 ` Michael S. Tsirkin
  0 siblings, 2 replies; 8+ messages in thread
From: Николай Зорин @ 2026-09-15 16:17 UTC (permalink / raw)
  To: qemu-devel; +Cc: thuth, mst, stefanha, kwolf

SWSA#4992cdf0-415c-45c1-be1a-71213467347d

The `virtio_ccw_get_vdev()` function can return a `NULL` pointer if the
corresponding subchannel driver data (`sch->driver_data`) is not initialized
or has been cleared.

If `vdev` is `NULL`, passing it directly into 
`virtio_queue_get_num(vdev, vq_idx)`
results in a `NULL` pointer dereference, which can lead to a hypervisor
crash or unexpected termination of the QEMU process.

Fix this by adding an explicit check for `!vdev` before verifying the
queue index and its capacity, returning `-EINVAL` early if the device
is missing or not bound to the subchannel.

Signed-off-by: Nikolay N Zorin <zorin@swemel.ru>
---
  hw/s390x/s390-hypercall.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/s390x/s390-hypercall.c b/hw/s390x/s390-hypercall.c
index ac1b08b2..fd2972c0 100644
--- a/hw/s390x/s390-hypercall.c
+++ b/hw/s390x/s390-hypercall.c
@@ -44,7 +44,7 @@ static int handle_virtio_ccw_notify(uint64_t subch_id, 
uint64_t data)
      }

      vdev = virtio_ccw_get_vdev(sch);
-    if (vq_idx >= VIRTIO_QUEUE_MAX || !virtio_queue_get_num(vdev, 
vq_idx)) {
+    if (!vdev || vq_idx >= VIRTIO_QUEUE_MAX || 
!virtio_queue_get_num(vdev, vq_idx)) {
          return -EINVAL;
      }
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-09-15 17:04 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-15 16:17 PATCH] hw/s390x/s390-hypercall: fix potential NULL dereference in handle_virtio_ccw_notify Николай Зорин
2026-09-15 16:32 ` Thomas Huth
2026-09-15 16:42   ` Николай Зорин
2026-09-15 16:50     ` Thomas Huth
2026-09-15 17:00       ` Николай Зорин
2026-09-15 17:02         ` Michael S. Tsirkin
2026-09-15 17:00     ` Michael S. Tsirkin
2026-09-15 16:53 ` Michael S. Tsirkin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.