From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 704AD23EA80 for ; Sun, 22 Feb 2026 11:21:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771759308; cv=none; b=n+AKEjAbPvgE+QqtpHGpiTzhvZyWKFETzQoYAorFm/jvQpGHErzIncq86FXrovj+VxjDFTLl7KFSiiXA90sSeXzN7vXQxDTOGUhXwf4REwbFRBtIUZ6RAUdeghu+SfJvaq44UDuq/xO2Bj0sKIZgQ1SfymxB/iu9mdpH77ql4Vc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771759308; c=relaxed/simple; bh=rkrhZGxSd+VBHZf31FNAsyPioRj1tB6aNXODDsIAcP4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=JjkGH8pRd8+WZgzmSscehkNXXOdmBp93YAyEDeclTwuFHYtaawgAs/Wa6wy3ChBVAmD/3YC26KYe4CFzH4ClmDZ8r3a1M6XQDNY5QkQoSyAIq4n9DtSvgzJgHxO1T3VkaqxRhPsIauZTCa/0JscHKA0ZW9E+Z3MeeyruYIz4JRY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=osR3VlYv; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="osR3VlYv" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6B6EEC116D0; Sun, 22 Feb 2026 11:21:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1771759308; bh=rkrhZGxSd+VBHZf31FNAsyPioRj1tB6aNXODDsIAcP4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=osR3VlYv7t2cMCbTPEGsUPqhC4nyac/EXxZBRzSYJHvLAp+YtCOJoLdlf7eCkV2PN XV+cBJqFE5Ems2zjJkr0+GMbIOLfMuSQoayo8dGSO8sK/ZARKRaaL9WZsaSljegEZJ NYaPewK5pMWpmYRMYFOL9C3bmYe2885ba9iXAbVxbB4E5g2wEJ7H65V5aCmDlSSjl0 yIjo1X3lEu/SMyt03CZxu+J3vGvG2zSxFSPu+C1flNPEYEvslLiBm7c6apPL9KxJoC b+W9lxDpY0zafx6k1Zi02iu21yTvmDB0vTTUCg0MM6UeUfFn5o0j9NsD5vl/N1TeLz dvf2ppJM/b4fw== Date: Sun, 22 Feb 2026 13:21:42 +0200 From: Mike Rapoport To: Ming Lei Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm: fix NULL NODE_DATA dereference for memoryless nodes on boot Message-ID: References: <20260222054451.3261-1-ming.lei@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260222054451.3261-1-ming.lei@redhat.com> Hi, On Sun, Feb 22, 2026 at 01:44:51PM +0800, Ming Lei wrote: > Commit d49004c5f0c1 ("arch, mm: consolidate initialization of nodes, > zones and memory map") moved free_area_init() from setup_arch() to > mm_core_init_early(), which runs after setup_arch() returns. > > This changed the ordering relative to init_cpu_to_node() on x86. Before > the commit, free_area_init() ran during paging_init() (called from > setup_arch()) *before* init_cpu_to_node(). After the commit, it runs > *after* init_cpu_to_node(). > > On machines with memoryless NUMA nodes (e.g., node 0 has CPUs but no > memory), this causes a NULL pointer dereference: > > 1. numa_register_nodes() skips memoryless nodes: no alloc_node_data() > and no node_set_online() for them. > 2. init_cpu_to_node() sets memoryless nodes online (they have CPUs) > but does not allocate NODE_DATA. > 3. free_area_init() checks "if (!node_online(nid))" to decide whether > to call alloc_offline_node_data(). Since the memoryless node is now > online, the allocation is skipped, leaving NODE_DATA(nid) == NULL. > 4. The immediate "pgdat = NODE_DATA(nid)" dereferences NULL. > > The crash happens before console_init(), so no output is visible without > earlyprintk. With earlyprintk enabled, the following panic is observed: > > BUG: unable to handle page fault for address: 000000000002a1e0 > Oops: Oops: 0000 [#1] SMP NOPTI > RIP: 0010:free_area_init_node+0x3a/0x540 > Call Trace: > > free_area_init+0x331/0x4e0 > start_kernel+0x69/0x4a0 > x86_64_start_reservations+0x24/0x30 > x86_64_start_kernel+0x125/0x130 > common_startup_64+0x13e/0x148 > > Kernel panic - not syncing: Attempted to kill the idle task! > > Fix this by checking "if (!NODE_DATA(nid))" instead of > "if (!node_online(nid))". This directly tests whether the per-node data > structure needs to be allocated, regardless of the node's online status. I believe that this change is fine for !x86 as well, but it deserves a sentence in the commit log. > Cc: Mike Rapoport (Microsoft) > Fixes: d49004c5f0c1 ("arch, mm: consolidate initialization of nodes, zones and memory map") > Signed-off-by: Ming Lei > --- > mm/mm_init.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/mm_init.c b/mm/mm_init.c > index 61d983d23f55..9d63cab36204 100644 > --- a/mm/mm_init.c > +++ b/mm/mm_init.c > @@ -1896,7 +1896,7 @@ static void __init free_area_init(void) > for_each_node(nid) { > pg_data_t *pgdat; > > - if (!node_online(nid)) > + if (!NODE_DATA(nid)) > alloc_offline_node_data(nid); A comment that says that if an architecture didn't allocate node data, we presume that the node is memoryless and offline would be nice here. > > pgdat = NODE_DATA(nid); > -- > 2.52.0 > -- Sincerely yours, Mike.