From nobody Mon Feb 9 07:23:00 2026 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 38F6517ADF8 for ; Mon, 27 Jan 2025 18:42:36 +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=1738003357; cv=none; b=IWq1QlLXGtg5kOcCbKMep5N3zpKvlXSgR4ExpVqNTiuSuYuOq3XFRbBCo49cHpjcFdbOCXI3SVEXkfxs7T9geivMBhZWa0u2AxigqNDfUWaHKIA1r87JPkkwm2E8eg+7RMWDmlBXglCtU2v6CIGKQfR+5siEEo+75SEUM4UkJOY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738003357; c=relaxed/simple; bh=mPoaC0K2464iUJshjGC5BsuNoFVG3pD6kDVF54HVfhA=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=JbShxXM6mo+TGRYdlBPfPFGJHubVepuzjw9jVfihKqQStbm4mNps2jm6ecyidpd8qc9WlXf80+on8hRE806NjcqKUl0ZlQdgpDYsBf7In2H7qy59MSirFxe7RQzeJV958v+L0irlZeVvDoRM6hPF+OCyrIdb++ckMdw5PjpdbM8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 59F7EC4CED2; Mon, 27 Jan 2025 18:42:35 +0000 (UTC) From: Catalin Marinas To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, Jakub Kicinski , "Matthieu Baerts (NGI0)" , Patrick Wang , Andrew Morton Subject: [PATCH] mm: kmemleak: Fix upper boundary check for physical address objects Date: Mon, 27 Jan 2025 18:42:33 +0000 Message-Id: <20250127184233.2974311-1-catalin.marinas@arm.com> X-Mailer: git-send-email 2.39.5 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 Content-Type: text/plain; charset="utf-8" Memblock allocations are registered by kmemleak separately, based on their physical address. During the scanning stage, it checks whether an object is within the min_low_pfn and max_low_pfn boundaries and ignores it otherwise. With the recent addition of __percpu pointer leak detection (commit 6c99d4eb7c5e ("kmemleak: enable tracking for percpu pointers")), kmemleak started reporting leaks in setup_zone_pageset() and setup_per_cpu_pageset(). These were caused by the node_data[0] object (initialised in alloc_node_data()) ending on the PFN_PHYS(max_low_pfn) boundary. The non-strict upper boundary check introduced by commit 84c326299191 ("mm: kmemleak: check physical address when scan") causes the pg_data_t object to be ignored (not scanned) and the __percpu pointers it contains to be reported as leaks. Make the max_low_pfn upper boundary check strict when deciding whether to ignore a physical address object and not scan it. Signed-off-by: Catalin Marinas Fixes: 84c326299191 ("mm: kmemleak: check physical address when scan") Reported-by: Jakub Kicinski Tested-by: Matthieu Baerts (NGI0) Cc: Patrick Wang Cc: Andrew Morton Cc: # 6.0.x --- mm/kmemleak.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/kmemleak.c b/mm/kmemleak.c index 820ba3b5cbfc..bb7d61fc4da3 100644 --- a/mm/kmemleak.c +++ b/mm/kmemleak.c @@ -1689,7 +1689,7 @@ static void kmemleak_scan(void) unsigned long phys =3D object->pointer; =20 if (PHYS_PFN(phys) < min_low_pfn || - PHYS_PFN(phys + object->size) >=3D max_low_pfn) + PHYS_PFN(phys + object->size) > max_low_pfn) __paint_it(object, KMEMLEAK_BLACK); }