History

objtool: Grow __cfi_* prefix symbols for all CFI+CALL_PADDING

For all CONFIG_CFI+CONFIG_CALL_PADDING configs, for C functions, the __cfi_ symbols only cover the 5-byte kCFI type hash. After that there also N bytes of NOP padding between the hash and the function entry which aren't associated with any symbol. The NOPs can be replaced with actual code at runtime. Without a symbol, unwinders and tooling have no way of knowing where those bytes belong. Grow the existing __cfi_* symbols to fill that gap. Note that assembly functions with SYM_TYPED_FUNC_START() aren't affected by this issue, their __cfi_ symbols also cover the padding. Also, CONFIG_PREFIX_SYMBOLS has no reason to exist: CONFIG_CALL_PADDING is what causes the compiler to emit NOP padding before function entry (via -fpatchable-function-entry), so it's the right condition for creating prefix symbols. Remove CONFIG_PREFIX_SYMBOLS, as it's no longer needed. Simplify the LONGEST_SYM_KUNIT_TEST dependency accordingly. Rework objtool's arguments a bit to handle the variety of prefix/cfi-related cases.

Josh Poimboeuf committed 6 months ago

Commit fc0bb991 parent cca84cb8 files · +84 −21Browse files

Showing the changes to scripts (1 of 8 files). Show all

Unified · Split

scripts/Makefile.lib+5−2
@@ -187,7 +187,11 @@ objtool-args-$(CONFIG_HAVE_JUMP_LABEL_HACK) += --hacks=jump_label · 186 unmodified lines
187objtool-args-$(CONFIG_HAVE_NOINSTR_HACK) += --hacks=noinstr187objtool-args-$(CONFIG_HAVE_NOINSTR_HACK) += --hacks=noinstr
188objtool-args-$(CONFIG_MITIGATION_CALL_DEPTH_TRACKING) += --hacks=skylake188objtool-args-$(CONFIG_MITIGATION_CALL_DEPTH_TRACKING) += --hacks=skylake
189objtool-args-$(CONFIG_X86_KERNEL_IBT) += --ibt189objtool-args-$(CONFIG_X86_KERNEL_IBT) += --ibt
190objtool-args-$(CONFIG_FINEIBT) += --cfi190objtool-args-$(CONFIG_CALL_PADDING) += --prefix=$(CONFIG_FUNCTION_PADDING_BYTES)
191ifdef CONFIG_CALL_PADDING
192objtool-args-$(CONFIG_CFI) += --cfi
193objtool-args-$(CONFIG_FINEIBT) += --fineibt
194endif
191objtool-args-$(CONFIG_FTRACE_MCOUNT_USE_OBJTOOL) += --mcount195objtool-args-$(CONFIG_FTRACE_MCOUNT_USE_OBJTOOL) += --mcount
192ifdef CONFIG_FTRACE_MCOUNT_USE_OBJTOOL196ifdef CONFIG_FTRACE_MCOUNT_USE_OBJTOOL
193objtool-args-$(CONFIG_HAVE_OBJTOOL_NOP_MCOUNT) += --mnop197objtool-args-$(CONFIG_HAVE_OBJTOOL_NOP_MCOUNT) += --mnop
@@ -200,7 +204,6 @@ objtool-args-$(CONFIG_STACK_VALIDATION) += --stackval · 6 unmodified lines
200objtool-args-$(CONFIG_HAVE_STATIC_CALL_INLINE) += --static-call204objtool-args-$(CONFIG_HAVE_STATIC_CALL_INLINE) += --static-call
201objtool-args-$(CONFIG_HAVE_UACCESS_VALIDATION) += --uaccess205objtool-args-$(CONFIG_HAVE_UACCESS_VALIDATION) += --uaccess
202objtool-args-$(or $(CONFIG_GCOV_KERNEL),$(CONFIG_KCOV)) += --no-unreachable206objtool-args-$(or $(CONFIG_GCOV_KERNEL),$(CONFIG_KCOV)) += --no-unreachable
203objtool-args-$(CONFIG_PREFIX_SYMBOLS) += --prefix=$(CONFIG_FUNCTION_PADDING_BYTES)
204objtool-args-$(CONFIG_OBJTOOL_WERROR) += --werror207objtool-args-$(CONFIG_OBJTOOL_WERROR) += --werror
205 208
206objtool-args = $(objtool-args-y) \209objtool-args = $(objtool-args-y) \