[linux-yocto] [PATCH 1/2] fs/proc: kcore: use kcore_list type to check for vmalloc/module address

zhe.he at windriver.com zhe.he at windriver.com
Tue Oct 24 20:06:48 PDT 2017


From: Ard Biesheuvel <ard.biesheuvel at linaro.org>

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 at huawei.com>
Tested-by: Tan Xiaojun <tanxiaojun at huawei.com>
Tested-by: Mark Rutland <mark.rutland at arm.com>
Acked-by: Mark Rutland <mark.rutland at arm.com>
Reviewed-by: Laura Abbott <labbott at redhat.com>
Reviewed-by: Jiri Olsa <jolsa at kernel.org>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel at linaro.org>
Signed-off-by: Will Deacon <will.deacon at arm.com>
[ To fix following Call Trace when accessing /proc/kcore
[ 3637.649161] Call trace:
[ 3637.649561] Exception stack(0xffffffc01d5dfaf0 to 0xffffffc01d5dfc20)
[ 3637.650306] fae0:                                   ffffff80085ff800 0000008000000000
[ 3637.651183] fb00: ffffffc01d5dfcc0 ffffff80081d0228 ffffffc01d5f4b80 ffffffc01ffe0050
[ 3637.652091] fb20: ffffffc01ffe0050 ffffffc01d5f4b80 0000034ef3b32e60 ffffff80089789a0
[ 3637.652970] fb40: ffffff800871b124 ffffffc01d5f1e60 ffffffc01d5dfb90 ffffff80080d6b1c
[ 3637.653848] fb60: ffffffc01ffe0000 ffffffc01d5f4b00 ffffffc01ffe0050 ffffffc01d5f4b80
[ 3637.654733] fb80: ffffff800895d000 ffffffc01d5f4b80 00c0000040400791 ffffffc01fffe210
[ 3637.655600] fba0: 0000000040000000 ffffff80089c8ac8 0000000000000004 0000000000001f0b
[ 3637.656481] fbc0: 0000000000000800 ffffff80089c8ac8 0000000000000000 0000000000000800
[ 3637.657353] fbe0: 0000007fd127f1e0 0000000000000012 1a13110001000415 00000016170f120a
[ 3637.658231] fc00: 0000000000000012 0000000000000011 ffffff80081f9120 0000007fa8d49f28
[ 3637.659130] [<ffffff80081d0228>] vmalloc_to_page+0xb8/0xd0
[ 3637.659811] [<ffffff80081d37d4>] vread+0x1a4/0x2c0
[ 3637.660420] [<ffffff8008274124>] read_kcore+0x2ac/0x3d8
[ 3637.661052] [<ffffff8008265554>] proc_reg_read+0x8c/0xd0
[ 3637.661694] [<ffffff80081f66a0>] __vfs_read+0x48/0x80
[ 3637.662313] [<ffffff80081f7b7c>] vfs_read+0x8c/0x128
[ 3637.662914] [<ffffff80081f9174>] SyS_read+0x54/0xb0
[ 3637.663512] [<ffffff8008083730>] el0_svc_naked+0x24/0x28
]
Signed-off-by: He Zhe <zhe.he at windriver.com>
---
 fs/proc/kcore.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
index 4ee5527..45629f4 100644
--- a/fs/proc/kcore.c
+++ b/fs/proc/kcore.c
@@ -504,7 +504,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))
-- 
2.8.1



More information about the linux-yocto mailing list