Skip to content
  • Artem Savkov's avatar
    objtool: Fix segfault in .cold detection with -ffunction-sections · 22566c16
    Artem Savkov authored and Ingo Molnar's avatar Ingo Molnar committed
    
    
    Because find_symbol_by_name() traverses the same lists as
    read_symbols(), changing sym->name in place without copying it affects
    the result of find_symbol_by_name().  In the case where a ".cold"
    function precedes its parent in sec->symbol_list, it can result in a
    function being considered a parent of itself. This leads to function
    length being set to 0 and other consequent side-effects including a
    segfault in add_switch_table().  The effects of this bug are only
    visible when building with -ffunction-sections in KCFLAGS.
    
    Fix by copying the search string instead of modifying it in place.
    
    Signed-off-by: default avatarArtem Savkov <asavkov@redhat.com>
    Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Fixes: 13810435 ("objtool: Support GCC 8's cold subfunctions")
    Link: http://lkml.kernel.org/r/910abd6b5a4945130fd44f787c...
    22566c16