Skip to contentSkip to conversation

crashdump-x86.c:Add a check for the crash kernel range in exclude_region()

PATCH In review chenhaixiang 2 participants 2 messages Mar 21, 2024 – Apr 23, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crashdump-x86.c:Add a check for the crash kernel range in exclude_region()

In some cases, such as start < mstart < mend < end when exclude_region(), this results in crash_memory_range[i].end becoming less than crash_memory_range[i].start, leading to incorrect address ranges. Adding a range check should be necessary.

---
 kexec/arch/i386/crashdump-x86.c | 8 ++++++++
 1 file changed, 8 insertions(+)
kexec/arch/i386/crashdump-x86.c +8 -0
index a01031e..30e9a41 100644
@@ -447,6 +447,14 @@ static int exclude_region(int *nr_ranges, uint64_t start, uint64_t end)
 			else
 				crash_memory_range[i].start = end + 1;
 		}
+		if (crash_memory_range[i].end < crash_memory_range[i].start) {
+			/* Crash memory range is unreasonable. */
+			fprintf(stderr, "Error: Crash memory range is unreasonable.\n");
+			dbgprintf("exclude_region: crash_memory_range[%d]\n"
+				"start = %016llx,end =  %016llx\n",
+				i, crash_memory_range[i].start, crash_memory_range[i].end);
+                        return -1;
+		}
 	}
 	/* Insert split memory region, if any. */
 	if (tidx >= 0) {
Signature · 7 lines
2.33.0


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#1 lore raw
Quoted 6 lines · chenhaixiang

In some cases, such as start < mstart < mend < end when exclude_region(), this results in crash_memory_range[i].end becoming less than crash_memory_range[i].start, leading to incorrect address ranges. Adding a range check should be necessary.

Hi,

Given the discussion at [1] I am assuming this patch should not go in. Please correct me if I am wrong.

[1] https://lore.kernel.org/all/[email protected]/

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec