Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

pidfs: allow bind-mounts

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.

Link: https://lore.kernel.org/r/20241219-work-pidfs-mount-v1-1-dbc56198b839@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>

+10 -3
+8 -2
fs/namespace.c
··· 32 32 #include <linux/fs_context.h> 33 33 #include <linux/shmem_fs.h> 34 34 #include <linux/mnt_idmapping.h> 35 + #include <linux/pidfs.h> 35 36 #include <linux/nospec.h> 36 37 37 38 #include "pnode.h" ··· 2733 2732 if (IS_MNT_UNBINDABLE(old)) 2734 2733 return mnt; 2735 2734 2736 - if (!check_mnt(old) && old_path->dentry->d_op != &ns_dentry_operations) 2737 - return mnt; 2735 + if (!check_mnt(old)) { 2736 + const struct dentry_operations *d_op = old_path->dentry->d_op; 2737 + 2738 + if (d_op != &ns_dentry_operations && 2739 + d_op != &pidfs_dentry_operations) 2740 + return mnt; 2741 + } 2738 2742 2739 2743 if (!recurse && has_locked_children(old, old_path->dentry)) 2740 2744 return mnt;
+1 -1
fs/pidfs.c
··· 510 510 return dynamic_dname(buffer, buflen, "anon_inode:[pidfd]"); 511 511 } 512 512 513 - static const struct dentry_operations pidfs_dentry_operations = { 513 + const struct dentry_operations pidfs_dentry_operations = { 514 514 .d_delete = always_delete_dentry, 515 515 .d_dname = pidfs_dname, 516 516 .d_prune = stashed_dentry_prune,
+1
include/linux/pidfs.h
··· 6 6 void __init pidfs_init(void); 7 7 void pidfs_add_pid(struct pid *pid); 8 8 void pidfs_remove_pid(struct pid *pid); 9 + extern const struct dentry_operations pidfs_dentry_operations; 9 10 10 11 #endif /* _LINUX_PID_FS_H */