From: Andrew Morton <akpm@linux-foundation.org>
To: mm-commits@vger.kernel.org,will@kernel.org,vivek.kasireddy@intel.com,
syzbot+7666ed2c3d42196bf7e3@syzkaller.appspotmail.com,skhawaja@google.com,
robin.murphy@arm.com,peterx@redhat.com,kevin.tian@intel.com,joro@8bytes.org,
jhubbard@nvidia.com,jgg@ziepe.ca,david@kernel.org,
xujiahao@cmss.chinamobile.com,akpm@linux-foundation.org
Subject: [merged] iommufd-only-hold-references-to-files-memfd_pin_folios-can-pin.patch removed from -mm tree
Date: Mon, 23 Nov 2026 20:46:55 -0800 [thread overview]
Message-ID: <20261124044655.CAF4D1F000C6@smtp.kernel.org> (raw)
In-Reply-To: <20261119163531.315791-1-xujiahao@cmss.chinamobile.com>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 3565 bytes --]
The quilt patch titled
Subject: iommufd: only hold references to files memfd_pin_folios() can pin
has been removed from the -mm tree. Its filename was
iommufd-only-hold-references-to-files-memfd_pin_folios-can-pin.patch
This patch was dropped because it was merged into mainline or a subsystem tree
------------------------------------------------------
From: Jiahao Xu <xujiahao@cmss.chinamobile.com>
Subject: iommufd: only hold references to files memfd_pin_folios() can pin
Date: Thu, 19 Nov 2026 16:35:31 +0800
iopt_map_file_pages() stores a reference to the file passed to
IOMMU_IOAS_MAP_FILE in the iopt_pages of the new mapping:
iopt_map_file_pages()
iopt_alloc_file_pages()
pages->file = get_file(file)
iopt_release_pages() drops that reference only when the iopt_pages is
destroyed, which for a file mapping happens while the iommufd file is
being torn down. Nothing restricts which file can be passed, so userspace
can map the iommufd file itself, or a vfio device fd bound to the same
iommufd, both of which own an iommufd_ctx reference. The reference graph
then contains a cycle and the file, the iopt_pages, the IOAS and the
iommufd_ctx are all leaked; kmemleak reports it as "memory leak in
path_openat" with the holder taken through iopt_map_file_pages().
Reverse the test instead of trying to enumerate the files that own an
iommufd_ctx: accept only the files that memfd_pin_folios() is able to pin,
which is exactly the set of files the mapping can be built from.
file_is_memfd_compatible() reports that set, so the same test can run here
before the reference is handed to iopt_pages. dma-bufs are unaffected:
they are taken by the dma_buf_get() branch above and never reach the file
branch, and iopt_pages holds the dma_buf there, not a struct file.
Link: https://patch.msgid.link/20261119163531.315791-1-xujiahao@cmss.chinamobile.com
Fixes: f4986a72d6e4 ("iommufd: Add IOMMU_IOAS_MAP_FILE")
Signed-off-by: Jiahao Xu <xujiahao@cmss.chinamobile.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reported-by: <syzbot+7666ed2c3d42196bf7e3@syzkaller.appspotmail.com>
Closes: https://syzkaller.appspot.com/bug?extid=7666ed2c3d42196bf7e3
Reviewed-by: Samiullah Khawaja <skhawaja@google.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: David Hildenbrand <david@kernel.org>
Cc: John Hubbard <jhubbard@nvidia.com>
Cc: Peter Xu <peterx@redhat.com>
Cc: Vivek Kasireddy <vivek.kasireddy@intel.com>
Cc: Kevin Tian <kevin.tian@intel.com>
Cc: Jörg Rödel <joro@8bytes.org>
Cc: Will Deacon <will@kernel.org>
Cc: Robin Murphy <robin.murphy@arm.com>
drivers/iommu/iommufd/io_pagetable.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
--- a/drivers/iommu/iommufd/io_pagetable.c~iommufd-only-hold-references-to-files-memfd_pin_folios-can-pin
+++ a/drivers/iommu/iommufd/io_pagetable.c
@@ -515,6 +515,18 @@ int iopt_map_file_pages(struct iommufd_c
if (!file)
return -EBADF;
+ /*
+ * iopt_pages keeps a reference to the file until the mapping is
+ * destroyed, so only accept the files memfd_pin_folios() is able
+ * to pin. Any other fd, in particular one that itself owns an
+ * iommufd_ctx (iommufd, vfio, ...), would put the file into a
+ * reference cycle with this iommufd and never be released.
+ */
+ if (!file_is_memfd_compatible(file)) {
+ fput(file);
+ return -EINVAL;
+ }
+
pages = iopt_alloc_file_pages(file, start_byte, start, length,
iommu_prot & IOMMU_WRITE);
fput(file);
_
Patches currently in -mm which might be from xujiahao@cmss.chinamobile.com are
next prev parent reply other threads:[~2026-11-24 4:46 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 8:35 [PATCH v2 1/2] mm/gup: add file_is_memfd_compatible() helper Jiahao Xu
2026-11-19 8:35 ` [PATCH v2 2/2] iommufd: only hold references to files memfd_pin_folios() can pin Jiahao Xu
2026-11-20 20:04 ` Samiullah Khawaja
2026-11-24 1:38 ` + iommufd-only-hold-references-to-files-memfd_pin_folios-can-pin.patch added to mm-new branch Andrew Morton
2026-11-24 4:46 ` Andrew Morton [this message]
2026-11-20 9:31 ` [PATCH v2 1/2] mm/gup: add file_is_memfd_compatible() helper David Hildenbrand (Arm)
2026-11-20 20:03 ` Samiullah Khawaja
2026-11-20 20:49 ` Jason Gunthorpe
2026-11-24 1:38 ` + mm-gup-add-file_is_memfd_compatible-helper.patch added to mm-new branch Andrew Morton
2026-11-24 2:34 ` Jiahao Xu
2026-11-24 4:47 ` Andrew Morton
2026-11-24 4:46 ` [merged] mm-gup-add-file_is_memfd_compatible-helper.patch removed from -mm tree Andrew Morton
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=20261124044655.CAF4D1F000C6@smtp.kernel.org \
--to=akpm@linux-foundation.org \
--cc=david@kernel.org \
--cc=jgg@ziepe.ca \
--cc=jhubbard@nvidia.com \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=mm-commits@vger.kernel.org \
--cc=peterx@redhat.com \
--cc=robin.murphy@arm.com \
--cc=skhawaja@google.com \
--cc=syzbot+7666ed2c3d42196bf7e3@syzkaller.appspotmail.com \
--cc=vivek.kasireddy@intel.com \
--cc=will@kernel.org \
--cc=xujiahao@cmss.chinamobile.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.