summaryrefslogtreecommitdiffstats
path: root/tools/objtool/check.c
diff options
context:
space:
mode:
authorPeter Zijlstra <peterz@infradead.org>2021-12-04 14:43:42 +0100
committerBorislav Petkov <bp@suse.de>2021-12-08 19:26:50 +0100
commit1cc1e4c8aab4213bd4e6353dec2620476a233d6d (patch)
tree098107adb9d0272c25287606abad1b846b3595e3 /tools/objtool/check.c
parentb17c2baa305cccbd16bafa289fd743cc2db77966 (diff)
downloadlinux-stable-1cc1e4c8aab4213bd4e6353dec2620476a233d6d.tar.gz
linux-stable-1cc1e4c8aab4213bd4e6353dec2620476a233d6d.tar.bz2
linux-stable-1cc1e4c8aab4213bd4e6353dec2620476a233d6d.zip
objtool: Add straight-line-speculation validation
Teach objtool to validate the straight-line-speculation constraints: - speculation trap after indirect calls - speculation trap after RET Notable: when an instruction is annotated RETPOLINE_SAFE, indicating speculation isn't a problem, also don't care about sls for that instruction. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Borislav Petkov <bp@suse.de> Link: https://lore.kernel.org/r/20211204134908.023037659@infradead.org
Diffstat (limited to 'tools/objtool/check.c')
-rw-r--r--tools/objtool/check.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 21735829b860..e28172f6e792 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -3084,6 +3084,12 @@ static int validate_branch(struct objtool_file *file, struct symbol *func,
switch (insn->type) {
case INSN_RETURN:
+ if (next_insn && next_insn->type == INSN_TRAP) {
+ next_insn->ignore = true;
+ } else if (sls && !insn->retpoline_safe) {
+ WARN_FUNC("missing int3 after ret",
+ insn->sec, insn->offset);
+ }
return validate_return(func, insn, &state);
case INSN_CALL:
@@ -3127,6 +3133,14 @@ static int validate_branch(struct objtool_file *file, struct symbol *func,
break;
case INSN_JUMP_DYNAMIC:
+ if (next_insn && next_insn->type == INSN_TRAP) {
+ next_insn->ignore = true;
+ } else if (sls && !insn->retpoline_safe) {
+ WARN_FUNC("missing int3 after indirect jump",
+ insn->sec, insn->offset);
+ }
+
+ /* fallthrough */
case INSN_JUMP_DYNAMIC_CONDITIONAL:
if (is_sibling_call(insn)) {
ret = validate_sibling_call(file, insn, &state);