Unverified Commit 3155a194 authored by Christian Brauner's avatar Christian Brauner
Browse files

pidfs: move setting flags into pidfs_alloc_file()

Instead od adding it into __pidfd_prepare() place it where the actual
file allocation happens and update the outdated comment.

Link: https://lore.kernel.org/r/20250305-work-pidfs-kill_on_last_close-v3-3-c8c3d8361705@kernel.org


Reviewed-by: default avatarJeff Layton <jlayton@kernel.org>
Reviewed-by: default avatarOleg Nesterov <oleg@redhat.com>
Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
parent b573bf6f
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -696,6 +696,10 @@ struct file *pidfs_alloc_file(struct pid *pid, unsigned int flags)
		return ERR_PTR(ret);

	pidfd_file = dentry_open(&path, flags, current_cred());
	/* Raise PIDFD_THREAD explicitly as do_dentry_open() strips it. */
	if (!IS_ERR(pidfd_file))
		pidfd_file->f_flags |= (flags & PIDFD_THREAD);

	path_put(&path);
	return pidfd_file;
}
+0 −5
Original line number Diff line number Diff line
@@ -2042,11 +2042,6 @@ static int __pidfd_prepare(struct pid *pid, unsigned int flags, struct file **re
	if (IS_ERR(pidfd_file))
		return PTR_ERR(pidfd_file);

	/*
	 * anon_inode_getfile() ignores everything outside of the
	 * O_ACCMODE | O_NONBLOCK mask, set PIDFD_THREAD manually.
	 */
	pidfd_file->f_flags |= (flags & PIDFD_THREAD);
	*ret = pidfd_file;
	return take_fd(pidfd);
}