Skip to content

Commit

Permalink
fuzz: add argument to support other sanitizers
Browse files Browse the repository at this point in the history
Allows for switching out zephyr configs for other sanitizers

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
  • Loading branch information
cujomalainey authored and kv2019i committed Sep 6, 2024
1 parent 7ec73c7 commit f383b0f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 0 additions & 1 deletion app/boards/native_sim_libfuzzer.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ CONFIG_SYS_HEAP_BIG_ONLY=y
CONFIG_ZEPHYR_NATIVE_DRIVERS=y
CONFIG_ARCH_POSIX_LIBFUZZER=y
CONFIG_ZEPHYR_POSIX_FUZZ_TICKS=100
CONFIG_ASAN=y

# Override incompatible options found in sof/app/prj.conf
# to silence build time warnings
Expand Down
1 change: 1 addition & 0 deletions app/configs/fuzz_asan.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONFIG_ASAN=y
10 changes: 9 additions & 1 deletion scripts/fuzz.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Usage:
-i4 Appends: -- -DCONFIG_IPC_MAJOR_4=y + fuzz_IPC4_features.conf
-i3 See above
-s Which sanitizer to use, defaults to address
-p Delete build-fuzz/ first ("pristine")
-b Do not run/fuzz: stop after the build.
-t n Fuzz for n seconds.
Expand Down Expand Up @@ -87,15 +88,17 @@ main()
local BUILD_ONLY=false
local FUZZER_STDOUT=/dev/stdout # bashism
local TEST_DURATION=3
local SANITIZER=address
local IPC

# Parse "$@". getopts stops after '--'
while getopts "i:hj:po:t:b" opt; do
while getopts "i:hj:ps:o:t:b" opt; do
case "$opt" in
i) IPC="$OPTARG";;
h) print_help; exit 0;;
j) if [ "$OPTARG" -eq 0 ]; then JOBS=$(nproc); else JOBS="$OPTARG"; fi;;
p) PRISTINE=true;;
s) SANITIZER="$OPTARG";;
o) FUZZER_STDOUT="$OPTARG";;
t) TEST_DURATION="$OPTARG";;
b) BUILD_ONLY=true;;
Expand All @@ -115,6 +118,11 @@ main()
conf_files_list+=";configs/fuzz_IPC${IPC}_features.conf"
fi

case $SANITIZER in
address) conf_files_list+=";configs/fuzz_asan.conf";;
*) echo "Unknown fuzzer type"; print_help; exit 1;;
esac

# Note there's never any reason to delete fuzz_corpus/.
# Don't trust `west build -p` because it is not 100% unreliable,
# especially not when doing unusual toolchain things.
Expand Down

0 comments on commit f383b0f

Please sign in to comment.