From 665c938b7dbe5b4ea686e413fe65780adb9434cd Mon Sep 17 00:00:00 2001 From: Evgeny Vereshchagin Date: Fri, 18 Nov 2022 07:09:30 +0000 Subject: [PATCH] oss-fuzz: turn on the alignment check explicitly to somewhat cover architectures where unaligned access can lead to crashes and make it possible for OSS-Fuzz to catch issues like https://github.com/util-linux/util-linux/pull/1906. With this patch applied the libblkid fuzz target built with the OSS-Fuzz toolchain triggers "runtime error: load of misaligned address" in `probe_exfat` so it seems to be working. --- tools/oss-fuzz.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/oss-fuzz.sh b/tools/oss-fuzz.sh index 3bb9d78fe1..4aa7f23b09 100755 --- a/tools/oss-fuzz.sh +++ b/tools/oss-fuzz.sh @@ -17,6 +17,13 @@ export CXXFLAGS=${CXXFLAGS:-$flags} export OUT=${OUT:-$(pwd)/out} mkdir -p $OUT +if [[ "$SANITIZER" == undefined ]]; then + additional_ubsan_checks=alignment + UBSAN_FLAGS="-fsanitize=$additional_ubsan_checks -fno-sanitize-recover=$additional_ubsan_checks" + CFLAGS+=" $UBSAN_FLAGS" + CXXFLAGS+=" $UBSAN_FLAGS" +fi + ./autogen.sh ./configure --disable-all-programs --enable-libuuid --enable-libfdisk --enable-last --enable-fuzzing-engine --enable-libmount --enable-libblkid make -j$(nproc) V=1 check-programs -- 2.47.2