]> rtime.felk.cvut.cz Git - hercules2020/nv-tegra/linux-4.4.git/commit
BACKPORT: pids: make task_tgid_nr_ns() safe
authorOleg Nesterov <oleg@redhat.com>
Fri, 1 Sep 2017 20:50:39 +0000 (13:50 -0700)
committermobile promotions <svcmobile_promotions@nvidia.com>
Wed, 29 Nov 2017 22:30:56 +0000 (14:30 -0800)
commit32c170491118159624bb05b7b4999b1e0313a43d
treef739d38fdb25f269d8bd81f10ec58125cbc1d059
parent5bf7371d40099d2bdde5cec1e0aa49813db4f7d0
BACKPORT: pids: make task_tgid_nr_ns() safe

This was reported many times, and this was even mentioned in commit
52ee2dfdd4f5 "pids: refactor vnr/nr_ns helpers to make them safe" but
somehow nobody bothered to fix the obvious problem: task_tgid_nr_ns()
is not safe because task->group_leader points to nowhere after the
exiting task passes exit_notify(), rcu_read_lock() can not help.

We really need to change __unhash_process() to nullify group_leader,
parent, and real_parent, but this needs some cleanups. Until then we
can turn task_tgid_nr_ns() into another user of __task_pid_nr_ns() and
fix the problem.

Reported-by: Troy Kensinger <tkensinger@google.com>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
(cherry picked from commit dd1c1f2f2028a7b851f701fc6a8ebe39dcb95e7c)

Bug 2000057

Change-Id: Iad19a77f4f0aa9f3b6b0539ac9c549fa64c18550
Reviewed-on: https://git-master.nvidia.com/r/1605402
GVS: Gerrit_Virtual_Submit
Reviewed-by: Hayden Du <haydend@nvidia.com>
Tested-by: Hayden Du <haydend@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
include/linux/pid.h
include/linux/sched.h
kernel/pid.c