Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(lazy-pages-fuzzer, ci): add error output on lazy pages fuzzer's smoke test fail #4198

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading