Re: [PATCH] latencytop: fix kernel panic and memory leak on proc
From: Arjan van de Ven
Date: Thu Feb 14 2008 - 19:48:27 EST
On Thu, 14 Feb 2008 14:51:19 -0800
Hiroshi Shimamoto <h-shimamoto@xxxxxxxxxxxxx> wrote:
> Hi,
>
> I posted 2 patches to fix kernel panic and memory leak.
> http://lkml.org/lkml/2008/2/14/282
> http://lkml.org/lkml/2008/2/14/283
>
> But, I think this patch is better than old ones.
>
> ---
> From: Hiroshi Shimamoto <h-shimamoto@xxxxxxxxxxxxx>
>
> Reading /proc/<pid>/latency or /proc/<pid>/task/<tid>/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.
>
> This can be reproduced by the follwoing script.
> while :
> do
> bash -c 'ls > ls.$$' &
> pid=$!
> cat /proc/$pid/latency &
> cat /proc/$pid/latency &
> cat /proc/$pid/latency &
> cat /proc/$pid/latency
> done
>
> And the task struct which gotten by get_proc_task() is never put.
> put_task_struct() should be called.
>
> This patch changes the private is used to store inode, and the task
> struct will be gotten and putted in read or write function.
>
> Signed-off-by: Hiroshi Shimamoto <h-shimamoto@xxxxxxxxxxxxx>
Fine with me; Ingo please merge
Thanks for working on this!
--
If you want to reach me at my work email, use arjan@xxxxxxxxxxxxxxx
For development, discussion and tips for power savings,
visit http://www.lesswatts.org
--
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/