Skip to contentSkip to conversation

not adding modules range to kcore if it's equal to vmcore range

PATCH Superseded Baoquan He 1 participant 2 messages Aug 26, 2014

Subsystems (2)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Baoquan He

author
#0 lore raw

PATCH v3 1/1 not adding 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 any flag to indicate both of them 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 completely can't give any help on this.

So in this patch a judgment added to check if modules range is equal to or included in vmalloc range completely. If yes, just skip adding the modules range. If and only if modules range is not completely included in vmalloc range just add it since the part out of vmalloc range need be accessible.

---
 fs/proc/kcore.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
fs/proc/kcore.c +4 -1
index 6df8d07..a4b7ff1 100644
@@ -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)
Signature · 1 line
1.9.0
author
#1 lore raw
Quoted 26 lines · Baoquan He

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 any flag to indicate both of them 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 completely can't give any help on this.

So in this patch a judgment added to check if modules range is equal to or included in vmalloc range completely. If yes, just skip adding the modules range. If and only if modules range is not completely included in vmalloc range just add it since the part out of vmalloc range need be accessible.

---
 fs/proc/kcore.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
fs/proc/kcore.c +0 -0
index 6df8d07..a4b7ff1 100644

fs/proc/kcore.c static void __init proc_kcore_text_init(void) · line 614

Quoted 6 lines
fs/proc/kcore.c +2 -1
@@ -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) ) {

Oh, the check should be like below expression which can denote that modules range is equal to or included in vmalloc range.

if ((MODULES_VADDR >= VMALLOC_START) && (MODULES_END <= VMALLOC_END) ) {

Nack this patch, will post a new one.

Quoted 9 lines
fs/proc/kcore.c +2 -0
+		kclist_add(&kcore_modules, (void *)MODULES_VADDR,
 			MODULES_END - MODULES_VADDR, KCORE_VMALLOC);
+	}
 }
 #else
 static void __init add_modules_range(void)
Signature · 1 line
1.9.0