From: "Li,Rongqing" <lirongqing@baidu.com>
To: Jason Gunthorpe <jgg@ziepe.ca>, Logan Gunthorpe <logang@deltatee.com>
Cc: Robin Murphy <robin.murphy@arm.com>,
Joerg Roedel <joro@8bytes.org>, "Will Deacon" <will@kernel.org>,
Lu Baolu <baolu.lu@linux.intel.com>,
"Luis Chamberlain" <mcgrof@kernel.org>,
Leon Romanovsky <leon@kernel.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"iommu@lists.linux.dev" <iommu@lists.linux.dev>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"hch@lst.de" <hch@lst.de>
Subject: 答复: 答复: [外部邮件] Re: [PATCH] iommu/dma-iommu: Fix wrong scatterlist length assignment in P2PDMA path
Date: Thu, 11 Jun 2026 12:21:27 +0000 [thread overview]
Message-ID: <f9d9a6b67cf84073a7dc453c277dcd9f@baidu.com> (raw)
In-Reply-To: <20260611115938.GF1066031@ziepe.ca>
> > Hi Li,
> >
> > On 2026-06-02 00:12, Li,Rongqing wrote:
> > >>> Fixes: a25e7962db ("PCI/P2PDMA: Refactor the p2pdma mapping
> > >>> helpers")
> > >>> Signed-off-by: Li RongQing <lirongqing@baidu.com>
> > >>
> > >> Hmm, I thought I had tested this stuff pretty thoroughly so I'm
> > >> surprised I missed that. But I guess seeing the users of these
> > >> specifically don't allow mixing with anonymous memory the vast
> > >> majority of tests would only have one segment.
> > >>
> > >> Can you confirm that you've reproduced and tested this and it
> > >> actually fixes a bug? Not just seeing something that looks strange.
> > >> I have a vague feeling it was intentional but looking at the code it looks
> wrong to me too.
> > >>
> > >> Thanks,
> > >>
> > > Cc: Christoph Hellwig
> > >
> > > Thanks for your feedback!
> > >
> > > This was found via code inspection. You are right that if nents == 1, or if
> nents > 1 but all segments happen to have the exact same length, this typo
> remains benign by pure coincidence.
> > >
> > > However, for a multi-segment scatterlist with varying lengths (e.g., a short
> 2KB head segment followed by standard 4KB segments), sg_dma_len(s) will
> mistakenly assign the 2KB head length to all subsequent 4KB segments. This
> will inevitably lead to silent data truncation or IOMMU page faults.
> > >
> > > Since sg_phys(s) correctly takes the current segment's address,
> sg_dma_len(s) should definitely use s->length to match it.
> > >
> > > I don't have a specific P2PDMA test rig to force multi-segment lists on
> hand right now, but the typo and its impact on varied segment lengths seem
> deterministic.
> >
> > Ok, yeah, I think you are correct. My tests that ran multiple segments
> > happened to all have the same length. But I don't have the hardware I
> > used at the moment so I can't test it either.
> >
> > Reviewed-by: Logan Gunthorpe <logang@deltatee.com>
>
> Rongqing can you please send a proper series with both of these fixes
> without threading so Joerg can pick them up?
>
I think there is no need to resend.
This patch needs to be merged by Joerg
Another patch has already been merged into the DMA library.
https://git.kernel.org/pub/scm/linux/kernel/git/mszyprowski/linux.git/commit/?h=dma-mapping-fixes&id=560000d619ef162568746ce287f0c725e24ea967
[Li,Rongqing]
> Thanks,
> Jason
next prev parent reply other threads:[~2026-06-11 12:23 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-30 11:28 lirongqing
2026-06-01 16:02 ` Logan Gunthorpe
2026-06-02 6:12 ` 答复: [外部邮件] " Li,Rongqing
2026-06-02 9:48 ` Li,Rongqing
2026-06-02 15:51 ` Logan Gunthorpe
2026-06-02 15:42 ` Logan Gunthorpe
2026-06-11 11:59 ` Jason Gunthorpe
2026-06-11 12:21 ` Li,Rongqing [this message]
2026-06-12 13:23 ` 答复: " Joerg Roedel
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=f9d9a6b67cf84073a7dc453c277dcd9f@baidu.com \
--to=lirongqing@baidu.com \
--cc=baolu.lu@linux.intel.com \
--cc=bhelgaas@google.com \
--cc=hch@lst.de \
--cc=iommu@lists.linux.dev \
--cc=jgg@ziepe.ca \
--cc=joro@8bytes.org \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=logang@deltatee.com \
--cc=mcgrof@kernel.org \
--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