From e7359216fa719e208bc96258fac6117b945914de Mon Sep 17 00:00:00 2001 From: Raj Shah Date: Sun, 4 Dec 2022 01:07:25 +0000 Subject: [PATCH] Add harness --- .github/workflows/mayhem.yml | 3 ++- mayhem/Dockerfile | 10 +++++++--- mayhem/{Mayhemfile => Mayhemfile_elf2nro} | 0 mayhem/Mayhemfile_local_bswap64 | 5 +++++ mayhem/fuzz_local_bswap64.cpp | 14 ++++++++++++++ 5 files changed, 28 insertions(+), 4 deletions(-) rename mayhem/{Mayhemfile => Mayhemfile_elf2nro} (100%) create mode 100644 mayhem/Mayhemfile_local_bswap64 create mode 100644 mayhem/fuzz_local_bswap64.cpp diff --git a/.github/workflows/mayhem.yml b/.github/workflows/mayhem.yml index 1886da4..5f31b8f 100644 --- a/.github/workflows/mayhem.yml +++ b/.github/workflows/mayhem.yml @@ -59,7 +59,8 @@ jobs: fail-fast: false matrix: mayhemfile: - - mayhem/Mayhemfile + - mayhem/Mayhemfile_elf2nro + - mayhem/Mayhemfile_local_bswap64 steps: - uses: actions/checkout@v3 diff --git a/mayhem/Dockerfile b/mayhem/Dockerfile index fdabec9..80e98f8 100644 --- a/mayhem/Dockerfile +++ b/mayhem/Dockerfile @@ -1,7 +1,7 @@ -FROM --platform=linux/amd64 ubuntu:20.04 as builder +FROM --platform=linux/amd64 ubuntu:22.04 as builder RUN apt-get update -RUN DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential automake pkg-config libtool liblz4-dev libz-dev +RUN DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential automake pkg-config libtool liblz4-dev libz-dev clang COPY . /repo WORKDIR /repo @@ -10,6 +10,10 @@ RUN ./configure --prefix=/install RUN make -j8 RUN make install -FROM ubuntu:20.04 as package +WORKDIR /repo/src +RUN clang++ /repo/mayhem/fuzz_local_bswap64.cpp -fsanitize=fuzzer,address -o /fuzz -I /repo/src + +FROM ubuntu:22.04 as package COPY --from=builder /install /install COPY --from=builder /repo/elf2nro / +COPY --from=builder /fuzz /fuzz_local_bswap64 diff --git a/mayhem/Mayhemfile b/mayhem/Mayhemfile_elf2nro similarity index 100% rename from mayhem/Mayhemfile rename to mayhem/Mayhemfile_elf2nro diff --git a/mayhem/Mayhemfile_local_bswap64 b/mayhem/Mayhemfile_local_bswap64 new file mode 100644 index 0000000..45a42f9 --- /dev/null +++ b/mayhem/Mayhemfile_local_bswap64 @@ -0,0 +1,5 @@ +project: switch-tools +target: local-bswap64 + +cmds: + - cmd: /fuzz_local_bswap64 diff --git a/mayhem/fuzz_local_bswap64.cpp b/mayhem/fuzz_local_bswap64.cpp new file mode 100644 index 0000000..06fcde5 --- /dev/null +++ b/mayhem/fuzz_local_bswap64.cpp @@ -0,0 +1,14 @@ +#include +#include +#include + +#include "types.h" +#include + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + FuzzedDataProvider provider(data, size); + uint64_t x = provider.ConsumeIntegral(); + __local_bswap64(x); + return 0; +} \ No newline at end of file