Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp1666798imw; Sat, 16 Jul 2022 11:49:35 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vXXhREqwgoBl2Y9LZX+o/35TMK91+NXqOj15JHTN1qFlMllwd72DeM4uDbOqzco5g/8/yI X-Received: by 2002:a05:6402:d05:b0:425:b7ab:776e with SMTP id eb5-20020a0564020d0500b00425b7ab776emr28144049edb.142.1657997374849; Sat, 16 Jul 2022 11:49:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657997374; cv=none; d=google.com; s=arc-20160816; b=Vi46P6vCe6NUjYeoJ5ul+Lc+lrjE0YuGYh7fiGe/FMKT8R3ga6J4uEfdem2dw8hd/d 6hfhfyHR5Q+d+4Yr3IMLQSxgcUZcQlOt8iC4aMUCIHgeJfv/R9bpN45EACz/Bjia6cJb NpuZH6s9ayZeeQfcDDE5/uOr+kYyl5LkbYpUEMFHNLXR8S9ix7H7RkO2Tcy6cpgFwKFr g/lzX70iQFYu8rWatCaRSopp+IRz6NYzqY99J48JfXUtMS5xGeiPfTy1xfDrteZlRiM2 +W+bB77KmLP5XUQlBM3flajqXvr3PXVCW1Eaqjacy3SUZ0KaC+vuJc0ZMW9G1XzCXlLF ZGew== 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; bh=WsEhwdLdNfwHR9LCxaWkzLk9jCaKVkk47P3wBYbLRH0=; b=khRkvPEUjBGX9SW8A1C58sOxbeE3mITd98kKDTtnUA8vG36n/pHf5V3cNUYVREzPXB o1a3+w4BkEghj6oOP+/F1MJeGM2a4InxLYWPXqKku0y9Rljd7FKHFYFQLY1qAeQOryf6 Qo6aOZHhieAGnY0+eniOSxP8IIBxLJgxOVuhYvF3+21efUj8YCj5Ws4vDcchm2LeqgSS xJp1G0sz8D/Gxfva1G0er1y9yd1ho2eTJp0qsSCpJdInPII/TmC4dpFuMOiZFRoMiBga aSlYJoV2IlwFD1m0sjSPk5btMMzq7N03OgpAU+76mOrUzOnRhhbIUZhKUX3BQ9Fn1QJF je7g== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ga39-20020a1709070c2700b0072b88c52a50si11295550ejc.645.2022.07.16.11.49.10; Sat, 16 Jul 2022 11:49:34 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231972AbiGPSnX (ORCPT + 99 others); Sat, 16 Jul 2022 14:43:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229558AbiGPSnW (ORCPT ); Sat, 16 Jul 2022 14:43:22 -0400 Received: from mail-qk1-f180.google.com (mail-qk1-f180.google.com [209.85.222.180]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 547A313EB2 for ; Sat, 16 Jul 2022 11:43:20 -0700 (PDT) Received: by mail-qk1-f180.google.com with SMTP id n2so4559882qkk.8 for ; Sat, 16 Jul 2022 11:43:20 -0700 (PDT) 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=WsEhwdLdNfwHR9LCxaWkzLk9jCaKVkk47P3wBYbLRH0=; b=k/Eyk5Aqnev5dHm/HZO7ZktvGtHfaXF9BbhwZH9QJyH9fLF9C7wROz9o1aWxQvKYeW +Jl0JfZ+Bl/NDYLsuwB57QsSJTK2nNTovwhIm3tvHkHQXOpgZX5EYrrVe8FUzPj336YB 0qTIqD4ChuuK4nNC7Yld5JxjrX01gPFkxFwoc+cL1OaGJ1C1/ZckCwTVoDPUPwqmNc+U lvk0wsk681s0iJR74Z/baidJuipv+l4KIRzaflh4GaQGIgsqKlYM//mjZXMDfnypl86J kn9Z14MISvP7s6oMnaRq+DUZUNIgUPhXougJEhpoH3o3k6gPV+oBNtLSAqulMEqeC3qh AE4Q== X-Gm-Message-State: AJIora9EdPaaEuNMlY9fsU1SqRCMwte2yS2B1m4ANBvQAWzX/w93BmbL k47pnQSv1V80pcLq3FDLtVwuLd/9NgVk6A== X-Received: by 2002:a37:6544:0:b0:6b5:bc75:1058 with SMTP id z65-20020a376544000000b006b5bc751058mr11711153qkb.248.1657996998976; Sat, 16 Jul 2022 11:43:18 -0700 (PDT) Received: from mail-yb1-f172.google.com (mail-yb1-f172.google.com. [209.85.219.172]) by smtp.gmail.com with ESMTPSA id h7-20020a05620a284700b0069fe1dfbeffsm7192630qkp.92.2022.07.16.11.43.18 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 16 Jul 2022 11:43:18 -0700 (PDT) Received: by mail-yb1-f172.google.com with SMTP id 6so13885827ybc.8 for ; Sat, 16 Jul 2022 11:43:18 -0700 (PDT) X-Received: by 2002:a05:6902:1246:b0:66e:ea31:8d05 with SMTP id t6-20020a056902124600b0066eea318d05mr20988380ybu.89.1657996997798; Sat, 16 Jul 2022 11:43:17 -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> In-Reply-To: <20220715163305.e70c8542d5e7d96c5fd87185@linux-foundation.org> From: Geert Uytterhoeven Date: Sat, 16 Jul 2022 20:43:06 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 1/1] mm: kfence: apply kmemleak_ignore_phys on early allocated pool To: Andrew Morton Cc: yee.lee@mediatek.com, Linux Kernel Mailing List , Catalin Marinas , Alexander Potapenko , Marco Elver , Dmitry Vyukov , Matthias Brugger , "open list:KFENCE" , "open list:MEMORY MANAGEMENT" , "moderated list:ARM/Mediatek SoC support" , "moderated list:ARM/Mediatek SoC support" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no 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 Hi Andrew, On Sat, Jul 16, 2022 at 1:33 AM Andrew Morton wrote: > On Fri, 15 Jul 2022 10:17:43 +0200 Geert Uytterhoeven wrote: > > On Tue, Jun 28, 2022 at 1:42 PM wrote: > > > From: Yee Lee > > > > > > This patch solves two issues. > > > > > > (1) The pool allocated by memblock needs to unregister from > > > kmemleak scanning. Apply kmemleak_ignore_phys to replace the > > > original kmemleak_free as its address now is stored in the phys tree. > > > > > > (2) The pool late allocated by page-alloc doesn't need to unregister. > > > Move out the freeing operation from its call path. > > > > > > Suggested-by: Catalin Marinas > > > Suggested-by: Marco Elver > > > Signed-off-by: Yee Lee > > > > Thank you, this fixes the storm of > > > > BUG: KFENCE: invalid read in scan_block+0x78/0x130 > > BUG: KFENCE: use-after-free read in scan_block+0x78/0x130 > > BUG: KFENCE: out-of-bounds read in scan_block+0x78/0x130 > > > > messages I was seeing on arm64. > > Thanks, but... > > - It would be great if we could identify a Fixes: for this. IIRC, I started seeing the issue with "[PATCH v4 3/4] mm: kmemleak: add rbtree and store physical address for objects allocated with PA" (i.e. commit 0c24e061196c21d5 ("mm: kmemleak: add rbtree and store physical address for objects allocated with PA")) of series "[PATCH v4 0/4] mm: kmemleak: store objects allocated with physical address separately and check when scan" (https://lore.kernel.org/all/20220611035551.1823303-1-patrick.wang.shcn@gmail.com), in an arm64 config that had enabled kfence. So I think this patch is sort of a dependency for that series. I had cherry-picked that series after bisecting a regression to commit 23c2d497de21f258 ("mm: kmemleak: take a full lowmem check in kmemleak_*_phys()") in v5.18-rc3, and having a look around. > - 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... Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds