From: Tycho Andersen <tycho@tycho.pizza>
To: Oleg Nesterov <oleg@redhat.com>
Cc: Christian Brauner <brauner@kernel.org>,
"Eric W. Biederman" <ebiederm@xmission.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 1/1] pidfd: implement PIDFD_THREAD flag for pidfd_open()
Date: Wed, 31 Jan 2024 10:23:54 -0700 [thread overview]
Message-ID: <ZbqCKgTuP/IaEbMM@tycho.pizza> (raw)
In-Reply-To: <20240131132602.GA23641@redhat.com>
Hi Oleg,
On Wed, Jan 31, 2024 at 02:26:02PM +0100, Oleg Nesterov wrote:
> With this flag:
>
> - pidfd_open() doesn't require that the target task must be
> a thread-group leader
>
> - pidfd_poll() succeeds when the task exits and becomes a
> zombie (iow, passes exit_notify()), even if it is a leader
> and thread-group is not empty.
>
> This means that the behaviour of pidfd_poll(PIDFD_THREAD,
> pid-of-group-leader) is not well defined if it races with
> exec() from its sub-thread; pidfd_poll() can succeed or not
> depending on whether pidfd_task_exited() is called before
> or after exchange_tids().
>
> Perhaps we can improve this behaviour later, pidfd_poll()
> can probably take sig->group_exec_task into account. But
> this doesn't really differ from the case when the leader
> exits before other threads (so pidfd_poll() succeeds) and
> then another thread execs and pidfd_poll() will block again.
I don't have a strong opinion here; leaving it "undefined" for now is
fine with me.
> @@ -2173,7 +2195,9 @@ static int __pidfd_prepare(struct pid *pid, unsigned int flags, struct file **re
> */
> int pidfd_prepare(struct pid *pid, unsigned int flags, struct file **ret)
> {
> - if (!pid || !pid_has_task(pid, PIDTYPE_TGID))
> + bool thread = flags & PIDFD_THREAD;
> +
> + if (!pid || !pid_has_task(pid, thread ? PIDTYPE_PID : PIDTYPE_TGID));
Small typo here, trailing ;. When I fix that, tests pass for me.
Assuming that's fixed up:
Reviewed-by: Tycho Andersen <tandersen@netflix.com>
Tested-by: Tycho Andersen <tandersen@netflix.com>
Thanks for your help!
Tycho
next prev parent reply other threads:[~2024-01-31 17:23 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-31 13:25 [PATCH v3 0/1] " Oleg Nesterov
2024-01-31 13:26 ` [PATCH v3 1/1] " Oleg Nesterov
2024-01-31 14:12 ` Christian Brauner
2024-01-31 14:19 ` Oleg Nesterov
2024-01-31 17:23 ` Tycho Andersen [this message]
2024-01-31 18:01 ` Oleg Nesterov
2024-01-31 18:15 ` Christian Brauner
2024-02-01 17:25 ` Christian Brauner
2024-02-01 18:10 ` Oleg Nesterov
2024-02-02 12:50 ` Christian Brauner
2024-02-05 15:22 ` Oleg Nesterov
2024-02-06 13:38 ` Christian Brauner
2024-02-08 7:54 ` kernel test robot
2024-02-08 8:58 ` Christian Brauner
2024-02-08 9:18 ` Oleg Nesterov
2024-01-31 13:58 ` [PATCH v3 0/1] " Christian Brauner
2024-01-31 14:12 ` Oleg Nesterov
2024-01-31 14:39 ` Christian Brauner
2024-01-31 16:10 ` Oleg Nesterov
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=ZbqCKgTuP/IaEbMM@tycho.pizza \
--to=tycho@tycho.pizza \
--cc=brauner@kernel.org \
--cc=ebiederm@xmission.com \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@redhat.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
all inboxes | Powered by JetHome®