Patch "objtool: Improve retpoline alternative handling" has been added to the 4.14-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
objtool: Improve retpoline alternative handling
to the 4.14-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
objtool_Improve_retpoline_alternative_handling.patch
and it can be found in the queue-4.14 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Subject: objtool: Improve retpoline alternative handling
From: Josh Poimboeuf [email protected]
Date: Mon Jan 29 22:00:39 2018 -0600
From: Josh Poimboeuf [email protected]
commit a845c7cf4b4cb5e9e3b2823867892b27646f3a98
Currently objtool requires all retpolines to be:
a) patched in with alternatives; and
b) annotated with ANNOTATE_NOSPEC_ALTERNATIVE.
If you forget to do both of the above, objtool segfaults trying to dereference a NULL 'insn->call_dest' pointer.
Avoid that situation and print a more helpful error message:
quirks.o: warning: objtool: efi_delete_dummy_variable()+0x99: unsupported intra-function call
quirks.o: warning: objtool: If this is a retpoline, please patch it in with alternatives and annotate it with ANNOTATE_NOSPEC_ALTERNATIVE.
Future improvements can be made to make objtool smarter with respect to retpolines, but this is a good incremental improvement for now.
--- tools/objtool/check.c | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-)
tools/objtool/check.c +16 -20
@@ -543,18 +543,14 @@ static int add_call_destinations(struct dest_off = insn->offset + insn->len + insn->immediate; insn->call_dest =find_symbol_by_offset (insn->sec, dest_off); -/* -* FIXME: Thanks to retpolines, it's now considered -* normal for a function to call within itself. So -* disable this warning for now. -*/ -#if 0 -if (!insn->call_dest) { -WARN_FUNC ("can't find call dest symbol at offset 0x%lx" , - insn->sec, insn->offset, dest_off); + +if (!insn->call_dest && !insn->ignore) { +WARN_FUNC ("unsupported intra-function call" , + insn->sec, insn->offset); +WARN ("If this is a retpoline, please patch it in with alternatives and annotate it with ANNOTATE_NOSPEC_ALTERNATIVE." );return -1 ; } -#endif + }else if (rela->sym->type ==STT_SECTION ) { insn->call_dest =find_symbol_by_offset (rela->sym->sec, rela->addend+4 );
@@ -648,6 +644,8 @@ static int handle_group_alt(struct objto last_new_insn = insn; + insn->ignore = orig_insn->ignore_alts; +if (insn->type !=INSN_JUMP_CONDITIONAL && insn->type !=INSN_JUMP_UNCONDITIONAL )continue ;
@@ -729,10 +727,6 @@ static int add_special_section_alts(stru goto out; } -/* Ignore retpoline alternatives. */ -if (orig_insn->ignore_alts) -continue ; - new_insn =NULL ;if (!special_alt->group || special_alt->new_len) { new_insn = find_insn(file, special_alt->new_sec,
@@ -1089,11 +1083,11 @@ static int decode_sections(struct objtooif (ret)return ret; - ret =add_call_destinations (file); + ret =add_special_section_alts (file);if (ret)return ret; - ret =add_special_section_alts (file); + ret =add_call_destinations (file);if (ret)return ret;
@@ -1720,10 +1714,12 @@ static int validate_branch(struct objtoo insn->visited = true; -list_for_each_entry (alt, &insn->alts, list) { - ret =validate_branch (file, alt->insn, state); -if (ret) -return 1 ; +if (!insn->ignore_alts) { +list_for_each_entry (alt, &insn->alts, list) { + ret =validate_branch (file, alt->insn, state); +if (ret) +return 1 ; + } }switch (insn->type) {
Patches currently in stable-queue which might be from [email protected] are
queue-4.14/objtool_Add_support_for_alternatives_at_the_end_of_a_section.patch queue-4.14/objtool_Warn_on_stripped_section_symbol.patch queue-4.14/objtool_Improve_retpoline_alternative_handling.patch