-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(utils, ci): add lazy pages fuzzer (#4005)
Co-authored-by: Sabaun Taraki <[email protected]>
- Loading branch information
1 parent
64ace22
commit dec469d
Showing
29 changed files
with
1,583 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/usr/bin/env sh | ||
|
||
SELF="$0" | ||
SCRIPTS="$(cd "$(dirname "$SELF")"/ && pwd)" | ||
|
||
. "$SCRIPTS"/fuzzer_consts.sh | ||
|
||
RUN_DURATION_SECS=10 | ||
PROCESS_NAME="lazy-pages-fuzzer-fuzz" | ||
OUTPUT_FILE="lazy_pages_fuzz_run" | ||
|
||
main() { | ||
echo " >> Checking lazy pages fuzzer" | ||
echo " >> Getting random bytes from /dev/urandom" | ||
# Fuzzer expects a minimal input size of 350 KiB. Without providing a corpus of the same or larger | ||
# size fuzzer will stuck for a long time with trying to test the target using 0..100 bytes. | ||
mkdir -p utils/lazy-pages-fuzzer/fuzz/corpus/main | ||
dd if=/dev/urandom of=utils/lazy-pages-fuzzer/fuzz/corpus/main/check-fuzzer-bytes bs=1 count="$INITIAL_INPUT_SIZE" | ||
|
||
# Remove lazy pages fuzzer run file | ||
rm -f $OUTPUT_FILE | ||
|
||
# Build lazy pages fuzzer | ||
LAZY_PAGES_FUZZER_ONLY_BUILD=1 ./scripts/gear.sh test lazy-pages-fuzz | ||
|
||
echo " >> Running lazy pages fuzzer for ${RUN_DURATION_SECS} seconds" | ||
|
||
# Run lazy pages fuzzer for a few seconds | ||
( RUST_LOG="error,lazy_pages_fuzzer::lazy_pages=trace" RUST_BACKTRACE=1 ./scripts/gear.sh test lazy-pages-fuzz "" > $OUTPUT_FILE 2>&1 ) & \ | ||
sleep ${RUN_DURATION_SECS} ; \ | ||
kill -s KILL $(pidof $PROCESS_NAME) 2> /dev/null ; \ | ||
echo " >> Lazy pages fuzzer run completed" ; | ||
|
||
# Trim output after SIGKILL backtrace | ||
OUTPUT=$(sed '/SIGKILL/,$d' $OUTPUT_FILE) | ||
|
||
if echo $OUTPUT | grep -q 'SIG: Unprotect WASM memory at address' && \ | ||
! echo $OUTPUT | grep -iq "ERROR" | ||
then | ||
echo "Success" | ||
exit 0 | ||
else | ||
echo "Failed" | ||
exit 1 | ||
fi | ||
} | ||
|
||
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.