From: Jason Gunthorpe <jgg@nvidia.com>
To: Yiming Qian <yimingqian591@gmail.com>,
David Hildenbrand <david@kernel.org>,
Vivek Kasireddy <vivek.kasireddy@intel.com>
Cc: Kevin Tian <kevin.tian@intel.com>, Joerg Roedel <joro@8bytes.org>,
Will Deacon <will@kernel.org>,
Robin Murphy <robin.murphy@arm.com>,
iommu@lists.linux.dev, linux-kernel@vger.kernel.org,
keenanat2000@gmail.com, linux-mm@kvack.org,
Christoph Hellwig <hch@lst.de>,
John Hubbard <jhubbard@nvidia.com>, Peter Xu <peterx@redhat.com>
Subject: Re: [PATCH] iommu/iommufd: Require write access for writable MAP_FILE mappings
Date: Sun, 7 Jun 2026 09:09:35 -0300 [thread overview]
Message-ID: <20260607120935.GG1962447@nvidia.com> (raw)
In-Reply-To: <20260607085320.73274-1-yimingqian591@gmail.com>
On Sun, Jun 07, 2026 at 08:53:18AM +0000, Yiming Qian wrote:
> IOMMU_IOAS_MAP_FILE pins folios from a shmem/tmpfs or hugetlb file and
> uses them as the backing storage for an IOAS mapping. When userspace sets
> IOMMU_IOAS_MAP_WRITEABLE, the resulting IOMMU PTEs allow DMA writes to the
> file-backed folios.
This looks like an issue with the API design in memfd_pin_folios(),
all users would have a similar bug I think.
I don't know much about memfd but this seems like a legitimate issue.
Add those involved with gup.c and the patch adding memfd_pin_folios()
> {
> struct iopt_pages *pages;
> + int rc;
> +
> + if (writable) {
> + if (!(file->f_mode & FMODE_WRITE))
> + return ERR_PTR(-EPERM);
> +
> + rc = mapping_map_writable(file->f_mapping);
> + if (rc)
> + return ERR_PTR(rc);
> + }
We probably need some kind of companion API for memfd_pin_folios(), a
start/pin/destroy kind of thing to manage this?
It should not be open coded like this.
Jason
parent reply other threads:[~2026-06-07 12:09 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <20260607085320.73274-1-yimingqian591@gmail.com>]
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=20260607120935.GG1962447@nvidia.com \
--to=jgg@nvidia.com \
--cc=david@kernel.org \
--cc=hch@lst.de \
--cc=iommu@lists.linux.dev \
--cc=jhubbard@nvidia.com \
--cc=joro@8bytes.org \
--cc=keenanat2000@gmail.com \
--cc=kevin.tian@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=peterx@redhat.com \
--cc=robin.murphy@arm.com \
--cc=vivek.kasireddy@intel.com \
--cc=will@kernel.org \
--cc=yimingqian591@gmail.com \
/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