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 7C0D8C43334 for ; Tue, 28 Jun 2022 12:10:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AE3F48E0002; Tue, 28 Jun 2022 08:10:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A94978E0001; Tue, 28 Jun 2022 08:10:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 95CC78E0002; Tue, 28 Jun 2022 08:10:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 87E678E0001 for ; Tue, 28 Jun 2022 08:10:56 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 3162F80427 for ; Tue, 28 Jun 2022 12:10:56 +0000 (UTC) X-FDA: 79627528512.05.5604902 Received: from mail-yb1-f182.google.com (mail-yb1-f182.google.com [209.85.219.182]) by imf08.hostedemail.com (Postfix) with ESMTP id D554E160038 for ; Tue, 28 Jun 2022 12:10:55 +0000 (UTC) Received: by mail-yb1-f182.google.com with SMTP id h187so19648765ybg.0 for ; Tue, 28 Jun 2022 05:10:55 -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=kivkjIcW/dBwtKQGxzqBhqyQNzFDh/iWcq1jAKuPzjQ=; b=CLRflZYyQbg2Iw8XCTaSt3HhmxKw/xrafgduTJjfhqjN2UgMgl+t/Gw4w6ILs6K9J4 MiBhpvtp9dwuJoICS/Nb1ZrtA3RQX7LEA7Mz5j+bBQgqJZtt6/ayHu+r5Hhb3qNZ4MWa hFjTG4fGYnkRgTZZBBgzYCRgfxmHlPzv/4ipJqE4P/j7/2M+hTvxyKMHh77AZQv+DXXp HhfG34tq68ucJafyFKHbBlkKZIavzOm2MyDj5K6/Q7swKn5I+xF/JVEwmlCwkvsZvZHr w9cyP8LjUEu4elAD/I0i18jI8ov478QkOC5jYowuBKa+OZLBRkMIuuXZdJu9woKbWYNY OIWw== 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=kivkjIcW/dBwtKQGxzqBhqyQNzFDh/iWcq1jAKuPzjQ=; b=7HyasSM7BKVymoMidrWiuv2ATpIKHvLC6+WWih2wtyuzWD+FYhQV8p8kJH9gnrp2XY Xflcp9Y9Vd+SvQYef8JLbl4Pfebco3y+K0DmxAVmvccB/FBgyyIf19aSRPOtzyoK+43C UsytrmwjswSAYvv/b0d2ECIojIoztp2uMWS871gtejmo6pwyoLWD6yoQCqYcmZaJDheH McLyddzognQc+aXmeCxYqf8YuYx4fSJkqtexVcSNmKTtVn2I/6Jychf8E6sfuZ7FZ8bg kzfUhJ+fp/Fb09MOEESZ/hdrG8nxobP6Wt2zlsuJI/qWZ7W1mjBP3NQwiKgi6dfPoQdH IL4w== X-Gm-Message-State: AJIora8VYDW8l34Q74XRIisw1ruFZQL+jGTGD4olXugydqOjjNo1gnCs aXlvP02nw6vtRQlf/+kgtPFopnjoSP5RBW663fTB2g== X-Google-Smtp-Source: AGRyM1smrNVxZFq8RnZCs9l8cbaNFOI8pfYR4MykJ5KZXRx6x1Zw9wNjdz4oF5DQdShpdaP6Z1l8ckzfBHZHCRervgg= X-Received: by 2002:a25:cc56:0:b0:66c:d0f6:2f0e with SMTP id l83-20020a25cc56000000b0066cd0f62f0emr10988742ybf.168.1656418254817; Tue, 28 Jun 2022 05:10:54 -0700 (PDT) MIME-Version: 1.0 References: <20220628113714.7792-1-yee.lee@mediatek.com> <20220628113714.7792-2-yee.lee@mediatek.com> In-Reply-To: <20220628113714.7792-2-yee.lee@mediatek.com> From: Marco Elver Date: Tue, 28 Jun 2022 14:10:18 +0200 Message-ID: Subject: Re: [PATCH v2 1/1] mm: kfence: apply kmemleak_ignore_phys on early allocated pool To: yee.lee@mediatek.com Cc: linux-kernel@vger.kernel.org, catalin.marinas@arm.com, Alexander Potapenko , Dmitry Vyukov , Andrew Morton , 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=1656418255; a=rsa-sha256; cv=none; b=0ezS+ld1uJ/39Zo89gRIEktUUqNP7cJbFjZ9S15BPr8I3/c3kJcYi8TkwmEeFbhy7CLzYR OMBImllusjsm44a6TVVHK/25Ti1HfLR46lAiKUjvxZZbOmoBwWhCWqwk24tVHfQpN31fW4 WFLaBbroL2SGSYRyErw2UIoZk/kc/fo= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=CLRflZYy; spf=pass (imf08.hostedemail.com: domain of elver@google.com designates 209.85.219.182 as permitted sender) smtp.mailfrom=elver@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656418255; 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:dkim-signature; bh=kivkjIcW/dBwtKQGxzqBhqyQNzFDh/iWcq1jAKuPzjQ=; b=mVzWHbjW/+YX4dLY7cuAtNJRcvRPGK3qxq7m2i4NvbYJ9MFkyYaBygYdUUiJAMJ3P6ktPQ TModCxiCsDTLF8sAUcQodZE675yP35Y/JTz+zicb4c3WO+dPccnF6a3Sti4bLRVgUm9ksV ubRa2+R0dCsYwAPf41c4/yu/Pbwzpkk= X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: D554E160038 X-Rspam-User: X-Stat-Signature: dpnx8tzbekpcb911795mmxgn56oa1m58 Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=CLRflZYy; spf=pass (imf08.hostedemail.com: domain of elver@google.com designates 209.85.219.182 as permitted sender) smtp.mailfrom=elver@google.com; dmarc=pass (policy=reject) header.from=google.com X-HE-Tag: 1656418255-725578 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 Tue, 28 Jun 2022 at 13:37, yee.lee via kasan-dev 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 Reviewed-by: Marco Elver Does this want a Fixes tag? > --- > mm/kfence/core.c | 18 +++++++++--------- > 1 file changed, 9 insertions(+), 9 deletions(-) > > diff --git a/mm/kfence/core.c b/mm/kfence/core.c > index 4e7cd4c8e687..32a4a75e820c 100644 > --- a/mm/kfence/core.c > +++ b/mm/kfence/core.c > @@ -600,14 +600,6 @@ static unsigned long kfence_init_pool(void) > addr += 2 * PAGE_SIZE; > } > > - /* > - * The pool is live and will never be deallocated from this point on. > - * Remove the pool object from the kmemleak object tree, as it would > - * otherwise overlap with allocations returned by kfence_alloc(), which > - * are registered with kmemleak through the slab post-alloc hook. > - */ > - kmemleak_free(__kfence_pool); > - > return 0; > } > > @@ -620,8 +612,16 @@ static bool __init kfence_init_pool_early(void) > > addr = kfence_init_pool(); > > - if (!addr) > + if (!addr) { > + /* > + * The pool is live and will never be deallocated from this point on. > + * Ignore the pool object from the kmemleak phys object tree, as it would > + * otherwise overlap with allocations returned by kfence_alloc(), which > + * are registered with kmemleak through the slab post-alloc hook. > + */ > + kmemleak_ignore_phys(__pa(__kfence_pool)); > return true; > + } > > /* > * Only release unprotected pages, and do not try to go back and change > -- > 2.18.0