Skip to content

Commit 3c68a92

Browse files
samitolvanenkees
authored andcommitted
objtool: Disable CFI warnings
The __cfi_ preambles contain a mov instruction that embeds the KCFI type identifier in the following format: ; type preamble __cfi_function: mov <id>, %eax function: ... While the preamble symbols are STT_FUNC and contain valid instructions, they are never executed and always fall through. Skip the warning for them. .kcfi_traps sections point to CFI traps in text sections. Also skip the warning about them referencing !ENDBR instructions. Signed-off-by: Sami Tolvanen <[email protected]> Reviewed-by: Kees Cook <[email protected]> Tested-by: Kees Cook <[email protected]> Tested-by: Nathan Chancellor <[email protected]> Acked-by: Josh Poimboeuf <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Tested-by: Peter Zijlstra (Intel) <[email protected]> Signed-off-by: Kees Cook <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 5141d3a commit 3c68a92

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tools/objtool/check.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3316,6 +3316,10 @@ static int validate_branch(struct objtool_file *file, struct symbol *func,
33163316
next_insn = next_insn_to_validate(file, insn);
33173317

33183318
if (func && insn->func && func != insn->func->pfunc) {
3319+
/* Ignore KCFI type preambles, which always fall through */
3320+
if (!strncmp(func->name, "__cfi_", 6))
3321+
return 0;
3322+
33193323
WARN("%s() falls through to next function %s()",
33203324
func->name, insn->func->name);
33213325
return 1;
@@ -4113,7 +4117,8 @@ static int validate_ibt(struct objtool_file *file)
41134117
!strcmp(sec->name, "__bug_table") ||
41144118
!strcmp(sec->name, "__ex_table") ||
41154119
!strcmp(sec->name, "__jump_table") ||
4116-
!strcmp(sec->name, "__mcount_loc"))
4120+
!strcmp(sec->name, "__mcount_loc") ||
4121+
!strcmp(sec->name, ".kcfi_traps"))
41174122
continue;
41184123

41194124
list_for_each_entry(reloc, &sec->reloc->reloc_list, list)

0 commit comments

Comments
 (0)