Skip to contentSkip to conversation

Question about Address Range Validation in Crash Kernel Allocation

DISCUSSION chenhaixiang (A) 2 participants 2 messages Mar 18, 2024 – Mar 19, 2024

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

Dear kexec Community Members,

I encountered an issue while using kexec-tools on my x86_64 machine.
When there is a segment marked as 'reserved' within the memory range allocated for the crash kernel in /proc/iomem,the output appears as follows:
2d4fd058-60efefff : System RAM
2d4fd058-58ffffff : System RAM

    49000000-58ffffff : Crash kernel
      53cbd000-53ccffff : Reserved

The crash_memory_range array will encounter incorrect address ranges:
CRASH MEMORY RANGES
000000002d4fd058-0000000048ffffff (0) 0000000053cbd000-0000000048ffffff (1) 0000000059000000-0000000053ccffff (0)

Read the code, I noticed that the get_crash_memory_ranges() function invokes exclude_region() to handle the splitting of memory regions, but it seems unable to properly handle the scenario described above. The code logic is as follows:
...

	if (start < mend && end > mstart) {
		if (start != mstart && end != mend) {
			/* Split memory region */
			crash_memory_range[i].end = start - 1;
			temp_region.start = end + 1;
			temp_region.end = mend;
			temp_region.type = RANGE_RAM;
			tidx = i+1;
		} else if (start != mstart)
			crash_memory_range[i].end = start - 1;
		else
			crash_memory_range[i].start = end + 1;
	}

...
If start < mstart < mend < end, resulting in crash_memory_range[i].end becoming less than crash_memory_range[i].start, leading to incorrect address ranges. I would like to know if this behavior is reasonable and whether it is necessary to validate the address ranges for compliance at the end.

Thank you for your time and assistance.

Chen Haixiang

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

#1 lore raw

Hi,

Quoted 8 lines · chenhaixiang (A)

Dear kexec Community Members,

I encountered an issue while using kexec-tools on my x86_64 machine.
When there is a segment marked as 'reserved' within the memory range allocated for the crash kernel in /proc/iomem,the output appears as follows:
2d4fd058-60efefff : System RAM
2d4fd058-58ffffff : System RAM

    49000000-58ffffff : Crash kernel
      53cbd000-53ccffff : Reserved

What kernel are you using? the version of kernel, and kexec-tools?

If you are testing on the latest mainline kernel, you could meet the issue Dave have met and fixed in below patch:

[PATCH] x86/kexec: do not update E820 kexec table for setup_data
https://lore.kernel.org/all/[email protected]/T/#u

Thanks
Baoquan

Quoted 27 lines

The crash_memory_range array will encounter incorrect address ranges:
CRASH MEMORY RANGES
000000002d4fd058-0000000048ffffff (0) 0000000053cbd000-0000000048ffffff (1) 0000000059000000-0000000053ccffff (0)

Read the code, I noticed that the get_crash_memory_ranges() function invokes exclude_region() to handle the splitting of memory regions, but it seems unable to properly handle the scenario described above. The code logic is as follows:
...

	if (start < mend && end > mstart) {
		if (start != mstart && end != mend) {
			/* Split memory region */
			crash_memory_range[i].end = start - 1;
			temp_region.start = end + 1;
			temp_region.end = mend;
			temp_region.type = RANGE_RAM;
			tidx = i+1;
		} else if (start != mstart)
			crash_memory_range[i].end = start - 1;
		else
			crash_memory_range[i].start = end + 1;
	}

...
If start < mstart < mend < end, resulting in crash_memory_range[i].end becoming less than crash_memory_range[i].start, leading to incorrect address ranges. I would like to know if this behavior is reasonable and whether it is necessary to validate the address ranges for compliance at the end.

Quoted 9 lines

Thank you for your time and assistance.

Chen Haixiang

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

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