* [PATCH] pidfd: clone: allow CLONE_THREAD | CLONE_PIDFD together
@ 2024-02-05 14:55 Oleg Nesterov
2024-02-06 13:40 ` Christian Brauner
2024-02-06 14:52 ` Tycho Andersen
0 siblings, 2 replies; 3+ messages in thread
From: Oleg Nesterov @ 2024-02-05 14:55 UTC (permalink / raw)
To: Christian Brauner
Cc: Andy Lutomirski, Eric W. Biederman, Tycho Andersen, linux-api,
linux-kernel
copy_process() just needs to pass PIDFD_THREAD to __pidfd_prepare()
if clone_flags & CLONE_THREAD.
We can also add another CLONE_ flag (or perhaps reuse CLONE_DETACHED)
to enforce PIDFD_THREAD without CLONE_THREAD.
Originally-from: Tycho Andersen <tycho@tycho.pizza>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
kernel/fork.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/kernel/fork.c b/kernel/fork.c
index 8d08a2d1b095..cd61ca87d0e6 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -2311,9 +2311,8 @@ __latent_entropy struct task_struct *copy_process(
/*
* - CLONE_DETACHED is blocked so that we can potentially
* reuse it later for CLONE_PIDFD.
- * - CLONE_THREAD is blocked until someone really needs it.
*/
- if (clone_flags & (CLONE_DETACHED | CLONE_THREAD))
+ if (clone_flags & CLONE_DETACHED)
return ERR_PTR(-EINVAL);
}
@@ -2536,8 +2535,10 @@ __latent_entropy struct task_struct *copy_process(
* if the fd table isn't shared).
*/
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, 0, &pidfile);
+ retval = __pidfd_prepare(pid, flags, &pidfile);
if (retval < 0)
goto bad_fork_free_pid;
pidfd = retval;
--
2.25.1.362.g51ebf55
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] pidfd: clone: allow CLONE_THREAD | CLONE_PIDFD together
2024-02-05 14:55 [PATCH] pidfd: clone: allow CLONE_THREAD | CLONE_PIDFD together Oleg Nesterov
@ 2024-02-06 13:40 ` Christian Brauner
2024-02-06 14:52 ` Tycho Andersen
1 sibling, 0 replies; 3+ messages in thread
From: Christian Brauner @ 2024-02-06 13:40 UTC (permalink / raw)
To: Oleg Nesterov
Cc: Christian Brauner, Andy Lutomirski, Eric W. Biederman,
Tycho Andersen, linux-api, linux-kernel
On Mon, 05 Feb 2024 15:55:32 +0100, Oleg Nesterov wrote:
> copy_process() just needs to pass PIDFD_THREAD to __pidfd_prepare()
> if clone_flags & CLONE_THREAD.
>
> We can also add another CLONE_ flag (or perhaps reuse CLONE_DETACHED)
> to enforce PIDFD_THREAD without CLONE_THREAD.
>
>
> [...]
Applied to the vfs.pidfd branch of the vfs/vfs.git tree.
Patches in the vfs.pidfd branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs.pidfd
[1/1] pidfd: clone: allow CLONE_THREAD | CLONE_PIDFD together
https://git.kernel.org/vfs/vfs/c/572a94c5290e
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] pidfd: clone: allow CLONE_THREAD | CLONE_PIDFD together
2024-02-05 14:55 [PATCH] pidfd: clone: allow CLONE_THREAD | CLONE_PIDFD together Oleg Nesterov
2024-02-06 13:40 ` Christian Brauner
@ 2024-02-06 14:52 ` Tycho Andersen
1 sibling, 0 replies; 3+ messages in thread
From: Tycho Andersen @ 2024-02-06 14:52 UTC (permalink / raw)
To: Oleg Nesterov
Cc: Christian Brauner, Andy Lutomirski, Eric W. Biederman, linux-api,
linux-kernel
On Mon, Feb 05, 2024 at 03:55:32PM +0100, Oleg Nesterov wrote:
> copy_process() just needs to pass PIDFD_THREAD to __pidfd_prepare()
> if clone_flags & CLONE_THREAD.
>
> We can also add another CLONE_ flag (or perhaps reuse CLONE_DETACHED)
> to enforce PIDFD_THREAD without CLONE_THREAD.
>
> Originally-from: Tycho Andersen <tycho@tycho.pizza>
Goes without saying I suppose, but,
Reviewed-by: Tycho Andersen <tandersen@netflix.com>
as well.
Tycho
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-02-06 14:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-05 14:55 [PATCH] pidfd: clone: allow CLONE_THREAD | CLONE_PIDFD together Oleg Nesterov
2024-02-06 13:40 ` Christian Brauner
2024-02-06 14:52 ` Tycho Andersen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).