From: Christian Brauner <brauner@kernel.org>
To: Oleg Nesterov <oleg@redhat.com>
Cc: Andy Lutomirski <luto@amacapital.net>,
"Eric W. Biederman" <ebiederm@xmission.com>,
Tycho Andersen <tycho@tycho.pizza>,
linux-api@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/2] pidfd: change pidfd_send_signal() to respect PIDFD_THREAD
Date: Sat, 10 Feb 2024 13:54:21 +0100 [thread overview]
Message-ID: <20240210-dackel-getan-619c70fefa62@brauner> (raw)
In-Reply-To: <20240210123033.GA27557@redhat.com>
On Sat, Feb 10, 2024 at 01:30:33PM +0100, Oleg Nesterov wrote:
> Christian,
>
> Thanks again! the last 2 commits in vfs.pidfd look good to me.
>
> As for this patch, I am not sure I understand your concerns, and I
> have another concern, please see below.
>
> For the moment, please forget about PIDFD_THREAD.
>
> On 02/10, Christian Brauner wrote:
> >
> > (1) kill(-1234) => kill process group with id 1234
> > (2) kill(0) => kill process group of @current
> >
> > which implementation wise is indicated by
> >
> > __kill_pgrp_info(..., pid ? find_vpid(-pid) ? task_pgrp(current))
> >
> > We're obviously not going to implement (2) as that doesn't really make a
> > sense for pidfd_send_signal().
>
> Sure,
>
> > But (1) is also wrong for pidfd_send_signal(). If we'd ever implement
> > (1) it should be via pidfd_open(1234, PIDFD_PROCESS_GROUP).
>
> Why do you think we need another flag for open() ?
We don't need one. We could if we wanted to was my point. But let's
ignore that for now.
>
> To me it looks fine if we allow to send the signal to pgrp if
> flags & PIDFD_SIGNAL_PROCESS_GROUP.
Yes, that's what I want too, I just wonder about the semantics.
>
> And pidfd_send_signal() can just do
>
> if (PIDFD_SIGNAL_THREAD_GROUP)
> ret = __kill_pgrp_info(sig, kinfo, pid);
> else
> ret = kill_pid_info_type(...);
>
> (yes, yes, this needs tasklist, just a pseudo code to simpliy)
>
> Now lets recall about PIDFD_THREAD.
>
> If the target task is a group leader - there is no difference.
>
> If it is not a leader - then __kill_pgrp_info() will always return
> -ESRCH, do_each_pid_task(PIDTYPE_PGID) won't find any task.
>
> And personally I think this is all we need.
>
> ------------------------------------------------------------------------------
> But if you want to make PIDFD_SIGNAL_THREAD_GROUP work even if the
> target task is not a leader, then yes, we need something like
>
> task_pgrp(pid_task(pid, PIDTYPE_PID))
>
> like you did in the new kill_pgrp_info() helper in this patch.
>
> I won't argue, but do you think this makes a lot of sense?
The question is what is more useful for userspace when they do:
pidfd_send_signal(1234, PIDFD_SEND_PROCESS_GROUP)?
(1) They either mean to signal a process group that is headed by 1234.
(2) Or they want to signal a process group of which 1234 is a member or
the leader.
From a usability perspective (1) is a lot more restrictive because it
requires @pidfd to refer to a process group leader. Whereas (2) doesn't
require userspace to hold a @pidfd to a process group leader. It is
enough to just hold a @pidfd. In other words, (2) has wider scope.
And intuitively that is what I had thought is more useful. But by that
logic PIDFD_SEND_THREAD_GROUP would have to signal to the thread-group
that @pidfd is in regardless of whether @pidfd is actually a
thread-group leader.
Which is also what you're pointing out, afaict.
next prev parent reply other threads:[~2024-02-10 12:54 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-09 13:06 [PATCH v2 1/2] signal: add the "int si_code" arg to prepare_kill_siginfo() Oleg Nesterov
2024-02-09 13:06 ` [PATCH v2 2/2] pidfd: change pidfd_send_signal() to respect PIDFD_THREAD Oleg Nesterov
2024-02-09 15:11 ` Christian Brauner
2024-02-09 15:15 ` Christian Brauner
2024-02-09 15:43 ` Oleg Nesterov
2024-02-09 15:49 ` Christian Brauner
2024-02-09 15:56 ` Oleg Nesterov
2024-02-10 10:23 ` Christian Brauner
2024-02-10 12:30 ` Oleg Nesterov
2024-02-10 12:47 ` Oleg Nesterov
2024-02-10 12:54 ` Christian Brauner [this message]
2024-02-10 13:15 ` Oleg Nesterov
2024-02-10 14:26 ` Christian Brauner
2024-02-10 16:51 ` Oleg Nesterov
2024-02-10 17:22 ` Christian Brauner
2024-02-14 12:36 ` Oleg Nesterov
2024-02-16 12:28 ` Christian Brauner
2024-02-16 13:06 ` Oleg Nesterov
2024-02-16 14:46 ` Christian Brauner
2024-02-16 18:12 ` Oleg Nesterov
2024-02-20 8:34 ` Christian Brauner
2024-02-20 9:02 ` Oleg Nesterov
2024-02-20 9:22 ` Christian Brauner
2024-02-20 11:00 ` Oleg Nesterov
2024-02-20 12:59 ` Christian Brauner
2024-02-20 16:22 ` Oleg Nesterov
2024-02-21 7:42 ` Christian Brauner
2024-02-21 12:55 ` Oleg Nesterov
2024-02-21 13:35 ` Christian Brauner
2024-02-09 19:08 ` Tycho Andersen
2024-02-09 15:10 ` [PATCH v2 1/2] signal: add the "int si_code" arg to prepare_kill_siginfo() Christian Brauner
2024-02-09 16:13 ` Christian Brauner
2024-02-09 16:22 ` Eric W. Biederman
2024-02-09 16:39 ` Oleg Nesterov
2024-02-09 19:36 ` Christian Brauner
2024-02-09 19:53 ` Oleg Nesterov
2024-02-09 20:01 ` Tycho Andersen
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=20240210-dackel-getan-619c70fefa62@brauner \
--to=brauner@kernel.org \
--cc=ebiederm@xmission.com \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=oleg@redhat.com \
--cc=tycho@tycho.pizza \
/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 NNTP newsgroup(s).