Skip to content

Commit 20bf2b3

Browse files
jpoimboesuryasaimadhu
authored andcommitted
x86/build: Disable CET instrumentation in the kernel
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: 29be86d ("kbuild: add -fcf-protection=none when using retpoline flags") Reported-by: Nikolay Borisov <[email protected]> Signed-off-by: Josh Poimboeuf <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Reviewed-by: Nikolay Borisov <[email protected]> Tested-by: Nikolay Borisov <[email protected]> Cc: <[email protected]> Cc: Seth Forshee <[email protected]> Cc: Masahiro Yamada <[email protected]> Link: https://lkml.kernel.org/r/20210128215219.6kct3h2eiustncws@treble
1 parent 6ee1d74 commit 20bf2b3

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

Makefile

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -948,12 +948,6 @@ KBUILD_CFLAGS += $(call cc-option,-Werror=designated-init)
948948
# change __FILE__ to the relative path from the srctree
949949
KBUILD_CPPFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
950950

951-
# ensure -fcf-protection is disabled when using retpoline as it is
952-
# incompatible with -mindirect-branch=thunk-extern
953-
ifdef CONFIG_RETPOLINE
954-
KBUILD_CFLAGS += $(call cc-option,-fcf-protection=none)
955-
endif
956-
957951
# include additional Makefiles when needed
958952
include-y := scripts/Makefile.extrawarn
959953
include-$(CONFIG_KASAN) += scripts/Makefile.kasan

arch/x86/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ else
120120

121121
KBUILD_CFLAGS += -mno-red-zone
122122
KBUILD_CFLAGS += -mcmodel=kernel
123+
124+
# Intel CET isn't enabled in the kernel
125+
KBUILD_CFLAGS += $(call cc-option,-fcf-protection=none)
123126
endif
124127

125128
ifdef CONFIG_X86_X32

0 commit comments

Comments
 (0)