From: josh@joshtriplett.org
To: Oleg Nesterov <oleg@redhat.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
Andrew Morton <akpm@linux-foundation.org>,
Andy Lutomirski <luto@amacapital.net>,
Ingo Molnar <mingo@redhat.com>, Kees Cook <keescook@chromium.org>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
"H. Peter Anvin" <hpa@zytor.com>, Rik van Riel <riel@redhat.com>,
Thomas Gleixner <tglx@linutronix.de>,
Thiago Macieira <thiago.macieira@intel.com>,
Michael Kerrisk <mtk.manpages@gmail.com>,
linux-kernel@vger.kernel.org, linux-api@vger.kernel.org,
linux-fsdevel@vger.kernel.org, x86@kernel.org
Subject: Re: [PATCH 6/6] clone4: Introduce new CLONE_FD flag to get task exit notification via fd
Date: Fri, 13 Mar 2015 12:57:07 -0700 [thread overview]
Message-ID: <20150313195707.GA10487@cloud> (raw)
In-Reply-To: <20150313162113.GA25966@redhat.com>
On Fri, Mar 13, 2015 at 05:21:13PM +0100, Oleg Nesterov wrote:
> Josh,
>
> I'll certainly try to read this series, but not before next week.
Thanks for looking at it.
> but a couple of nits right now.
>
> On 03/12, Josh Triplett wrote:
> >
> > When passed CLONE_FD, clone4 will return a file descriptor rather than a
> > PID. When the child process exits, it gets automatically reaped,
>
> And even I have no idea what you are actually doing, this doesn't look
> right, see below.
>
> > +static unsigned int clonefd_poll(struct file *file, poll_table *wait)
> > +{
> > + struct task_struct *p = file->private_data;
> > + poll_wait(file, &p->clonefd_wqh, wait);
> > + return p->exit_state == EXIT_DEAD ? (POLLIN | POLLRDNORM) : 0;
> > +}
> > +
> > +static ssize_t clonefd_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
> > +{
> > + struct task_struct *p = file->private_data;
> > + int ret = 0;
> > +
> > + /* EOF after first read */
> > + if (*ppos)
> > + return 0;
> > +
> > + if (file->f_flags & O_NONBLOCK)
> > + ret = -EAGAIN;
> > + else
> > + ret = wait_event_interruptible(p->clonefd_wqh, p->exit_state == EXIT_DEAD);
> > +
> > + if (p->exit_state == EXIT_DEAD) {
>
> Again, I simply do not know what this code does at all. But I bet the usage
> of EXIT_DEAD is wrong ;)
>
> OK, OK, I can be wrong. But I simply do not see what protects this task_struct
> if it is EXIT_DEAD (in fact even if it is EXIT_ZOMBIE).
If by "what protects" you mean "what keeps it alive", the file
descriptor holds a reference to the task_struct by calling
get_task_struct when created and put_task_struct when released.
This wait_event_interruptible pairs with the wake_up_all called from
clonefd_do_notify, which exit_notify calls *after* setting the task to
TASK_DEAD.
Apart from that, what about what the code is doing isn't clear?
> > @@ -598,7 +600,9 @@ static void exit_notify(struct task_struct *tsk, int group_dead)
> > if (group_dead)
> > kill_orphaned_pgrp(tsk->group_leader, NULL);
> >
> > - if (unlikely(tsk->ptrace)) {
> > + if (tsk->autoreap) {
> > + autoreap = true;
>
> Debuggers won't be happy. A ptraced task should not autoreap itself.
A process launching a new process with CLONE_FD is explicitly requesting
that the process be automatically reaped without any other process
having to wait on it. The task needs to not become a zombie, because
otherwise, it'll show up in waitpid(-1, ...) calls in the parent
process, which would break the ability to use this to completely
encapsulate process management within a library and not interfere with
the parent's process handling via SIGCHLD and wait{pid,3,4}.
- Josh Triplett
next prev parent reply other threads:[~2015-03-13 19:57 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-13 1:40 [PATCH 0/6] CLONE_FD: Task exit notification via file descriptor Josh Triplett
2015-03-13 1:40 ` [PATCH 1/6] clone: Support passing tls argument via C rather than pt_regs magic Josh Triplett
[not found] ` <cover.1426180120.git.josh-iaAMLnmF4UmaiuxdJuQwMA@public.gmane.org>
2015-03-13 1:40 ` [PATCH 2/6] x86: Opt into HAVE_COPY_THREAD_TLS, for both 32-bit and 64-bit Josh Triplett
[not found] ` <cf79b9f0c40314e6bfda7c634e378015bd7ba037.1426180120.git.josh-iaAMLnmF4UmaiuxdJuQwMA@public.gmane.org>
2015-03-13 22:01 ` Andy Lutomirski
2015-03-13 22:31 ` josh
2015-03-13 22:38 ` Andy Lutomirski
[not found] ` <CALCETrWspvNcEYxwbo1+ifXSj7Qj7YdcRgmNvZ1RaBrUAK12Zw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-03-13 22:43 ` josh-iaAMLnmF4UmaiuxdJuQwMA
2015-03-13 22:45 ` Andy Lutomirski
[not found] ` <CALCETrW3kJSVz4ffVC6YdB+ELukhOHNgPFKZSziMq5nn_Nq3Zg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-03-13 23:01 ` josh-iaAMLnmF4UmaiuxdJuQwMA
2015-03-13 1:40 ` [PATCH 5/6] fs: Make alloc_fd non-private Josh Triplett
2015-03-13 2:07 ` [PATCH 0/6] CLONE_FD: Task exit notification via file descriptor Thiago Macieira
2015-03-13 16:05 ` David Drysdale
2015-03-13 19:42 ` Josh Triplett
2015-03-13 21:16 ` Thiago Macieira
2015-03-13 21:44 ` josh
2015-03-13 21:33 ` Andy Lutomirski
[not found] ` <CALCETrXH+Ui1XqVZjFB=8vDpJLCYeVf+XNUPGWNfwDsNKi_nKg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-03-13 21:45 ` josh-iaAMLnmF4UmaiuxdJuQwMA
2015-03-13 21:51 ` Andy Lutomirski
[not found] ` <CALCETrWwkdWkNCsrcSAn+7f9SJCuYA-TV9=AygWMhXCC9Njp9Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-03-14 1:11 ` Thiago Macieira
2015-03-14 19:03 ` Thiago Macieira
2015-03-14 19:29 ` Josh Triplett
2015-03-15 10:18 ` David Drysdale
2015-03-15 10:59 ` Josh Triplett
2015-03-15 8:55 ` David Drysdale
2015-03-13 1:40 ` [PATCH 3/6] Introduce a new clone4 syscall with more flag bits and extensible arguments Josh Triplett
2015-03-13 1:40 ` [PATCH 4/6] signal: Factor out a helper function to process task_struct exit_code Josh Triplett
2015-03-13 1:41 ` [PATCH 6/6] clone4: Introduce new CLONE_FD flag to get task exit notification via fd Josh Triplett
2015-03-13 16:21 ` Oleg Nesterov
2015-03-13 19:57 ` josh [this message]
2015-03-13 21:34 ` Andy Lutomirski
2015-03-13 22:20 ` josh
2015-03-13 22:28 ` Andy Lutomirski
[not found] ` <CALCETrVRqgsbpi9pPRwy42cuXiDzyPgWRJmfSRSQM7eGFfsZYA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-03-13 22:34 ` josh-iaAMLnmF4UmaiuxdJuQwMA
2015-03-13 22:38 ` Andy Lutomirski
2015-03-14 14:14 ` Oleg Nesterov
[not found] ` <20150314141414.GA11062-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-03-14 14:32 ` Oleg Nesterov
2015-03-14 18:38 ` Thiago Macieira
2015-03-14 18:54 ` Oleg Nesterov
[not found] ` <20150314185424.GA6813-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-03-14 22:03 ` Josh Triplett
2015-03-14 22:26 ` Thiago Macieira
2015-03-14 19:01 ` Josh Triplett
2015-03-14 19:18 ` Oleg Nesterov
[not found] ` <20150314191836.GA8416-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-03-14 19:47 ` Oleg Nesterov
[not found] ` <20150314194721.GA9654-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-03-14 20:14 ` Josh Triplett
2015-03-14 20:30 ` Oleg Nesterov
[not found] ` <20150314203029.GA11656-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-03-14 22:14 ` Josh Triplett
2015-03-14 20:03 ` Josh Triplett
2015-03-14 20:20 ` Oleg Nesterov
2015-03-14 22:09 ` Josh Triplett
[not found] ` <9c39c576e1d9a9912b4aec54d833a73a84d2f592.1426180120.git.josh-iaAMLnmF4UmaiuxdJuQwMA@public.gmane.org>
2015-03-14 14:35 ` Oleg Nesterov
[not found] ` <20150314143558.GB12086-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-03-14 19:15 ` Josh Triplett
2015-03-14 19:24 ` Oleg Nesterov
[not found] ` <20150314192456.GA8707-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-03-14 19:48 ` Josh Triplett
2015-03-13 1:41 ` [PATCH] clone4.2: New manpage documenting clone4(2) Josh Triplett
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=20150313195707.GA10487@cloud \
--to=josh@joshtriplett.org \
--cc=akpm@linux-foundation.org \
--cc=hpa@zytor.com \
--cc=keescook@chromium.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=mingo@redhat.com \
--cc=mtk.manpages@gmail.com \
--cc=oleg@redhat.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=riel@redhat.com \
--cc=tglx@linutronix.de \
--cc=thiago.macieira@intel.com \
--cc=viro@zeniv.linux.org.uk \
--cc=x86@kernel.org \
/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).