]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
objtool: Fix UNWIND_HINT_{SAVE,RESTORE} across basic blocks
authorJosh Poimboeuf <jpoimboe@kernel.org>
Tue, 27 Feb 2024 07:35:27 +0000 (23:35 -0800)
committerKees Cook <keescook@chromium.org>
Fri, 1 Mar 2024 06:34:42 +0000 (22:34 -0800)
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: 8faea26e6111 ("objtool: Re-add UNWIND_HINT_{SAVE_RESTORE}")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202402240702.zJFNmahW-lkp@intel.com/
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Link: https://lore.kernel.org/r/20240227073527.avcm5naavbv3cj5s@treble
Signed-off-by: Kees Cook <keescook@chromium.org>
tools/objtool/check.c

index 548ec3cd7c00ca532a286eca1e6ae46b20ae0101..c4c2f75eadfd908154ab7c782524719f2995726c 100644 (file)
@@ -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;
                                }