Skip to content

Commit ddf5628

Browse files
samitolvanenmasahir0y
authored andcommitted
kbuild: Fix CFI failures with GCOV
With GCOV_PROFILE_ALL, Clang injects __llvm_gcov_* functions to each object file, and the functions are indirectly called during boot. However, when code is injected to object files that are not part of vmlinux.o, it's also not processed by objtool, which breaks CFI hash randomization as the hashes in these files won't be included in the .cfi_sites section and thus won't be randomized. Similarly to commit 42633ed ("kbuild: Fix CFI hash randomization with KASAN"), disable GCOV for .vmlinux.export.o and init/version-timestamp.o to avoid emitting unnecessary functions to object files that don't otherwise have executable code. Fixes: 0c3e806 ("x86/cfi: Add boot time hash randomization") Reported-by: Joe Fradley <joefradley@google.com> Signed-off-by: Sami Tolvanen <samitolvanen@google.com> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Kees Cook <keescook@chromium.org> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
1 parent 3602906 commit ddf5628

2 files changed

Lines changed: 2 additions & 0 deletions

File tree

init/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,4 @@ include/generated/utsversion.h: FORCE
6060
$(obj)/version-timestamp.o: include/generated/utsversion.h
6161
CFLAGS_version-timestamp.o := -include include/generated/utsversion.h
6262
KASAN_SANITIZE_version-timestamp.o := n
63+
GCOV_PROFILE_version-timestamp.o := n

scripts/Makefile.vmlinux

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ quiet_cmd_cc_o_c = CC $@
1919

2020
ifdef CONFIG_MODULES
2121
KASAN_SANITIZE_.vmlinux.export.o := n
22+
GCOV_PROFILE_.vmlinux.export.o := n
2223
targets += .vmlinux.export.o
2324
vmlinux: .vmlinux.export.o
2425
endif

0 commit comments

Comments
 (0)