Skip to content

Commit

Permalink
fix(lazy-pages-fuzzer, ci): add error output on lazy pages fuzzer's s…
Browse files Browse the repository at this point in the history
…moke test fail (#4198)
  • Loading branch information
ByteNacked authored Aug 28, 2024
1 parent b20f192 commit 9296293
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ jobs:
- name: "ACTIONS: Checkout"
uses: actions/checkout@v4

- name: "Install deps"
run: |
sudo apt update
sudo apt install -y xxd
- name: "MOUNT: Logs path"
run: |
FUZZER_LOGS_PATH=/mnt/fuzzer_logs
Expand Down
21 changes: 15 additions & 6 deletions scripts/check-lazy-pages-fuzzer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ SCRIPTS="$(cd "$(dirname "$SELF")"/ && pwd)"
RUN_DURATION_SECS=10
PROCESS_NAME="lazy-pages-fuzzer-fuzz"
OUTPUT_FILE="lazy_pages_fuzz_run"
# Don't need big input for smoke test
INITIAL_INPUT_SIZE=1000
FUZZER_INPUT_FILE=utils/lazy-pages-fuzzer/fuzz/corpus/main/check-fuzzer-bytes

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"
dd if=/dev/urandom of=$FUZZER_INPUT_FILE bs=1 count="$INITIAL_INPUT_SIZE"

# Remove lazy pages fuzzer run file
rm -f $OUTPUT_FILE
Expand All @@ -29,20 +30,28 @@ main() {
( 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" ;
echo " >> Lazy pages fuzzer run finished" ;

# 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"
echo -e "\nSuccess"
exit 0
else
echo "Failed"
cat $OUTPUT_FILE
echo -e "\nFailure"
print_seed
exit 1
fi
}

print_seed() {
echo -e "\n Seed start: \""
xxd -p $FUZZER_INPUT_FILE | tr --delete '\n'
echo -e "\n\" seed end."
}

main

0 comments on commit 9296293

Please sign in to comment.