[PATCH] /fs/proc/: 'larger than buffer size' memory accessed by clear_user()
authorAdam B. Jerome <abj@novell.com>
Wed, 12 Jul 2006 16:03:07 +0000 (09:03 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Wed, 12 Jul 2006 19:52:55 +0000 (12:52 -0700)
Address a potential 'larger than buffer size' memory access by
clear_user().  Without this patch, this call to clear_user() can attempt to
clear too many (tsz) bytes resulting in a wrong (-EFAULT) return code by
read_kcore().

Signed-off-by: Adam B. Jerome <abj@novell.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
fs/proc/kcore.c

index 8d6d85d7400f829c44444fa5143858eedd193735..6a984f64edd7179893887528f07a63f90bf7b15c 100644 (file)
@@ -382,7 +382,7 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
                                 */
                                if (n) { 
                                        if (clear_user(buffer + tsz - n,
-                                                               tsz - n))
+                                                               n))
                                                return -EFAULT;
                                }
                        } else {