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 4A51D1DF25D; Wed, 19 Feb 2025 09:27:21 +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=1739957241; cv=none; b=XFLEXCTEi9Ce2ApaKYc0Rc4Wv7/yQ8AsCpAvUBULV6GmIzpayyfuPAES/tolblSjLy0hIIiEMSDDtSjeobg961up39ENH/f6ib++FZNGiDEnhro1TEsrXFlYQSHfhqn4epWCwYvkwNabYhXf6xzIEm0ogBdbSPli38Xye0EBFV8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739957241; c=relaxed/simple; bh=O6qKr1O0mPYtjZ0gfRq9heDmobWhU5nzqjkF0Z02zuE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Q/BzBM2K0F2NWSQd+G0LhYJM6cTcOyl72/gVSf3WsJX5uT11B9Q2sGn0VE/rCTr6HeVS8H/LSEfFHeC+HMRrI78mMahDZ/KMUKYdYwwH406f/Z4As5sQFHQ6b99NQ7xfOf7gxvhDK3misQB5jP9D3/iaiIYhPKyBdKiwPKLzxbQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=nOfqrJVY; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="nOfqrJVY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C9A37C4CED1; Wed, 19 Feb 2025 09:27:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1739957241; bh=O6qKr1O0mPYtjZ0gfRq9heDmobWhU5nzqjkF0Z02zuE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nOfqrJVYDXE7xQ3fo9wWxz2fF/DYQI/caf+fL62Y+R4rz/bevX3uStgJeJUlaUYuF RpjYCez2I/wqNQlcbTfMkn1W5cyshrShK6X5OI7+PqgRMurx5m+sfmbGYYDWbqxbJK 0OVDphFRZIDs1SWPKERooruO+bg1/HD/KYcrvLWU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Catalin Marinas , Jakub Kicinski , "Matthieu Baerts (NGI0)" , Patrick Wang , Andrew Morton Subject: [PATCH 6.1 416/578] mm: kmemleak: fix upper boundary check for physical address objects Date: Wed, 19 Feb 2025 09:27:00 +0100 Message-ID: <20250219082709.382941580@linuxfoundation.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250219082652.891560343@linuxfoundation.org> References: <20250219082652.891560343@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Catalin Marinas commit 488b5b9eca68497b533ced059be5eff19578bbca upstream. 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. Link: https://lkml.kernel.org/r/20250127184233.2974311-1-catalin.marinas@arm.com Fixes: 84c326299191 ("mm: kmemleak: check physical address when scan") Signed-off-by: Catalin Marinas Reported-by: Jakub Kicinski Tested-by: Matthieu Baerts (NGI0) Cc: Patrick Wang Cc: [6.0.x] Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- mm/kmemleak.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/mm/kmemleak.c +++ b/mm/kmemleak.c @@ -1520,7 +1520,7 @@ static void kmemleak_scan(void) unsigned long phys = object->pointer; if (PHYS_PFN(phys) < min_low_pfn || - PHYS_PFN(phys + object->size) >= max_low_pfn) + PHYS_PFN(phys + object->size) > max_low_pfn) __paint_it(object, KMEMLEAK_BLACK); }