From: Oleg Nesterov <oleg@redhat.com>
To: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: "Jürg Billeter" <j@bitron.ch>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Kees Cook" <keescook@chromium.org>,
"Andy Lutomirski" <luto@kernel.org>,
linux-api@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] prctl: add PR_{GET,SET}_KILL_DESCENDANTS_ON_EXIT
Date: Thu, 29 Nov 2018 13:34:09 +0100 [thread overview]
Message-ID: <20181129123409.GA10645@redhat.com> (raw)
In-Reply-To: <87r2f5gr9g.fsf@xmission.com>
On 11/28, Eric W. Biederman wrote:
>
> Oleg Nesterov <oleg@redhat.com> writes:
>
> > On 11/27, Jürg Billeter wrote:
> >>
> >> @@ -704,6 +713,9 @@ static void exit_notify(struct task_struct *tsk, int group_dead)
> >> struct task_struct *p, *n;
> >> LIST_HEAD(dead);
> >>
> >> + if (group_dead && tsk->signal->kill_descendants_on_exit)
> >> + walk_process_tree(tsk, kill_descendant_visitor, NULL);
> >
> > Well, this is not exactly right, at least this is suboptimal in that
> > other sub-threads can too call walk_process_tree(kill_descendant_visitor)
> > later for no reason.
>
> Oleg I think I am missing something.
No, it is stupid me who can't read,
> Reading kernel/exit.c I see "group_dead = atomic_dec_and_test(&tsk->signal->live)".
> Which seems like enough to ensure exactly one task/thread calls walk_process_tree.
Of course you right, sorry for confusion.
To me it would be more clean to call walk_process_tree(kill_descendant_visitor)
unconditionally in find_new_reaper() right before "if (has_child_subreaper)", but
then we will need to shift read_lock(tasklist) from walk_process_tree().
So I think the patch is mostly fine, the only problem I can see is that
PR_SET_KILL_DESCENDANTS_ON_EXIT can race with PR_SET_CHILD_SUBREAPER, they both
need to update the bits in the same word.
Oleg.
next prev parent reply other threads:[~2018-11-29 12:34 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-27 22:54 [PATCH 0/1] Add prctl to kill descendants on exit Jürg Billeter
2018-11-27 22:54 ` [PATCH] prctl: add PR_{GET,SET}_KILL_DESCENDANTS_ON_EXIT Jürg Billeter
2018-11-28 14:42 ` Oleg Nesterov
2018-11-28 15:23 ` Eric W. Biederman
2018-11-29 12:34 ` Oleg Nesterov [this message]
2018-11-29 15:41 ` Jürg Billeter
2018-11-30 10:33 ` Oleg Nesterov
2018-12-01 4:28 ` Kees Cook
2018-11-30 8:00 ` [PATCH v2 0/1] Add prctl to kill descendants on exit Jürg Billeter
2018-11-30 8:00 ` [PATCH v2 1/1] prctl: add PR_{GET,SET}_KILL_DESCENDANTS_ON_EXIT Jürg Billeter
2018-11-30 11:22 ` Oleg Nesterov
2018-11-30 13:40 ` Florian Weimer
2018-12-01 10:39 ` Jürg Billeter
2018-12-01 12:28 ` Florian Weimer
2018-12-01 13:57 ` Jürg Billeter
2018-12-06 15:54 ` [PATCH v2 0/1] Add prctl to kill descendants on exit Jürg Billeter
2019-01-18 13:11 ` [RESEND PATCH " Jürg Billeter
2019-01-18 13:11 ` [RESEND PATCH v2 1/1] prctl: add PR_{GET,SET}_KILL_DESCENDANTS_ON_EXIT Jürg Billeter
2019-01-29 1:23 ` Andrew Morton
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=20181129123409.GA10645@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=ebiederm@xmission.com \
--cc=j@bitron.ch \
--cc=keescook@chromium.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=tglx@linutronix.de \
/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).