1. 26 Apr, 2022 15 commits
  2. 24 Apr, 2022 14 commits
  3. 22 Apr, 2022 6 commits
  4. 20 Apr, 2022 2 commits
  5. 16 Apr, 2022 1 commit
    • Kees Cook's avatar
      lkdtm: Add CFI_BACKWARD to test ROP mitigations · 2e53b877
      Kees Cook authored
      In order to test various backward-edge control flow integrity methods,
      add a test that manipulates the return address on the stack. Currently
      only arm64 Pointer Authentication and Shadow Call Stack is supported.
      
       $ echo CFI_BACKWARD | cat >/sys/kernel/debug/provoke-crash/DIRECT
      
      Under SCS, successful test of the mitigation is reported as:
      
       lkdtm: Performing direct entry CFI_BACKWARD
       lkdtm: Attempting unchecked stack return address redirection ...
       lkdtm: ok: redirected stack return address.
       lkdtm: Attempting checked stack return address redirection ...
       lkdtm: ok: control flow unchanged.
      
      Under PAC, successful test of the mitigation is reported by the PAC
      exception handler:
      
       lkdtm: Performing direct entry CFI_BACKWARD
       lkdtm: Attempting unchecked stack return address redirection ...
       lkdtm: ok: redirected stack return address.
       lkdtm: Attempting checked stack return address redirection ...
       Unable to handle kernel paging request at virtual address bfffffc0088d0514
       Mem abort info:
         ESR = 0x86000004
         EC = 0x21: IABT (current EL), IL = 32 bits
         SET = 0, FnV = 0
         EA = 0, S1PTW = 0
         FSC = 0x04: level 0 translation fault
       [bfffffc0088d0514] address between user and kernel address ranges
       ...
      
      If the CONFIGs are missing (or the mitigation isn't working), failure
      is reported as:
      
       lkdtm: Performing direct entry CFI_BACKWARD
       lkdtm: Attempting unchecked stack return address redirection ...
       lkdtm: ok: redirected stack return address.
       lkdtm: Attempting checked stack return address redirection ...
       lkdtm: FAIL: stack return address was redirected!
       lkdtm: This is probably expected, since this kernel was built *without* CONFIG_ARM64_PTR_AUTH_KERNEL=y nor CONFIG_SHADOW_CALL_STACK=y
      Co-developed-by: default avatarDan Li <ashimida@linux.alibaba.com>
      Signed-off-by: default avatarDan Li <ashimida@linux.alibaba.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Link: https://lore.kernel.org/lkml/20220416001103.1524653-1-keescook@chromium.org
      2e53b877
  6. 12 Apr, 2022 2 commits
    • Kees Cook's avatar
      lkdtm: Move crashtype definitions into each category · 73f62e60
      Kees Cook authored
      It's long been annoying that to add a new LKDTM test one had to update
      lkdtm.h and core.c to get it "registered". Switch to a per-category
      list and update the crashtype walking code in core.c to handle it.
      
      This also means that all the lkdtm_* tests themselves can be static now.
      
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      73f62e60
    • Christophe Leroy's avatar
      lkdtm/bugs: Don't expect thread termination without CONFIG_UBSAN_TRAP · 8bfdbddd
      Christophe Leroy authored
      When you don't select CONFIG_UBSAN_TRAP, you get:
      
        # echo ARRAY_BOUNDS > /sys/kernel/debug/provoke-crash/DIRECT
      [  102.265827] ================================================================================
      [  102.278433] UBSAN: array-index-out-of-bounds in drivers/misc/lkdtm/bugs.c:342:16
      [  102.287207] index 8 is out of range for type 'char [8]'
      [  102.298722] ================================================================================
      [  102.313712] lkdtm: FAIL: survived array bounds overflow!
      [  102.318770] lkdtm: Unexpected! This kernel (5.16.0-rc1-s3k-dev-01884-g720dcf79314a ppc) was built with CONFIG_UBSAN_BOUNDS=y
      
      It is not correct because when CONFIG_UBSAN_TRAP is not selected
      you can't expect array bounds overflow to kill the thread.
      
      Modify the logic so that when the kernel is built with
      CONFIG_UBSAN_BOUNDS but without CONFIG_UBSAN_TRAP, you get a warning
      about CONFIG_UBSAN_TRAP not been selected instead.
      
      This also require a fix of pr_expected_config(), otherwise the
      following error is encountered.
      
        CC      drivers/misc/lkdtm/bugs.o
      drivers/misc/lkdtm/bugs.c: In function 'lkdtm_ARRAY_BOUNDS':
      drivers/misc/lkdtm/bugs.c:351:2: error: 'else' without a previous 'if'
        351 |  else
            |  ^~~~
      
      Fixes: c75be56e ("lkdtm/bugs: Add ARRAY_BOUNDS to selftests")
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Link: https://lore.kernel.org/r/363b58690e907c677252467a94fe49444c80ea76.1649704381.git.christophe.leroy@csgroup.eu
      8bfdbddd