You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
qemu/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>
2 weeks ago
..
3270-ccw.c qom: Have class_init() take a const data argument 7 months ago
Kconfig s390x: virtio-mem support 12 months ago
ap-bridge.c qom: Make InterfaceInfo[] uses const 7 months ago
ap-device.c qom: Have class_init() take a const data argument 7 months ago
ap-stub.c s390: implementing CHSC SEI for AP config change 6 months ago
ccw-device.c hw/s390x/ccw-device: Fix memory leak in loadparm setter 5 months ago
ccw-device.h hw/s390x: Restrict "loadparm" property to devices that can be used for booting 1 year ago
cpu-topology.c qapi: make s390x specific CPU commands unconditionally available 6 months ago
css-bridge.c qom: Make InterfaceInfo[] uses const 7 months ago
css.c include/system: Move exec/address-spaces.h to system/address-spaces.h 8 months ago
event-facility.c hw/s390x: add SCLP event type CPI 5 months ago
ipl.c hw/core/loader: capture Error from load_image_targphys 1 month ago
ipl.h target/s390x: Return UVC cmd code, RC and RRC value when DIAG 308 Subcode 10 fails to enter secure mode 7 months ago
meson.build hw/s390x: add SCLP event type CPI 5 months ago
s390-ccw.c qom: Have class_init() take a const data argument 7 months ago
s390-hypercall.c hw/s390x: Fix a possible crash with passed-through virtio devices 2 weeks ago
s390-hypercall.h s390x/s390-hypercall: introduce DIAG500 STORAGE_LIMIT 12 months ago
s390-pci-bus.c s390x/pci: set kvm_msi_via_irqfd_allowed 2 months ago
s390-pci-inst.c hw/s390x: Use memory_region_size() 1 month ago
s390-pci-kvm.c s390x/pci: refresh fh before disabling aif 2 years ago
s390-pci-vfio.c hw/vfio/types.h: rename TYPE_VFIO_PCI_BASE to TYPE_VFIO_PCI_DEVICE 2 months ago
s390-skeys-kvm.c qom: Have class_init() take a const data argument 7 months ago
s390-skeys.c qapi: remove the misc-target.json file 6 months ago
s390-stattrib-kvm.c hw/s390x/s390-stattrib: Include missing 'exec/target_page.h' header 2 months ago
s390-stattrib.c hw/s390x/s390-stattrib: Include missing 'exec/target_page.h' header 2 months ago
s390-virtio-ccw.c hw/s390x/ccw: Remove deprecated s390-ccw-virtio-4.2 machine 1 month ago
sclp.c hw/s390x/ccw: Remove SCLPDevice::increment_size field 1 month ago
sclpcpi.c qapi/machine-s390x: add QAPI event SCLP_CPI_INFO_AVAILABLE 1 month ago
sclpcpu.c qom: Have class_init() take a const data argument 7 months ago
sclpquiesce.c qom: Have class_init() take a const data argument 7 months ago
tod-kvm.c qom: Have class_init() take a const data argument 7 months ago
tod-tcg.c qom: Have class_init() take a const data argument 7 months ago
tod.c qom: Have class_init() take a const data argument 7 months ago
trace-events hw/s390x: Introduce s390_skeys_get|set() helpers 1 year ago
trace.h trace: switch position of headers to what Meson requires 5 years ago
vhost-scsi-ccw.c qom: Have class_init() take a const data argument 7 months ago
vhost-user-fs-ccw.c qom: Have class_init() take a const data argument 7 months ago
vhost-vsock-ccw.c qom: Have class_init() take a const data argument 7 months ago
virtio-ccw-9p.c qom: Have class_init() take a const data argument 7 months ago
virtio-ccw-balloon.c qom: Have class_init() take a const data argument 7 months ago
virtio-ccw-blk.c qom: Have class_init() take a const data argument 7 months ago
virtio-ccw-crypto.c qom: Have class_init() take a const data argument 7 months ago
virtio-ccw-gpu.c qom: Have class_init() take a const data argument 7 months ago
virtio-ccw-input.c qom: Have class_init() take a const data argument 7 months ago
virtio-ccw-md-stubs.c s390x/virtio-ccw: add support for virtio based memory devices 12 months ago
virtio-ccw-md.c qom: Make InterfaceInfo[] uses const 7 months ago
virtio-ccw-md.h s390x/virtio-ccw: add support for virtio based memory devices 12 months ago
virtio-ccw-mem.c qom: Have class_init() take a const data argument 7 months ago
virtio-ccw-mem.h s390x: virtio-mem support 12 months ago
virtio-ccw-net.c qom: Have class_init() take a const data argument 7 months ago
virtio-ccw-rng.c qom: Have class_init() take a const data argument 7 months ago
virtio-ccw-scsi.c qom: Have class_init() take a const data argument 7 months ago
virtio-ccw-serial.c qom: Have class_init() take a const data argument 7 months ago
virtio-ccw.c migration: Fix regression of passing error_fatal into vmstate_load_state() 1 month ago
virtio-ccw.h hw/s390/virtio-ccw: Convert to three-phase reset 1 year ago