Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Register
  • Sign in
  • L linux
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • Deployments
    • Deployments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • Kirill Smelkov
  • linux
  • Repository
  • linux
  • tools
  • perf
  • util
  • thread-stack.c
Find file BlameHistoryPermalink
  • Petr Pavlu's avatar
    x86/retpoline,kprobes: Skip optprobe check for indirect jumps with retpolines and IBT · 833fd800
    Petr Pavlu authored Jul 11, 2023
    The kprobes optimization check can_optimize() calls
    insn_is_indirect_jump() to detect indirect jump instructions in
    a target function. If any is found, creating an optprobe is disallowed
    in the function because the jump could be from a jump table and could
    potentially land in the middle of the target optprobe.
    
    With retpolines, insn_is_indirect_jump() additionally looks for calls to
    indirect thunks which the compiler potentially used to replace original
    jumps. This extra check is however unnecessary because jump tables are
    disabled when the kernel is built with retpolines. The same is currently
    the case with IBT.
    
    Based on this observation, remove the logic to look for calls to
    indirect thunks and skip the check for indirect jumps altogether if the
    kernel is built with retpolines or IBT. Remove subsequently the symbols
    __indirect_thunk_start and __indirect_thunk_end which are no longer
    needed.
    
    Dropping this logic indirectly fixes a problem where the range
    [__indirect_thunk_start, __indirect_thunk_end] wrongly included also the
    return thunk. It caused that machines which used the return thunk as
    a mitigation and didn't have it patched by any alternative ended up not
    being able to use optprobes in any regular function.
    
    Fixes: 0b53c374
    
     ("x86/retpoline: Use -mfunction-return")
    Suggested-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
    Suggested-by: default avatarMasami Hiramatsu (Google) <mhiramat@kernel.org>
    Signed-off-by: default avatarPetr Pavlu <petr.pavlu@suse.com>
    Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
    Signed-off-by: default avatarBorislav Petkov (AMD) <bp@alien8.de>
    Acked-by: default avatarMasami Hiramatsu (Google) <mhiramat@kernel.org>
    Link: https://lore.kernel.org/r/20230711091952.27944-3-petr.pavlu@suse.com
    833fd800
GitLab Nexedi Edition | About GitLab | About Nexedi | 沪ICP备2021021310号-2 | 沪ICP备2021021310号-7