Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6818129rwn; Tue, 13 Sep 2022 09:22:22 -0700 (PDT) X-Google-Smtp-Source: AA6agR7Uij8K/cKLNvnPk/zGoYu/fqH6AdHCZWJDKSk1bnY78t+7iDyWZl2JV6FAxAC0g2pGYUUP X-Received: by 2002:a63:81c1:0:b0:434:f41f:496 with SMTP id t184-20020a6381c1000000b00434f41f0496mr26267532pgd.208.1663086142566; Tue, 13 Sep 2022 09:22:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663086142; cv=none; d=google.com; s=arc-20160816; b=TKZh05KLPxwrisLAcKk4rehhd/wl9uDOkzBwfMBiskegCDL+ofbxidBQy1B1u3dpM5 mpmuZR50JbMv+xe1lJ20Teyyv1pqwOHSF+UivzXv2K8RelajQdYITQFPf5foFfOVlj7p nm+u+dcoB0Yzw59KGzatcEIA25Ep1J4ETTRSK2/BC73lQoeO+dKCLOUgbZzT+ORPk23n RMHokTIMURciOf6H20GFwRZeHtvExDfBz0dE2Ci4lv/6b4QJg3mbkwdoAnM13l0T+4gx /UFOe+thT7QW+muwUScB+2G1ILBCQSJCW45dA2/sQViIi18TtSUUjZcMJQ3Ju6wlE+62 WhGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=eY7oYHDXaHxicEvAjL3lcHoyUHfJuvEyopU/0teQWj8=; b=Ba4XkT6xwnmsnEJ3NpYFdza2iwE/IQZJz0S2z5kf6A1PoHrs9vlKl4dYKmH0Xgm+Pn yTDW/5ghVrG0igND2BHZoBR+eo1XmYtBw/jjNvnQKxE3GSVIWThlT3LKGNU6nJcjWkox CUax4bU/Kd9uXv6/BxAnKpIf8bTPpecgnRBOfji6otwhFUaip22dw67dCSsvYucEIzJ1 7o81WoxjwMzIQ7COWWbIE+Mqoi96YYEf1TneTemA4R0FEKJkNE3b4bLPZyFnozYDOdf5 fmTZ9hKgOh4MM4nyYo9equtOBhFlEAjzriII/cYeh47YlvdNFPbUXBkVsGq94eYp2xHN cWVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nhYXXc3U; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s26-20020a63ff5a000000b0042bd711f28asi444128pgk.273.2022.09.13.09.22.10; Tue, 13 Sep 2022 09:22:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nhYXXc3U; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234858AbiIMOyT (ORCPT + 99 others); Tue, 13 Sep 2022 10:54:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233771AbiIMOuT (ORCPT ); Tue, 13 Sep 2022 10:50:19 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7ADD671739; Tue, 13 Sep 2022 07:26:08 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5B4C3614CA; Tue, 13 Sep 2022 14:26:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 68977C433C1; Tue, 13 Sep 2022 14:26:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1663079161; bh=mGwilQNMz8rWwIIMssiaTJwKrROZCcdiCFXPZnexT9U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nhYXXc3U0l/3Umoj+MTBOkzuIQLt496oOJB4cpfdeIlYiPKLDZB/U6SmWacFqzNA1 Fy4KO0YEYP4S+DsF4z4rf3hqDrLPmhzha28aNdUxxcmsGxesgcwjWPqEEXWr6znLc3 oqR/uvjGz3qx9bFzP9QWrpridsP9NZZo26uEkF6A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yee Lee Subject: [PATCH 5.4 005/108] Revert "mm: kmemleak: take a full lowmem check in kmemleak_*_phys()" Date: Tue, 13 Sep 2022 16:05:36 +0200 Message-Id: <20220913140353.781915114@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220913140353.549108748@linuxfoundation.org> References: <20220913140353.549108748@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yee Lee This reverts commit 23c2d497de21f25898fbea70aeb292ab8acc8c94. Commit 23c2d497de21 ("mm: kmemleak: take a full lowmem check in kmemleak_*_phys()") brought false leak alarms on some archs like arm64 that does not init pfn boundary in early booting. The final solution lands on linux-6.0: commit 0c24e061196c ("mm: kmemleak: add rbtree and store physical address for objects allocated with PA"). Revert this commit before linux-6.0. The original issue of invalid PA can be mitigated by additional check in devicetree. The false alarm report is as following: Kmemleak output: (Qemu/arm64) unreferenced object 0xffff0000c0170a00 (size 128): comm "swapper/0", pid 1, jiffies 4294892404 (age 126.208s) hex dump (first 32 bytes): 62 61 73 65 00 00 00 00 00 00 00 00 00 00 00 00 base............ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace: [<(____ptrval____)>] __kmalloc_track_caller+0x1b0/0x2e4 [<(____ptrval____)>] kstrdup_const+0x8c/0xc4 [<(____ptrval____)>] kvasprintf_const+0xbc/0xec [<(____ptrval____)>] kobject_set_name_vargs+0x58/0xe4 [<(____ptrval____)>] kobject_add+0x84/0x100 [<(____ptrval____)>] __of_attach_node_sysfs+0x78/0xec [<(____ptrval____)>] of_core_init+0x68/0x104 [<(____ptrval____)>] driver_init+0x28/0x48 [<(____ptrval____)>] do_basic_setup+0x14/0x28 [<(____ptrval____)>] kernel_init_freeable+0x110/0x178 [<(____ptrval____)>] kernel_init+0x20/0x1a0 [<(____ptrval____)>] ret_from_fork+0x10/0x20 This pacth is also applicable to linux-5.17.y/linux-5.18.y/linux-5.19.y Cc: Signed-off-by: Yee Lee Signed-off-by: Greg Kroah-Hartman --- mm/kmemleak.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/mm/kmemleak.c +++ b/mm/kmemleak.c @@ -1123,7 +1123,7 @@ EXPORT_SYMBOL(kmemleak_no_scan); void __ref kmemleak_alloc_phys(phys_addr_t phys, size_t size, int min_count, gfp_t gfp) { - if (PHYS_PFN(phys) >= min_low_pfn && PHYS_PFN(phys) < max_low_pfn) + if (!IS_ENABLED(CONFIG_HIGHMEM) || PHYS_PFN(phys) < max_low_pfn) kmemleak_alloc(__va(phys), size, min_count, gfp); } EXPORT_SYMBOL(kmemleak_alloc_phys); @@ -1137,7 +1137,7 @@ EXPORT_SYMBOL(kmemleak_alloc_phys); */ void __ref kmemleak_free_part_phys(phys_addr_t phys, size_t size) { - if (PHYS_PFN(phys) >= min_low_pfn && PHYS_PFN(phys) < max_low_pfn) + if (!IS_ENABLED(CONFIG_HIGHMEM) || PHYS_PFN(phys) < max_low_pfn) kmemleak_free_part(__va(phys), size); } EXPORT_SYMBOL(kmemleak_free_part_phys); @@ -1149,7 +1149,7 @@ EXPORT_SYMBOL(kmemleak_free_part_phys); */ void __ref kmemleak_not_leak_phys(phys_addr_t phys) { - if (PHYS_PFN(phys) >= min_low_pfn && PHYS_PFN(phys) < max_low_pfn) + if (!IS_ENABLED(CONFIG_HIGHMEM) || PHYS_PFN(phys) < max_low_pfn) kmemleak_not_leak(__va(phys)); } EXPORT_SYMBOL(kmemleak_not_leak_phys); @@ -1161,7 +1161,7 @@ EXPORT_SYMBOL(kmemleak_not_leak_phys); */ void __ref kmemleak_ignore_phys(phys_addr_t phys) { - if (PHYS_PFN(phys) >= min_low_pfn && PHYS_PFN(phys) < max_low_pfn) + if (!IS_ENABLED(CONFIG_HIGHMEM) || PHYS_PFN(phys) < max_low_pfn) kmemleak_ignore(__va(phys)); } EXPORT_SYMBOL(kmemleak_ignore_phys);