Unverified Commit 3781680f authored by Christian Brauner's avatar Christian Brauner
Browse files

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: default avatarChristian Brauner <brauner@kernel.org>
parents 16ecd47c f63df616
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -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)
	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;
+1 −1
Original line number Diff line number Diff line
@@ -510,7 +510,7 @@ static char *pidfs_dname(struct dentry *dentry, char *buffer, int buflen)
	return dynamic_dname(buffer, buflen, "anon_inode:[pidfd]");
}

static const struct dentry_operations pidfs_dentry_operations = {
const struct dentry_operations pidfs_dentry_operations = {
	.d_delete	= always_delete_dentry,
	.d_dname	= pidfs_dname,
	.d_prune	= stashed_dentry_prune,
+1 −0
Original line number Diff line number Diff line
@@ -6,5 +6,6 @@ struct file *pidfs_alloc_file(struct pid *pid, unsigned int flags);
void __init pidfs_init(void);
void pidfs_add_pid(struct pid *pid);
void pidfs_remove_pid(struct pid *pid);
extern const struct dentry_operations pidfs_dentry_operations;

#endif /* _LINUX_PID_FS_H */
+1 −0
Original line number Diff line number Diff line
@@ -7,3 +7,4 @@ pidfd_fdinfo_test
pidfd_getfd_test
pidfd_setns_test
pidfd_file_handle_test
pidfd_bind_mount
+1 −1
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@ CFLAGS += -g $(KHDR_INCLUDES) -pthread -Wall

TEST_GEN_PROGS := pidfd_test pidfd_fdinfo_test pidfd_open_test \
	pidfd_poll_test pidfd_wait pidfd_getfd_test pidfd_setns_test \
	pidfd_file_handle_test
	pidfd_file_handle_test pidfd_bind_mount

include ../lib.mk
Loading