From patchwork Mon Sep 7 13:40:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Elver X-Patchwork-Id: 11761043 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 29045746 for ; Mon, 7 Sep 2020 13:41:32 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D42C421481 for ; Mon, 7 Sep 2020 13:41:31 +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="gJMepwpD" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D42C421481 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 387F98E0008; Mon, 7 Sep 2020 09:41:29 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 35FD28E0001; Mon, 7 Sep 2020 09:41:29 -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 13E9B8E0008; Mon, 7 Sep 2020 09:41:29 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0007.hostedemail.com [216.40.44.7]) by kanga.kvack.org (Postfix) with ESMTP id E9C5B8E0001 for ; Mon, 7 Sep 2020 09:41:28 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id ACE8B362A for ; Mon, 7 Sep 2020 13:41:28 +0000 (UTC) X-FDA: 77236377456.21.bread74_2617d31270cc Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin21.hostedemail.com (Postfix) with ESMTP id 78099180442C0 for ; Mon, 7 Sep 2020 13:41:28 +0000 (UTC) X-Spam-Summary: 1,0,0,3a799732ffbf97e1,d41d8cd98f00b204,3hjhwxwukcfex4exaz77z4x.v75416dg-553etv3.7az@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:4321:4605:5007:6119:6120:6261:6653:6742:6743:7576:7901:7903:9969:10004:10400:11026:11473:11658:11914:12043:12048:12294:12297:12438:12555:12679:12895:13069:13311:13357:13972:14096:14097:14181:14394:14659:14721:21080:21444:21451:21627:30054:30090,0,RBL:209.85.218.74:@flex--elver.bounces.google.com:.lbl8.mailshell.net-66.100.201.100 62.18.0.100;04y8zusu3oeo3kd3zi6a8d56tph1ryp691f483yg4p7swc4u7no9syao9541cqx.zmqqhu5o6ppnehs6y1gjo6z7jkz8chdwmamsx6hy7171hd4xbeguwyfabn7oatg.n-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,LU A_SUMMAR X-HE-Tag: bread74_2617d31270cc X-Filterd-Recvd-Size: 5129 Received: from mail-ej1-f74.google.com (mail-ej1-f74.google.com [209.85.218.74]) by imf07.hostedemail.com (Postfix) with ESMTP for ; Mon, 7 Sep 2020 13:41:27 +0000 (UTC) Received: by mail-ej1-f74.google.com with SMTP id ce9so5565386ejb.7 for ; Mon, 07 Sep 2020 06:41:27 -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=6l8eSHfBJbgjXLH4YKy244cAN4v6gWSGUkqWIYWs5l8=; b=gJMepwpDD2I7mUYxDrgz/A+g9gfSD/BA/UuHnQFWRrhx63jrzAm++vIK181a9bjlv9 +fyJs0UBhDwHyL6bmgDBoBCj+YXB5NcIWStWKiSyw+U5jw3hXU5qNrqCgVh70poBTziM hVjzHzlUPAP+6ZrjPMb0VVDUmjdbm+Fic5uHT4D0LLJBRfryu3ilfMTyrvJ6Pe67zAKM QPB1+20ESihTrASldDU+keBcOA+VdB6aTwV7W7EB3NGfe+MymBScoWc26UcdcpDZRQUj K7o1qF+WpCWcT7AO1+jrbBJd9uRJMgPkaub7KeMCED/zCqeZW5LsKuVbAAFjxIU1VdGp kNhw== 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=6l8eSHfBJbgjXLH4YKy244cAN4v6gWSGUkqWIYWs5l8=; b=BYkQwol0nSR7bTzGwOrfCklHpYScQ+0hRxXUFYWWoxeofEDWJWbL2RIvc073NarcE2 gpYRxfujZy+eV+A16W1SHqBp/eS8+QwshkdbXll6drdYfbyeofQ9I4rJ98sozvblfPVa 4+sGTi119oVGinx5OIhRQg/j9vaMng2zHo4InIr9HMM7Zma6ne2mIo56vOsdLi9QnIrq ZCJpyLaRdyUDT3UAIQKldXDeCBhP2pfaxeUhi85gjz8rZF37AQUq7yRJCghAQa0aadY7 0y/G320CCvZH0kTqdOpj4Yo88XWRBTOikDwp911Y0VmXJiRLXflvX8sRFrjygDEGCy/l FMnw== X-Gm-Message-State: AOAM533UUD9Eqkl4DBwJayUTscp/2+iT9F5uf89LktV4mQuh7mocrJ35 Rg1ULJSXaun9VcBvBLxWOTkgWYUEsQ== X-Google-Smtp-Source: ABdhPJyZu6FsfB3DPagX7+/xIWmjZXKqXJcTOhpqkU8N9KdWRQ4MmOfijnPAcqP/AO+UJAuVA1aIngFA6A== X-Received: from elver.muc.corp.google.com ([2a00:79e0:15:13:f693:9fff:fef4:2449]) (user=elver job=sendgmr) by 2002:a50:be82:: with SMTP id b2mr22342862edk.303.1599486086811; Mon, 07 Sep 2020 06:41:26 -0700 (PDT) Date: Mon, 7 Sep 2020 15:40:52 +0200 In-Reply-To: <20200907134055.2878499-1-elver@google.com> Message-Id: <20200907134055.2878499-8-elver@google.com> Mime-Version: 1.0 References: <20200907134055.2878499-1-elver@google.com> X-Mailer: git-send-email 2.28.0.526.ge36021eeef-goog Subject: [PATCH RFC 07/10] kfence, kmemleak: make KFENCE compatible with KMEMLEAK From: Marco Elver To: elver@google.com, glider@google.com, akpm@linux-foundation.org, catalin.marinas@arm.com, cl@linux.com, rientjes@google.com, iamjoonsoo.kim@lge.com, mark.rutland@arm.com, penberg@kernel.org Cc: hpa@zytor.com, paulmck@kernel.org, andreyknvl@google.com, aryabinin@virtuozzo.com, luto@kernel.org, bp@alien8.de, dave.hansen@linux.intel.com, dvyukov@google.com, edumazet@google.com, gregkh@linuxfoundation.org, mingo@redhat.com, jannh@google.com, corbet@lwn.net, keescook@chromium.org, peterz@infradead.org, cai@lca.pw, tglx@linutronix.de, 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-Rspamd-Queue-Id: 78099180442C0 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 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. Co-developed-by: Marco Elver Signed-off-by: Marco Elver Signed-off-by: Alexander Potapenko --- mm/kmemleak.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/mm/kmemleak.c b/mm/kmemleak.c index 5e252d91eb14..2809c25c0a88 100644 --- a/mm/kmemleak.c +++ b/mm/kmemleak.c @@ -97,6 +97,7 @@ #include #include +#include #include #include @@ -1946,8 +1947,18 @@ void __init kmemleak_init(void) /* register the data/bss sections */ create_object((unsigned long)_sdata, _edata - _sdata, 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. */ + create_object((unsigned long)__bss_start, __kfence_pool - __bss_start, + KMEMLEAK_GREY, GFP_ATOMIC); + create_object((unsigned long)__kfence_pool + KFENCE_POOL_SIZE, + __bss_stop - (__kfence_pool + KFENCE_POOL_SIZE), + KMEMLEAK_GREY, GFP_ATOMIC); +#else create_object((unsigned long)__bss_start, __bss_stop - __bss_start, KMEMLEAK_GREY, GFP_ATOMIC); +#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,