qemu-cr16/hw/s390x
Thomas Huth e5cb62e7b6 hw/s390x: Fix a possible crash with passed-through virtio devices
Consider the following nested setup: An L1 host uses some virtio device
(e.g. virtio-keyboard) for the L2 guest, and this L2 guest passes this
device through to the L3 guest. Since the L3 guest sees a virtio device,
it might send virtio notifications to the QEMU in L2 for that device.
But since the QEMU in L2 defined this device as vfio-ccw, the function
handle_virtio_ccw_notify() cannot handle this and crashes: It calls
virtio_ccw_get_vdev() that casts sch->driver_data into a VirtioCcwDevice,
but since "sch" belongs to a vfio-ccw device, that driver_data rather
points to a CcwDevice instead. So as soon as QEMU tries to use some
VirtioCcwDevice specific data from that device, we've lost.

We must not take virtio notifications for such devices. Thus fix the
issue by adding a check to the handle_virtio_ccw_notify() handler to
refuse all devices that are not our own virtio devices. Like in the
other branches that detect wrong settings, we return -EINVAL from the
function, which will later be placed in GPR2 to inform the guest about
the error.

Reviewed-by: Halil Pasic <pasic@linux.ibm.com>
Reviewed-by: Eric Farman <farman@linux.ibm.com>
Tested-by: Eric Farman <farman@linux.ibm.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Acked-by: Christian Borntraeger <borntraeger@linux.ibm.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20251118174047.73103-1-thuth@redhat.com>
2025-11-21 08:33:15 +01:00
..
3270-ccw.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
ap-bridge.c qom: Make InterfaceInfo[] uses const 2025-04-25 17:00:41 +02:00
ap-device.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
ap-stub.c s390: implementing CHSC SEI for AP config change 2025-06-11 14:01:58 +02:00
ccw-device.c hw/s390x/ccw-device: Fix memory leak in loadparm setter 2025-06-26 00:42:28 +02:00
ccw-device.h hw/s390x: Restrict "loadparm" property to devices that can be used for booting 2024-11-18 10:54:42 +01:00
cpu-topology.c qapi: make s390x specific CPU commands unconditionally available 2025-05-28 18:56:08 +02:00
css-bridge.c qom: Make InterfaceInfo[] uses const 2025-04-25 17:00:41 +02:00
css.c include/system: Move exec/address-spaces.h to system/address-spaces.h 2025-04-23 14:08:21 -07:00
event-facility.c hw/s390x: add SCLP event type CPI 2025-06-25 17:04:40 +02:00
ipl.c hw/core/loader: capture Error from load_image_targphys 2025-10-28 08:19:18 +01:00
ipl.h target/s390x: Return UVC cmd code, RC and RRC value when DIAG 308 Subcode 10 fails to enter secure mode 2025-04-30 09:48:57 +02:00
Kconfig s390x: virtio-mem support 2024-12-21 20:15:06 +01:00
meson.build hw/s390x: add SCLP event type CPI 2025-06-25 17:04:40 +02:00
s390-ccw.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
s390-hypercall.c hw/s390x: Fix a possible crash with passed-through virtio devices 2025-11-21 08:33:15 +01:00
s390-hypercall.h s390x/s390-hypercall: introduce DIAG500 STORAGE_LIMIT 2024-12-21 15:59:59 +01:00
s390-pci-bus.c s390x/pci: set kvm_msi_via_irqfd_allowed 2025-10-10 10:02:51 +02:00
s390-pci-inst.c hw/s390x: Use memory_region_size() 2025-11-03 08:27:59 +01:00
s390-pci-kvm.c s390x/pci: refresh fh before disabling aif 2024-01-19 11:38:32 +01:00
s390-pci-vfio.c hw/vfio/types.h: rename TYPE_VFIO_PCI_BASE to TYPE_VFIO_PCI_DEVICE 2025-09-25 17:55:20 +02:00
s390-skeys-kvm.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
s390-skeys.c qapi: remove the misc-target.json file 2025-05-28 18:54:18 +02:00
s390-stattrib-kvm.c hw/s390x/s390-stattrib: Include missing 'exec/target_page.h' header 2025-10-07 05:03:56 +02:00
s390-stattrib.c hw/s390x/s390-stattrib: Include missing 'exec/target_page.h' header 2025-10-07 05:03:56 +02:00
s390-virtio-ccw.c hw/s390x/ccw: Remove deprecated s390-ccw-virtio-4.2 machine 2025-10-21 15:47:21 +02:00
sclp.c hw/s390x/ccw: Remove SCLPDevice::increment_size field 2025-10-21 15:47:21 +02:00
sclpcpi.c qapi/machine-s390x: add QAPI event SCLP_CPI_INFO_AVAILABLE 2025-10-21 15:46:41 +02:00
sclpcpu.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
sclpquiesce.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
tod-kvm.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
tod-tcg.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
tod.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
trace-events hw/s390x: Introduce s390_skeys_get|set() helpers 2024-06-19 12:42:03 +02:00
trace.h trace: switch position of headers to what Meson requires 2020-08-21 06:18:24 -04:00
vhost-scsi-ccw.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
vhost-user-fs-ccw.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
vhost-vsock-ccw.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
virtio-ccw-9p.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
virtio-ccw-balloon.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
virtio-ccw-blk.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
virtio-ccw-crypto.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
virtio-ccw-gpu.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
virtio-ccw-input.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
virtio-ccw-md-stubs.c s390x/virtio-ccw: add support for virtio based memory devices 2024-12-21 15:59:59 +01:00
virtio-ccw-md.c qom: Make InterfaceInfo[] uses const 2025-04-25 17:00:41 +02:00
virtio-ccw-md.h s390x/virtio-ccw: add support for virtio based memory devices 2024-12-21 15:59:59 +01:00
virtio-ccw-mem.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
virtio-ccw-mem.h s390x: virtio-mem support 2024-12-21 20:15:06 +01:00
virtio-ccw-net.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
virtio-ccw-rng.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
virtio-ccw-scsi.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
virtio-ccw-serial.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
virtio-ccw.c migration: Fix regression of passing error_fatal into vmstate_load_state() 2025-11-03 16:04:10 -05:00
virtio-ccw.h hw/s390/virtio-ccw: Convert to three-phase reset 2024-09-13 15:31:43 +01:00