diff options
| author | Oleg Nesterov <oleg@redhat.com> | 2014-12-10 15:45:21 -0800 |
|---|---|---|
| committer | Moyster <oysterized@gmail.com> | 2019-05-02 18:30:15 +0200 |
| commit | 3d9de0a637cea0b04567a972a36183f3fe7d6e01 (patch) | |
| tree | be075c7a24e79fc3f3c2f39ec6a5ecbdce3455ad | |
| parent | 559fd8158b1f63102feece0dcc05dacb357bd0f6 (diff) | |
sched_show_task: fix unsafe usage of ->real_parent
rcu_read_lock() can not protect p->real_parent if release_task(p) was
already called, change sched_show_task() to check pis_alive() like other
users do.
Note: we need some helpers to cleanup the code like this. And it seems
that that the usage of cpu_curr(cpu) in dump_cpu_task() is not safe too.
Change-Id: Id0b9f6dca6181fc9e406f003b3a652f27ae9109b
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Cc: Aaron Tomlin <atomlin@redhat.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>,
Cc: Sterling Alexander <stalexan@redhat.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Roland McGrath <roland@hack.frob.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
| -rw-r--r-- | kernel/sched/core.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 83259a8ad..82cb989d6 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -5265,8 +5265,10 @@ void sched_show_task(struct task_struct *p) #ifdef CONFIG_DEBUG_STACK_USAGE free = stack_not_used(p); #endif + ppid = 0; rcu_read_lock(); - ppid = task_pid_nr(rcu_dereference(p->real_parent)); + if (pid_alive(p)) + ppid = task_pid_nr(rcu_dereference(p->real_parent)); rcu_read_unlock(); printk(KERN_CONT "%5lu %5d %6d 0x%08lx\n", free, task_pid_nr(p), ppid, |
