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: 11776671 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 8951059D for ; Tue, 15 Sep 2020 13:43:33 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5442C20936 for ; Tue, 15 Sep 2020 13:43:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="byGcpxuT"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="I0hVk/Jv"; 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 5442C20936 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:From:Subject:References:Mime-Version:Message-Id: In-Reply-To:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=UBpnEfb2GLk9Xvn0l5y9dx304hTVO0WCeCpZEL5vEIE=; b=byGcpxuTAQbbzHklOXXFsw2EL u79Yq2lkagPcPTn+lizm8k/Q00Fg5YpwtX1WYp5HeARxHXkdekqcHPIwSYFtj46HFfeYETGgGE7Pe pviIkFyhahtfCAobAUlGgwRq52hzcoah2IyfPQr/DPlmO24jxlTLGpyFe32MTwXz7Si1WsI04VDFA ZZY2VODC1/GSNKRPuO2wtSkMZ/vVoVafKlBYPSlpXGK11MvTSHMhRj3G2fgq63nobcPNM8xkmegn8 QHpocEIeLBuFBw2zG7a2WSeI5LzMwBFsvn6UjcNMAWVo6mUsvv7sYKNGZ97hHxjTEfUkDmz4RR4DL 3Xbn2rIbw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kIBDJ-0005tN-RI; Tue, 15 Sep 2020 13:41:41 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kIBD8-0005ok-La for linux-arm-kernel@merlin.infradead.org; Tue, 15 Sep 2020 13:41:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:Cc:To:From:Subject: References:Mime-Version:Message-Id:In-Reply-To:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=A4TgnPIs4KlOFwMVz2jZ7oTmV4CFA6JHdIybpn/o/fA=; b=I0hVk/JvKKhGkM5VG/L3YozuHG oGWb9r5rak87v8/JydYjYey6D5cnHUDYic7LNMmeeo3ZcqaC/rfb4bE8uR1AscfTRnExF23HiJ074 UME4Su2/+pdKwJvueJ2lxYmoWEg2fCaBb4dupYw8G7iKBR38EKE/K+i3Ms0rcsdXhJMraT4cmJh8A EAKv5TREK71uERuHrc4dQx1w6dwh5vsAXdq9XtYBolnEobnIntZN11XCk1XSskieRFeChY1MvAf7N LsfkR1KcU1ilxRNeBd5xA4nrO5sXa+s3z0FafawDd9zsxnPTb8pLNO6N8sUOiPPpMwh71RjT2pXzj +aQ2yGLg==; Received: from mail-wm1-x34a.google.com ([2a00:1450:4864:20::34a]) by casper.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kIAtZ-0001il-II for linux-arm-kernel@lists.infradead.org; Tue, 15 Sep 2020 13:21:33 +0000 Received: by mail-wm1-x34a.google.com with SMTP id y18so1164159wma.4 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=Sk3ZeuF14JNdNbKjfXoUA8c7zAnM08jlLXH9n3HXvjPuNj89TQmoX0ccO+OBFt0AG/ DLFVdFUI/y8GJ9HCcvNlPp7ag6YrGWbqAPM/GhvRLCgPJGghUpM+h9LiNw81mvoy4gTA ioWLtx4oBQ+4YJPRmL4QY1tixyRjhmH4Qm9Hwwu8nuufzDtpK1K3UDA0h4UarTOpHjoN UuIJ/ujnZ4Vi8NSC2gPle6WmWELWbxRsC3Aw94iOW1CPi+sarSvN4PO8JvRkBQd/gBcW 9H89HmKQzZlosCaj7YP7EhTYzFCaT5uJv9rIYmqU7oyA7TQ261245joOb6ifsYbtzB5j KM0Q== X-Gm-Message-State: AOAM533HJNBVOsAtjrKUNxevQFpkG9uMbaiPyIeKrWh8JJcaApV9MoYj 0NFWw+MrMGefMo+AMlJ+vFkq57nKeQ== 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200915_142117_742825_9367B1E8 X-CRM114-Status: GOOD ( 11.14 ) X-Spam-Score: -9.6 (---------) X-Spam-Report: SpamAssassin version 3.4.4 on casper.infradead.org summary: Content analysis details: (-9.6 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:34a listed in] [list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -7.5 USER_IN_DEF_DKIM_WL From: address is in the default DKIM white-list -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.0 DKIMWL_WL_MED DKIMwl.org - Medium sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, linux-doc@vger.kernel.org, peterz@infradead.org, catalin.marinas@arm.com, dave.hansen@linux.intel.com, linux-mm@kvack.org, edumazet@google.com, hpa@zytor.com, cl@linux.com, will@kernel.org, corbet@lwn.net, x86@kernel.org, kasan-dev@googlegroups.com, mingo@redhat.com, vbabka@suse.cz, rientjes@google.com, aryabinin@virtuozzo.com, keescook@chromium.org, paulmck@kernel.org, jannh@google.com, andreyknvl@google.com, bp@alien8.de, luto@kernel.org, Jonathan.Cameron@huawei.com, tglx@linutronix.de, dvyukov@google.com, linux-arm-kernel@lists.infradead.org, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, penberg@kernel.org, cai@lca.pw, iamjoonsoo.kim@lge.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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. 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,