From nobody Tue Dec 2 02:05:58 2025 Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.5]) (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 E62162D29AA for ; Thu, 20 Nov 2025 14:43:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=117.135.210.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763649792; cv=none; b=SsUGWp8r2NsK+r27s4WZY2ujmWnwQUPwaLBRtIiQqEUinAf+AI0Eu7EddijU0/9t6SzSV/Zq4LzjEHlDY9AOyJ2Bc/+cMYb216IR9p2m6fz5qK07ZYy3We95y/6p4keR5mMIr9f6aSZ6KR7zsOr0R3BVblEbmGKYHdqVC7Cwqgg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763649792; c=relaxed/simple; bh=spV5L6H1+JkcT2bjV3bV6+NvN1FGjSO/RDMsckEXpuM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JzZrnd3EGo2S0nTyQGguWkTkOdgbOTKsOuax++Fq2FZOuC2v5Yyl+733wPoklzpRZSOO38T5ZyqB51i8gXfV+6HBVlKahjUfOZVJTJ70nWJERIn8BHIBh5G3qAi8iNat9wVCmC28Y33PRvN3dtt6Bq2du5nT23zDAg/msmI73vM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=T6DiTPF0; arc=none smtp.client-ip=117.135.210.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="T6DiTPF0" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=Vq tJVjFf2VTiEsbahcHSK1+SUTx0HAzBAG6cy3z+p1Y=; b=T6DiTPF0QphyeJ6ynn rpY6XD2TiGV6q27qAf8VLfdX98bhKJJh+KtuE1Hrjnxm4LekyutigidujNaJZWUG r84wyEXl/6O4Z5VDNM9CPz8nx5HVZn7NGs0xkQwThGDFvJjgCC4iACP8KbFJO8vA U8CfGhL9bNzEy5/5EKKrUSi7E= Received: from ubuntu24-z.. (unknown []) by gzga-smtp-mtada-g0-2 (Coremail) with SMTP id _____wA3yJmuKB9pTEQrBQ--.727S4; Thu, 20 Nov 2025 22:41:55 +0800 (CST) From: ranxiaokai627@163.com To: catalin.marinas@arm.com, akpm@linux-foundation.org, graf@amazon.com, rppt@kernel.org, pasha.tatashin@soleen.com, pratyush@kernel.org, changyuanl@google.com Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, kexec@lists.infradead.org, ran.xiaokai@zte.com.cn, ranxiaokai627@163.com Subject: [PATCH 2/2] liveupdate: Fix boot failure due to kmemleak access to unmapped pages Date: Thu, 20 Nov 2025 14:41:47 +0000 Message-ID: <20251120144147.90508-3-ranxiaokai627@163.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251120144147.90508-1-ranxiaokai627@163.com> References: <20251120144147.90508-1-ranxiaokai627@163.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-CM-TRANSID: _____wA3yJmuKB9pTEQrBQ--.727S4 X-Coremail-Antispam: 1Uf129KBjvJXoW7Kr48CF43Jw4DKryfuFWktFb_yoW8tr4xpF yvkF1DCw4jy34jqFWxZa4v934Fga90kw17AFyj934avr9Fv3s3tws5ZryUtryUXrZ3KF4j vFWDK3yruw4UZFDanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zEs2-UUUUUU= X-CM-SenderInfo: xudq5x5drntxqwsxqiywtou0bp/xtbBEBwMTGkfJUZRjQABsE Content-Type: text/plain; charset="utf-8" From: Ran Xiaokai When booting with debug_pagealloc=3Don while having: CONFIG_KEXEC_HANDOVER_ENABLE_DEFAULT=3Dy CONFIG_DEBUG_KMEMLEAK_DEFAULT_OFF=3Dn the system fails to boot due to page faults during kmemleak scanning. This occurs because: With debug_pagealloc enabled, __free_pages() invokes debug_pagealloc_unmap_pages(), clearing the _PAGE_PRESENT bit for freed pages in the direct mapping. Commit 3dc92c311498 ("kexec: add Kexec HandOver (KHO) generation helpers") releases the KHO scratch region via init_cma_reserved_pageblock(), unmapping its physical pages. Subsequent kmemleak scanning accesses these unmapped pages, triggering fatal page faults. Call kmemleak_no_scan_phys() from kho_reserve_scratch() to exclude the reserved region from scanning before it is released to the buddy allocator. Fixes: 3dc92c311498 ("kexec: add Kexec HandOver (KHO) generation helpers") Signed-off-by: Ran Xiaokai --- kernel/liveupdate/kexec_handover.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_h= andover.c index 224bdf5becb6..dd4942d1d76c 100644 --- a/kernel/liveupdate/kexec_handover.c +++ b/kernel/liveupdate/kexec_handover.c @@ -11,6 +11,7 @@ =20 #include #include +#include #include #include #include @@ -654,6 +655,7 @@ static void __init kho_reserve_scratch(void) if (!addr) goto err_free_scratch_desc; =20 + kmemleak_no_scan_phys(addr); kho_scratch[i].addr =3D addr; kho_scratch[i].size =3D size; i++; @@ -664,6 +666,7 @@ static void __init kho_reserve_scratch(void) if (!addr) goto err_free_scratch_areas; =20 + kmemleak_no_scan_phys(addr); kho_scratch[i].addr =3D addr; kho_scratch[i].size =3D size; i++; @@ -676,6 +679,7 @@ static void __init kho_reserve_scratch(void) if (!addr) goto err_free_scratch_areas; =20 + kmemleak_no_scan_phys(addr); kho_scratch[i].addr =3D addr; kho_scratch[i].size =3D size; i++; --=20 2.25.1