lkml.org 
[lkml]   [2014]   [Nov]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/5] sched_show_task: fix unsafe usage of ->real_parent
On Mon, Nov 10, 2014 at 11:00:26PM +0100, Oleg Nesterov wrote:
> 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.
>
> Signed-off-by: Oleg Nesterov <oleg@redhat.com>

Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>

> ---
> 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 240157c..1ec75c9 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -4572,8 +4572,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,
> --
> 1.5.5.1
>


\
 
 \ /
  Last update: 2014-11-11 12:21    [W:0.117 / U:0.104 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site