Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6826731rwn; Tue, 13 Sep 2022 09:29:30 -0700 (PDT) X-Google-Smtp-Source: AA6agR54CWsxkvZRlLLJdb1BmTJNxxuIgtDNU1r/IPw2283SVPdYd+oo9q8ZxsAuquXKqHIO5R8J X-Received: by 2002:a05:6a00:139b:b0:540:de3c:cf9d with SMTP id t27-20020a056a00139b00b00540de3ccf9dmr23186154pfg.54.1663086570010; Tue, 13 Sep 2022 09:29:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663086570; cv=none; d=google.com; s=arc-20160816; b=pEDU9STj2iXO4Ti61bj4riMxnnaLx0oiqoL8WYd6HGC7uvRiw7E+s8ABCIHYYFit42 e3jFBm6ai9MCo6fmEaQuebGij373ZwOwQ33KzeSFX8ijXw2T4v6vv9g5oBYI+3nhEP+O GQVUZIBk0UbpR+7MsCQgLGkKjcJhXpUrsqa4Oc0avN66DwGS8g/0bYsx9+BYPthyOF4j rA8qJ5ciixtHksABCGtRK6cu+oX3pzBx7QMd8m1B+jeRPJZD/rXW273qqz4HIWsYo+lN 9PzI9EtVdDGDQisIcxBRR7EOvyYrkat+ppjsRdikU9s1ssOsdGkUlsfn3bPPudUaNXjw W8dw== 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=2yb0U87xeHQJmdcx4TSpI9a1YYx6d9Q4Di9Ebvh4hLY=; b=abXM4tdZkaO3OH59LzWHlEkhBTZU6FUQpN5WVgEhmzqi/oorV1Kx7+Ez5mGu9c61PN sCdVxIdDwcIAEg/RjlgU5Y+l/HcFWGNJu/y3lVnUJyEFHBf5fnykLej6N7sHlvdakh+c YicRXpNPtWW4VcXKE449u+rPVIZ6cnDsY748L25PD47u/cLB4xy4iYWXBmcVaz1TpIcg iQcO0nzDWdgznulApWKpyz9CCvF4e39A9U4gh7heniScCFG83ZDl1fj7KBBhxa6UZw56 U9kODldyYCINTAabWHJi0R+x0i4Vy8hqY3huHGIRd0pFYVCWTfiJezNdlzbZkQc9XSXH jhZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="SSiyfN/U"; 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 k4-20020a056a00134400b0053e989053f9si12103151pfu.114.2022.09.13.09.29.17; Tue, 13 Sep 2022 09:29:29 -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="SSiyfN/U"; 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 S232861AbiIMOcT (ORCPT + 99 others); Tue, 13 Sep 2022 10:32:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233892AbiIMOaN (ORCPT ); Tue, 13 Sep 2022 10:30:13 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 728124BA70; Tue, 13 Sep 2022 07:18:59 -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 ams.source.kernel.org (Postfix) with ESMTPS id 7E0D4B80EFC; Tue, 13 Sep 2022 14:18:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F11C0C433D7; Tue, 13 Sep 2022 14:18:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1663078687; bh=Jj5MrzVa9xEDcsvzFhbjkV6ih9ASPJTW0wXXrjRGgFI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SSiyfN/UbrkPRmHVAMwgl4O0ZNSXvV4yr/hMGO9f4cLxfnB1TJ6ph0Rwfr7qSx03y 2yplH3c3fkFz1RT1GqsAeUUZz+refciJLPuzalRqozbEcw/4pBVlZq83drhZlYrhQz X4bImRY7u/zzdjNZIv2wvIjIRKEc3IEZw/Prj5FI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yee Lee Subject: [PATCH 5.15 007/121] Revert "mm: kmemleak: take a full lowmem check in kmemleak_*_phys()" Date: Tue, 13 Sep 2022 16:03:18 +0200 Message-Id: <20220913140357.642793963@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220913140357.323297659@linuxfoundation.org> References: <20220913140357.323297659@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 @@ -1125,7 +1125,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); @@ -1139,7 +1139,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); @@ -1151,7 +1151,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); @@ -1163,7 +1163,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);