* [PATCH v5 01/18] memfd: export memfd_get_seals()
[not found] <20260921004834.2601285-1-skhawaja@google.com>
@ 2026-09-21 0:48 ` Samiullah Khawaja
0 siblings, 0 replies; only message in thread
From: Samiullah Khawaja @ 2026-09-21 0:48 UTC (permalink / raw)
To: David Woodhouse, Lu Baolu, Joerg Roedel, Will Deacon,
Jason Gunthorpe
Cc: Samiullah Khawaja, Hugh Dickins, Baolin Wang, Andrew Morton,
linux-mm, Pratyush Yadav (Google), Ankit Soni, Robin Murphy,
Kevin Tian, Alex Williamson, Shuah Khan, iommu, linux-kernel, kvm,
Pasha Tatashin, David Matlack, Pranjal Shrivastava, Vipin Sharma
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@google.com>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org
Acked-by: Pratyush Yadav (Google) <pratyush@kernel.org>
Reviewed-by: Ankit Soni <Ankit.Soni@amd.com>
Signed-off-by: Samiullah Khawaja <skhawaja@google.com>
---
mm/memfd.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/mm/memfd.c b/mm/memfd.c
index c708d92533f4..888ccf3778c7 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>
@@ -310,12 +311,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.1082.g2b9226bbc0-goog
^ permalink raw reply related [flat|nested] only message in thread