Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=ae0027869db7d28563cd783865fab04ffd18419c
Commit:     ae0027869db7d28563cd783865fab04ffd18419c
Parent:     2d07b255c7b8a9723010e5c74778e058dc05162e
Author:     Hiroshi Shimamoto <[EMAIL PROTECTED]>
AuthorDate: Thu Feb 14 10:26:24 2008 -0800
Committer:  Ingo Molnar <[EMAIL PROTECTED]>
CommitDate: Mon Feb 25 16:34:17 2008 +0100

    latencytop: fix kernel panic while reading latency proc file
    
    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.
    
    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 <[EMAIL PROTECTED]>
    Signed-off-by: Ingo Molnar <[EMAIL PROTECTED]>
---
 fs/proc/base.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/fs/proc/base.c b/fs/proc/base.c
index 96ee899..989e307 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;
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to