From patchwork Mon Sep 21 13:26:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Elver X-Patchwork-Id: 11789861 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 65E06112C for ; Mon, 21 Sep 2020 13:27:01 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2D70B235F8 for ; Mon, 21 Sep 2020 13:27:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="t/PhPbvg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2D70B235F8 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 5C049900063; Mon, 21 Sep 2020 09:26:56 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 53229900059; Mon, 21 Sep 2020 09:26:56 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3A131900063; Mon, 21 Sep 2020 09:26:56 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0223.hostedemail.com [216.40.44.223]) by kanga.kvack.org (Postfix) with ESMTP id 10B29900059 for ; Mon, 21 Sep 2020 09:26:56 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 8A75A180AD806 for ; Mon, 21 Sep 2020 13:26:55 +0000 (UTC) X-FDA: 77287143990.22.air42_0003b2c27145 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin22.hostedemail.com (Postfix) with ESMTP id 6887718038E60 for ; Mon, 21 Sep 2020 13:26:55 +0000 (UTC) X-Spam-Summary: 1,0,0,a5d03e47de48fec9,d41d8cd98f00b204,3hapoxwukcby07h0d2aa270.ya8749gj-886hwy6.ad2@flex--elver.bounces.google.com,,RULES_HIT:41:152:355:379:541:800:960:973:988:989:1260:1277:1313:1314:1345:1359:1437:1516:1518:1535:1541:1593:1594:1711:1730:1747:1777:1792:2393:2553:2559:2562:3138:3139:3140:3141:3142:3152:3352:3865:3866:3870:4250:4605:5007:6261:6653:6742:6743:7576:7903:9969:10004:10400:11026:11473:11658:11914:12043:12294:12297:12438:12555:12679:12895:13069:13311:13357:13972:14096:14097:14181:14394:14659:14721:21080:21444:21451:21627:21740:30054:30090,0,RBL:209.85.160.201:@flex--elver.bounces.google.com:.lbl8.mailshell.net-66.100.201.100 62.18.0.100;04yg9kons5btmcmdqetaronjf3gnmyp9nnjer3hy6nmfmfkdptec6sbygfwd3p7.zjg74bwdya5sb4xr8tr1wshyomk61s6ckeq7ja6ab9y8zwyoacaeyacxo7m87pd.y-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: air42_0003b2c27145 X-Filterd-Recvd-Size: 5017 Received: from mail-qt1-f201.google.com (mail-qt1-f201.google.com [209.85.160.201]) by imf26.hostedemail.com (Postfix) with ESMTP for ; Mon, 21 Sep 2020 13:26:54 +0000 (UTC) Received: by mail-qt1-f201.google.com with SMTP id 7so12784922qtp.18 for ; Mon, 21 Sep 2020 06:26:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=Xu8t61b4dNKr+fiQ7+DCPl49hEzGiBe/cMhyep8752Q=; b=t/PhPbvgVmVZNO9No4Qsi0HZRKHniwTfNY8al1/FxEWkHh40tZwZm8AG2oTdT6OtOE 0U1EmeVMJvqIU3FT608D0nMfNpWZdrS74pAWAyQtXEcglvXWT3hoZM3gk9OIvEZlM92Y njI4DKdBxtMEsniD1uoqdp7LR2Kx0bmYr03XdW/yAxE9foJVT6JQDImhnmsDt0m+l50I qBJ7XAVxF44YbVX+PQeCKvfjZ+JK9mDAS6pkbvbegvxujp51QBihra7o3Hi9nduA2yG3 PeiSIZbpwxu8jilOBEUmyAhKDo3ggadkcLt4SwKR3jtuywvAeXsITeIKnUnfOR+kZORB MdbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=Xu8t61b4dNKr+fiQ7+DCPl49hEzGiBe/cMhyep8752Q=; b=nV7V0DiAYwSTsGkkyFai1QRJRMhpQXbTWa6zbVDZHgmT0SDPohQS4grcuFzZGCM4wa vyIh5jolqIu0/rdpcUbXj6dD3YyHDpsgzZPmVXrD/Yjfvoa7WDYEqz5QjfwdJwyPRvUF EIl+8tzv/m+mGZ3Rvucw9Kx5KYOWA2yY6RZIAmJjdudY87ywGbT7W+D8l9M25LqEOYJk 5UszpRiiBTecxY+HMXiccTbU0JUUK3S0nEswnXIcQEjCa7D1ZJ1YnWy+xadW8Bc90TMC /6qHFix7MSAieVm/UhfhPKaE717pq2BQu7SbE7oR70ppfvjlnUIfA6otq4sNL1CBkOuH dRew== X-Gm-Message-State: AOAM533LPG7sArcnnU6dXBW5IrQVjw5jZ4bUJ6SftAd/lnf1b1Nkqq1Q V6dfX4qcilgJX6jHRGeHQp/E/VLcjQ== X-Google-Smtp-Source: ABdhPJwlomHZW5LFrUvnOYp1W3ILbDMFcZXnyVZmSCcK70XUPvRiAPt5y/KlgaYdqO/4DLRWjmwMvNsM3A== X-Received: from elver.muc.corp.google.com ([2a00:79e0:15:13:f693:9fff:fef4:2449]) (user=elver job=sendgmr) by 2002:a0c:e311:: with SMTP id s17mr28925297qvl.45.1600694813892; Mon, 21 Sep 2020 06:26:53 -0700 (PDT) Date: Mon, 21 Sep 2020 15:26:08 +0200 In-Reply-To: <20200921132611.1700350-1-elver@google.com> Message-Id: <20200921132611.1700350-8-elver@google.com> Mime-Version: 1.0 References: <20200921132611.1700350-1-elver@google.com> X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [PATCH v3 07/10] kfence, kmemleak: make KFENCE compatible with KMEMLEAK From: Marco Elver To: elver@google.com, akpm@linux-foundation.org, glider@google.com Cc: hpa@zytor.com, paulmck@kernel.org, andreyknvl@google.com, aryabinin@virtuozzo.com, luto@kernel.org, bp@alien8.de, catalin.marinas@arm.com, cl@linux.com, dave.hansen@linux.intel.com, rientjes@google.com, dvyukov@google.com, edumazet@google.com, gregkh@linuxfoundation.org, hdanton@sina.com, mingo@redhat.com, jannh@google.com, Jonathan.Cameron@huawei.com, corbet@lwn.net, iamjoonsoo.kim@lge.com, keescook@chromium.org, mark.rutland@arm.com, penberg@kernel.org, peterz@infradead.org, sjpark@amazon.com, tglx@linutronix.de, vbabka@suse.cz, will@kernel.org, x86@kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org 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: From: Alexander Potapenko Add compatibility with KMEMLEAK, by making KMEMLEAK aware of the KFENCE memory pool. This allows building debug kernels with both enabled, which also helped in debugging KFENCE. Reviewed-by: Dmitry Vyukov Co-developed-by: Marco Elver Signed-off-by: Marco Elver Signed-off-by: Alexander Potapenko --- v2: * Rework using delete_object_part() [suggested by Catalin Marinas]. --- mm/kmemleak.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mm/kmemleak.c b/mm/kmemleak.c index 5e252d91eb14..feff16068e8e 100644 --- a/mm/kmemleak.c +++ b/mm/kmemleak.c @@ -97,6 +97,7 @@ #include #include +#include #include #include @@ -1948,6 +1949,11 @@ void __init kmemleak_init(void) KMEMLEAK_GREY, GFP_ATOMIC); create_object((unsigned long)__bss_start, __bss_stop - __bss_start, KMEMLEAK_GREY, GFP_ATOMIC); +#if defined(CONFIG_KFENCE) && defined(CONFIG_HAVE_ARCH_KFENCE_STATIC_POOL) + /* KFENCE objects are located in .bss, which may confuse kmemleak. Skip them. */ + delete_object_part((unsigned long)__kfence_pool, KFENCE_POOL_SIZE); +#endif + /* only register .data..ro_after_init if not within .data */ if (&__start_ro_after_init < &_sdata || &__end_ro_after_init > &_edata) create_object((unsigned long)__start_ro_after_init,