From: Hiroshi Shimamoto Date: Thu, 14 Feb 2008 18:26:24 +0000 (-0800) Subject: latencytop: fix kernel panic while reading latency proc file X-Git-Tag: v2.6.25-rc4~160^2~2 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=ae0027869db7d28563cd783865fab04ffd18419c;p=linux-2.6-omap-h63xx.git latencytop: fix kernel panic while reading latency proc file Reading /proc//latency or /proc//task//latency could cause NULL pointer dereference. In lstats_open(), get_proc_task() can return NULL, in which case the kernel will oops at lstats_show_proc() because m->private is NULL. When get_proc_task() returns NULL, the kernel should return -ENOENT. This can be reproduced by the following script. while : do date bash -c 'ls > ls.$$' & pid=$! cat /proc/$pid/latency & cat /proc/$pid/latency & cat /proc/$pid/latency & cat /proc/$pid/latency done Signed-off-by: Hiroshi Shimamoto Signed-off-by: Ingo Molnar --- diff --git a/fs/proc/base.c b/fs/proc/base.c index 96ee899d650..989e3078d7a 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -350,6 +350,8 @@ static int lstats_open(struct inode *inode, struct file *file) struct seq_file *m; struct task_struct *task = get_proc_task(inode); + if (!task) + return -ENOENT; ret = single_open(file, lstats_show_proc, NULL); if (!ret) { m = file->private_data;