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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5CE92C43334 for ; Tue, 19 Jul 2022 11:50:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231980AbiGSLuq (ORCPT ); Tue, 19 Jul 2022 07:50:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230134AbiGSLuo (ORCPT ); Tue, 19 Jul 2022 07:50:44 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9555A10A8 for ; Tue, 19 Jul 2022 04:50:42 -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 3E9C361614 for ; Tue, 19 Jul 2022 11:50:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 39A21C341C6; Tue, 19 Jul 2022 11:50:39 +0000 (UTC) Date: Tue, 19 Jul 2022 12:50:35 +0100 From: Catalin Marinas To: Geert Uytterhoeven Cc: Andrew Morton , yee.lee@mediatek.com, Linux Kernel Mailing List , 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" Subject: Re: [PATCH v2 1/1] mm: kfence: apply kmemleak_ignore_phys on early allocated pool Message-ID: References: <20220628113714.7792-1-yee.lee@mediatek.com> <20220628113714.7792-2-yee.lee@mediatek.com> <20220715163305.e70c8542d5e7d96c5fd87185@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jul 16, 2022 at 08:43:06PM +0200, Geert Uytterhoeven wrote: > 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. Yes, I think it fixes 0c24e061196c21d5 since after that commit, the kmemleak_free() no longer worked as expected on physically allocated objects. -- Catalin