diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 15119754b1..384826b880 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -92,7 +92,7 @@ jobs: - name: Remove existing clang and LLVM run: sudo apt purge llvm* clang* lld* lldb* opt* - name: Install and cache deps - run: sudo apt install ninja-build shellcheck libgtk-3-dev gcc-arm-linux-gnueabi g++-arm-linux-gnueabi libslirp-dev libz3-dev + run: sudo apt update && sudo apt install ninja-build shellcheck libgtk-3-dev gcc-arm-linux-gnueabi g++-arm-linux-gnueabi libslirp-dev libz3-dev - name: Add nightly rustfmt and clippy run: rustup toolchain install nightly --component rustfmt --component clippy --component miri --allow-downgrade - name: Install ucd-generate @@ -143,7 +143,7 @@ jobs: toolchain: stable - name: Install and cache deps - run: sudo apt install ninja-build shellcheck libgtk-3-dev gcc-arm-linux-gnueabi g++-arm-linux-gnueabi libslirp-dev libz3-dev + run: sudo apt update && sudo apt install ninja-build shellcheck libgtk-3-dev gcc-arm-linux-gnueabi g++-arm-linux-gnueabi libslirp-dev libz3-dev - name: Add nightly rustfmt and clippy run: rustup toolchain install nightly --component clippy --allow-downgrade && rustup default nightly - uses: actions/checkout@v3 @@ -178,7 +178,7 @@ jobs: - name: Remove existing clang and LLVM run: sudo apt purge llvm* clang* - name: Install and cache deps - run: sudo apt install ninja-build clang-format shellcheck libgtk-3-dev gcc-arm-linux-gnueabi g++-arm-linux-gnueabi libslirp-dev libz3-dev + run: sudo apt update && sudo apt install ninja-build clang-format shellcheck libgtk-3-dev gcc-arm-linux-gnueabi g++-arm-linux-gnueabi libslirp-dev libz3-dev - name: Install cargo-hack run: curl -LsSf https://github.com/taiki-e/cargo-hack/releases/latest/download/cargo-hack-x86_64-unknown-linux-gnu.tar.gz | tar xzf - -C ~/.cargo/bin - name: Install ucd-generate @@ -282,7 +282,7 @@ jobs: directory: ${{ runner.temp }}/llvm version: 17 - name: Install deps - run: sudo apt install nasm ninja-build gcc-arm-linux-gnueabi g++-arm-linux-gnueabi gcc-aarch64-linux-gnu g++-aarch64-linux-gnu gcc-mipsel-linux-gnu g++-mipsel-linux-gnu gcc-powerpc-linux-gnu g++-powerpc-linux-gnu libc6-dev-i386-cross libc6-dev libc6-dev-i386 lib32gcc-11-dev lib32stdc++-11-dev libgtk-3-dev pax-utils libz3-dev + run: sudo apt update && sudo apt install nasm ninja-build gcc-arm-linux-gnueabi g++-arm-linux-gnueabi gcc-aarch64-linux-gnu g++-aarch64-linux-gnu gcc-mipsel-linux-gnu g++-mipsel-linux-gnu gcc-powerpc-linux-gnu g++-powerpc-linux-gnu libc6-dev-i386-cross libc6-dev libc6-dev-i386 lib32gcc-11-dev lib32stdc++-11-dev libgtk-3-dev pax-utils libz3-dev - name: pip install run: python3 -m pip install msgpack jinja2 find_libpython # Note that nproc needs to have coreutils installed on macOS, so the order of CI commands matters. @@ -356,7 +356,7 @@ jobs: directory: ${{ runner.temp }}/llvm version: 17 - name: Install deps - run: sudo apt install nasm ninja-build gcc-arm-linux-gnueabi g++-arm-linux-gnueabi gcc-aarch64-linux-gnu g++-aarch64-linux-gnu gcc-mipsel-linux-gnu g++-mipsel-linux-gnu gcc-powerpc-linux-gnu g++-powerpc-linux-gnu libc6-dev-i386-cross libc6-dev libc6-dev-i386 lib32gcc-11-dev lib32stdc++-11-dev libgtk-3-dev pax-utils libz3-dev + run: sudo apt update && sudo apt install nasm ninja-build gcc-arm-linux-gnueabi g++-arm-linux-gnueabi gcc-aarch64-linux-gnu g++-aarch64-linux-gnu gcc-mipsel-linux-gnu g++-mipsel-linux-gnu gcc-powerpc-linux-gnu g++-powerpc-linux-gnu libc6-dev-i386-cross libc6-dev libc6-dev-i386 lib32gcc-11-dev lib32stdc++-11-dev libgtk-3-dev pax-utils libz3-dev - name: pip install run: python3 -m pip install msgpack jinja2 find_libpython # Note that nproc needs to have coreutils installed on macOS, so the order of CI commands matters. @@ -387,6 +387,153 @@ jobs: if: runner.os == 'Linux' run: RUN_ON_CI=1 RUN_QEMU_FUZZER=1 LLVM_CONFIG=llvm-config ./scripts/test_all_fuzzers.sh + baby_fuzzers: + strategy: + matrix: + os: [ubuntu-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + - name: Free Disk Space (Ubuntu) + if: runner.os == 'Linux' + uses: jlumbroso/free-disk-space@main + with: + # this might remove tools that are actually needed, + # if set to "true" but frees about 6 GB + tool-cache: false + + # all of these default to true, but feel free to set to + # "false" if necessary for your workflow + android: true + dotnet: true + haskell: true + large-packages: false + docker-images: true + swap-storage: true + - name: Add nightly rustfmt and clippy + run: rustup toolchain install nightly --component rustfmt --component clippy --allow-downgrade + - name: Add no_std toolchain + run: rustup toolchain install nightly-x86_64-unknown-linux-gnu ; rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-gnu + - name: Add wasm target + run: rustup target add wasm32-unknown-unknown + - name: Install ucd-generate + run: cargo install -f ucd-generate + - name: Remove obsolete llvm (Linux) + if: runner.os == 'Linux' + run: sudo apt purge llvm* clang* + - name: Install LLVM and Clang + uses: KyleMayes/install-llvm-action@v1 + with: + directory: ${{ runner.temp }}/llvm + version: 17 + - name: Install deps + run: sudo apt update && sudo apt install nasm ninja-build gcc-arm-linux-gnueabi g++-arm-linux-gnueabi gcc-aarch64-linux-gnu g++-aarch64-linux-gnu gcc-mipsel-linux-gnu g++-mipsel-linux-gnu gcc-powerpc-linux-gnu g++-powerpc-linux-gnu libc6-dev-i386-cross libc6-dev libc6-dev-i386 lib32gcc-11-dev lib32stdc++-11-dev libgtk-3-dev pax-utils libz3-dev + - name: pip install + run: python3 -m pip install msgpack jinja2 find_libpython + # Note that nproc needs to have coreutils installed on macOS, so the order of CI commands matters. + - name: enable mult-thread for `make` + run: export MAKEFLAGS="-j$(expr $(nproc) \+ 1)" + - name: install cargo-make + uses: baptiste0928/cargo-install@v1.3.0 + with: + crate: cargo-make + - name: install wasm-pack + uses: baptiste0928/cargo-install@v1.3.0 + with: + crate: wasm-pack + - name: install chrome + uses: browser-actions/setup-chrome@v1 + with: + chrome-version: stable + - uses: actions/checkout@v3 + with: + submodules: true # recursively checkout submodules + fetch-depth: 0 # to diff with origin/main + - uses: Swatinem/rust-cache@v2 + - name: Symlink Headers + if: runner.os == 'Linux' + # We can't install gcc-multilib which would usually do this for us due to collisions with other packages + run: sudo ln -s /usr/include/asm-generic /usr/include/asm + - name: Build and run example fuzzers (Linux) + if: runner.os == 'Linux' + run: RUN_ON_CI=1 RUN_BABY_FUZZER=1 LLVM_CONFIG=llvm-config ./scripts/test_all_fuzzers.sh + + libpng_fuzzers: + strategy: + matrix: + os: [ubuntu-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + - name: Free Disk Space (Ubuntu) + if: runner.os == 'Linux' + uses: jlumbroso/free-disk-space@main + with: + # this might remove tools that are actually needed, + # if set to "true" but frees about 6 GB + tool-cache: false + + # all of these default to true, but feel free to set to + # "false" if necessary for your workflow + android: true + dotnet: true + haskell: true + large-packages: false + docker-images: true + swap-storage: true + - name: Add nightly rustfmt and clippy + run: rustup toolchain install nightly --component rustfmt --component clippy --allow-downgrade + - name: Add no_std toolchain + run: rustup toolchain install nightly-x86_64-unknown-linux-gnu ; rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-gnu + - name: Add wasm target + run: rustup target add wasm32-unknown-unknown + - name: Install ucd-generate + run: cargo install -f ucd-generate + - name: Remove obsolete llvm (Linux) + if: runner.os == 'Linux' + run: sudo apt purge llvm* clang* + - name: Install LLVM and Clang + uses: KyleMayes/install-llvm-action@v1 + with: + directory: ${{ runner.temp }}/llvm + version: 17 + - name: Install deps + run: sudo apt update && sudo apt install nasm ninja-build gcc-arm-linux-gnueabi g++-arm-linux-gnueabi gcc-aarch64-linux-gnu g++-aarch64-linux-gnu gcc-mipsel-linux-gnu g++-mipsel-linux-gnu gcc-powerpc-linux-gnu g++-powerpc-linux-gnu libc6-dev-i386-cross libc6-dev libc6-dev-i386 lib32gcc-11-dev lib32stdc++-11-dev libgtk-3-dev pax-utils libz3-dev + - name: pip install + run: python3 -m pip install msgpack jinja2 find_libpython + # Note that nproc needs to have coreutils installed on macOS, so the order of CI commands matters. + - name: enable mult-thread for `make` + run: export MAKEFLAGS="-j$(expr $(nproc) \+ 1)" + - name: install cargo-make + uses: baptiste0928/cargo-install@v1.3.0 + with: + crate: cargo-make + - name: install wasm-pack + uses: baptiste0928/cargo-install@v1.3.0 + with: + crate: wasm-pack + - name: install chrome + uses: browser-actions/setup-chrome@v1 + with: + chrome-version: stable + - uses: actions/checkout@v3 + with: + submodules: true # recursively checkout submodules + fetch-depth: 0 # to diff with origin/main + - uses: Swatinem/rust-cache@v2 + - name: Symlink Headers + if: runner.os == 'Linux' + # We can't install gcc-multilib which would usually do this for us due to collisions with other packages + run: sudo ln -s /usr/include/asm-generic /usr/include/asm + - name: Build and run example fuzzers (Linux) + if: runner.os == 'Linux' + run: RUN_ON_CI=1 RUN_LIBPNG_FUZZER=1 LLVM_CONFIG=llvm-config ./scripts/test_all_fuzzers.sh nostd-build: runs-on: ubuntu-latest diff --git a/fuzzers/libfuzzer_libpng_ctx/Makefile.toml b/fuzzers/libfuzzer_libpng_ctx/Makefile.toml index fb2da9e0fa..8d66dbc8e3 100644 --- a/fuzzers/libfuzzer_libpng_ctx/Makefile.toml +++ b/fuzzers/libfuzzer_libpng_ctx/Makefile.toml @@ -101,6 +101,8 @@ rm -rf libafl_unix_shmem_server || true timeout 31s ./${FUZZER_NAME} --cores 0 --input ./corpus >fuzz_stdout.log 2>/dev/null || true if grep -qa "corpus: 30" fuzz_stdout.log; then echo "Fuzzer is working" +elif grep -qa "objectives: 1" fuzz_stdout.log; then + echo "Fuzzer finds timeout or crash" else echo "Fuzzer does not generate any testcases or any crashes" exit 1 diff --git a/libafl_bolts/src/os/windows_exceptions.rs b/libafl_bolts/src/os/windows_exceptions.rs index e914a14dbd..ee89f19a02 100644 --- a/libafl_bolts/src/os/windows_exceptions.rs +++ b/libafl_bolts/src/os/windows_exceptions.rs @@ -362,7 +362,10 @@ pub unsafe extern "system" fn handle_exception( .as_mut() .unwrap() .ExceptionCode; - let exception_code = ExceptionCode::try_from(code.0).unwrap(); + let exception_code = match ExceptionCode::try_from(code.0) { + Ok(x) => x, + Err(_) => ExceptionCode::Other, + }; log::info!("Received exception; code: {}", exception_code); internal_handle_exception(exception_code, exception_pointers) } diff --git a/scripts/test_all_fuzzers.sh b/scripts/test_all_fuzzers.sh index 414b3ee830..3b2668b131 100755 --- a/scripts/test_all_fuzzers.sh +++ b/scripts/test_all_fuzzers.sh @@ -15,12 +15,18 @@ else export PROFILE_DIR=debug fi -if [[ -z "${RUN_QEMU_FUZZER}" ]]; then - fuzzers=$(echo "$fuzzers" | tr ' ' '\n' | grep -v "qemu") - backtrace_fuzzers=$(echo "$backtrace_fuzzers" | tr ' ' '\n' | grep -v "qemu") -else +if [[ -n "${RUN_QEMU_FUZZER}" ]]; then fuzzers=$(echo "$fuzzers" | tr ' ' '\n' | grep "qemu") backtrace_fuzzers=$(echo "$backtrace_fuzzers" | tr ' ' '\n' | grep "qemu") +elif [[ -n "${RUN_BABY_FUZZER}" ]]; then + fuzzers=$(echo "$fuzzers" | tr ' ' '\n' | grep "baby") + backtrace_fuzzers=$(echo "$backtrace_fuzzers" | tr ' ' '\n' | grep "baby") +elif [[ -n "${RUN_LIBPNG_FUZZER}" ]]; then + fuzzers=$(echo "$fuzzers" | tr ' ' '\n' | grep "libpng") + backtrace_fuzzers=$(echo "$backtrace_fuzzers" | tr ' ' '\n' | grep "libpng") +else + fuzzers=$(echo "$fuzzers" | tr ' ' '\n' | grep -v "qemu" | grep -v "baby" | grep -v "libpng") + backtrace_fuzzers=$(echo "$backtrace_fuzzers" | tr ' ' '\n' | grep -v "qemu" | grep -v "baby" | grep -v "libpng") fi libafl=$(pwd)