From patchwork Fri Jul 31 23:07:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 11695571 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 389AC14B7 for ; Fri, 31 Jul 2020 23:11:53 +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 D99DA205CB for ; Fri, 31 Jul 2020 23:11:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="a6ovTMrD"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="R0afgxMV"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="eXzbc1BP" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D99DA205CB 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=F55fS79iV//Tleh9405tSmma8yPXs9HNrMf3GmRUl1M=; b=a6ovTMrDXTQ3Mieih2O5taruM r1N/Na7E+s2LuldsjqmmPSjmeuWpZIAse3ISzDzqWQP11sBvMhspUvwC9rcjmt74eR9L23BGgKdkM quAU3e2pcncXl1TIL/LO4ITPSJBQl/8Quf3zBHE49jU8e6kpN1VySpny4ydSS4P1tYIl6VYjtpXJB ygqBtbaXwZn2tdRkGNI7tDupqSvYMaf2vylLFdHbQ85Qu+ZgbG0fietexCs1Zq8c8khC85ic+DaP8 bP7SNYlbHhmiCGOIT/1YHuMEFxtHW4g6WFGfCZfhpf/ncvHgKh8XOAMVJuWo1oX/a4f5XkKu+5t43 b+WV1gsAw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k1eBN-0000l1-N0; Fri, 31 Jul 2020 23:11:22 +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 1k1e94-0008GI-VP for linux-arm-kernel@merlin.infradead.org; Fri, 31 Jul 2020 23:08:59 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=GiVQAgnHSmh3I5R0gtbyLBJa4hDaxzbWftSOld1BSI0=; b=R0afgxMVksk9EPQCqj2QcREPZp 5hMg/jq65U3ZQwpKXKFHtJittfDE+lnWSEReSTOmp5xvtJgRJwbIo29CC5qBpG5odhlKBd8qjFktv OMxKGkjoaPPj0/l5ajsdmaalxnz/pFKdzmS3kf/1EXlAE8+kJrc3918e5cCeJe4okCIPIBQKyTP9N M5OUbO3+IskOjiXFwZ0u0IYIMrQURoFBHwykCEemT6jYAR7LbA1v33Xn7qoADVWLYRYmP5uoFXbv8 VTBy5rfOtr+Maq26KeMTk0oPZ8UB3TYe7VxEWw/K5BLILPyk/UC28aldEwarcPQqf7sCLpFCZcAlF 59dlaEYQ==; Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]) by casper.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k1e8s-0000Z6-Pb for linux-arm-kernel@lists.infradead.org; Fri, 31 Jul 2020 23:08:57 +0000 Received: by mail-pf1-x442.google.com with SMTP id s26so15178495pfm.4 for ; Fri, 31 Jul 2020 16:08:46 -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=GiVQAgnHSmh3I5R0gtbyLBJa4hDaxzbWftSOld1BSI0=; b=eXzbc1BPKkTHPMZyF8VMqMXApjwlt+Z0Q4rDhEXSO/t0UYVMGhVF2JvNEDOO9RLwvH 2iTlarNmR2z09AgsvCjkYUsb5PlzXqXLkM6GENu0SdaRyStQUuDsuPkPWsufjYyiDb2N XwF2edaq78XYfUe1PD8t2h2H1ccKfVc9P+lhk= 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=GiVQAgnHSmh3I5R0gtbyLBJa4hDaxzbWftSOld1BSI0=; b=lsf3ciSS/tzyfjkg/fyVHlWIZVDnlEzMuuNpjbTrDBzsJA5mx05wk7vNE9UGcvcqrV hiDkGlG47ynG8B1oEf1WMyNrua8/LC059xiIjK1OQqn10X0a7nZha7cWdBQEtmhMC4Tc EYg4z/l+lXp3iUm2eTFlCUP4hykvjjSWV+sGa8ESlP7cNVeMwZGNKYhixVTSw4CZYTIM J4RAa/P4Qy5PMsX18RKG1oqNSW9e7byBRw3bxMRTesaTAJ9zmdcTzhKJY435bfEcGgo6 i15CTD5cB6pU5Q73/tQeQrP32cwjb2HswJOszW9ZEJLFU7sydZ3Jxbw7PFO0ikQO+ZIM SPPA== X-Gm-Message-State: AOAM532cYXzyvkqbXzvRFNzvnnMepyoE8RDKsw9fZq3g8hBAip/GHChw GQI+a5zdW7dwX+LRAkowSODV3g== X-Google-Smtp-Source: ABdhPJyRco/+NDd+heFvXx5i5JyQetAJX+BYme+lc8pixFz7LH/UuTvXw+HXPYf+c6sJEWtGbRKmtQ== X-Received: by 2002:a63:6ca:: with SMTP id 193mr5786021pgg.269.1596236924037; Fri, 31 Jul 2020 16:08:44 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id o23sm12166552pfd.126.2020.07.31.16.08.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 16:08:39 -0700 (PDT) From: Kees Cook To: Thomas Gleixner , Will Deacon Subject: [PATCH v5 14/36] efi/libstub: Disable -mbranch-protection Date: Fri, 31 Jul 2020 16:07:58 -0700 Message-Id: <20200731230820.1742553-15-keescook@chromium.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200731230820.1742553-1-keescook@chromium.org> References: <20200731230820.1742553-1-keescook@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200801_000848_401845_648D62EB X-CRM114-Status: GOOD ( 16.15 ) X-Spam-Score: -2.1 (--) X-Spam-Report: SpamAssassin version 3.4.4 on casper.infradead.org summary: Content analysis details: (-2.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:442 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -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.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 , linux-arch@vger.kernel.org, linux-efi@vger.kernel.org, Kees Cook , Arnd Bergmann , clang-built-linux@googlegroups.com, Catalin Marinas , Masahiro Yamada , x86@kernel.org, Nick Desaulniers , Russell King , linux-kernel@vger.kernel.org, Atish Patra , Arvind Sankar , Ingo Molnar , James Morse , Nathan Chancellor , Borislav Petkov , Peter Collingbourne , Ard Biesheuvel , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org In preparation for adding --orphan-handling=warn to more architectures, disable -mbranch-protection, as EFI does not yet support it[1]. This was noticed due to it producing unwanted .note.gnu.property sections (prefixed with .init due to the objcopy build step). However, we must also work around a bug in Clang where the section is still emitted for code-less object files[2], so also remove the section during the objcopy. [1] https://lore.kernel.org/lkml/CAMj1kXHck12juGi=E=P4hWP_8vQhQ+-x3vBMc3TGeRWdQ-XkxQ@mail.gmail.com [2] https://bugs.llvm.org/show_bug.cgi?id=46480 Cc: Arvind Sankar Cc: Atish Patra Cc: linux-efi@vger.kernel.org Acked-by: Ard Biesheuvel Reviewed-by: Nick Desaulniers Signed-off-by: Kees Cook --- drivers/firmware/efi/libstub/Makefile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile index b4f8c80cc591..d7d395ede89f 100644 --- a/drivers/firmware/efi/libstub/Makefile +++ b/drivers/firmware/efi/libstub/Makefile @@ -18,7 +18,8 @@ cflags-$(CONFIG_X86) += -m$(BITS) -D__KERNEL__ \ # arm64 uses the full KBUILD_CFLAGS so it's necessary to explicitly # disable the stackleak plugin cflags-$(CONFIG_ARM64) := $(subst $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) \ - -fpie $(DISABLE_STACKLEAK_PLUGIN) + -fpie $(DISABLE_STACKLEAK_PLUGIN) \ + $(call cc-option,-mbranch-protection=none) cflags-$(CONFIG_ARM) := $(subst $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) \ -fno-builtin -fpic \ $(call cc-option,-mno-single-pic-base) @@ -66,6 +67,12 @@ lib-$(CONFIG_X86) += x86-stub.o CFLAGS_arm32-stub.o := -DTEXT_OFFSET=$(TEXT_OFFSET) CFLAGS_arm64-stub.o := -DTEXT_OFFSET=$(TEXT_OFFSET) +# Even when -mbranch-protection=none is set, Clang will generate a +# .note.gnu.property for code-less object files (like lib/ctype.c), +# so work around this by explicitly removing the unwanted section. +# https://bugs.llvm.org/show_bug.cgi?id=46480 +STUBCOPY_FLAGS-y += --remove-section=.note.gnu.property + # # For x86, bootloaders like systemd-boot or grub-efi do not zero-initialize the # .bss section, so the .bss section of the EFI stub needs to be included in the