From: Ard Biesheuvel Date: Wed, 14 Jun 2017 10:43:54 +0000 (+0200) Subject: fs/proc: kcore: use kcore_list type to check for vmalloc/module address X-Git-Tag: Ubuntu-4.10.0-29.33~14 X-Git-Url: https://git.proxmox.com/?p=mirror_ubuntu-zesty-kernel.git;a=commitdiff_plain;h=a0d0b3e180962e5ba7bee75f815370b6460d8b44 fs/proc: kcore: use kcore_list type to check for vmalloc/module address BugLink: https://bugs.launchpad.net/bugs/1702749 Instead of passing each start address into is_vmalloc_or_module_addr() to decide whether it falls into either the VMALLOC or the MODULES region, we can simply check the type field of the current kcore_list entry, since it will be set to KCORE_VMALLOC based on exactly the same conditions. As a bonus, when reading the KCORE_TEXT region on architectures that have one, this will avoid using vread() on the region if it happens to intersect with a KCORE_VMALLOC region. This is due the fact that the KCORE_TEXT region is the first one to be added to the kcore region list. Reported-by: Tan Xiaojun Tested-by: Tan Xiaojun Tested-by: Mark Rutland Acked-by: Mark Rutland Reviewed-by: Laura Abbott Reviewed-by: Jiri Olsa Signed-off-by: Ard Biesheuvel Signed-off-by: Will Deacon (cherry picked from commit 737326aa510b5f7d2f38ded739914a9d5e4e4cea) Signed-off-by: dann frazier Acked-by: Seth Forshee Acked-by: Stefan Bader Signed-off-by: Thadeu Lima de Souza Cascardo --- diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c index 0b80ad87b4d6..dfd10980d7d5 100644 --- a/fs/proc/kcore.c +++ b/fs/proc/kcore.c @@ -500,7 +500,7 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos) if (&m->list == &kclist_head) { if (clear_user(buffer, tsz)) return -EFAULT; - } else if (is_vmalloc_or_module_addr((void *)start)) { + } else if (m->type == KCORE_VMALLOC) { vread(buf, (char *)start, tsz); /* we have to zero-fill user buffer even if no read */ if (copy_to_user(buffer, buf, tsz))