Skip to content

Commit c75be56

Browse files
keesgregkh
authored andcommitted
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: [email protected] Suggested-by: Guillaume Tucker <[email protected]> Signed-off-by: Kees Cook <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 09cbd1d commit c75be56

File tree

3 files changed

+4
-0
lines changed

3 files changed

+4
-0
lines changed

drivers/misc/lkdtm/bugs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ void lkdtm_ARRAY_BOUNDS(void)
267267
kfree(not_checked);
268268
kfree(checked);
269269
pr_err("FAIL: survived array bounds overflow!\n");
270+
pr_expected_config(CONFIG_UBSAN_BOUNDS);
270271
}
271272

272273
void lkdtm_CORRUPT_LIST_ADD(void)

tools/testing/selftests/lkdtm/config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ CONFIG_HARDENED_USERCOPY=y
66
# CONFIG_HARDENED_USERCOPY_FALLBACK is not set
77
CONFIG_RANDOMIZE_KSTACK_OFFSET_DEFAULT=y
88
CONFIG_INIT_ON_ALLOC_DEFAULT_ON=y
9+
CONFIG_UBSAN_BOUNDS=y
10+
CONFIG_UBSAN_TRAP=y

tools/testing/selftests/lkdtm/tests.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ EXCEPTION
77
#EXHAUST_STACK Corrupts memory on failure
88
#CORRUPT_STACK Crashes entire system on success
99
#CORRUPT_STACK_STRONG Crashes entire system on success
10+
ARRAY_BOUNDS
1011
CORRUPT_LIST_ADD list_add corruption
1112
CORRUPT_LIST_DEL list_del corruption
1213
STACK_GUARD_PAGE_LEADING

0 commit comments

Comments
 (0)