• Kees Cook's avatar
    fortify: Provide KUnit counters for failure testing · 4ce615e7
    Kees Cook authored
    The standard C string APIs were not designed to have a failure mode;
    they were expected to always succeed without memory safety issues.
    Normally, CONFIG_FORTIFY_SOURCE will use fortify_panic() to stop
    processing, as truncating a read or write may provide an even worse
    system state. However, this creates a problem for testing under things
    like KUnit, which needs a way to survive failures.
    
    When building with CONFIG_KUNIT, provide a failure path for all users
    of fortify_panic, and track whether the failure was a read overflow or
    a write overflow, for KUnit tests to examine. Inspired by similar logic
    in the slab tests.
    Signed-off-by: default avatarKees Cook <keescook@chromium.org>
    4ce615e7
string_helpers.c 24.1 KB