From patchwork Tue Sep 29 13:38:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Elver X-Patchwork-Id: 11806009 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 0DB921668 for ; Tue, 29 Sep 2020 14:01:15 +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 B2F4020C09 for ; Tue, 29 Sep 2020 14:01:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ZGZTBF0d"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="gckW7KKj"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="B8oKuahj" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B2F4020C09 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=Yh54l7HcgyH9ECvHMC6VOV8a1wDZbsxXN+HwlQIDT/M=; b=ZGZTBF0dqTeWefYVyYX6fCdbZ Xpvut/aSPxMbUNyXjKtDRzbxmZorJYEIkxn1FSKOO/1EWNhnx9oeCkULICzvrnV8y99XmZ1mgO8oP bDSI2JSth5/YfTtCRMLCFL2v6XjWB3CKLgRc2O34GA0+gxsIOpg6wRL/2DSZ56Q9yBuOrDvjMeLpU VKvGffYiTGin8sPn8uhQsO/kqkJQz+d459JPxf6lMQ2NF6ammbZTKZ3N9XLROJjTwo+/2i9k0AepL lWyJIRvBziKRWnDOi++Tus0eAYL4scukg8QHPyTgbAgyN42DH1iEvUuryAJnZPEG7iNYnYyKOe3Z4 CEkFo9Yaw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNGBf-0002hH-9D; Tue, 29 Sep 2020 14:00:59 +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 1kNGB0-0002Qg-M7 for linux-arm-kernel@merlin.infradead.org; Tue, 29 Sep 2020 14:00:18 +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=3tnm6vmpSMHKvgeLXX0r5hzQnU0w3hMCi/2IZuY8XC4=; b=gckW7KKjVXI9FfT+5oIwcTGB2J C+1ykOVmUaKzNv11/Hjp9XiQwWlWSfYpXTL/aHAbsC+EayX/7PdXEJNPflFLhcjZfFYxKz7GqfqR/ lLQUkUgVCk6IIqWudQitw5nKXKl4CPT4UtA5Ffex66I8h9hXL2i6SXj2Wv5rmi4DYyim7GcPy8fqO xt26DMzDyf/j+UEOkwR3KQ2EmgR6wKoco5DOzk4iJHFwoHR889C+K1o7Vt3U512lHRtgtnBg0Lj3D SQuhMpTe35qai/krumyYpaw3h6PYd73iz5QbKBpAemgbmvORZTCWWYrVVffEiNfvCEmsqN2MDQVG6 9q09zWDw==; Received: from mail-qk1-x74a.google.com ([2607:f8b0:4864:20::74a]) by casper.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNFqQ-0001lq-N1 for linux-arm-kernel@lists.infradead.org; Tue, 29 Sep 2020 13:39:06 +0000 Received: by mail-qk1-x74a.google.com with SMTP id h191so2689132qke.1 for ; Tue, 29 Sep 2020 06:39:01 -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=ZdB05i/cKWM0EC9omvk8lgOYCAuIMURa7salKQ9aRdur9aqLQ3QvTvM+mlozuxsLWw YM5MCm8y65i5g7hCAPNP/4UiRKBkJaiBNKMv4evllBJFKExIAwIza0zX38aeWycMxPmU qaCcDlHqWexYjUjiEYYp7ZdIh4L8Pd6eSkX8IvYX83rdnb/iaNb2iiWKdRocmdf78BH2 UxSfJnmbILcOUuxqFgaJnecX/IHbgCCYTg4ChCfOpy+2++lE9+4d5vsCzjys88c2PFb1 HbdZNoY5rmtdJ3r9NSIb0XEzPAxCZRyGQObkCz6gBbcYQn/qj/Y/wnPx/hIysfbvkm5K ok+Q== X-Gm-Message-State: AOAM531YaqfNaO3SLJ1XQalhojA8O7F4IY0GpZOw7atCHgWoZyO5oOqv CeCTFf8ZD8AAkODYyooGkIFJoPbHkQ== X-Google-Smtp-Source: ABdhPJwtIaHl0p1/67p2AF0f5fwhdcugbouYy5zrrvCrbYXz74CVzZuBR+e9JMHZddr7RXMLFJNheXoidg== 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200929_143902_952042_0A5FCD0E X-CRM114-Status: GOOD ( 10.60 ) X-Spam-Score: -10.1 (----------) X-Spam-Report: SpamAssassin version 3.4.4 on casper.infradead.org summary: Content analysis details: (-10.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:74a listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -7.5 USER_IN_DEF_DKIM_WL From: address is in the default DKIM white-list 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.5 DKIMWL_WL_MED DKIMwl.org - Medium trust 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, hdanton@sina.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, sjpark@amazon.com, 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, 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. 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,