All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] prevent null pointer dereference during zpci hot unplug
@ 2026-02-10  6:52 Aby Sam Ross
  2026-02-10 14:21 ` Eric Farman
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Aby Sam Ross @ 2026-02-10  6:52 UTC (permalink / raw)
  To: qemu-s390x; +Cc: qemu-devel, mjrosato, farman, Aby Sam Ross

vfio-pci hostdev realize during zpci hot plug fails (in `vfio_pci_realize()`)
if the vfio group file in `/dev/vfio/` lacks appropriate permissions and the
hostdev[/properties] addition doesn't reach the point where it could be
associated with previously added zpci device (in `s390_pcihost_plug()`).
As a result, zpci iommu pointer remains null. The zpci hot unplug following the
failed hostdev addition assumes zpci iommu pointer was assigned and tries to
make use of it to end the dma count resulting in a null pointer dereference.
In the non-hotplug scenario, `qdev_unplug()` for the zpci device is not called
after hostdev addition failure and this issue is not encountered.

Fixes: 37fa32de7073
Signed-off-by: Aby Sam Ross <abysamross@ibm.com>
---
 hw/s390x/s390-pci-bus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c
index b438d63c44..3166b91c46 100644
--- a/hw/s390x/s390-pci-bus.c
+++ b/hw/s390x/s390-pci-bus.c
@@ -1248,7 +1248,7 @@ static void s390_pcihost_unplug(HotplugHandler *hotplug_dev, DeviceState *dev,
         pbdev->fid = 0;
         QTAILQ_REMOVE(&s->zpci_devs, pbdev, link);
         g_hash_table_remove(s->zpci_table, &pbdev->idx);
-        if (pbdev->iommu->dma_limit) {
+        if (pbdev->iommu && pbdev->iommu->dma_limit) {
             s390_pci_end_dma_count(s, pbdev->iommu->dma_limit);
         }
         qdev_unrealize(dev);
-- 
2.52.0



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

end of thread, other threads:[~2026-02-13 14:05 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-10  6:52 [PATCH] prevent null pointer dereference during zpci hot unplug Aby Sam Ross
2026-02-10 14:21 ` Eric Farman
2026-02-10 14:54 ` Matthew Rosato
2026-02-10 17:26 ` Farhan Ali
2026-02-12 11:47   ` [PATCH v2] s390x/pci: " Aby Sam Ross
2026-02-12 15:50     ` Halil Pasic
2026-02-12 16:55       ` Matthew Rosato
2026-02-12 19:25         ` Halil Pasic
2026-02-13  6:34           ` [PATCH v3] " Aby Sam Ross

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.