fs/proc/task_mmu.c: fix buffer overflow in add_page_map()
[pandora-kernel.git] / fs / proc / task_mmu.c
index 3efa725..ef1740d 100644 (file)
@@ -604,7 +604,7 @@ const struct file_operations proc_clear_refs_operations = {
 };
 
 struct pagemapread {
-       int pos, len;
+       int pos, len;           /* units: PM_ENTRY_BYTES, not bytes */
        u64 *buffer;
 };
 
@@ -792,8 +792,8 @@ static ssize_t pagemap_read(struct file *file, char __user *buf,
        if (!count)
                goto out_task;
 
-       pm.len = PM_ENTRY_BYTES * (PAGEMAP_WALK_SIZE >> PAGE_SHIFT);
-       pm.buffer = kmalloc(pm.len, GFP_TEMPORARY);
+       pm.len = (PAGEMAP_WALK_SIZE >> PAGE_SHIFT);
+       pm.buffer = kmalloc(pm.len * PM_ENTRY_BYTES, GFP_TEMPORARY);
        ret = -ENOMEM;
        if (!pm.buffer)
                goto out_task;