Re: [PATCH] getrusage: fill ru_maxrss value

From: Oleg Nesterov
Date: Mon Nov 24 2008 - 13:02:34 EST


On 11/24, Jiri Pirko wrote:
>
> @@ -1588,6 +1589,13 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r)
> accumulate_thread_rusage(t, r);
> t = next_thread(t);
> } while (t != p);
> + if (p->mm) {
> + update_hiwater_rss(p->mm);
> + if (r->ru_maxrss < p->mm->hiwater_rss)
> + r->ru_maxrss = p->mm->hiwater_rss;

The task can free its ->mm right after the check. You need get_task_mm(),
but you can't do this under ->siglock because it takes task_lock().

I think you can move this code outside of lock_task_sighand().

Oleg.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/