Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4123103pxb; Mon, 8 Feb 2021 08:28:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJxdEqQb7zFomNpgIK321VFq6FO9hnnSoHzgayErNxmUTbS+GT+NuJcnu7omPqb0MDGi1avO X-Received: by 2002:a50:d4d9:: with SMTP id e25mr17932171edj.183.1612801739307; Mon, 08 Feb 2021 08:28:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612801739; cv=none; d=google.com; s=arc-20160816; b=FAyH3z0eY2mloATHAWGHD6JRlFzND/jic+jUR+Bztb4lS5sOLeN5V34jF1uUpgeaZp q+NdhxCzhE9mL13MazfyRYMcqs8zeK9rNXgOGjIIZ5gp72e07D3gWqcIy8xtg7D/JJYR HkH4ORv6mTPRe9Jth785IrFTZz8d951lPpfg1RFN+MI7BXmZ3ANZJieo+bjWJcgXwckp B27s16KslUZg1xlgAFaT4eAvYyHi5SNMI0liuj1b0eHt50pbcrKKaLqcS2yTWn3uFUGG 0HF9EVnUbsa5ghXRv+x9Ppn0CS5Hv8xLqTzuFveLthQq2rfec5CergYEg/jrfIlPMPaI XIlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=58F0EtZgxaVNRFgQT06jz75XpZUx4aafQHCXwNNHFOE=; b=meBl0gCRHjxsNgYEQSpPMHQA4VW336vyCOX00MkksH+Bw9U4D1Z7PZ1qYvHRhHPu0/ NaN49Mq5mKOIFnhIEud+HAVwyWzwy3fR/gBC9dv/tcou7G50eFlkVs7mKVKXrn7iC1QP 9aKmMTtiAlr2NIJXLTi/W3Cl3QP2ujYpLfdPcymej6sgrV66FAZNmkECoQnIyD+t1OMv 5MELeoB/f678pYZqSJtfEoOa+Xp8+6P6dS/h88nJFr4Wft6n8oDxu+ZLEcXIbFRET8Nk Hp2yzovXFJFxT1uu+SQB0WSjNxonVwMCoDSpKtjR3fT3KtAcB2ZdgTxbXkqTsW16aAOl wqSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2cbd6n2D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x2si11283117ejn.747.2021.02.08.08.28.34; Mon, 08 Feb 2021 08:28:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2cbd6n2D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234296AbhBHQZS (ORCPT + 99 others); Mon, 8 Feb 2021 11:25:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:55768 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232699AbhBHPI5 (ORCPT ); Mon, 8 Feb 2021 10:08:57 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 41C7564ECB; Mon, 8 Feb 2021 15:06:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612796806; bh=8nH3qRivrO5E+F6y1Ttt6BSVl0UawVdXt1IkzWevB7k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2cbd6n2DtKG9nuovLGwYn8wRrP4leE+GtbjMEQ3wpjSc41VVYGavhkegEApGWKwxL NFEpjO63zib3du3EbTYAzScdhyleiCUpenYMQhu76LzOZyGCW2clZruoQ8DNFcbmCv kGph+A3+9WOjKmCEKonzk0g5MGPKxKqnAYMdz5G8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nikolay Borisov , Josh Poimboeuf , Borislav Petkov , Seth Forshee , Masahiro Yamada Subject: [PATCH 4.14 26/30] x86/build: Disable CET instrumentation in the kernel Date: Mon, 8 Feb 2021 16:01:12 +0100 Message-Id: <20210208145806.298526525@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210208145805.239714726@linuxfoundation.org> References: <20210208145805.239714726@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Josh Poimboeuf commit 20bf2b378729c4a0366a53e2018a0b70ace94bcd upstream. With retpolines disabled, some configurations of GCC, and specifically the GCC versions 9 and 10 in Ubuntu will add Intel CET instrumentation to the kernel by default. That breaks certain tracing scenarios by adding a superfluous ENDBR64 instruction before the fentry call, for functions which can be called indirectly. CET instrumentation isn't currently necessary in the kernel, as CET is only supported in user space. Disable it unconditionally and move it into the x86's Makefile as CET/CFI... enablement should be a per-arch decision anyway. [ bp: Massage and extend commit message. ] Fixes: 29be86d7f9cb ("kbuild: add -fcf-protection=none when using retpoline flags") Reported-by: Nikolay Borisov Signed-off-by: Josh Poimboeuf Signed-off-by: Borislav Petkov Reviewed-by: Nikolay Borisov Tested-by: Nikolay Borisov Cc: Cc: Seth Forshee Cc: Masahiro Yamada Link: https://lkml.kernel.org/r/20210128215219.6kct3h2eiustncws@treble Signed-off-by: Greg Kroah-Hartman --- Makefile | 6 ------ arch/x86/Makefile | 3 +++ 2 files changed, 3 insertions(+), 6 deletions(-) --- a/Makefile +++ b/Makefile @@ -844,12 +844,6 @@ KBUILD_CFLAGS += $(call cc-option,-Wer # change __FILE__ to the relative path from the srctree KBUILD_CFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=) -# ensure -fcf-protection is disabled when using retpoline as it is -# incompatible with -mindirect-branch=thunk-extern -ifdef CONFIG_RETPOLINE -KBUILD_CFLAGS += $(call cc-option,-fcf-protection=none) -endif - # use the deterministic mode of AR if available KBUILD_ARFLAGS := $(call ar-option,D) --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -138,6 +138,9 @@ else KBUILD_CFLAGS += -mno-red-zone KBUILD_CFLAGS += -mcmodel=kernel + # Intel CET isn't enabled in the kernel + KBUILD_CFLAGS += $(call cc-option,-fcf-protection=none) + # -funit-at-a-time shrinks the kernel .text considerably # unfortunately it makes reading oopses harder. KBUILD_CFLAGS += $(call cc-option,-funit-at-a-time)