diff options
author | 2025-03-25 08:17:25 +0100 | |
---|---|---|
committer | 2025-03-25 08:17:25 +0100 | |
commit | 2487b6b9bf2874cfca7efb59c95650c5b1d88d43 (patch) | |
tree | 8bd7a32686e006b1cbeeb80511114c63ac442c87 /kernel/fork.c | |
parent | x86/speculation: Remove the extra #ifdef around CALL_NOSPEC (diff) | |
parent | x86 boot build: make git ignore stale 'tools' directory (diff) | |
download | wireguard-linux-2487b6b9bf2874cfca7efb59c95650c5b1d88d43.tar.xz wireguard-linux-2487b6b9bf2874cfca7efb59c95650c5b1d88d43.zip |
Merge branch 'linus' into x86/urgent, to pick up fixes and refresh the branch
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/fork.c')
-rw-r--r-- | kernel/fork.c | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/kernel/fork.c b/kernel/fork.c index 735405a9c5f3..f11ac96b7587 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -2032,25 +2032,18 @@ static inline void rcu_copy_process(struct task_struct *p) */ static int __pidfd_prepare(struct pid *pid, unsigned int flags, struct file **ret) { - int pidfd; struct file *pidfd_file; - pidfd = get_unused_fd_flags(O_CLOEXEC); + CLASS(get_unused_fd, pidfd)(O_CLOEXEC); if (pidfd < 0) return pidfd; pidfd_file = pidfs_alloc_file(pid, flags | O_RDWR); - if (IS_ERR(pidfd_file)) { - put_unused_fd(pidfd); + 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 pidfd; + return take_fd(pidfd); } /** @@ -2432,8 +2425,11 @@ __latent_entropy struct task_struct *copy_process( if (clone_flags & CLONE_PIDFD) { int flags = (clone_flags & CLONE_THREAD) ? PIDFD_THREAD : 0; - /* Note that no task has been attached to @pid yet. */ - retval = __pidfd_prepare(pid, flags, &pidfile); + /* + * Note that no task has been attached to @pid yet indicate + * that via CLONE_PIDFD. + */ + retval = __pidfd_prepare(pid, flags | PIDFD_CLONE, &pidfile); if (retval < 0) goto bad_fork_free_pid; pidfd = retval; |