1. 05 4月, 2022 2 次提交
    • P
      objtool: Fix SLS validation for kcov tail-call replacement · 7a53f408
      Peter Zijlstra 提交于
      Since not all compilers have a function attribute to disable KCOV
      instrumentation, objtool can rewrite KCOV instrumentation in noinstr
      functions as per commit:
      
        f56dae88 ("objtool: Handle __sanitize_cov*() tail calls")
      
      However, this has subtle interaction with the SLS validation from
      commit:
      
        1cc1e4c8 ("objtool: Add straight-line-speculation validation")
      
      In that when a tail-call instrucion is replaced with a RET an
      additional INT3 instruction is also written, but is not represented in
      the decoded instruction stream.
      
      This then leads to false positive missing INT3 objtool warnings in
      noinstr code.
      
      Instead of adding additional struct instruction objects, mark the RET
      instruction with retpoline_safe to suppress the warning (since we know
      there really is an INT3).
      
      Fixes: 1cc1e4c8 ("objtool: Add straight-line-speculation validation")
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Link: https://lkml.kernel.org/r/20220323230712.GA8939@worktop.programming.kicks-ass.net
      7a53f408
    • P
      objtool: Fix IBT tail-call detection · d139bca4
      Peter Zijlstra 提交于
      Objtool reports:
      
        arch/x86/crypto/poly1305-x86_64.o: warning: objtool: poly1305_blocks_avx() falls through to next function poly1305_blocks_x86_64()
        arch/x86/crypto/poly1305-x86_64.o: warning: objtool: poly1305_emit_avx() falls through to next function poly1305_emit_x86_64()
        arch/x86/crypto/poly1305-x86_64.o: warning: objtool: poly1305_blocks_avx2() falls through to next function poly1305_blocks_x86_64()
      
      Which reads like:
      
      0000000000000040 <poly1305_blocks_x86_64>:
      	 40:       f3 0f 1e fa             endbr64
      	...
      
      0000000000000400 <poly1305_blocks_avx>:
      	400:       f3 0f 1e fa             endbr64
      	404:       44 8b 47 14             mov    0x14(%rdi),%r8d
      	408:       48 81 fa 80 00 00 00    cmp    $0x80,%rdx
      	40f:       73 09                   jae    41a <poly1305_blocks_avx+0x1a>
      	411:       45 85 c0                test   %r8d,%r8d
      	414:       0f 84 2a fc ff ff       je     44 <poly1305_blocks_x86_64+0x4>
      	...
      
      These are simple conditional tail-calls and *should* be recognised as
      such by objtool, however due to a mistake in commit 08f87a93
      ("objtool: Validate IBT assumptions") this is failing.
      
      Specifically, the jump_dest is +4, this means the instruction pointed
      at will not be ENDBR and as such it will fail the second clause of
      is_first_func_insn() that was supposed to capture this exact case.
      
      Instead, have is_first_func_insn() look at the previous instruction.
      
      Fixes: 08f87a93 ("objtool: Validate IBT assumptions")
      Reported-by: NStephen Rothwell <sfr@canb.auug.org.au>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Link: https://lkml.kernel.org/r/20220322115125.811582125@infradead.org
      d139bca4
  2. 15 3月, 2022 10 次提交
  3. 25 1月, 2022 1 次提交
  4. 16 12月, 2021 1 次提交
  5. 14 12月, 2021 4 次提交
    • E
      exit: Rename complete_and_exit to kthread_complete_and_exit · cead1855
      Eric W. Biederman 提交于
      Update complete_and_exit to call kthread_exit instead of do_exit.
      
      Change the name to reflect this change in functionality.  All of the
      users of complete_and_exit are causing the current kthread to exit so
      this change makes it clear what is happening.
      
      Move the implementation of kthread_complete_and_exit from
      kernel/exit.c to to kernel/kthread.c.  As this function is kthread
      specific it makes most sense to live with the kthread functions.
      
      There are no functional change.
      Signed-off-by: N"Eric W. Biederman" <ebiederm@xmission.com>
      cead1855
    • E
      exit: Rename module_put_and_exit to module_put_and_kthread_exit · ca3574bd
      Eric W. Biederman 提交于
      Update module_put_and_exit to call kthread_exit instead of do_exit.
      
      Change the name to reflect this change in functionality.  All of the
      users of module_put_and_exit are causing the current kthread to exit
      so this change makes it clear what is happening.  There is no
      functional change.
      Signed-off-by: N"Eric W. Biederman" <ebiederm@xmission.com>
      ca3574bd
    • E
      exit: Implement kthread_exit · bbda86e9
      Eric W. Biederman 提交于
      The way the per task_struct exit_code is used by kernel threads is not
      quite compatible how it is used by userspace applications.  The low
      byte of the userspace exit_code value encodes the exit signal.  While
      kthreads just use the value as an int holding ordinary kernel function
      exit status like -EPERM.
      
      Add kthread_exit to clearly separate the two kinds of uses.
      Signed-off-by: N"Eric W. Biederman" <ebiederm@xmission.com>
      bbda86e9
    • E
      exit: Add and use make_task_dead. · 0e25498f
      Eric W. Biederman 提交于
      There are two big uses of do_exit.  The first is it's design use to be
      the guts of the exit(2) system call.  The second use is to terminate
      a task after something catastrophic has happened like a NULL pointer
      in kernel code.
      
      Add a function make_task_dead that is initialy exactly the same as
      do_exit to cover the cases where do_exit is called to handle
      catastrophic failure.  In time this can probably be reduced to just a
      light wrapper around do_task_dead. For now keep it exactly the same so
      that there will be no behavioral differences introducing this new
      concept.
      
      Replace all of the uses of do_exit that use it for catastraphic
      task cleanup with make_task_dead to make it clear what the code
      is doing.
      
      As part of this rename rewind_stack_do_exit
      rewind_stack_and_make_dead.
      Signed-off-by: N"Eric W. Biederman" <ebiederm@xmission.com>
      0e25498f
  6. 11 12月, 2021 1 次提交
  7. 10 12月, 2021 2 次提交
  8. 09 12月, 2021 1 次提交
  9. 11 11月, 2021 1 次提交
  10. 29 10月, 2021 4 次提交
  11. 06 10月, 2021 1 次提交
  12. 01 10月, 2021 1 次提交
  13. 17 9月, 2021 1 次提交
    • P
      objtool: Support pv_opsindirect calls for noinstr · db2b0c5d
      Peter Zijlstra 提交于
      Normally objtool will now follow indirect calls; there is no need.
      
      However, this becomes a problem with noinstr validation; if there's an
      indirect call from noinstr code, we very much need to know it is to
      another noinstr function. Luckily there aren't many indirect calls in
      entry code with the obvious exception of paravirt. As such, noinstr
      validation didn't work with paravirt kernels.
      
      In order to track pv_ops[] call targets, objtool reads the static
      pv_ops[] tables as well as direct assignments to the pv_ops[] array,
      provided the compiler makes them a single instruction like:
      
        bf87:       48 c7 05 00 00 00 00 00 00 00 00        movq   $0x0,0x0(%rip)
          bf92 <xen_init_spinlocks+0x5f>
          bf8a: R_X86_64_PC32     pv_ops+0x268
      
      There are, as of yet, no warnings for when this goes wrong :/
      
      Using the functions found with the above means, all pv_ops[] calls are
      now subject to noinstr validation.
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20210624095149.118815755@infradead.org
      db2b0c5d
  14. 15 9月, 2021 3 次提交
  15. 14 5月, 2021 1 次提交
  16. 12 5月, 2021 2 次提交
  17. 20 4月, 2021 1 次提交
  18. 02 4月, 2021 3 次提交