ubsan: make pointer overflow recoverable
authorYann Collet <cyan@fb.com>
Thu, 17 Sep 2020 22:34:03 +0000 (15:34 -0700)
committerYann Collet <cyan@fb.com>
Thu, 17 Sep 2020 22:34:03 +0000 (15:34 -0700)
the way `base` is used must allow 2-complement address overflow.
`base` is effectively a virtual pointer, never dereferenced directly.
What matters is `base + index`.
This is the address that will be dereference and must be valid (it is properly validated).

Makefile

index ef1fd2e..6bf952c 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -143,7 +143,7 @@ clangtest-native: clean
        @CFLAGS="-O3 -Werror -Wconversion -Wno-sign-conversion" $(MAKE) -C $(TESTDIR) native CC=clang
 
 usan: clean
-       CC=clang CFLAGS="-O3 -g -fsanitize=undefined -fno-sanitize-recover=undefined" $(MAKE) test FUZZER_TIME="-T30s" NB_LOOPS=-i1
+       CC=clang CFLAGS="-O3 -g -fsanitize=undefined -fno-sanitize-recover=undefined -fsanitize-recover=pointer-overflow" $(MAKE) test FUZZER_TIME="-T30s" NB_LOOPS=-i1
 
 usan32: clean
        CFLAGS="-m32 -O3 -g -fsanitize=undefined" $(MAKE) test FUZZER_TIME="-T30s" NB_LOOPS=-i1