[PATCH] kho: do not reserve empty per-node bootmem areas

sashiko-bot at kernel.org sashiko-bot at kernel.org
Wed Oct 14 06:27:27 PDT 2026


Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] kho: incomplete fix for zero-size memblock allocations in bootmem
--

commit 67ab500bd948f5a3b52f1c8170626cb8f1dfc6c3
Author: Pratyush Yadav (Google) <pratyush at kernel.org>

kho: do not reserve empty per-node bootmem areas

Some nodes do not allocate any early boot memory, causing memblock to
return an address without reserving anything when requested with zero size.
This address is recorded in kho_bootmem with a size of 0, and can cause KHO
to fail to initialize. This patch skips bootmem reservation for memoryless
nodes entirely.

> diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_handover.c
> index 7018e25e4eda1..6f1f55fe31819 100644
> --- a/kernel/liveupdate/kexec_handover.c
> +++ b/kernel/liveupdate/kexec_handover.c

[ ... ]

> @@ -882,6 +882,9 @@ static void __init kho_reserve_bootmem(void)
>  	 */
>  	for_each_node_state(nid, N_MEMORY) {
>  		size = bootmem_size_node(nid);
> +		if (!size)
> +			continue;
> +
>  		addr = memblock_alloc_range_nid(size, BOOTMEM_ALIGNMENT_BYTES,

[Severity: High]
This adds a zero-size check for per-node bootmem allocations, but does the
same issue exist for bootmem_size_lowmem and bootmem_size_global?

Looking at kho_reserve_bootmem() just before this hunk, they are allocated
without a similar check:

kernel/liveupdate/kexec_handover.c:kho_reserve_bootmem() {
    ...
	size = bootmem_size_lowmem;
	addr = memblock_phys_alloc_range(size, BOOTMEM_ALIGNMENT_BYTES, 0,
					 ARCH_LOW_ADDRESS_LIMIT);
	if (!addr) {
    ...
	size = bootmem_size_global;
	addr = memblock_phys_alloc(size, BOOTMEM_ALIGNMENT_BYTES);
	if (!addr) {
    ...
}

If bootmem_size_lowmem or bootmem_size_global evaluates to 0 (for example
via boot parameters or on systems lacking lowmem), will memblock return an
unreserved address and add it to kho_bootmem with size 0? Alternatively,
if the region has no free memory, could the 0-size allocation fail and halt
KHO initialization entirely?

Later, if KHO attempts to preserve a contiguous range of pages that spans
across this unreserved boundary, could kho_bootmem_overlap() incorrectly
evaluate the overlap and fail the preservation request?

>  						0, MEMBLOCK_ALLOC_ACCESSIBLE,
>  						nid, true);
>  		if (!addr) {

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261014131547.259138-1-pratyush@kernel.org?part=1



More information about the kexec mailing list