From nobody Fri Apr 17 07:44:18 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 3464BFC0A for ; Sun, 22 Feb 2026 05:45:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771739138; cv=none; b=E0pGTaHGtpvnwziKh9YFHVD5xY606Mu7NBnRbnPiW0zXmbw9vgpy23koyyBPu+ky8924LZsyMEb6Izivoq04vZCCzJEfnqm/+Wrb+6fPPrtzPEiFtPNslfJtEaT0duyGyKcdKJzvH5/HNdrxbXq/cZEMkO5IRK5l5fzT5P0E5Fs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771739138; c=relaxed/simple; bh=FOuIj+ZtuDH5uaUftdQYZp0O/57MjvEf6HKTkEy/Jkg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Gforj0H0UQ5xmXq8eDUzVIA4nI56GEY69pD3Dm9k6RaCP/4GcnhF/mZVxM3qApmeXBU5G/ksRF3lQ+kmwEqLd8V+oPRkPWSYzm066HvnF0vc6S11HseZif8DXP3CiFY1bXR6xQa7fU5Yk8Lcfq6tjCpO+2YVvIVbZwWwu59TOS0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Att2FZSR; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Att2FZSR" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771739136; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=2YqpAD0U8T4fQHE/+t7PELDOy2lVte7kXSbCsAFkn3w=; b=Att2FZSROwFWfQ4XnFpVW0z/F6GnLt/iJm/toER8cc0Ba+ixhIMIbbb/aVWwMXhC/5Y0Ov iIwkA0cikB9+LrTklsH60EjpJZ7wkI2n1IwFor2m8pfZft8PB8Pqz7NDKWEgiujkGsL6ho 6I3vUSUTdHuQrFn3AheI1bMRPJNN7fs= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-634-0Ngkhli9NAq41G0r0JAkQQ-1; Sun, 22 Feb 2026 00:45:34 -0500 X-MC-Unique: 0Ngkhli9NAq41G0r0JAkQQ-1 X-Mimecast-MFC-AGG-ID: 0Ngkhli9NAq41G0r0JAkQQ_1771739133 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3662D195608F; Sun, 22 Feb 2026 05:45:33 +0000 (UTC) Received: from localhost (unknown [10.72.116.6]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0E92A30001BE; Sun, 22 Feb 2026 05:45:31 +0000 (UTC) From: Ming Lei To: Andrew Morton , linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, Ming Lei , "Mike Rapoport (Microsoft)" Subject: [PATCH] mm: fix NULL NODE_DATA dereference for memoryless nodes on boot Date: Sun, 22 Feb 2026 13:44:51 +0800 Message-ID: <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-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Content-Type: text/plain; charset="utf-8" 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) =3D=3D NULL. 4. The immediate "pgdat =3D 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. 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; =20 - if (!node_online(nid)) + if (!NODE_DATA(nid)) alloc_offline_node_data(nid); =20 pgdat =3D NODE_DATA(nid); --=20 2.52.0