From: Tycho Andersen <tycho@tycho.pizza>
To: Christian Brauner <brauner@kernel.org>
Cc: Oleg Nesterov <oleg@redhat.com>,
linux-kernel@vger.kernel.org, linux-api@vger.kernel.org,
Tycho Andersen <tycho@tycho.pizza>,
Tycho Andersen <tandersen@netflix.com>
Subject: [PATCH v3 3/3] clone: allow CLONE_THREAD | CLONE_PIDFD together
Date: Tue, 23 Jan 2024 08:34:52 -0700 [thread overview]
Message-ID: <20240123153452.170866-4-tycho@tycho.pizza> (raw)
In-Reply-To: <20240123153452.170866-1-tycho@tycho.pizza>
From: Tycho Andersen <tandersen@netflix.com>
This removes the restriction of CLONE_THREAD | CLONE_PIDFD being specified
together. Assuming the previous patch sorts out all the thorny issues this
should be safe. I've left it as a separate patch since it is not strictly
necessary as a usecase for us, but might be nice? Perhaps we want to wait
until someone actually needs it though.
Signed-off-by: Tycho Andersen <tandersen@netflix.com>
---
kernel/fork.c | 3 +--
.../selftests/pidfd/pidfd_non_tgl_test.c | 17 +++++++++++++++++
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/kernel/fork.c b/kernel/fork.c
index 44969cd472f0..25fccf7c08a7 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -2296,9 +2296,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);
}
diff --git a/tools/testing/selftests/pidfd/pidfd_non_tgl_test.c b/tools/testing/selftests/pidfd/pidfd_non_tgl_test.c
index c0624b127fab..a34208c2307e 100644
--- a/tools/testing/selftests/pidfd/pidfd_non_tgl_test.c
+++ b/tools/testing/selftests/pidfd/pidfd_non_tgl_test.c
@@ -546,6 +546,22 @@ static int test_non_tgl_waitid_exec(void)
return ret;
}
+static int test_clone_thread_pidfd(void)
+{
+ pid_t pid;
+ int flags = CLONE_THREAD | CLONE_VM | CLONE_SIGHAND | CLONE_PIDFD;
+ int pidfd;
+
+ pid = clone(thread_sleep, stack + STACK_SIZE, flags, NULL, &pidfd);
+ if (pid < 0) {
+ perror("clone");
+ return KSFT_FAIL;
+ }
+
+ close(pidfd);
+ return KSFT_PASS;
+}
+
#define T(x) { x, #x }
struct pidfd_non_tgl_test {
int (*fn)();
@@ -557,6 +573,7 @@ struct pidfd_non_tgl_test {
T(test_non_tgl_exit_poll),
T(test_non_tgl_waitid_exit),
T(test_non_tgl_waitid_exec),
+ T(test_clone_thread_pidfd),
};
#undef T
--
2.34.1
prev parent reply other threads:[~2024-01-23 15:35 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-23 15:34 [PATCH v3 0/3] pidfds for non thread group leaders Tycho Andersen
2024-01-23 15:34 ` [PATCH v3 1/3] pidfd: allow pidfd_open() on non-thread-group leaders Tycho Andersen
2024-01-23 19:56 ` Oleg Nesterov
2024-01-23 21:10 ` Tycho Andersen
2024-01-23 22:22 ` Oleg Nesterov
2024-01-24 1:25 ` Oleg Nesterov
2024-01-25 14:08 ` Oleg Nesterov
2024-01-25 17:17 ` Christian Brauner
2024-01-25 17:51 ` Oleg Nesterov
2024-01-25 18:03 ` Tycho Andersen
2024-01-25 18:25 ` Oleg Nesterov
2024-01-25 18:30 ` Oleg Nesterov
2024-01-25 18:36 ` Tycho Andersen
2024-01-26 9:49 ` Christian Brauner
2024-01-26 9:42 ` Christian Brauner
2024-01-26 14:33 ` Oleg Nesterov
2024-01-26 9:47 ` Christian Brauner
2024-01-26 14:33 ` Oleg Nesterov
2024-01-27 14:26 ` Christian Brauner
2024-01-26 21:50 ` Tycho Andersen
2024-01-27 10:54 ` Oleg Nesterov
2024-01-27 14:33 ` Christian Brauner
2024-01-27 15:55 ` Tycho Andersen
2024-01-27 16:31 ` Oleg Nesterov
2024-01-27 17:20 ` Tycho Andersen
2024-01-27 19:31 ` Oleg Nesterov
2024-01-27 20:44 ` Tycho Andersen
2024-01-27 21:10 ` Oleg Nesterov
2024-01-29 11:23 ` [RFC PATCH] pidfd: implement PIDFD_THREAD flag for pidfd_open() Oleg Nesterov
2024-01-29 13:41 ` Christian Brauner
2024-01-29 14:31 ` Tycho Andersen
2024-01-29 15:14 ` Christian Brauner
2024-01-30 11:21 ` Oleg Nesterov
2024-01-31 18:11 ` Andy Lutomirski
2024-01-31 18:48 ` Oleg Nesterov
2024-01-31 19:14 ` Oleg Nesterov
2024-01-31 19:24 ` Andy Lutomirski
2024-01-31 19:46 ` Christian Brauner
2024-01-31 19:50 ` Andy Lutomirski
2024-02-01 13:30 ` Christian Brauner
2024-02-01 13:39 ` Christian Brauner
2024-02-01 19:33 ` Andy Lutomirski
2024-01-23 15:34 ` [PATCH v3 2/3] selftests/pidfd: add non-thread-group leader tests Tycho Andersen
2024-01-23 15:34 ` Tycho Andersen [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240123153452.170866-4-tycho@tycho.pizza \
--to=tycho@tycho.pizza \
--cc=brauner@kernel.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@redhat.com \
--cc=tandersen@netflix.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).