From: Jason Gunthorpe <jgg@ziepe.ca>
To: Peiyang He <peiyang_he@smail.nju.edu.cn>
Cc: "Tian, Kevin" <kevin.tian@intel.com>,
"iommu@lists.linux.dev" <iommu@lists.linux.dev>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"joro@8bytes.org" <joro@8bytes.org>,
"will@kernel.org" <will@kernel.org>,
"robin.murphy@arm.com" <robin.murphy@arm.com>,
"syzkaller@googlegroups.com" <syzkaller@googlegroups.com>
Subject: Re: [BUG] iommufd/selftest: KASAN slab-use-after-free in iommu_report_device_fault
Date: Mon, 10 Aug 2026 17:02:15 -0300 [thread overview]
Message-ID: <20260810200215.GA518032@ziepe.ca> (raw)
In-Reply-To: <ACFE02E91C9C4025+1b43727a-2964-4c96-8a6b-bf732a7c5620@smail.nju.edu.cn>
On Tue, Jul 28, 2026 at 01:32:09PM +0800, Peiyang He wrote:
> On 2026/7/27 17:41, Tian, Kevin wrote:
> >> From: Peiyang He <peiyang_he@smail.nju.edu.cn>
> >> Sent: Wednesday, July 22, 2026 5:52 PM
> >>
> > [...]
> > > Since iommu_attach_handle_get() explicitly says that the caller should be
> >> responsible for "synchronize the call of iommu_attach_handle_get()
> >> with domain attachment and detachment", maybe we shouldn't add extra
> >> lifetime
> >> management mechanism around iommu_attach_handle, instead we should
> >> fix this at the caller side.
> >>
> >> Fault report can run concurrently with PASID detach and replacement, but
> >> before the old attach handle is removed and freed, mockdev must block new
> >> reports
> >> for that PASID and wait for in-flight iommu_report_device_fault() calls to
> >> finish.
> >>
> >
> > yes the mock driver should drain in-flight fault requests before the
> > actual detachment, just like other iommu drivers do.
>
> Hi Kevin,
>
> Thanks for your reply. I looked into the code in more detail. Would this
> approach make sense?
>
> In iommufd_test_trigger_iopf(), call iommu_report_device_fault() under the protection
> of idev->igroup->lock. Since detach and replace also require the same lock, they can
> be serialized with fault reporting. This would ensure that a mock fault report either
> completes before detach/replace starts, or starts only after the old handle has been removed.
> Thus it should prevent the UAF.
>
> Would this simple serialization meet the design intention of mock dev? Or would you prefer
> an explicit quiesce/drain mechanism instead?
The mock driver should follow the expected design of a real driver, so
I'd put an internal rwsem or something like that to protect this
Jason
next prev parent reply other threads:[~2026-08-10 20:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-22 9:52 Peiyang He
2026-07-27 9:41 ` Tian, Kevin
2026-07-28 5:32 ` Peiyang He
2026-08-10 20:02 ` Jason Gunthorpe [this message]
2026-08-11 9:59 ` Peiyang He
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=20260810200215.GA518032@ziepe.ca \
--to=jgg@ziepe.ca \
--cc=iommu@lists.linux.dev \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peiyang_he@smail.nju.edu.cn \
--cc=robin.murphy@arm.com \
--cc=syzkaller@googlegroups.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®