From: Mostafa Saleh <smostafa@google.com>
To: Nicolin Chen <nicolinc@nvidia.com>
Cc: linux-kernel@vger.kernel.org, iommu@lists.linux.dev,
linux-arm-kernel@lists.infradead.org, will@kernel.org,
robin.murphy@arm.com, joro@8bytes.org, jgg@ziepe.ca,
praan@google.com
Subject: Re: [PATCH 2/7] iommu/arm-smmu-v3: Prevent rbtree corruption from duplicate streams
Date: Tue, 1 Sep 2026 08:44:49 +0000 [thread overview]
Message-ID: <apaQgcURYAuzBpAy@google.com> (raw)
In-Reply-To: <apGudts94pqFL20G@nvidia.com>
On Fri, Aug 28, 2026 at 08:51:18AM -0700, Nicolin Chen wrote:
> On Fri, Aug 28, 2026 at 12:53:37PM +0000, Mostafa Saleh wrote:
> > In handling PCI devices with duplicate IDs, arm_smmu_insert_master()
> > will continue the loop skipping the duplicate sids insertion in the
> > rbtree.
> > However, in the error path of arm_smmu_insert_master() and in
> > arm_smmu_remove_master(), the code loops over all fwspec->num_ids and
> > calls rb_erase() unconditionally.
> >
> > For the duplicate streams, the node is zero allocated including the
> > parent pointer "__rb_parent_color". That means rb_erase() will think
> > that this node is root and it will corrupt the tree which includes
> > other masters not being removed.
> >
> > Fix this by initializing those nodes with RB_CLEAR_NODE() and check
> > if they are empty before erasing.
> >
> > Fixes: cdf315f907d4 ("iommu/arm-smmu-v3: Maintain a SID->device structure")
> > Reported-by: Sashiko <>
> > Signed-off-by: Mostafa Saleh <smostafa@google.com>
>
> I submitted a similar patch a while ago :)
> https://lore.kernel.org/linux-iommu/9136477b9c737a50cecc38f2ee6704a01510169a.1783044582.git.nicolinc@nvidia.com/
Oh, I missed that, I haven't looked at this series. I beleive this
bug exists in the current tree so it is better to send separately.
Anyway, I ok dropping this patch if you want to re-send yours.
Thanks,
Mostafa
>
> And I think the fix tag, as mine posted, should be:
> Fixes: b00d24997a11 ("iommu/arm-smmu-v3: Fix iommu_device_probe bug due to duplicated stream ids")
>
> Before that commit, a duplicated SID gets -EINVAL and errors out.
>
> Thanks
> Nicolin
next prev parent reply other threads:[~2026-09-01 8:45 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-28 12:53 [PATCH 0/7] iommu/arm-smmu-v3: Fixes reported by Sashiko Mostafa Saleh
2026-08-28 12:53 ` [PATCH 1/7] iommu/arm-smmu-v3: Ensure L2 tables are visible before L1 ptrs Mostafa Saleh
2026-08-28 14:27 ` Jason Gunthorpe
2026-08-28 16:03 ` Nicolin Chen
2026-08-28 12:53 ` [PATCH 2/7] iommu/arm-smmu-v3: Prevent rbtree corruption from duplicate streams Mostafa Saleh
2026-08-28 14:27 ` Jason Gunthorpe
2026-08-28 15:51 ` Nicolin Chen
2026-09-01 8:44 ` Mostafa Saleh [this message]
2026-08-28 12:53 ` [PATCH 3/7] iommu/arm-smmu-v3-iommufd: Fix error path in arm_vsmmu_cache_invalidate() Mostafa Saleh
2026-08-28 14:27 ` Jason Gunthorpe
2026-09-01 8:47 ` Mostafa Saleh
2026-08-28 12:53 ` [PATCH 4/7] iommu/arm-smmu-v3-test: Fix arm_smmu_v3_test_debug_print_used_bits() Mostafa Saleh
2026-08-28 14:27 ` Jason Gunthorpe
2026-08-28 16:12 ` Nicolin Chen
2026-08-28 12:53 ` [PATCH 5/7] iommu/arm-smmu-v3-test: Add missing error checks for inv array Mostafa Saleh
2026-08-28 14:27 ` Jason Gunthorpe
2026-09-01 8:51 ` Mostafa Saleh
2026-08-28 12:53 ` [PATCH 6/7] iommu/arm-smmu-v3-test: Fix OOB in arm_smmu_v3_invs_test_verify() Mostafa Saleh
2026-08-28 14:27 ` Jason Gunthorpe
2026-08-28 16:14 ` Nicolin Chen
2026-08-28 12:53 ` [PATCH 7/7] iommu/arm-smmu-v3-test: Fix UBSAN error Mostafa Saleh
2026-08-28 14:27 ` Jason Gunthorpe
2026-08-28 16:14 ` Nicolin Chen
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=apaQgcURYAuzBpAy@google.com \
--to=smostafa@google.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@ziepe.ca \
--cc=joro@8bytes.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nicolinc@nvidia.com \
--cc=praan@google.com \
--cc=robin.murphy@arm.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox