From patchwork Mon Jun 22 19:31:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 11618847 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 12750912 for ; Mon, 22 Jun 2020 19:33:49 +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 DFCB820776 for ; Mon, 22 Jun 2020 19:33:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="EQZimtnA"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="jQvwT91a" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DFCB820776 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org 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:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=WiJIsZ3FhXbSZuX509uP/1onvvdjOmaPGHZ+gJ9GJT0=; b=EQZimtnA72AJ72NWpIi0e4p8c bLreeeRBI1bPJLL6C5zVUKRzHxDpvWRZkEAHRP1roBWa5cK7GQQfjMjDG6lIgK99cSh8FHH9aw7lu r/9OjCR1GFBqxBEH3He/5kTCID6b17WPt2KJ1RqUoxoDbwwzMHj6dtlt7g+Bma/hsfGXOmsY5iG/c G9spYAKGeLm2YOJdcOxVJ+rizeCYFcemR2IN2xcFtu68yIbR4Xa2wcrItNbtvMs6aPn6Z6rWDz4pp juXYzCW3HFgwlOaaRQIolxF35j3374un1RtUVW3RfDl/J8+j1eGxgOHYVHqAZF7YVVyArmc7Z5lrX ePzd3SVCg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jnSAl-00022G-0F; Mon, 22 Jun 2020 19:32:03 +0000 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jnSAc-0001zg-Ka for linux-arm-kernel@lists.infradead.org; Mon, 22 Jun 2020 19:31:57 +0000 Received: by mail-pf1-x443.google.com with SMTP id x22so8865975pfn.3 for ; Mon, 22 Jun 2020 12:31:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bd9f3BBqo3zGwwTfmvjboaNS4RxuJ7DCwqiU44HfZsQ=; b=jQvwT91aNdu6DbbTFmcHtowv1QDuWeDxsDk/RqKsPvwbGbHTpYzrDrmmY/0dq+aBJQ jlwYwDhLmthT175NDbEj6C17KQJgc9BEyT+EwcD3Md/NbUgFJ+PR+YCJt9RkY1QSZdRZ QY9d67wu3uA3m5bOy/gHJd8An71KIaVS3oaeE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bd9f3BBqo3zGwwTfmvjboaNS4RxuJ7DCwqiU44HfZsQ=; b=Y0ZmL4Z7c8oAhkeK0oMFDkjJl+AWOQxv+ntMxRacODL+TzePEdUvrMBTlA8WHPayeV FkGbM89mxzbEzkcT/2nGZNI23ofhoWv13Faz2wxAC5ci0NTfw7N+YfUaoz923tzeODOk yb8mvCjpUd0DX5oLT3p28A0goksKeBJAOPDT+LdEpBVKnTN7WZ5aprru4w6lrAjk3jjq hGNttbqanlcGNOAm+xE1jxLbecj+O2YNbGTEhL2BJJWIoBKcA/cbpDw28U+GcDA6WvF5 ++IguLJ1ckveVC/2Xn/ah+u0KiZjoiJkwb/zq9Uz6lj4ZJGgN8pMYpas+V+IzNxYjnGI H37Q== X-Gm-Message-State: AOAM531K5opgiryYlIhsVx944PnGPa+NxspcBEZt6ImxCSp9SKDxsXO8 9w4bqP75PECO5DYMQVJ9H59NOQ== X-Google-Smtp-Source: ABdhPJy/XsCwbSTQ8GDNdy6eIPIN39i7/vLM9SHQLKSs+iIR061Tg/mVW3fZLxYeE/B4wCdXiH9v5A== X-Received: by 2002:a62:1d0b:: with SMTP id d11mr15185345pfd.1.1592854312494; Mon, 22 Jun 2020 12:31:52 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id y18sm14064284pfn.177.2020.06.22.12.31.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jun 2020 12:31:50 -0700 (PDT) From: Kees Cook To: Thomas Gleixner Subject: [PATCH v4 2/5] init_on_alloc: Unpessimize default-on builds Date: Mon, 22 Jun 2020 12:31:43 -0700 Message-Id: <20200622193146.2985288-3-keescook@chromium.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200622193146.2985288-1-keescook@chromium.org> References: <20200622193146.2985288-1-keescook@chromium.org> MIME-Version: 1.0 X-Spam-Note: CRM114 invocation failed X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:443 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 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_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_HIGH DKIMwl.org - Whitelisted High 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 , Kees Cook , Jann Horn , Ard Biesheuvel , Peter Zijlstra , Catalin Marinas , x86@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Alexander Potapenko , linux-arm-kernel@lists.infradead.org, Andy Lutomirski , kernel-hardening@lists.openwall.com, Will Deacon , Elena Reshetova , Alexander Popov Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Right now, the state of CONFIG_INIT_ON_ALLOC_DEFAULT_ON (and ...ON_FREE...) did not change the assembly ordering of the static branch tests. Use the new jump_label macro to check CONFIG settings to default to the "expected" state, unpessimizes the resulting assembly code. Reviewed-by: Alexander Potapenko Signed-off-by: Kees Cook --- include/linux/mm.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 0e6824fd4458..0a05b20870c2 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2892,7 +2892,8 @@ static inline void kernel_poison_pages(struct page *page, int numpages, DECLARE_STATIC_KEY_MAYBE(CONFIG_INIT_ON_ALLOC_DEFAULT_ON, init_on_alloc); static inline bool want_init_on_alloc(gfp_t flags) { - if (static_branch_unlikely(&init_on_alloc) && + if (static_branch_maybe(CONFIG_INIT_ON_ALLOC_DEFAULT_ON, + &init_on_alloc) && !page_poisoning_enabled()) return true; return flags & __GFP_ZERO; @@ -2901,7 +2902,8 @@ static inline bool want_init_on_alloc(gfp_t flags) DECLARE_STATIC_KEY_MAYBE(CONFIG_INIT_ON_FREE_DEFAULT_ON, init_on_free); static inline bool want_init_on_free(void) { - return static_branch_unlikely(&init_on_free) && + return static_branch_maybe(CONFIG_INIT_ON_FREE_DEFAULT_ON, + &init_on_free) && !page_poisoning_enabled(); }