From: Jason Gunthorpe <jgg@ziepe.ca>
To: Sina Hassani <sina@openai.com>
Cc: kevin.tian@intel.com, joro@8bytes.org, will@kernel.org,
robin.murphy@arm.com, iommu@lists.linux.dev,
linux-kernel@vger.kernel.org, Aaron Wisner <awiz@openai.com>,
stable@vger.kernel.org
Subject: Re: [PATCH] Fixes a race in iopt_unmap_iova_range
Date: Mon, 6 Apr 2026 19:17:43 -0300 [thread overview]
Message-ID: <20260406221743.GI2551565@ziepe.ca> (raw)
In-Reply-To: <CAAJpGJTzJZ0OgEU8NhyJ3dR1Y1V5x6CwbBjLW_kYLu+FTt9woQ@mail.gmail.com>
On Mon, Apr 06, 2026 at 03:00:36PM -0700, Sina Hassani wrote:
> Bug: iopt_unmap_iova_range releases the lock on iova_rwsem inside the loop
> body when getting to the more expensive unmap operations. This is fine on
> its own except the loop condition is based on the first area that matches
> the unmap address range. If a concurrent call to map picks an area that was
> unmapped in the previous iterations, this loop will try to mistakenly unmap
> them.
Does this mean you are also using the automatic IOVA allocator?
It is certainly an error for userspace to be mapping to IOVA that is
under concurrent unmap.
> io_pagetable *iopt, unsigned long start,
> iopt_put_pages(pages);
>
> unmapped_bytes += area_last - area_first + 1;
> + start = area_last + 1;
This seems like a reasonable solution, but area_last + 1 can overflow
and that needs to be delt with too.
/* Do not reconsider things already unmapped in case of concurrent allocation */
if (area_last != last)
start = area_last + 1;
?
Jason
next prev parent reply other threads:[~2026-04-06 22:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-06 22:00 Sina Hassani
2026-04-06 22:17 ` Jason Gunthorpe [this message]
2026-04-06 23:07 ` Sina Hassani
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=20260406221743.GI2551565@ziepe.ca \
--to=jgg@ziepe.ca \
--cc=awiz@openai.com \
--cc=iommu@lists.linux.dev \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=robin.murphy@arm.com \
--cc=sina@openai.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
all inboxes | Powered by JetHome®