summaryrefslogtreecommitdiff
path: root/fs/namespace.c
diff options
context:
space:
mode:
authorChristian Brauner <brauner@kernel.org>2024-12-22 11:03:19 +0100
committerChristian Brauner <brauner@kernel.org>2024-12-22 11:03:19 +0100
commit3781680fba3eab0b34b071cb9443fd5ad92d23cf (patch)
tree82dfe679fafa184df26af5425b28d81b73b8f45f /fs/namespace.c
parent16ecd47cb0cd895c7c2f5dd5db50f6c005c51639 (diff)
parentf63df61651be541cc5699083faa1bfbaa105ed44 (diff)
Merge patch series "pidfs: support bind-mounts"
Christian Brauner <brauner@kernel.org> says: Allow bind-mounting pidfds. Similar to nsfs let's allow bind-mounts for pidfds. This allows pidfds to be safely recovered and checked for process recycling. Instead of checking d_ops for both nsfs and pidfs we could in a follow-up patch add a flag argument to struct dentry_operations that functions similar to file_operations->fop_flags. * patches from https://lore.kernel.org/r/20241219-work-pidfs-mount-v1-0-dbc56198b839@kernel.org: selftests: add pidfd bind-mount tests pidfs: allow bind-mounts Link: https://lore.kernel.org/r/20241219-work-pidfs-mount-v1-0-dbc56198b839@kernel.org Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'fs/namespace.c')
-rw-r--r--fs/namespace.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/fs/namespace.c b/fs/namespace.c
index 23e81c2a1e3f..7baffa2ea582 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -32,6 +32,7 @@
#include <linux/fs_context.h>
#include <linux/shmem_fs.h>
#include <linux/mnt_idmapping.h>
+#include <linux/pidfs.h>
#include <linux/nospec.h>
#include "pnode.h"
@@ -2732,8 +2733,13 @@ static struct mount *__do_loopback(struct path *old_path, int recurse)
if (IS_MNT_UNBINDABLE(old))
return mnt;
- if (!check_mnt(old) && old_path->dentry->d_op != &ns_dentry_operations)
- return mnt;
+ if (!check_mnt(old)) {
+ const struct dentry_operations *d_op = old_path->dentry->d_op;
+
+ if (d_op != &ns_dentry_operations &&
+ d_op != &pidfs_dentry_operations)
+ return mnt;
+ }
if (!recurse && has_locked_children(old, old_path->dentry))
return mnt;