23 Jul, 2022

2 commits

  • commit 8faea26e611189e933ea2281975ff4dc7c1106b6 upstream.

    Commit

    c536ed2fffd5 ("objtool: Remove SAVE/RESTORE hints")

    removed the save/restore unwind hints because they were no longer
    needed. Now they're going to be needed again so re-add them.

    Signed-off-by: Josh Poimboeuf
    Signed-off-by: Peter Zijlstra (Intel)
    Signed-off-by: Borislav Petkov
    Signed-off-by: Thadeu Lima de Souza Cascardo
    Signed-off-by: Greg Kroah-Hartman

    Josh Poimboeuf
     
  • commit a09a6e2399ba0595c3042b3164f3ca68a3cff33e upstream.

    Since entry asm is tricky, add a validation pass that ensures the
    retbleed mitigation has been done before the first actual RET
    instruction.

    Entry points are those that either have UNWIND_HINT_ENTRY, which acts
    as UNWIND_HINT_EMPTY but marks the instruction as an entry point, or
    those that have UWIND_HINT_IRET_REGS at +0.

    This is basically a variant of validate_branch() that is
    intra-function and it will simply follow all branches from marked
    entry points and ensures that all paths lead to ANNOTATE_UNRET_END.

    If a path hits RET or an indirection the path is a fail and will be
    reported.

    There are 3 ANNOTATE_UNRET_END instances:

    - UNTRAIN_RET itself
    - exception from-kernel; this path doesn't need UNTRAIN_RET
    - all early exceptions; these also don't need UNTRAIN_RET

    Signed-off-by: Peter Zijlstra (Intel)
    Signed-off-by: Borislav Petkov
    Reviewed-by: Josh Poimboeuf
    Signed-off-by: Borislav Petkov
    [cascardo: tools/objtool/builtin-check.c no link option validation]
    [cascardo: tools/objtool/check.c opts.ibt is ibt]
    [cascardo: tools/objtool/include/objtool/builtin.h leave unret option as bool, no struct opts]
    [cascardo: objtool is still called from scripts/link-vmlinux.sh]
    [cascardo: no IBT support]
    Signed-off-by: Thadeu Lima de Souza Cascardo
    Signed-off-by: Greg Kroah-Hartman

    Peter Zijlstra
     

27 Jan, 2021

2 commits

  • The ORC metadata generated for UNWIND_HINT_FUNC isn't actually very
    func-like. With certain usages it can cause stack state mismatches
    because it doesn't set the return address (CFI_RA).

    Also, users of UNWIND_HINT_RET_OFFSET no longer need to set a custom
    return stack offset. Instead they just need to specify a func-like
    situation, so the current ret_offset code is hacky for no good reason.

    Solve both problems by simplifying the RET_OFFSET handling and
    converting it into a more useful UNWIND_HINT_FUNC.

    If we end up needing the old 'ret_offset' functionality again in the
    future, we should be able to support it pretty easily with the addition
    of a custom 'sp_offset' in UNWIND_HINT_FUNC.

    Signed-off-by: Josh Poimboeuf
    Link: https://lore.kernel.org/r/db9d1f5d79dddfbb3725ef6d8ec3477ad199948d.1611263462.git.jpoimboe@redhat.com

    Josh Poimboeuf
     
  • To be used for adding asm functions to the ignore list. The "aw" is
    needed to help the ELF section metadata match GCC-created sections.
    Otherwise the linker creates duplicate sections instead of combining
    them.

    Signed-off-by: Josh Poimboeuf
    Link: https://lore.kernel.org/r/8faa476f9a5ac89af27944ec184c89f95f3c6c49.1611263462.git.jpoimboe@redhat.com

    Josh Poimboeuf
     

26 Oct, 2020

1 commit

  • Use a more generic form for __section that requires quotes to avoid
    complications with clang and gcc differences.

    Remove the quote operator # from compiler_attributes.h __section macro.

    Convert all unquoted __section(foo) uses to quoted __section("foo").
    Also convert __attribute__((section("foo"))) uses to __section("foo")
    even if the __attribute__ has multiple list entry forms.

    Conversion done using the script at:

    https://lore.kernel.org/lkml/75393e5ddc272dc7403de74d645e6c6e0f4e70eb.camel@perches.com/2-convert_section.pl

    Signed-off-by: Joe Perches
    Reviewed-by: Nick Desaulniers
    Reviewed-by: Miguel Ojeda
    Signed-off-by: Linus Torvalds

    Joe Perches
     

10 Sep, 2020

3 commits