2006-01-22 22:18:08

by Albert D. Cahalan

[permalink] [raw]
Subject: [PATCH 3/4] pmap: fix integer overflow


This fixes an integer overflow in the /proc/*/maps files.
The size of a file may exceed the limit of unsigned long
on a 32-bit platform.

Some parsers will break if they encounter a mapping of a
file that has an offset which doesn't fit into unsigned long.
Parsers which need the offset to be correct will break
without this change though. Parsers which can not handle
large numbers are likely to get LONG_MAX from strtol().

Signed-off-by: Albert Cahalan <[email protected]>

---

This applies to -git4, grabbed Saturday night.


diff -Naurd 2/fs/proc/task_mmu.c 3/fs/proc/task_mmu.c
--- 2/fs/proc/task_mmu.c 2006-01-22 15:20:24.000000000 -0500
+++ 3/fs/proc/task_mmu.c 2006-01-22 15:26:54.000000000 -0500
@@ -135,14 +135,14 @@
ino = inode->i_ino;
}

- seq_printf(m, "%08lx-%08lx %c%c%c%c %08lx %02x:%02x %lu %n",
+ seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
vma->vm_start,
vma->vm_end,
flags & VM_READ ? 'r' : '-',
flags & VM_WRITE ? 'w' : '-',
flags & VM_EXEC ? 'x' : '-',
flags & VM_MAYSHARE ? 's' : 'p',
- vma->vm_pgoff << PAGE_SHIFT,
+ (unsigned long long)vma->vm_pgoff << PAGE_SHIFT,
MAJOR(dev), MINOR(dev), ino, &len);

/*