All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-devel@nongnu.org, Aby Sam Ross <abysamross@ibm.com>,
	Eric Farman <farman@linux.ibm.com>,
	Matthew Rosato <mjrosato@linux.ibm.com>,
	Farhan Ali <alifm@linux.ibm.com>,
	Halil Pasic <pasic@linux.ibm.com>
Subject: [PULL 01/10] s390x/pci: prevent null pointer dereference during zpci hot unplug
Date: Mon,  2 Mar 2026 13:34:04 +0100	[thread overview]
Message-ID: <20260302123413.274700-2-thuth@redhat.com> (raw)
In-Reply-To: <20260302123413.274700-1-thuth@redhat.com>

From: Aby Sam Ross <abysamross@ibm.com>

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.

All other uses of zpci iommu without null check happens after both the zpci and
hostdev(pci) devices are plugged and are safe from null dereference.

Fixes: 37fa32de7073 ("s390x/pci: Honor DMA limits set by vfio")

Signed-off-by: Aby Sam Ross <abysamross@ibm.com>
Acked-by: Eric Farman <farman@linux.ibm.com>
Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com>
Reviewed-by: Farhan Ali <alifm@linux.ibm.com>
Suggested-by: Halil Pasic <pasic@linux.ibm.com>
Message-ID: <b45cefc3147c2c8446772dab0f53d030fb92406a.1770963150.git.abysamross@ibm.com>
Signed-off-by: Thomas Huth <thuth@redhat.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 b438d63c444..3166b91c461 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.53.0



  reply	other threads:[~2026-03-02 12:34 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-02 12:34 [PULL 00/10] microblazeel removal, improved docker detection, etc Thomas Huth
2026-03-02 12:34 ` Thomas Huth [this message]
2026-03-02 12:34 ` [PULL 02/10] tests/functional: Make sure test case .py files are executable Thomas Huth
2026-03-02 12:34 ` [PULL 03/10] tests/functional: Remove the microblazeel test Thomas Huth
2026-03-02 12:34 ` [PULL 04/10] tests/qtest: Remove the microblazeel target from the qtests Thomas Huth
2026-03-02 12:34 ` [PULL 05/10] gitlab-ci: Remove the microblazeel target from the CI jobs Thomas Huth
2026-03-02 12:34 ` [PULL 06/10] Remove the qemu-system-microblazeel target from the build Thomas Huth
2026-03-02 12:34 ` [PULL 07/10] tests/docker: improve handling of docker probes Thomas Huth
2026-03-02 12:34 ` [PULL 08/10] tests/docker: add support for podman remote access Thomas Huth
2026-03-02 12:34 ` [PULL 09/10] tests/docker: allow display of docker output Thomas Huth
2026-03-02 12:34 ` [PULL 10/10] gitlab: ensure docker output is always displayed in CI Thomas Huth
2026-03-03  9:43 ` [PULL 00/10] microblazeel removal, improved docker detection, etc Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260302123413.274700-2-thuth@redhat.com \
    --to=thuth@redhat.com \
    --cc=abysamross@ibm.com \
    --cc=alifm@linux.ibm.com \
    --cc=farman@linux.ibm.com \
    --cc=mjrosato@linux.ibm.com \
    --cc=pasic@linux.ibm.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.