From: Lu Baolu <baolu.lu@linux.intel.com>
To: Joerg Roedel <joro@8bytes.org>
Cc: "Pranjal Shrivastava" <praan@google.com>,
"Guanghui Feng" <guanghuifeng@linux.alibaba.com>,
"Michał Grzelak" <michal.grzelak@intel.com>,
"Michael Bommarito" <michael.bommarito@gmail.com>,
iommu@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: [PATCH 5/6] iommu/vt-d: Fix RB-tree corruption in probe error path
Date: Wed, 3 Jun 2026 07:34:24 +0800 [thread overview]
Message-ID: <20260602233426.357499-6-baolu.lu@linux.intel.com> (raw)
In-Reply-To: <20260602233426.357499-1-baolu.lu@linux.intel.com>
From: Pranjal Shrivastava <praan@google.com>
The info->node RB-tree member is zero-initialized via kzalloc. If
a device does not support ATS, the device_rbtree_insert() call is
skipped. If a subsequent probe step fails, the error path jumps to
device_rbtree_remove(), which misinterprets the zeroed node as
a tree root and corrupts the device RB-tree.
Fix this by explicitly initializing the RB-node as empty using
RB_CLEAR_NODE() during initialization and guarding the removal with
RB_EMPTY_NODE().
Fixes: 4f1492efb495 ("iommu/vt-d: Revert ATS timing change to fix boot failure")
Reported-by: sashiko-bot@kernel.org
Closes: https://lore.kernel.org/all/20260525205628.CD4431F000E9@smtp.kernel.org/
Suggested-by: Baolu Lu <baolu.lu@linux.intel.com>
Signed-off-by: Pranjal Shrivastava <praan@google.com>
Link: https://lore.kernel.org/r/20260531170254.60493-2-praan@google.com
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
---
drivers/iommu/intel/iommu.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index 4d0e65bc131d..849d06dfe1ae 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -157,7 +157,10 @@ static void device_rbtree_remove(struct device_domain_info *info)
unsigned long flags;
spin_lock_irqsave(&iommu->device_rbtree_lock, flags);
- rb_erase(&info->node, &iommu->device_rbtree);
+ if (!RB_EMPTY_NODE(&info->node)) {
+ rb_erase(&info->node, &iommu->device_rbtree);
+ RB_CLEAR_NODE(&info->node);
+ }
spin_unlock_irqrestore(&iommu->device_rbtree_lock, flags);
}
@@ -3254,6 +3257,7 @@ static struct iommu_device *intel_iommu_probe_device(struct device *dev)
info->dev = dev;
info->iommu = iommu;
+ RB_CLEAR_NODE(&info->node);
if (dev_is_pci(dev)) {
if (ecap_dev_iotlb_support(iommu->ecap) &&
pci_ats_supported(pdev) &&
--
2.43.0
next prev parent reply other threads:[~2026-06-02 23:36 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-02 23:34 [PATCH 0/6] [PULL REQUEST] Intel IOMMU updates for v7.2 Lu Baolu
2026-06-02 23:34 ` [PATCH 1/6] iommu/vt-d: Avoid WARNING in sva unbind path Lu Baolu
2026-06-02 23:34 ` [PATCH 2/6] iommu/vt-d: Clear Present bit before tearing down scalable-mode context entry Lu Baolu
2026-06-02 23:34 ` [PATCH 3/6] iommu/vt-d: Remove typo from pasid_pte_config_nested() Lu Baolu
2026-06-02 23:34 ` [PATCH 4/6] iommu/vt-d: Improve IOMMU fault information Lu Baolu
2026-06-02 23:34 ` Lu Baolu [this message]
2026-06-02 23:34 ` [PATCH 6/6] iommu/vt-d: Fix Use-After-Free in probe error path Lu Baolu
2026-06-04 3:44 ` [PATCH 0/6] [PULL REQUEST] Intel IOMMU updates for v7.2 Baolu Lu
2026-06-04 5:27 ` Pranjal Shrivastava
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=20260602233426.357499-6-baolu.lu@linux.intel.com \
--to=baolu.lu@linux.intel.com \
--cc=guanghuifeng@linux.alibaba.com \
--cc=iommu@lists.linux.dev \
--cc=joro@8bytes.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.bommarito@gmail.com \
--cc=michal.grzelak@intel.com \
--cc=praan@google.com \
/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.