Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3802821pxk; Tue, 29 Sep 2020 06:43:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwlGJvnHmaB9IvLqm7dDikDrcL5a5oqCG/lom3hDeTc6R7HSe6PR/OqG2sa1b1RpzYkRnJt X-Received: by 2002:a17:906:ecf1:: with SMTP id qt17mr4010672ejb.158.1601386987065; Tue, 29 Sep 2020 06:43:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601386987; cv=none; d=google.com; s=arc-20160816; b=O5vSrr6h15/pXPq+7djyIiQGv77qi/Sm1yvR/R6XGoPopUqY3D3MQnf7OOpwbKC2iQ 6TgK6lQA137YORAwil/n54obO8LWdvk8Sedgmg7ANUWQJP3UIgUOMVNT+dwxFz4oNFEl 34HUHpOPf24AD0YH/+BAF0SXSCV7SQLn5XxDWIo/f6v/FA59RrJXi1eVV9tpy6D2fGCs g2rqCJ3S/MF1McH8l/k0CaUkDYCUeLG+S2LahEiUcxtrkHov4GASINuc60z2llR2+ap9 6tHbL80cG5d2fY12NDTwosaqZgtQyr1PVVK29SO5iNRHvsXmjNJEt51jqhCdOrOw7bAF iexw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:sender:dkim-signature; bh=3tnm6vmpSMHKvgeLXX0r5hzQnU0w3hMCi/2IZuY8XC4=; b=e0D/DYrDWa2C6PaNT22r1DCQi9rNUCiMBb06uFspWFY4GhBsy9Msqo5XPDKabJQnl7 l82+fGwFk21I9fOmKmRQCDqlTyNb7x/DRm57XY/WtLa1jaPf/g8b2c6EZTvp96ImGgVZ Tp/UwhI18KVf8GEdWykp+7Q63kArwPa6njiVvDkKGFbTgs26rgsOsEa6ksatl/p0NChK 13KTT31+8JkXU3sRCGm9Ds/Zm8jtCD9w/m/gU5xEruLiQREoLMp7fLIhVHyxx7DKboZj lR/8m8DN0Pu10p8UFfSsPPzxNyQyvyH99xj+YYcXO8SRU7OrhQgAlxNhniA/XTDzsnAr v23g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=B8oKuahj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z15si3038412ejr.202.2020.09.29.06.42.43; Tue, 29 Sep 2020 06:43:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=B8oKuahj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730362AbgI2Njg (ORCPT + 99 others); Tue, 29 Sep 2020 09:39:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730068AbgI2NjA (ORCPT ); Tue, 29 Sep 2020 09:39:00 -0400 Received: from mail-qk1-x74a.google.com (mail-qk1-x74a.google.com [IPv6:2607:f8b0:4864:20::74a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96A46C0613D1 for ; Tue, 29 Sep 2020 06:39:00 -0700 (PDT) Received: by mail-qk1-x74a.google.com with SMTP id u23so2663914qku.17 for ; Tue, 29 Sep 2020 06:39:00 -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=3tnm6vmpSMHKvgeLXX0r5hzQnU0w3hMCi/2IZuY8XC4=; b=B8oKuahjPhaobOS0+ZDZGeKP9b3kVA3jwzCcxNIsL5l1hg6A5Zc2U7KFaMS3MAGMY0 O2hL41mHABBucJ709F1NABK5TlE3h6kkzR3QjUDxvA69lT2Vmg+yqtS1B3XgMaAjvzE+ 4mgLADkAmStachF+w18Th9hgSjlkxnNdA2E+2i5jhFaedCK3jmA81x81mzqGH5xIBIyK TkMYQ2Kj9iLx5+B4T/SPDvnT0Vw3vVftV8o6Nh1/NgB6hH97rCmgsyRflrUvp714+JV1 oewV3A8DvxbQp4xOKTchYf3ipkGxIuyOJaeI8Huuw90A7+lq5iDbB1TqBs3kuFRIJ003 1ODg== 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=3tnm6vmpSMHKvgeLXX0r5hzQnU0w3hMCi/2IZuY8XC4=; b=Vmkql/gVHaMPeDZeBllv0UfxBjCNT2GoSZXJyzdXYEpZdwDjYU+L8R8koRRGY1fWH1 s9M4b70v7wUcXonTTsoAvtC/lBR3191Hg28xuzveA4JZB4MH/qUSDShNJ45n7CtyWdXb vVKoURx4okkp10OPAH7gAonSyAzt52rKoXXwFnS+FtUhwwcUF61P1NjukNoxaeV1HmRh UtJ7c9hF9c4VgsN/RvUSULq3YFC8wghdm3Yh3hGcalQ8uqSTRyp/bBPwSnl87jQ7vlEF ux7RCVaTA+fBx3hn2kVooJC81y1K3E1Tkm/Gf0+hX75iEbx6To1voGrFdTtayMpu7//L znAA== X-Gm-Message-State: AOAM531ZBmWmu50sf8MKx1omTJXsqTXLOKxcZGJvKxVNV/xx3dl0669K ppDu2twCimQC9CVJ9Lbg+oV7ioWqXg== Sender: "elver via sendgmr" X-Received: from elver.muc.corp.google.com ([2a00:79e0:15:13:f693:9fff:fef4:2449]) (user=elver job=sendgmr) by 2002:a0c:fe8b:: with SMTP id d11mr4599326qvs.48.1601386739523; Tue, 29 Sep 2020 06:38:59 -0700 (PDT) Date: Tue, 29 Sep 2020 15:38:10 +0200 In-Reply-To: <20200929133814.2834621-1-elver@google.com> Message-Id: <20200929133814.2834621-8-elver@google.com> Mime-Version: 1.0 References: <20200929133814.2834621-1-elver@google.com> X-Mailer: git-send-email 2.28.0.709.gb0816b6eb0-goog Subject: [PATCH v4 07/11] 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 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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, -- 2.28.0.709.gb0816b6eb0-goog