summaryrefslogtreecommitdiff
path: root/include/linux/exportfs.h
diff options
context:
space:
mode:
authorAmir Goldstein <amir73il@gmail.com>2026-01-29 11:02:12 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-02-26 15:01:26 -0800
commit19000a2af40b13a537b6e80986c5ded6197b7e2d (patch)
treeba7a27c3914e71edb8fb43ecf7107dd3cc966080 /include/linux/exportfs.h
parentd1a3e3fa215392614c7099edf052bcc0bbd951a1 (diff)
nfsd: do not allow exporting of special kernel filesystems
[ Upstream commit b3c78bc53630d14a5770451ede3a30e7052f3b8b ] pidfs and nsfs recently gained support for encode/decode of file handles via name_to_handle_at(2)/open_by_handle_at(2). These special kernel filesystems have custom ->open() and ->permission() export methods, which nfsd does not respect and it was never meant to be used for exporting those filesystems by nfsd. Therefore, do not allow nfsd to export filesystems with custom ->open() or ->permission() methods. Fixes: b3caba8f7a34a ("pidfs: implement file handle support") Fixes: 5222470b2fbb3 ("nsfs: support file handles") Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Amir Goldstein <amir73il@gmail.com> Link: https://patch.msgid.link/20260129100212.49727-3-amir73il@gmail.com Reviewed-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Christian Brauner <brauner@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'include/linux/exportfs.h')
-rw-r--r--include/linux/exportfs.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/linux/exportfs.h b/include/linux/exportfs.h
index f0cf2714ec52..9bd93d6bd9a4 100644
--- a/include/linux/exportfs.h
+++ b/include/linux/exportfs.h
@@ -317,6 +317,15 @@ static inline bool exportfs_can_decode_fh(const struct export_operations *nop)
return nop && nop->fh_to_dentry;
}
+static inline bool exportfs_may_export(const struct export_operations *nop)
+{
+ /*
+ * Do not allow nfs export for filesystems with custom ->open() or
+ * ->permission() ops, which nfsd does not respect (e.g. pidfs, nsfs).
+ */
+ return exportfs_can_decode_fh(nop) && !nop->open && !nop->permission;
+}
+
static inline bool exportfs_can_encode_fh(const struct export_operations *nop,
int fh_flags)
{