Re: [PATCH] mm/sparse: fix preinited section_mem_map clobbering on failure path

David Hildenbrand (Arm)
2026-03-31T21:06:10Z

On 3/31/26 22:10, Andrew Morton wrote:
> On Tue, 31 Mar 2026 19:37:24 +0800 Muchun Song <songmuchun@bytedance.com> wrote:
>
>> sparse_init_nid() is careful to leave alone every section whose vmemmap
>> has already been set up by sparse_vmemmap_init_nid_early(); it only
>> clears section_mem_map for the rest:
>>
>> if (!preinited_vmemmap_section(ms))
>> ms->section_mem_map = 0;
>>
>> A leftover line after that conditional block
>>
>> ms->section_mem_map = 0;
>>
>> was supposed to be deleted but was missed in the failure path, causing the
>> field to be overwritten for all sections when memory allocation fails,
>> effectively destroying the pre-initialization check.
>>
>> Drop the stray assignment so that preinited sections retain their
>> already valid state.
>
> Here I go again ;) Are there userspace impacts?
>
> AI review thinks it found a different bug:
> https://sashiko.dev/#/patchset/20260331113724.2080833-1-songmuchun@bytedance.com

It speculates about a BUG_ON that we should easily hit with hugetlb
vmemmap optimization during boot I think (which we don't)? That
naturally make me skeptical.

But sounds like something to double check independently of this patch here.

--
Cheers,

David