Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

lkdtm/bugs: Add ARRAY_BOUNDS to selftests

Add CONFIG hints about why the ARRAY_BOUNDS test might fail, and
similarly include the CONFIGs needed to pass the ARRAY_BOUNDS test via
the selftests, and add to selftests.

Cc: kernelci@groups.io
Suggested-by: Guillaume Tucker <guillaume.tucker@collabora.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20210818174855.2307828-2-keescook@chromium.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Kees Cook and committed by
Greg Kroah-Hartman
c75be56e 09cbd1df

+4
+1
drivers/misc/lkdtm/bugs.c
··· 267 267 kfree(not_checked); 268 268 kfree(checked); 269 269 pr_err("FAIL: survived array bounds overflow!\n"); 270 + pr_expected_config(CONFIG_UBSAN_BOUNDS); 270 271 } 271 272 272 273 void lkdtm_CORRUPT_LIST_ADD(void)
+2
tools/testing/selftests/lkdtm/config
··· 6 6 # CONFIG_HARDENED_USERCOPY_FALLBACK is not set 7 7 CONFIG_RANDOMIZE_KSTACK_OFFSET_DEFAULT=y 8 8 CONFIG_INIT_ON_ALLOC_DEFAULT_ON=y 9 + CONFIG_UBSAN_BOUNDS=y 10 + CONFIG_UBSAN_TRAP=y
+1
tools/testing/selftests/lkdtm/tests.txt
··· 7 7 #EXHAUST_STACK Corrupts memory on failure 8 8 #CORRUPT_STACK Crashes entire system on success 9 9 #CORRUPT_STACK_STRONG Crashes entire system on success 10 + ARRAY_BOUNDS 10 11 CORRUPT_LIST_ADD list_add corruption 11 12 CORRUPT_LIST_DEL list_del corruption 12 13 STACK_GUARD_PAGE_LEADING