WSL2-Linux-Kernel/drivers/misc/lkdtm
Amit Daniel Kachhap 6cb6982f42 lkdtm: arm64: test kernel pointer authentication
This test is specific for arm64. When in-kernel Pointer Authentication
config is enabled, the return address stored in the stack is signed.
This feature helps in ROP kind of attack. If any parameters used to
generate the pac (<key, sp, lr>) is modified then this will fail in
the authentication stage and will lead to abort.

This test changes the input parameter APIA kernel keys to cause abort.
The pac computed from the new key can be same as last due to hash
collision so this is retried for few times as there is no reliable way
to compare the pacs. Even though this test may fail even after retries
but this may cause authentication failure at a later stage in earlier
function returns.

This test can be invoked as,
echo CORRUPT_PAC > /sys/kernel/debug/provoke-crash/DIRECT

or as below if inserted as a module,
insmod lkdtm.ko cpoint_name=DIRECT cpoint_type=CORRUPT_PAC cpoint_count=1

[   13.118166] lkdtm: Performing direct entry CORRUPT_PAC
[   13.118298] lkdtm: Clearing PAC from the return address
[   13.118466] Unable to handle kernel paging request at virtual address bfff8000108648ec
[   13.118626] Mem abort info:
[   13.118666]   ESR = 0x86000004
[   13.118866]   EC = 0x21: IABT (current EL), IL = 32 bits
[   13.118966]   SET = 0, FnV = 0
[   13.119117]   EA = 0, S1PTW = 0

Signed-off-by: Amit Daniel Kachhap <amit.kachhap@arm.com>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Cc: Kees Cook <keescook@chromium.org>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
2020-03-18 09:50:21 +00:00
..
Makefile lkdtm: Add Control Flow Integrity test 2019-08-12 15:28:51 -07:00
bugs.c lkdtm: arm64: test kernel pointer authentication 2020-03-18 09:50:21 +00:00
cfi.c lkdtm: Add Control Flow Integrity test 2019-08-12 15:28:51 -07:00
core.c lkdtm: arm64: test kernel pointer authentication 2020-03-18 09:50:21 +00:00
heap.c lkdtm/heap: add tests for freelist hardening 2019-07-12 11:05:41 -07:00
lkdtm.h lkdtm: arm64: test kernel pointer authentication 2020-03-18 09:50:21 +00:00
perms.c lkdtm: Add tests for NULL pointer dereference 2019-01-09 12:00:31 -08:00
refcount.c lkdtm: Remove references to CONFIG_REFCOUNT_FULL 2019-11-25 09:15:46 +01:00
rodata.c lkdtm: Relocate code to subdirectory 2018-03-06 19:18:55 -08:00
stackleak.c lkdtm: Add a test for STACKLEAK 2018-09-04 10:35:47 -07:00
usercopy.c lkdtm/usercopy: Moves the KERNEL_DS test to non-canonical 2019-04-07 10:38:31 -07:00