new file mode 100755
@@ -0,0 +1,49 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0+
+
+if [ "$#" -lt 3 ]; then
+ echo "Usage: './bin path/to/afl-harness path/to/afl_crash [path/to/linux/src/root]'"
+ exit
+fi
+
+export AFL_HARNESS="$1"
+export LINUX_SRC="$3"
+
+diagnose_segfault() {
+ SOURCE=$(gdb -batch -ex r -ex 'bt 2' --args $@ 2>&1 | grep -Po '#1.* \K([^ ]+:[0-9]+)');
+ IFS=: read FILE LINE <<< "$SOURCE"
+
+ OP="$(sed -n "${LINE}p" "$LINUX_SRC/$FILE" 2>/dev/null)"
+ if [ $? -ne 0 ]; then
+ OP="$(sed -n "${LINE}p" "$LINUX_SRC/tools/fuzz/x86_instruction_emulation/$FILE" 2>/dev/null)"
+ fi
+
+ OP="$(echo $OP | grep -Po 'ops->\K([^(]+)')"
+ if [ -z "$OP" ]; then
+ echo "SEGV: unknown, in $FILE:$LINE"
+ else
+ echo "Expected: segfaulting on emulator->$OP"
+ fi
+}
+export -f diagnose_segfault
+
+bin() {
+ OUTPUT=$(bash -c "timeout 1s $AFL_HARNESS $1 2>&1" 2>&1)
+ RETVAL=$?
+
+ echo "$OUTPUT"
+ if [ $RETVAL -eq 0 ]; then
+ echo "Terminated successfully"
+ elif [ $RETVAL -eq 124 ]; then
+ echo "Unknown: killed due to timeout. Loop likely."
+ elif echo "$OUTPUT" | grep -q "SEGV"; then
+ echo "$(diagnose_segfault $AFL_HARNESS $1)"
+ elif echo "$OUTPUT" | grep -q "FPE"; then
+ echo "Expected: floating point exception."
+ else
+ echo "Unknown cause of crash."
+ fi
+}
+export -f bin
+
+echo "$(bin $2 2>&1)"
new file mode 100755
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+mkdir -p all
+rm -rf all/*
+find . -type f -wholename '*crashes/id*' | parallel 'cp {} ./all/$(basename $(dirname {//})):{/}'
new file mode 100644
@@ -0,0 +1,9 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0+
+
+REMOTE=$1
+DSTDIR=/dev/shm
+
+rsync -av $(pwd) $REMOTE:$DSTDIR
+
+ssh $REMOTE "cd $DSTDIR/$(basename $(pwd)); bash -s tools/fuzz/x86_instruction_emulation/scripts/deploy_remote.sh"
new file mode 100755
@@ -0,0 +1,10 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0+
+
+SCRIPTDIR=$(pwd)/tools/fuzz/x86ie/scripts
+
+$SCRIPTDIR/install_deps_ubuntu.sh
+source $SCRIPTDIR/install_afl.sh
+CC=$AFLPATH/afl-gcc $SCRIPTDIR/build.sh
+sudo bash -c "echo core >/proc/sys/kernel/core_pattern"
+TIMEOUT="${TIMEOUT:-1d}" FUZZDIR="${FUZZDIR:-$(pwd)/fuzz}" $SCRIPTDIR/run.sh
new file mode 100755
@@ -0,0 +1,11 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0+
+
+if [ "$#" -lt 3 ]; then
+ echo "Usage: '$0 path/to/afl-harness path/to/afl_crash_dir path/to/linux/src/root'"
+ exit
+fi
+
+mkdir -p output
+rm -rf output/*
+find $2 -type f | parallel ./bin.sh $1 {} $3 '>' ./output/{/}.out
@@ -13,5 +13,3 @@ set AFL_USE_ASAN
make clean all
export AFLPATH="$(pwd)"
popd
-
-sudo bash -c "echo core >/proc/sys/kernel/core_pattern"
new file mode 100755
@@ -0,0 +1,5 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0+
+
+sudo apt update
+sudo apt install -y make gcc wget screen build-essential libssh-dev flex bison libelf-dev bc
new file mode 100755
@@ -0,0 +1,6 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0+
+
+make clean
+make tools/fuzz_clean
+FUZZDIR="./fuzz" ./tools/fuzz/x86ie/scripts/build.sh
new file mode 100755
@@ -0,0 +1,9 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0+
+
+if [ "$#" -lt 1 ]; then
+ echo "Usage: '$0 path/to/output/dir'"
+ exit
+fi
+
+time bash -c "find $1 -type f -exec tail -n 1 {} \; | sort | uniq -c | sort -rn"
Not meant for upstream consumption. --- v2 -> v3: - Introduced this patch as a place for non-essential dev scripts v3 -> v4: - Made deploy_remote.sh use a 1d timeout - Removed core dump setup from install_afl.sh - Added core dump setup into deploy_remote.sh Signed-off-by: Sam Caccavale <samcacc@amazon.de> --- tools/fuzz/x86ie/scripts/bin.sh | 49 +++++++++++++++++++ tools/fuzz/x86ie/scripts/coalesce.sh | 5 ++ tools/fuzz/x86ie/scripts/deploy.sh | 9 ++++ tools/fuzz/x86ie/scripts/deploy_remote.sh | 10 ++++ tools/fuzz/x86ie/scripts/gen_output.sh | 11 +++++ tools/fuzz/x86ie/scripts/install_afl.sh | 2 - .../fuzz/x86ie/scripts/install_deps_ubuntu.sh | 5 ++ tools/fuzz/x86ie/scripts/rebuild.sh | 6 +++ tools/fuzz/x86ie/scripts/summarize.sh | 9 ++++ 9 files changed, 104 insertions(+), 2 deletions(-) create mode 100755 tools/fuzz/x86ie/scripts/bin.sh create mode 100755 tools/fuzz/x86ie/scripts/coalesce.sh create mode 100644 tools/fuzz/x86ie/scripts/deploy.sh create mode 100755 tools/fuzz/x86ie/scripts/deploy_remote.sh create mode 100755 tools/fuzz/x86ie/scripts/gen_output.sh create mode 100755 tools/fuzz/x86ie/scripts/install_deps_ubuntu.sh create mode 100755 tools/fuzz/x86ie/scripts/rebuild.sh create mode 100755 tools/fuzz/x86ie/scripts/summarize.sh