Skip to content

Commit 737326a

Browse files
Ard Biesheuvelwildea01
authored andcommitted
fs/proc: kcore: use kcore_list type to check for vmalloc/module address
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 <tanxiaojun@huawei.com> Tested-by: Tan Xiaojun <tanxiaojun@huawei.com> Tested-by: Mark Rutland <mark.rutland@arm.com> Acked-by: Mark Rutland <mark.rutland@arm.com> Reviewed-by: Laura Abbott <labbott@redhat.com> Reviewed-by: Jiri Olsa <jolsa@kernel.org> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Will Deacon <will.deacon@arm.com>
1 parent 06c35ef commit 737326a

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎fs/proc/kcore.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
504504
if (&m->list == &kclist_head) {
505505
if (clear_user(buffer, tsz))
506506
return -EFAULT;
507-
} else if (is_vmalloc_or_module_addr((void *)start)) {
507+
} else if (m->type == KCORE_VMALLOC) {
508508
vread(buf, (char *)start, tsz);
509509
/* we have to zero-fill user buffer even if no read */
510510
if (copy_to_user(buffer, buf, tsz))

0 commit comments

Comments
 (0)