Skip to content

Commit fa4a3f8

Browse files
committed
fortify: Add KUnit tests for runtime overflows
With fortify overflows able to be redirected, we can use KUnit to exercise the overflow conditions. Add tests for every API covered by CONFIG_FORTIFY_SOURCE, except for memset() and memcpy(), which are special-cased for now. Disable warnings in the Makefile since we're explicitly testing known-bad string handling code patterns. Note that this makes the LKDTM FORTIFY_STR* tests obsolete, but those can be removed separately. Signed-off-by: Kees Cook <keescook@chromium.org>
1 parent 4ce615e commit fa4a3f8

2 files changed

Lines changed: 607 additions & 2 deletions

File tree

lib/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,8 @@ obj-$(CONFIG_OVERFLOW_KUNIT_TEST) += overflow_kunit.o
402402
CFLAGS_stackinit_kunit.o += $(call cc-disable-warning, switch-unreachable)
403403
obj-$(CONFIG_STACKINIT_KUNIT_TEST) += stackinit_kunit.o
404404
CFLAGS_fortify_kunit.o += $(call cc-disable-warning, unsequenced)
405+
CFLAGS_fortify_kunit.o += $(call cc-disable-warning, stringop-overread)
406+
CFLAGS_fortify_kunit.o += $(call cc-disable-warning, stringop-truncation)
405407
CFLAGS_fortify_kunit.o += $(DISABLE_STRUCTLEAK_PLUGIN)
406408
obj-$(CONFIG_FORTIFY_KUNIT_TEST) += fortify_kunit.o
407409
obj-$(CONFIG_STRCAT_KUNIT_TEST) += strcat_kunit.o

0 commit comments

Comments
 (0)