From mboxrd@z Thu Jan 1 00:00:00 1970 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22B09C43334 for ; Sat, 16 Jul 2022 18:43:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CAB5C6B0075; Sat, 16 Jul 2022 14:43:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C5BAA6B0078; Sat, 16 Jul 2022 14:43:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B71C86B007B; Sat, 16 Jul 2022 14:43:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id A8CF26B0075 for ; Sat, 16 Jul 2022 14:43:21 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 6E7DA341C9 for ; Sat, 16 Jul 2022 18:43:21 +0000 (UTC) X-FDA: 79693835802.26.489DB23 Received: from mail-qt1-f176.google.com (mail-qt1-f176.google.com [209.85.160.176]) by imf08.hostedemail.com (Postfix) with ESMTP id 06A1B160024 for ; Sat, 16 Jul 2022 18:43:19 +0000 (UTC) Received: by mail-qt1-f176.google.com with SMTP id g24so3356726qtu.2 for ; Sat, 16 Jul 2022 11:43:19 -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=JNOQkInpdUy+f4I5zCikk99C4uG39KfqrufKUtJEOJarP5nyXm+l6XVkUawO+sDFTB 1zlNwvmxkFuNLfIoTvJndAjgKf8riyOKg/waMR9ODhTv3gu57YYqNG4lkN3LN9NEudZz K0DVidUUoQM3m7nC9tZ1f0nm5ZZ7LEK7WmPePf1GyRjnO3jQBzPWdiRz4TJbBMY4iCBe s8ONsQunIiaoHX8uWrCOA+mWJY82mIVzzcOEpKv00ziSLr8EMWWV+qPbooXOgGxEcaxm DCZwoN+FPf2DrYlobl3MerlpgLiyTLO8M2/IWvdgpfpegUSdSnOnFDWFfHHi1E1f4XYs fYJw== X-Gm-Message-State: AJIora8qT7KWOKvk94SYzcb2cI5UKaSC91uxze6Zw7vWNcPt+FB6qS73 g65fLUh4VI++sGyOBGBniBzxgkQo8OwZAw== X-Google-Smtp-Source: AGRyM1vTbds1BlRHjpcTYgju66E0pVE+byJxnalF0KrsG+sjlB1Dsl9bjSZdsZcdIzf/2MpnbO5Zog== X-Received: by 2002:a05:622a:1116:b0:31e:d8e4:ac30 with SMTP id e22-20020a05622a111600b0031ed8e4ac30mr8545633qty.660.1657996998776; Sat, 16 Jul 2022 11:43:18 -0700 (PDT) Received: from mail-yb1-f173.google.com (mail-yb1-f173.google.com. [209.85.219.173]) by smtp.gmail.com with ESMTPSA id h13-20020a05620a284d00b006aee5df383csm6724184qkp.134.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-f173.google.com with SMTP id h62so13835660ybb.11 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" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657997000; a=rsa-sha256; cv=none; b=Lxsu40InJGHOrsvqnxTqB0dPOHPB8DGpu/PdytTUY+n9YgIIp8saF95KZ0yPiw1Bf4LOY5 BrUhB5DGDr+LIVKo97hisgdFsCmmO6Qivt0EMsJsCiMzJP0vB4szz15ZkcsjMG7jzYMYQc EjKylkwzTlIyM4hURdZ118duEyLhBj0= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=none; spf=pass (imf08.hostedemail.com: domain of geert.uytterhoeven@gmail.com designates 209.85.160.176 as permitted sender) smtp.mailfrom=geert.uytterhoeven@gmail.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657997000; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WsEhwdLdNfwHR9LCxaWkzLk9jCaKVkk47P3wBYbLRH0=; b=UOymv5eUjIHne40QRjG0bM5gWgd/QmqYk5S/BwHgvQoUwiq6OIT8hBsIH7IGLJVAzAUqyn Rdll2TNBdI/yukVTHb1pU0LA4f45qjVOsKF2c7DNTkBLOgY5/G+FaIbhe6HR4nRYy4xIjU reyoGyC2EP9KCGhI7nz/k5sHP5TQQmA= X-Stat-Signature: g985obe8nezjza343tf3k6fkrc1i5ne7 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 06A1B160024 X-Rspam-User: Authentication-Results: imf08.hostedemail.com; dkim=none; spf=pass (imf08.hostedemail.com: domain of geert.uytterhoeven@gmail.com designates 209.85.160.176 as permitted sender) smtp.mailfrom=geert.uytterhoeven@gmail.com; dmarc=none X-HE-Tag: 1657996999-693103 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: 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