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
  • scripts
  • Makefile.vmlinux
Find file BlameHistoryPermalink
  • Josh Poimboeuf's avatar
    x86/retpoline: Make sure there are no unconverted return thunks due to KCSAN · 2d7ce49f
    Josh Poimboeuf authored Oct 17, 2023
    Enabling CONFIG_KCSAN leads to unconverted, default return thunks to
    remain after patching.
    
    As David Kaplan describes in his debugging of the issue, it is caused by
    a couple of KCSAN-generated constructors which aren't processed by
    objtool:
    
      "When KCSAN is enabled, GCC generates lots of constructor functions
      named _sub_I_00099_0 which call __tsan_init and then return.  The
      returns in these are generally annotated normally by objtool and fixed
      up at runtime.  But objtool runs on vmlinux.o and vmlinux.o does not
      include a couple of object files that are in vmlinux, like
      init/version-timestamp.o and .vmlinux.export.o, both of which contain
      _sub_I_00099_0 functions.  As a result, the returns in these functions
      are not annotated, and the panic occurs when we call one of them in
      do_ctors and it uses the default return thunk.
    
      This difference can be seen by counting the number of these functions in the object files:
      $ objdump -d vmlinux.o|grep -c "<_sub_I_00099_0>:"
      2601
      $ objdump -d vmlinux|grep -c "<_sub_I_00099_0>:"
      2603
    
      If these functions are only run during kernel boot, there is no
      speculation concern."
    
    Fix it by disabling KCSAN on version-timestamp.o and .vmlinux.export.o
    so the extra functions don't get generated.  KASAN and GCOV are already
    disabled for those files.
    
      [ bp: Massage commit message. ]
    
    Closes: https://lore.kernel.org/lkml/20231016214810.GA3942238@dev-arch.thelio-3990X/
    
    
    Reported-by: default avatarNathan Chancellor <nathan@kernel.org>
    Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@kernel.org>
    Signed-off-by: default avatarBorislav Petkov (AMD) <bp@alien8.de>
    Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
    Acked-by: default avatarMarco Elver <elver@google.com>
    Tested-by: default avatarNathan Chancellor <nathan@kernel.org>
    Link: https://lore.kernel.org/r/20231017165946.v4i2d4exyqwqq3bx@treble
    2d7ce49f
GitLab Nexedi Edition | About GitLab | About Nexedi | 沪ICP备2021021310号-2 | 沪ICP备2021021310号-7