From: Niklas Schnelle <schnelle@linux.ibm.com>
To: Cam Miller <cam@linux.ibm.com>,
jpb@kernel.org, joro@8bytes.org, will@kernel.org
Cc: robin.murphy@arm.com, iommu@lists.linux.dev,
virtualization@lists.linux.dev, linux-kernel@vger.kernel.org,
mjrosato@linux.ibm.com
Subject: Re: [RFC linux v1 1/3] iommu/virtio: Fix out-of-order teardown in viommu_remove()
Date: Wed, 25 Nov 2026 15:59:50 +0100 [thread overview]
Message-ID: <a79cdc1ece955a62375d5b0f832267158d68aeff.camel@linux.ibm.com> (raw)
In-Reply-To: <20261124155410.768743-2-cam@linux.ibm.com>
On Tue, 2026-11-24 at 10:54 -0500, Cam Miller wrote:
> Fix bug in viommu_remove() by swapping out-of-order IOMMU unregistration
> and sysfs removal steps.
>
> Other IOMMU drivers all call iommu_device_unregister() before
> iommu_device_sysfs_remove(). Before this change, viommu_remove() had
> incorrectly reversed this ordering, leading to the following kernel
> oops.
>
> BUG: kernel NULL pointer dereference, address: 0000000000000030
> ...snip...
> RIP: 0010:sysfs_remove_link_from_group+0x10/0x40
> ...snip..
> Call Trace:
> <TASK>
> ...snip...
> ? sysfs_remove_link_from_group+0x10/0x40
> iommu_deinit_device+0x2a/0xe0
> __iommu_group_remove_device+0xb0/0xe0
> ? __pfx_remove_iommu_group+0x10/0x10
> remove_iommu_group+0x35/0x60
> bus_for_each_dev+0x83/0xd0
> iommu_device_unregister+0x3d/0xb0
> viommu_remove+0x25/0x60
> virtio_dev_remove+0x3c/0x90
> ...snip...
>
> iommu_device_sysfs_remove() will set iommu->dev = NULL after tearing
> down the corresponding sysfs entry. Then iommu_device_unregister() will
> iterate over every endpoint device attached to the IOMMU and reference
> the null iommu->dev pointer, specifically via call
> sysfs_remove_link_from_group(&iommu->dev->kobj, ...).
>
> Fixes: edcd69ab9a32 ("iommu: Add virtio-iommu driver")
> Signed-off-by: Cam Miller <cam@linux.ibm.com>
> ---
> drivers/iommu/virtio-iommu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iommu/virtio-iommu.c b/drivers/iommu/virtio-iommu.c
> index 587fc13197f1..a08474eeed58 100644
> --- a/drivers/iommu/virtio-iommu.c
> +++ b/drivers/iommu/virtio-iommu.c
> @@ -1254,8 +1254,8 @@ static void viommu_remove(struct virtio_device *vdev)
> {
> struct viommu_dev *viommu = vdev->priv;
>
> - iommu_device_sysfs_remove(&viommu->iommu);
> iommu_device_unregister(&viommu->iommu);
> + iommu_device_sysfs_remove(&viommu->iommu);
>
> /* Stop all virtqueues */
> virtio_reset_device(vdev);
Looks good to me. Thanks!
Reviewed-by: Niklas Schnelle <schnelle@linux.ibm.com>
next prev parent reply other threads:[~2026-11-25 15:01 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 15:54 [RFC linux v1 0/3] iommu/virtio: fix remove Cam Miller
2026-11-24 15:54 ` [RFC linux v1 1/3] iommu/virtio: Fix out-of-order teardown in viommu_remove() Cam Miller
2026-11-25 14:59 ` Niklas Schnelle [this message]
2026-11-24 15:54 ` [RFC linux v1 2/3] iommu/virtio: Prevent driver unbind via sysfs Cam Miller
2026-11-25 20:14 ` Niklas Schnelle
2026-11-24 15:54 ` [RFC linux v1 3/3] iommu/virtio: Add device links for endpoints Cam Miller
2026-11-25 20:31 ` Niklas Schnelle
2026-11-27 22:17 ` Jean-Philippe Brucker
2026-11-24 16:04 ` [RFC linux v1 0/3] iommu/virtio: fix remove sashiko-bot
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=a79cdc1ece955a62375d5b0f832267158d68aeff.camel@linux.ibm.com \
--to=schnelle@linux.ibm.com \
--cc=cam@linux.ibm.com \
--cc=iommu@lists.linux.dev \
--cc=joro@8bytes.org \
--cc=jpb@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mjrosato@linux.ibm.com \
--cc=robin.murphy@arm.com \
--cc=virtualization@lists.linux.dev \
--cc=will@kernel.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.