mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Robin Murphy <robin.murphy@arm.com>
To: Nicolin Chen <nicolinc@nvidia.com>,
	"Peng Fan (OSS)" <peng.fan@oss.nxp.com>
Cc: Will Deacon <will@kernel.org>,
	"Joerg Roedel (AMD)" <joro@8bytes.org>,
	Jean-Philippe Brucker <jpb@kernel.org>,
	Jason Gunthorpe <jgg@ziepe.ca>,
	Thierry Reding <thierry.reding@kernel.org>,
	Krishna Reddy <vdumpa@nvidia.com>,
	Jonathan Hunter <jonathanh@nvidia.com>,
	linux-arm-kernel@lists.infradead.org, iommu@lists.linux.dev,
	linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org,
	Peng Fan <peng.fan@nxp.com>
Subject: Re: [PATCH RFC v5 2/6] iommu/arm-smmu-v3: Allocate streams individually
Date: Thu, 8 Oct 2026 14:21:43 +0100	[thread overview]
Message-ID: <7626c1be-305e-478a-a017-548341d25419@arm.com> (raw)
In-Reply-To: <asbTEPMJvm9T00c+@nvidia.com>

On 08/10/2026 12:17 am, Nicolin Chen wrote:
> On Tue, Oct 06, 2026 at 08:19:08PM +0800, Peng Fan (OSS) wrote:
>> From: Peng Fan <peng.fan@nxp.com>
>>
>> Change master->streams from an embedded array of struct arm_smmu_stream
>> to an array of pointers, with each stream individually allocated.
>>
>> Prepare for shared-SID support where multiple masters will point to the
>> same stream object. With embedded structs, sharing requires duplicating
>> stream state and manually keeping fields like ste_installed in sync.
>> With individually allocated streams, a sharing master can simply point to
>> the existing stream.
>>
>> The sort comparator is updated to dereference the pointer indirection.
>>
>> No functional change.
>>
>> Suggested-by: Nicolin Chen <nicolinc@nvidia.com>
>> Link: https://lore.kernel.org/linux-iommu/arG6hmng3NddGEHm@nvidia.com/
>> Assisted-by: LLM
>> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> 
> Reviewed-by: Nicolin Chen <nicolinc@nvidia.com>
> 
>> diff --git a/drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c b/drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c
>> index 6644075c1431e..bc62a3d5a63f9 100644
>> --- a/drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c
>> +++ b/drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c
>> @@ -1257,7 +1257,7 @@ static int tegra241_vintf_init_vsid(struct iommufd_vdevice *vdev)
>>   	struct arm_smmu_master *master = dev_iommu_priv_get(dev);
>>   	struct tegra241_vintf *vintf = viommu_to_vintf(vdev->viommu);
>>   	struct tegra241_vintf_sid *vsid = vdev_to_vsid(vdev);
>> -	struct arm_smmu_stream *stream = &master->streams[0];
>> +	struct arm_smmu_stream *stream = master->streams[0];
> 
> Sashiko raised a concern of an out-of-bounds pointer dereference.
> 
> Though it's practically not possible, probably it would be safer
> to move this behind the check:
> 
> 	if (master->num_streams != 1)
> 		return -EOPNOTSUPP;

The IORT path unconditionally adds 1 ID via acpi_iommu_fwspec_init(), so 
num_streams==0 could only potentially happen with DT if a fwspec was 
parsed using #iommu-cells==0, except arm_smmu_device_dt_probe() would 
refuse to probe the entire SMMU if that was anything other than 1, so 
no, this definitely cannot ever be out of bounds.

Thanks,
Robin.

  reply	other threads:[~2026-10-08 13:21 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-06 12:19 [PATCH RFC v5 0/6] iommu/arm-smmu-v3: Support shared Stream IDs Peng Fan (OSS)
2026-10-06 12:19 ` [PATCH RFC v5 1/6] iommu/arm-smmu-v3: Don't rb_erase() a never-inserted stream node Peng Fan (OSS)
2026-10-06 12:19 ` [PATCH RFC v5 2/6] iommu/arm-smmu-v3: Allocate streams individually Peng Fan (OSS)
2026-10-07 23:17   ` Nicolin Chen
2026-10-08 13:21     ` Robin Murphy [this message]
2026-10-08 17:32       ` Nicolin Chen
2026-10-06 12:19 ` [PATCH RFC v5 3/6] iommu/arm-smmu-v3: Delay stream allocation to inside the mutex Peng Fan (OSS)
2026-10-07 23:55   ` Nicolin Chen
2026-10-08 13:50     ` Peng Fan
2026-10-08 12:55   ` Robin Murphy
2026-10-08 13:49     ` Peng Fan
2026-10-06 12:19 ` [PATCH RFC v5 4/6] iommu/arm-smmu-v3: Support shared SIDs in insert/remove_master Peng Fan (OSS)
2026-10-08  1:02   ` Nicolin Chen
2026-10-08 14:07     ` Peng Fan
2026-10-06 12:19 ` [PATCH RFC v5 5/6] iommu/arm-smmu-v3: Group aliasing devices into the same IOMMU group Peng Fan (OSS)
2026-10-06 12:19 ` [PATCH RFC v5 6/6] iommu/arm-smmu-v3: Wire up shared-SID STE ordering and feature gating Peng Fan (OSS)
2026-10-08  1:29   ` 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=7626c1be-305e-478a-a017-548341d25419@arm.com \
    --to=robin.murphy@arm.com \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@ziepe.ca \
    --cc=jonathanh@nvidia.com \
    --cc=joro@8bytes.org \
    --cc=jpb@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=nicolinc@nvidia.com \
    --cc=peng.fan@nxp.com \
    --cc=peng.fan@oss.nxp.com \
    --cc=thierry.reding@kernel.org \
    --cc=vdumpa@nvidia.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

all inboxes | Powered by JetHome®