From: Alex Mastro <amastro@fb.com>
To: Mostafa Saleh <smostafa@google.com>
Cc: Alex Mastro <amastro@fb.com>,
"Tian, Kevin" <kevin.tian@intel.com>,
"Keith Busch" <kbusch@kernel.org>, Jason Gunthorpe <jgg@ziepe.ca>,
Alex Williamson <alex.williamson@redhat.com>,
Bjorn Helgaas <bhelgaas@google.com>,
"David Reiss" <dreiss@meta.com>, Joerg Roedel <joro@8bytes.org>,
Leon Romanovsky <leon@kernel.org>,
Li Zhe <lizhe.67@bytedance.com>,
Mahmoud Adam <mngyadam@amazon.de>,
Philipp Stanner <pstanner@redhat.com>,
Robin Murphy <robin.murphy@arm.com>,
"Kasireddy, Vivek" <vivek.kasireddy@intel.com>,
"Will Deacon" <will@kernel.org>,
Yunxiang Li <Yunxiang.Li@amd.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"iommu@lists.linux.dev" <iommu@lists.linux.dev>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>
Subject: Re: [TECH TOPIC] vfio, iommufd: Enabling user space drivers to vend more granular access to client processes
Date: Mon, 22 Sep 2025 10:46:23 -0700 [thread overview]
Message-ID: <20250922174630.3123741-1-amastro@fb.com> (raw)
In-Reply-To: <aNETcPELm72zlkwR@google.com>
On Mon, Sep 22, 2025 at 09:14:24AM +0000, Mostafa Saleh wrote:
> On Fri, Sep 19, 2025 at 07:00:04AM +0000, Tian, Kevin wrote:
> > the proposal includes two parts: BAR access and IOMMU mapping. For
> > the latter looks the intention is more around releasing resource. But
> > the former sounds more like a security enhancement - instead of
> > granting the client full access to the entire device it aims to expose
> > only a region of BAR resource necessary into guest. Then as Jason
> > questioned what is the value of doing so when one client can program
> > arbitrary DMA address into the exposed BAR region to attack mapped
> > memory of other clients and the USD... there is no hw isolation
> > within a partitioned IOAS unless the device supports PASID then
> > each client can be associated to its own IOAS space.
>
> That’s also my opinion, it seems that PASIDs are not supported in
> that case, that’s why the clients share the same IOVA address space,
> instead of each one having their own.
Yes, we do have cases where PASID is not supported by our hardware.
> In that case I think as all of this is cooperative and can’t be enforced,
> one process can corrupt another process memory that is mapped the IOMMU.
In systems lacking PASID, some degree of enforcement would still be possible via
USD and device policies. In a ~similar way to how an in-kernel driver wanting
to accomplish our same goals (enabling a client and device able to access each
other's memory directly) would presumably need to enforce this.
I have been thinking along the following lines:
Imagine that we want the client and device to communicate with each other
directly via queues in each other's memory, bypassing interaction with the
driver.
As part of granting access to a client process:
- The USD allocates some IOAS slice for the client.
- The USD prepares a restricted IOMMU fd to be shared with the client which
only has mapping permissions to the IOAS slice.
- The USD configures the device: "DMA initiated across this region of
client-accessible BAR is only allowed to target the client's IOAS slice."
- The USD vends the client a dma-buf exposing a view of only that client's queue
space, along with the restricted IOMMU fd.
Given the above setup, barring bugs in the USD, or the device hardware/firmware,
it should be impossible for one client to corrupt another client's address
space, since the side-effects it is able to create by accessing its BAR slice
have been constrained by a combination of USD + device policy.
Next, we need to address revocation. The USD needs to be able revoke:
1) client access to BAR memory
2) device access to client memory
Issue (2) was touched on in the original tech topic email, but we haven't
covered (1) yet.
For (1) to be possible, I think we need to grant the VFIO user (USD in this
specific case) the ability to revoke a dma-buf in a way that prevents "peer"
access to the device -- whether the peer is some other device, or a user space
client process.
Following a dma_buf_ops.mmap, I suppose that revocation would mean:
- Poisoning the dma-buf fd to disallow the creation of additional mmaps.
- Zapping the PTEs backing existing mmaps. Subsequent access to the unmapped
client address space should trigger page faults.
Thanks,
Alex
next prev parent reply other threads:[~2025-09-22 17:48 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-18 21:44 [TECH TOPIC] vfio, iommufd: Enabling user space drivers to vend more granular access to client processes Alex Mastro
2025-09-18 22:57 ` Jason Gunthorpe
2025-09-18 23:24 ` Keith Busch
2025-09-19 7:00 ` Tian, Kevin
2025-09-19 11:58 ` Jason Gunthorpe
2025-09-22 9:14 ` Mostafa Saleh
2025-09-22 17:46 ` Alex Mastro [this message]
2025-09-22 17:51 ` Jason Gunthorpe
2025-09-19 11:56 ` Jason Gunthorpe
2025-09-19 15:57 ` Alex Williamson
2025-09-19 17:14 ` Alex Mastro
2025-09-19 16:13 ` Alex Mastro
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=20250922174630.3123741-1-amastro@fb.com \
--to=amastro@fb.com \
--cc=Yunxiang.Li@amd.com \
--cc=alex.williamson@redhat.com \
--cc=bhelgaas@google.com \
--cc=dreiss@meta.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@ziepe.ca \
--cc=joro@8bytes.org \
--cc=kbusch@kernel.org \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lizhe.67@bytedance.com \
--cc=mngyadam@amazon.de \
--cc=pstanner@redhat.com \
--cc=robin.murphy@arm.com \
--cc=smostafa@google.com \
--cc=vivek.kasireddy@intel.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