Skip to content

Commit a1b3d2f

Browse files
martinetdgregkh
authored andcommitted
fs/proc/kcore.c: fix invalid memory access in multi-page read optimization
The 'm' kcore_list item could point to kclist_head, and it is incorrect to look at m->addr / m->size in this case. There is no choice but to run through the list of entries for every address if we did not find any entry in the previous iteration Reset 'm' to NULL in that case at Omar Sandoval's suggestion. [[email protected]: add comment] Link: http://lkml.kernel.org/r/[email protected] Fixes: bf991c2 ("proc/kcore: optimize multiple page reads") Signed-off-by: Dominique Martinet <[email protected]> Reviewed-by: Andrew Morton <[email protected]> Cc: Omar Sandoval <[email protected]> Cc: Alexey Dobriyan <[email protected]> Cc: Eric Biederman <[email protected]> Cc: James Morse <[email protected]> Cc: Bhupesh Sharma <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 889c695 commit a1b3d2f

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

fs/proc/kcore.c

+1
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,7 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
464464
ret = -EFAULT;
465465
goto out;
466466
}
467+
m = NULL; /* skip the list anchor */
467468
} else if (m->type == KCORE_VMALLOC) {
468469
vread(buf, (char *)start, tsz);
469470
/* we have to zero-fill user buffer even if no read */

0 commit comments

Comments
 (0)