From be1a4c1985a6fb9cc3554bfacccd927efa1429b9 Mon Sep 17 00:00:00 2001 From: Baoquan He Date: Fri, 3 Oct 2014 00:02:36 +0000 Subject: [PATCH] fs/proc/kcore.c: don't add modules range to kcore if it's equal to vmcore range On some ARCHs modules range is eauql to vmalloc range. E.g on i686 "#define MODULES_VADDR VMALLOC_START" "#define MODULES_END VMALLOC_END" This will cause 2 duplicate program segments in /proc/kcore, and no flag to indicate they are different. This is confusing. And usually people who need check the elf header or read the content of kcore will check memory ranges. Two program segments which are the same are unnecessary. So check if the modules range is equal to vmalloc range. If so, just skip adding the modules range. Signed-off-by: Baoquan He Cc: Xishi Qiu Cc: Paul Gortmaker Signed-off-by: Andrew Morton --- fs/proc/kcore.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c index 6df8d0722c970e..69cb67b56bbfd6 100644 --- a/fs/proc/kcore.c +++ b/fs/proc/kcore.c @@ -610,8 +610,11 @@ static void __init proc_kcore_text_init(void) struct kcore_list kcore_modules; static void __init add_modules_range(void) { - kclist_add(&kcore_modules, (void *)MODULES_VADDR, + if ( (MODULES_VADDR != VMALLOC_START) && + (MODULES_END != VMALLOC_END) ) { + kclist_add(&kcore_modules, (void *)MODULES_VADDR, MODULES_END - MODULES_VADDR, KCORE_VMALLOC); + } } #else static void __init add_modules_range(void)