From patchwork Tue Sep 15 13:20:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Elver X-Patchwork-Id: 11776605 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 018FC6CA for ; Tue, 15 Sep 2020 13:21:37 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A191520829 for ; Tue, 15 Sep 2020 13:21:36 +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="oYmwUA55" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A191520829 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 14E2E90005B; Tue, 15 Sep 2020 09:21:19 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0ACA090004C; Tue, 15 Sep 2020 09:21:19 -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 F057790005B; Tue, 15 Sep 2020 09:21:18 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0235.hostedemail.com [216.40.44.235]) by kanga.kvack.org (Postfix) with ESMTP id D7B2690004C for ; Tue, 15 Sep 2020 09:21:18 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 717E3363B for ; Tue, 15 Sep 2020 13:21:18 +0000 (UTC) X-FDA: 77265357036.19.match72_3916e6127111 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin19.hostedemail.com (Postfix) with ESMTP id 5DF351ACC2A for ; Tue, 15 Sep 2020 13:21:17 +0000 (UTC) X-Spam-Summary: 1,0,0,773f6d5320783925,d41d8cd98f00b204,3y79gxwukcm4y5fyb08805y.w86527eh-664fuw4.8b0@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:1534: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.221.73:@flex--elver.bounces.google.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100;04yrz9oaisz9uq7hi4tak5jkk7oisoph3w5p3yj7snmfmfkdpt3pzy8hs9wm3p7.zjg74b5drzfcxds3esfzb94995k61s6ckeq7ja6ab9y8zwyoacaeyacxo7m87pd.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:27,LUA_SUMMARY:none X-HE-Tag: match72_3916e6127111 X-Filterd-Recvd-Size: 4937 Received: from mail-wr1-f73.google.com (mail-wr1-f73.google.com [209.85.221.73]) by imf39.hostedemail.com (Postfix) with ESMTP for ; Tue, 15 Sep 2020 13:21:16 +0000 (UTC) Received: by mail-wr1-f73.google.com with SMTP id j7so1218648wro.14 for ; Tue, 15 Sep 2020 06:21:16 -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=A4TgnPIs4KlOFwMVz2jZ7oTmV4CFA6JHdIybpn/o/fA=; b=oYmwUA55tcvUaLXjfS/MZrSItzoh7D6nc9NF+TniY3ZoIx24Ls8Q/UZyvcRB/q/Tad aCO/x2/UGHmC8tlOnbemPKF8Fz9QA6KXlPgcUFvuoWXJjhdLNUiERkK0AzVZtW4gc78I r3yZX58ua7derhVDvSUCiyP7P8dm372cj6OuHlfBrxf4Df7lXMGOHh1g3PSnwuNFTP+Z YnQPVErJVrlKvqOcU4kPbDBSx1gNCL07qGR9NTqDwNLaAk/mg2XSaRfIJ/yFwh6geFZD Mv189/jYStN4uSdfpvMjRCvsRILDaR83YRXOsHZHQYKtWbsGtVSpJV9evgpFF0v17Dhr JUZw== 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=A4TgnPIs4KlOFwMVz2jZ7oTmV4CFA6JHdIybpn/o/fA=; b=e3ALhjHKPpRuZrTJQhXt3+C0piMYdEDDdaz2x3P2P6/IMv0ApopdcDZuOg52p4eiVr t+v3eTIr3xpEKhUBK5IRZ3GeX/cdFhvN7w7Ax21yjZoFXIuPA2bo+2Qw+T8c9uRclW3r XIfIFBBfRffilMJtW+Ux2RvHkjUfwvKppC+U032ryzPOsNGFf3hhfscXA6VoKmJK1Yku pGWi6JMvf/t/+/v61SkgD+FeGljrEK/pQdIBnRJ7I1bobafXGoo6mo0ruyISXX1VE1Nf fo/FBujMmp9E8JgInIc4MYBbhKO6czuXxOPOJ4rs1h/oUWuur6MeIxEgVtdyOzpZVG9p o/AQ== X-Gm-Message-State: AOAM532j2eIcXDjJEadCsY0UsnHFDfemEO+L0jlA/nDu1ypXJl4dv99R KHQVfWMlp3tUuLXS+dOR2iIugJWccA== X-Google-Smtp-Source: ABdhPJwJ9IZxHT97cXa5uoGFBvjbuWBl7DGE0CrhPkVSiotm4bBDWmiGegcVd7G5e99XRLCFU6KLs1co6Q== X-Received: from elver.muc.corp.google.com ([2a00:79e0:15:13:f693:9fff:fef4:2449]) (user=elver job=sendgmr) by 2002:a1c:80cd:: with SMTP id b196mr4760527wmd.104.1600176075555; Tue, 15 Sep 2020 06:21:15 -0700 (PDT) Date: Tue, 15 Sep 2020 15:20:43 +0200 In-Reply-To: <20200915132046.3332537-1-elver@google.com> Message-Id: <20200915132046.3332537-8-elver@google.com> Mime-Version: 1.0 References: <20200915132046.3332537-1-elver@google.com> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [PATCH v2 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, 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, cai@lca.pw, 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-Rspamd-Queue-Id: 5DF351ACC2A X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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 --- 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,