[PATCH v4 01/18] memfd: export memfd_get_seals()

From: Samiullah Khawaja

Date: Fri Aug 07 2026 - 22:27:46 EST


memfd_get_seals() is used by iommufd during preservation to make sure
that he preserved memfd was sealed when it was mapped into iommufd.
Since iommufd can be built as a module, export memfd_get_seals() to
avoid linker error.

Cc: Hugh Dickins <hughd@xxxxxxxxxx>
Cc: Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx>
Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Cc: linux-mm@xxxxxxxxx

Acked-by: Pratyush Yadav (Google) <pratyush@xxxxxxxxxx>
Reviewed-by: Ankit Soni <Ankit.Soni@xxxxxxx>
Signed-off-by: Samiullah Khawaja <skhawaja@xxxxxxxxxx>
---
mm/memfd.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/mm/memfd.c b/mm/memfd.c
index abe13b291ddc..c489b55df3bb 100644
--- a/mm/memfd.c
+++ b/mm/memfd.c
@@ -6,6 +6,7 @@
* use by hugetlbfs as well as tmpfs.
*/

+#include <linux/export.h>
#include <linux/fs.h>
#include <linux/vfs.h>
#include <linux/pagemap.h>
@@ -309,12 +310,19 @@ int memfd_add_seals(struct file *file, unsigned int seals)
return error;
}

+/**
+ * memfd_get_seals - Gets current seals on a memfd
+ * @file: struct file representing the memfd
+ *
+ * Returns seals if file is a memfd, otherwise returns -EINVAL
+ */
int memfd_get_seals(struct file *file)
{
unsigned int *seals = memfd_file_seals_ptr(file);

return seals ? *seals : -EINVAL;
}
+EXPORT_SYMBOL_GPL(memfd_get_seals);

long memfd_fcntl(struct file *file, unsigned int cmd, unsigned int arg)
{
--
2.55.0.679.g6767b8d81c-goog