public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: Chaitanya Kulkarni <ckulkarnilinux@gmail.com>
Cc: will@kernel.org, robin.murphy@arm.com, joro@8bytes.org,
	robin.clark@oss.qualcomm.com,
	linux-arm-kernel@lists.infradead.org, kch@nvidia.com,
	stable@vger.kernel.org
Subject: Re: [PATCH] iommu/io-pgtable-arm: fix size_t signedness bug in unmap path
Date: Mon, 5 Jan 2026 15:07:16 -0400	[thread overview]
Message-ID: <20260105190716.GB193546@nvidia.com> (raw)
In-Reply-To: <20251219232858.51902-1-ckulkarnilinux@gmail.com>

On Fri, Dec 19, 2025 at 03:28:58PM -0800, Chaitanya Kulkarni wrote:
> __arm_lpae_unmap() returns size_t but was returning -ENOENT (negative
> error code) when encountering an unmapped PTE. Since size_t is unsigned,
> -ENOENT (typically -2) becomes a huge positive value (0xFFFFFFFFFFFFFFFE
> on 64-bit systems).
> 
> This corrupted value propagates through the call chain:
>   __arm_lpae_unmap() returns -ENOENT as size_t
>   -> arm_lpae_unmap_pages() returns it
>   -> __iommu_unmap() adds it to iova address
>   -> iommu_pgsize() triggers BUG_ON due to corrupted iova
> 
> This can cause IOVA address overflow in __iommu_unmap() loop and
> trigger BUG_ON in iommu_pgsize() from invalid address alignment.
> 
> Fix by returning 0 instead of -ENOENT. The WARN_ON already signals
> the error condition, and returning 0 (meaning "nothing unmapped")
> is the correct semantic for size_t return type. This matches the
> behavior of other io-pgtable implementations (io-pgtable-arm-v7s,
> io-pgtable-dart) which return 0 on error conditions.
> 
> Fixes: 3318f7b5cefb ("iommu/io-pgtable-arm: Add quirk to quiet WARN_ON()")
> Cc: stable@vger.kernel.org
> Signed-off-by: Chaitanya Kulkarni <ckulkarnilinux@gmail.com>
> ---
>  drivers/iommu/io-pgtable-arm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>

At least the iommu_pgsize() path runs with !IO_PGTABLE_QUIRK_NO_WARN
and we don't hit that WARN_ON() before the return, but the GPU folks
using this NO_WARN path might have an issue so it should be fixed..

Jason

  parent reply	other threads:[~2026-01-05 19:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-19 23:28 [PATCH] iommu/io-pgtable-arm: fix size_t signedness bug in unmap path Chaitanya Kulkarni
2025-12-20 14:35 ` Rob Clark
2026-01-05 19:07 ` Jason Gunthorpe [this message]
2026-01-05 21:25 ` Will Deacon
2026-01-15 22:08   ` Chaitanya Kulkarni

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=20260105190716.GB193546@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=ckulkarnilinux@gmail.com \
    --cc=joro@8bytes.org \
    --cc=kch@nvidia.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=robin.clark@oss.qualcomm.com \
    --cc=robin.murphy@arm.com \
    --cc=stable@vger.kernel.org \
    --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