Skip to content

Commit

Permalink
objtool: Fix UNWIND_HINT_{SAVE,RESTORE} across basic blocks
Browse files Browse the repository at this point in the history
If SAVE and RESTORE unwind hints are in different basic blocks, and
objtool sees the RESTORE before the SAVE, it errors out with:

  vmlinux.o: warning: objtool: vmw_port_hb_in+0x242: objtool isn't smart enough to handle this CFI save/restore combo

In such a case, defer following the RESTORE block until the
straight-line path gets followed later.

Fixes: 8faea26 ("objtool: Re-add UNWIND_HINT_{SAVE_RESTORE}")
Reported-by: kernel test robot <[email protected]>
Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
Signed-off-by: Josh Poimboeuf <[email protected]>
Link: https://lore.kernel.org/r/20240227073527.avcm5naavbv3cj5s@treble
Signed-off-by: Kees Cook <[email protected]>
  • Loading branch information
jpoimboe authored and kees committed Mar 1, 2024
1 parent c5e6d3d commit 10b4c4b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tools/objtool/check.c
Original file line number Diff line number Diff line change
Expand Up @@ -3620,6 +3620,18 @@ static int validate_branch(struct objtool_file *file, struct symbol *func,
}

if (!save_insn->visited) {
/*
* If the restore hint insn is at the
* beginning of a basic block and was
* branched to from elsewhere, and the
* save insn hasn't been visited yet,
* defer following this branch for now.
* It will be seen later via the
* straight-line path.
*/
if (!prev_insn)
return 0;

WARN_INSN(insn, "objtool isn't smart enough to handle this CFI save/restore combo");
return 1;
}
Expand Down

0 comments on commit 10b4c4b

Please sign in to comment.