Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp2003466imn; Mon, 1 Aug 2022 07:47:54 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vBB/eUQlIBwEhBCUv6OHAfEKAfkLwcpxqaWNTNgpFB7EdwfsXEvY/hG1QVswWGkSHhjOav X-Received: by 2002:a17:907:e91:b0:72f:d76:b22c with SMTP id ho17-20020a1709070e9100b0072f0d76b22cmr12184439ejc.364.1659365274625; Mon, 01 Aug 2022 07:47:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659365274; cv=none; d=google.com; s=arc-20160816; b=UnELa7JPbHHua0R2cvgmsgsxH/4LxITG0Vk2TxOINDiEbAEW+OWZ6OOYNtaB2X5Wy0 IRrv8XjrcIfL/oqUxzQruj7PBr82X1BLCbpiwtvO+ycJao/Mrf5vRPSMhDxyY69AH2Wu Z4RR41UDEvfrf0pL4IXnT/4PMSdydAQav24TIdclMD0ogwG8VxX0bgGciJooGH/lOTqe J/qoHmZb1oNsF8T0Zvjk/M8sBehZdHsmNTrelKIDOmzhqr0XDGaZeHcjbGbFtSGCJ1r3 qMCaRSV9umQndlbh1y7c2edabVJ3cjSSQXhFA/Pw5oMQiAF4IA467OpzVHdxMzJ0pS1i 0ISw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=G5UhvGzRrQcBGCWtOdqFEgZwHRGSXUKRpcxRX6CD/7s=; b=eQEqqeAD53dkSJozz/JSiWS2/Q7CEg+c119dnMA6FTfxUVXsCpaVsZtpQIHDaYGP6f BjMiFrEjwXXCdPbIjSn5Sx0CJYMUyXBZRG8HiFpY9uktST473OUy2WJ2wPwOKFvpNVbm T7R1hy3l9za82z6Ou62x3GD/0ojrDlTI9n/Mt6xggnkO8Iise2vkItR+PivDqGdLLXD+ yrFu55AQJ7ipSQfArrbpPT9Im4S9eFubwjQS3QZYUvBEHl39Cs2vrXXyMqYBxOAi/GYi oh/kBxG5z1AcTUzh5ghHBU0X6FKYE5+VUoDlg5IzivOX4EgjNajN1Wyjb7KMeRh5c6hK rSqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=rAPWjvDI; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g22-20020a056402321600b0043cfcf25a48si299666eda.489.2022.08.01.07.47.28; Mon, 01 Aug 2022 07:47:54 -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=@google.com header.s=20210112 header.b=rAPWjvDI; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232046AbiHAOGa (ORCPT + 99 others); Mon, 1 Aug 2022 10:06:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229943AbiHAOG2 (ORCPT ); Mon, 1 Aug 2022 10:06:28 -0400 Received: from mail-yw1-x1129.google.com (mail-yw1-x1129.google.com [IPv6:2607:f8b0:4864:20::1129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E82CDE0CE for ; Mon, 1 Aug 2022 07:06:27 -0700 (PDT) Received: by mail-yw1-x1129.google.com with SMTP id 00721157ae682-31f661b3f89so109798067b3.11 for ; Mon, 01 Aug 2022 07:06:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=G5UhvGzRrQcBGCWtOdqFEgZwHRGSXUKRpcxRX6CD/7s=; b=rAPWjvDI2x1MNj7Bu1CCOyfybJSBeCkfp/LO5TNPavNuMm1PCpq9vZac1affXCfVvt HfQUD8IDa7FYkHaDZMmcJgTJksD4uPs0blDFqQ4TqvxFRHM8ukS10lHLa+Zyoq/SswML dFVjUkxMDEro74y/G2bBenIgy9dTvbXgFbkcc5PnIJ+4PHL3ocZEDki/xulKClATsVTa 8hSok7ks8K8ULZoPe5omstJhi8J3ZuM96/LSTUO/Sv9qL1U6a5psDTTSJObennoaI22A l4ANlFj4EZS+9RCDlPFPQfV+2r3BvdiPIQi/w8S3AYyLyMpIaQxPp6Uea92VnIcplfZ1 WoRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=G5UhvGzRrQcBGCWtOdqFEgZwHRGSXUKRpcxRX6CD/7s=; b=56U6ocwS6avLO1T9qihBw5c6syuQ3kiP6ndU03sKyPhnKHeJkGxk+lozyHW0w5d5KH pDE2f9ScHBRSFV5Dj2x9LeZzrwcqmQwmqa/wTBOkyKQRyaQye8EZeAk1BPjpzR6ycQWe 98DzTNa6GjrTiWmccHPiAH8l7/0Pot8h7q7djnrzN+nzKhdMmht8/J5SDbkrkT9VRw7A LGF4J4pYuJQT1VNy9Mk59gT9JQMGCDOz/+zRimHBBlM3PFm6mJ9ZeOwLuNUyu7SirkJc NA4O8AibjOZxh7NaTwjKfAIx/nA9Pb8uBsxV/+x0uXbNiCLWOLAeNNy2jCzv6ySNsQXT xepg== X-Gm-Message-State: ACgBeo1FyuTPRRpfS3c+fYMQSOaD4G0eYyVs/VjvPD2XULV2iPeJc7mw TD8ImA5kkIKf4TDXus50q3oWbxU5AxLIVK+VzoFJDQ== X-Received: by 2002:a0d:f045:0:b0:324:55ec:6595 with SMTP id z66-20020a0df045000000b0032455ec6595mr11570098ywe.255.1659362787035; Mon, 01 Aug 2022 07:06:27 -0700 (PDT) MIME-Version: 1.0 References: <20220628113714.7792-1-yee.lee@mediatek.com> <20220628113714.7792-2-yee.lee@mediatek.com> <20220715163305.e70c8542d5e7d96c5fd87185@linux-foundation.org> <20220719161356.df8d7f6fc5414cc9cc7f8302@linux-foundation.org> In-Reply-To: From: Marco Elver Date: Mon, 1 Aug 2022 16:05:50 +0200 Message-ID: Subject: Re: [PATCH v2 1/1] mm: kfence: apply kmemleak_ignore_phys on early allocated pool To: Dave Hansen Cc: Andrew Morton , Geert Uytterhoeven , yee.lee@mediatek.com, Linux Kernel Mailing List , Catalin Marinas , Alexander Potapenko , Dmitry Vyukov , Matthias Brugger , "open list:KFENCE" , "open list:MEMORY MANAGEMENT" , "moderated list:ARM/Mediatek SoC support" , "moderated list:ARM/Mediatek SoC support" , Dave Hansen , "the arch/x86 maintainers" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 [+x86 maintainers ...] On Wed, 20 Jul 2022 at 01:22, Dave Hansen wrote: > On 7/19/22 16:13, Andrew Morton wrote: > > On Mon, 18 Jul 2022 16:26:25 +0200 Marco Elver wrote: > > > >> On Sat, 16 Jul 2022 at 20:43, Geert Uytterhoeven wrote: > >> [...] > >>>> - This patch has been accused of crashing the kernel: > >>>> > >>>> https://lkml.kernel.org/r/YsFeUHkrFTQ7T51Q@xsang-OptiPlex-9020 > >>>> > >>>> Do we think that report is bogus? > >>> I think all of this is highly architecture-specific... > >> The report can be reproduced on i386 with CONFIG_X86_PAE=y. But e.g. > >> mm/memblock.c:memblock_free() is also guilty of using __pa() on > >> previously memblock_alloc()'d addresses. Looking at the phys addr > >> before memblock_alloc() does virt_to_phys(), the result of __pa() > >> looks correct even on PAE, at least for the purpose of passing it on > >> to kmemleak(). So I don't know what that BUG_ON(slow_virt_to_phys() != > >> phys_addr) is supposed to tell us here. > >> > > It's only been nine years, so I'm sure Dave can remember why he added > > it ;) > > > > BUG_ON(slow_virt_to_phys((void *)x) != phys_addr); > > > > in arch/x86/mm/physaddr.c:__phys_addr(). > > I think I intended it to double check that the linear map is *actually* > a linear map for 'x'. Sure, we can use the "x - PAGE_OFFSET" shortcut, > but did it turn out to be actually accurate for the address it was handed? > > I'd be curious what the page tables actually say for the address that's > causing problems. test robot just reminded us again: https://lore.kernel.org/all/YufXncrWhJZH0ifB@xsang-OptiPlex-9020/T/#u Few things I noticed: * mm/memblock.c's memblock_free() also uses __pa() to convert back to physical address. Presumably that's also wrong. What should be used instead? * kmemleak happily converts phys_addr_t to unsigned long everywhere, but with i386 PAE, this will narrow a 64-bit address to a 32-bit address. Is that correct? Does kmemleak need a "depends on 64BIT || !PHYS_ADDR_T_64BIT"?