[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190501151312.GA30235@redhat.com>
Date: Wed, 1 May 2019 17:13:12 +0200
From: Oleg Nesterov <oleg@...hat.com>
To: "Joel Fernandes (Google)" <joel@...lfernandes.org>
Cc: linux-kernel@...r.kernel.org,
Andy Lutomirski <luto@...capital.net>,
Steven Rostedt <rostedt@...dmis.org>,
Daniel Colascione <dancol@...gle.com>,
Christian Brauner <christian@...uner.io>,
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 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.
Oleg.
Powered by blists - more mailing lists