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 A9ADDC433EF for ; Tue, 19 Jul 2022 11:50:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4113E6B0071; Tue, 19 Jul 2022 07:50:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 397E16B0073; Tue, 19 Jul 2022 07:50:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 239086B0074; Tue, 19 Jul 2022 07:50:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 0DF446B0071 for ; Tue, 19 Jul 2022 07:50:44 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id CB9A160FA6 for ; Tue, 19 Jul 2022 11:50:43 +0000 (UTC) X-FDA: 79703682366.11.E47FA7B Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf18.hostedemail.com (Postfix) with ESMTP id 5AB041C0084 for ; Tue, 19 Jul 2022 11:50:43 +0000 (UTC) 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 4A3DF6162A; 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: ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1658231443; a=rsa-sha256; cv=none; b=Eh0sGON2dIKqa0Y5f/HDMnbWgNI4gU4JmhpYKVQenGKycNPabp6C4deeSic6uQNUFglzp2 g0mllqLT8G+fwYQ76YrninEaeQQLMPhyyfSPxDYqCHd0RxE8p5uD7rUEYNU1lREEv6ZdrE AAPHg6v7xbRqT61s71KdB2Z4lIsQygI= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; spf=pass (imf18.hostedemail.com: domain of cmarinas@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cmarinas@kernel.org; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1658231443; 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=OLuSjFfvcEuEmaQo9SbJ+jxYDKXN8EVDEVD/m4JEzVU=; b=wadxHtVYQaFYY0pY7Ss2saSuGMHW8i1ncb2Mi41DdKscEKYXonPRPLMJDXGXEBSsEE67s4 zG3yWzyv9C6+cNDYJnkd8GS+/6o/VlxdQIc2/H/h5+E5Ws285gTlVJgrQYqgWfWTdJ3jpN cJxCzHhd5JQ/ihbYl4oD1ttGsRc5E1k= X-Rspam-User: X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 5AB041C0084 Authentication-Results: imf18.hostedemail.com; dkim=none; spf=pass (imf18.hostedemail.com: domain of cmarinas@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cmarinas@kernel.org; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none) X-Stat-Signature: qahx4co97b1wnpxxwbi4edy1mdyp75cq X-HE-Tag: 1658231443-383843 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: 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