[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190502151320.cvc6uc3b4bmww23k@brauner.io>
Date: Thu, 2 May 2019 17:13:21 +0200
From: Christian Brauner <christian@...uner.io>
To: Oleg Nesterov <oleg@...hat.com>
Cc: "Joel Fernandes (Google)" <joel@...lfernandes.org>,
linux-kernel@...r.kernel.org,
Andy Lutomirski <luto@...capital.net>,
Steven Rostedt <rostedt@...dmis.org>,
Daniel Colascione <dancol@...gle.com>,
Jann Horn <jannh@...gle.com>,
Tim Murray <timmurray@...gle.com>,
Jonathan Kowalski <bl0pbl33p@...il.com>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Al Viro <viro@...iv.linux.org.uk>,
Kees Cook <keescook@...omium.org>,
David Howells <dhowells@...hat.com>, kernel-team@...roid.com,
Andrew Morton <akpm@...ux-foundation.org>,
Arnd Bergmann <arnd@...db.de>,
"Eric W. Biederman" <ebiederm@...ssion.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Ingo Molnar <mingo@...nel.org>,
KJ Tsanaktsidis <ktsanaktsidis@...desk.com>,
linux-kselftest@...r.kernel.org, Michal Hocko <mhocko@...e.com>,
Nadav Amit <namit@...are.com>,
"Peter Zijlstra (Intel)" <peterz@...radead.org>,
Serge Hallyn <serge@...lyn.com>, Shuah Khan <shuah@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>,
Tycho Andersen <tycho@...ho.ws>
Subject: Re: [PATCH v2 1/2] Add polling support to pidfd
On Wed, May 01, 2019 at 05:13:12PM +0200, Oleg Nesterov wrote:
> On 04/30, Joel Fernandes (Google) wrote:
> >
> > +static unsigned int pidfd_poll(struct file *file, struct poll_table_struct *pts)
> > +{
> > + struct task_struct *task;
> > + struct pid *pid = file->private_data;
> > + int poll_flags = 0;
> > +
> > + poll_wait(file, &pid->wait_pidfd, pts);
> > +
> > + rcu_read_lock();
> > + task = pid_task(pid, PIDTYPE_PID);
> > + WARN_ON_ONCE(task && !thread_group_leader(task));
> ^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> Ah, this is not right, we can race with de_thread() which changes the leader,
> in particular it does leader->exit_signal = -1 to indicate that this thread is
> no longer a group leader, but pid_task() can return the old leader.
>
> We are going to check thread_group_empty() below, it won't be true in this case,
> so this race should not make any harm.
>
> Just remove this WARN_ON(). We can't use has_group_leader_pid(), it can return
> false if pid_task() returns the new leader.
>
> Otherwise I see no problems.
I'll remove the WARN_ON() check when applying this. Can I get your
Acked/Review, Oleg?
Christian
Powered by blists - more mailing lists