aboutsummaryrefslogtreecommitdiffstats
path: root/lib/string_helpers.c
diff options
context:
space:
mode:
authorKees Cook <[email protected]>2024-01-18 23:06:05 +0000
committerKees Cook <[email protected]>2024-02-21 04:44:49 +0000
commit557f8c582a9ba8abe6aa0fd734b6f342af106b26 (patch)
tree6644df0a1d37b46be67f234d27b11d7f58067446 /lib/string_helpers.c
parentubsan: Remove CONFIG_UBSAN_SANITIZE_ALL (diff)
downloadkernel-557f8c582a9ba8abe6aa0fd734b6f342af106b26.tar.gz
kernel-557f8c582a9ba8abe6aa0fd734b6f342af106b26.zip
ubsan: Reintroduce signed overflow sanitizer
In order to mitigate unexpected signed wrap-around[1], bring back the signed integer overflow sanitizer. It was removed in commit 6aaa31aeb9cf ("ubsan: remove overflow checks") because it was effectively a no-op when combined with -fno-strict-overflow (which correctly changes signed overflow from being "undefined" to being explicitly "wrap around"). Compilers are adjusting their sanitizers to trap wrap-around and to detecting common code patterns that should not be instrumented (e.g. "var + offset < var"). Prepare for this and explicitly rename the option from "OVERFLOW" to "WRAP" to more accurately describe the behavior. To annotate intentional wrap-around arithmetic, the helpers wrapping_add/sub/mul_wrap() can be used for individual statements. At the function level, the __signed_wrap attribute can be used to mark an entire function as expecting its signed arithmetic to wrap around. For a single object file the Makefile can use "UBSAN_SIGNED_WRAP_target.o := n" to mark it as wrapping, and for an entire directory, "UBSAN_SIGNED_WRAP := n" can be used. Additionally keep these disabled under CONFIG_COMPILE_TEST for now. Link: https://github.com/KSPP/linux/issues/26 [1] Cc: Miguel Ojeda <[email protected]> Cc: Nathan Chancellor <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Hao Luo <[email protected]> Reviewed-by: Marco Elver <[email protected]> Reviewed-by: Justin Stitt <[email protected]> Signed-off-by: Kees Cook <[email protected]>
Diffstat (limited to 'lib/string_helpers.c')
0 files changed, 0 insertions, 0 deletions