From patchwork Wed Oct 13 05:47:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 12554871 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98992C433FE for ; Wed, 13 Oct 2021 05:48:05 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2594061027 for ; Wed, 13 Oct 2021 05:48:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2594061027 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 6978C6B006C; Wed, 13 Oct 2021 01:48:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 647926B0071; Wed, 13 Oct 2021 01:48:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 50F63900002; Wed, 13 Oct 2021 01:48:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0108.hostedemail.com [216.40.44.108]) by kanga.kvack.org (Postfix) with ESMTP id 3E65F6B006C for ; Wed, 13 Oct 2021 01:48:04 -0400 (EDT) Received: from smtpin40.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id F25DC182DA488 for ; Wed, 13 Oct 2021 05:48:03 +0000 (UTC) X-FDA: 78690333246.40.F2BC4E4 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf13.hostedemail.com (Postfix) with ESMTP id 9EB54103B952 for ; Wed, 13 Oct 2021 05:48:03 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 9BA7960241; Wed, 13 Oct 2021 05:48:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634104082; bh=mdVw099jB84PTiR0YrwKOQUKSbZlwv5o94JdBfjiwck=; h=From:To:Cc:Subject:Date:From; b=p+3Z5JkcODT2tpRoY9rCTjOSo1IFtXswsiLfemZuKWI4JB4lsfHuk1/6y1PLrj7le PpI0Yb0yT5VqxSZG38cr9l0+F9u90/Nl5OsTORTkUn2Pq8wh25Jq0vLBsw6CW/rbEa 3GIQxI/a2oCBmXLpqgACC3ShQ7XCa0venwO71f+tH6gpL91QUlS8zDW+rJFAFl+hJf Se9w3RMJ/sK0NAYCSmZdLZj8ipBCNlWonu+WBfx4Gw7svakpUzdr5eNFJBc1lR9AiM hlzZDMmF30oeTkd3m3Lk1bpBWk7Veopfg9Gu8IjOiOYGBlX+rumNyatYwEbyTR9FZy 7BAitRCA6fHZw== From: Mike Rapoport To: linux-mm@kvack.org Cc: Andrew Morton , Catalin Marinas , Mike Rapoport , Mike Rapoport , Vladimir Zapolskiy , linux-kernel@vger.kernel.org Subject: [PATCH] memblock: exclude NOMAP regions from kmemleak Date: Wed, 13 Oct 2021 08:47:56 +0300 Message-Id: <20211013054756.12177-1-rppt@kernel.org> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 9EB54103B952 X-Stat-Signature: b66t9538dmsyxm3tr9j8affrbm8uge3i Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=p+3Z5Jkc; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf13.hostedemail.com: domain of rppt@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=rppt@kernel.org X-HE-Tag: 1634104083-503261 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Mike Rapoport Vladimir Zapolskiy reports: commit a7259df76702 ("memblock: make memblock_find_in_range method private") invokes a kernel panic while running kmemleak on OF platforms with nomaped regions: Unable to handle kernel paging request at virtual address fff000021e00000 [...] scan_block+0x64/0x170 scan_gray_list+0xe8/0x17c kmemleak_scan+0x270/0x514 kmemleak_write+0x34c/0x4ac Indeed, NOMAP regions don't have linear map entries so an attempt to scan these areas would fault. Prevent such faults by excluding NOMAP regions from kmemleak. Link: https://lore.kernel.org/all/8ade5174-b143-d621-8c8e-dc6a1898c6fb@linaro.org Fixes: a7259df76702 ("memblock: make memblock_find_in_range method private") Signed-off-by: Mike Rapoport Tested-by: Vladimir Zapolskiy Acked-by: Catalin Marinas Reviewed-by: Anshuman Khandual --- mm/memblock.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) base-commit: 64570fbc14f8d7cb3fe3995f20e26bc25ce4b2cc diff --git a/mm/memblock.c b/mm/memblock.c index 184dcd2e5d99..5c3503c98b2f 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -936,7 +936,12 @@ int __init_memblock memblock_mark_mirror(phys_addr_t base, phys_addr_t size) */ int __init_memblock memblock_mark_nomap(phys_addr_t base, phys_addr_t size) { - return memblock_setclr_flag(base, size, 1, MEMBLOCK_NOMAP); + int ret = memblock_setclr_flag(base, size, 1, MEMBLOCK_NOMAP); + + if (!ret) + kmemleak_free_part_phys(base, size); + + return ret; } /**