From: Greg KH <gregkh@linuxfoundation.org>
To: Jinhui Guo <guojinhui.liam@bytedance.com>
Cc: stable@vger.kernel.org, joro@8bytes.org,
linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org
Subject: Re: [PATCH 5.4.y] iommu/amd: Fix 2G+ memory-size overflow in unmap_sg()
Date: Thu, 30 Oct 2025 12:50:46 +0100 [thread overview]
Message-ID: <2025103008-prideful-trunks-8562@gregkh> (raw)
In-Reply-To: <20251030111956.308-1-guojinhui.liam@bytedance.com>
On Thu, Oct 30, 2025 at 07:19:56PM +0800, Jinhui Guo wrote:
> Since npages is declared as int, shifting npages << PAGE_SHIFT
> for a 2 GB+ scatter-gather list overflows before reaching
> __unmap_single(), leading to incorrect unmapping.
>
> A 2 GB region equals 524,288 pages. The expression
> npages << PAGE_SHIFT yields 0x80000000, which exceeds
> INT32_MAX (0x7FFFFFFF). Casting to size_t therefore produces
> 0xFFFFFFFF80000000, an overflow value that breaks the unmap
> size calculation.
>
> Fix the overflow by casting npages to size_t before the
> PAGE_SHIFT left-shift.
>
> Fixes: 89736a0ee81d ("Revert "iommu/amd: Remove the leftover of bypass support"")
> Cc: stable@vger.kernel.org # 5.4
> Signed-off-by: Jinhui Guo <guojinhui.liam@bytedance.com>
> ---
>
> Hi,
>
> We hit an IO_PAGE_FAULT on AMD with 5.4-stable when mapping a
> 2 GB scatter-gather list.
>
> The fault is caused by an overflow in unmap_sg(): on stable-5.4
> the SG-mmap path was never moved to the IOMMU framework, so the
> bug exists only in this branch.
What upstream commit fixed this? And why not just backport that?
And as this kernel is only going to be "alive" for one more month (i.e.
probably one more release), why care about it now at all? Shouldn't you
already have moved your whole infrastructure off of it by now?
Especially because, as of right now, release 5.4.301 contains 1527
unfixed CVEs? Surely that should mean something? :)
thanks,
greg k-h
prev parent reply other threads:[~2025-10-30 11:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-30 11:19 [PATCH 5.4.y] iommu/amd: Fix 2G+ memory-size overflow in unmap_sg() Jinhui Guo
2025-10-30 11:50 ` Greg KH [this message]
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=2025103008-prideful-trunks-8562@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=guojinhui.liam@bytedance.com \
--cc=iommu@lists.linux-foundation.org \
--cc=joro@8bytes.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.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