From: Sam Caccavale <samcacc@amazon.de>
To: unlisted-recipients:; (no To-header on input)
Cc: <samcaccavale@gmail.com>, <nmanthey@amazon.de>,
<wipawel@amazon.de>, <dwmw@amazon.co.uk>, <mpohlack@amazon.de>,
<graf@amazon.de>, <karahmed@amazon.de>,
<andrew.cooper3@citrix.com>, <JBeulich@suse.com>,
<pbonzini@redhat.com>, <rkrcmar@redhat.com>, <tglx@linutronix.de>,
<mingo@redhat.com>, <bp@alien8.de>, <hpa@zytor.com>,
<paullangton4@gmail.com>, <anirudhkaushik@google.com>,
<x86@kernel.org>, <kvm@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, Sam Caccavale <samcacc@amazon.de>
Subject: [PATCH v3 5/5] Development scripts for crash triage and deploy
Date: Mon, 24 Jun 2019 16:24:14 +0200 [thread overview]
Message-ID: <20190624142414.22096-6-samcacc@amazon.de> (raw)
In-Reply-To: <20190624142414.22096-1-samcacc@amazon.de>
Not meant for upstream consumption.
---
v2 -> v3:
- Introduced this patch as a place for non-essential dev scripts
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 | 9 ++++
tools/fuzz/x86ie/scripts/gen_output.sh | 11 +++++
.../fuzz/x86ie/scripts/install_deps_ubuntu.sh | 5 ++
tools/fuzz/x86ie/scripts/rebuild.sh | 6 +++
tools/fuzz/x86ie/scripts/summarize.sh | 9 ++++
8 files changed, 103 insertions(+)
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
diff --git a/tools/fuzz/x86ie/scripts/bin.sh b/tools/fuzz/x86ie/scripts/bin.sh
new file mode 100755
index 000000000000..6383a883ff33
--- /dev/null
+++ b/tools/fuzz/x86ie/scripts/bin.sh
@@ -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)"
diff --git a/tools/fuzz/x86ie/scripts/coalesce.sh b/tools/fuzz/x86ie/scripts/coalesce.sh
new file mode 100755
index 000000000000..b15d583c2c32
--- /dev/null
+++ b/tools/fuzz/x86ie/scripts/coalesce.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+mkdir -p all
+rm -rf all/*
+find . -type f -wholename '*crashes/id*' | parallel 'cp {} ./all/$(basename $(dirname {//})):{/}'
diff --git a/tools/fuzz/x86ie/scripts/deploy.sh b/tools/fuzz/x86ie/scripts/deploy.sh
new file mode 100644
index 000000000000..f95c3aa2b5b5
--- /dev/null
+++ b/tools/fuzz/x86ie/scripts/deploy.sh
@@ -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"
diff --git a/tools/fuzz/x86ie/scripts/deploy_remote.sh b/tools/fuzz/x86ie/scripts/deploy_remote.sh
new file mode 100755
index 000000000000..1279ad6eadb2
--- /dev/null
+++ b/tools/fuzz/x86ie/scripts/deploy_remote.sh
@@ -0,0 +1,9 @@
+#!/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
+FUZZDIR="${FUZZDIR:-$(pwd)/fuzz}" $SCRIPTDIR/run.sh
diff --git a/tools/fuzz/x86ie/scripts/gen_output.sh b/tools/fuzz/x86ie/scripts/gen_output.sh
new file mode 100755
index 000000000000..6c0707eb6d08
--- /dev/null
+++ b/tools/fuzz/x86ie/scripts/gen_output.sh
@@ -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
diff --git a/tools/fuzz/x86ie/scripts/install_deps_ubuntu.sh b/tools/fuzz/x86ie/scripts/install_deps_ubuntu.sh
new file mode 100755
index 000000000000..5525bc8b659c
--- /dev/null
+++ b/tools/fuzz/x86ie/scripts/install_deps_ubuntu.sh
@@ -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
diff --git a/tools/fuzz/x86ie/scripts/rebuild.sh b/tools/fuzz/x86ie/scripts/rebuild.sh
new file mode 100755
index 000000000000..809a4551cb0c
--- /dev/null
+++ b/tools/fuzz/x86ie/scripts/rebuild.sh
@@ -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
diff --git a/tools/fuzz/x86ie/scripts/summarize.sh b/tools/fuzz/x86ie/scripts/summarize.sh
new file mode 100755
index 000000000000..27761f283ee3
--- /dev/null
+++ b/tools/fuzz/x86ie/scripts/summarize.sh
@@ -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"
--
2.17.1
Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Ralf Herbrich
Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879
prev parent reply other threads:[~2019-06-24 14:25 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-24 14:24 [PATCH v3 0/5] x86 instruction emulator fuzzing Sam Caccavale
2019-06-24 14:24 ` [PATCH v3 1/5] Build target for emulate.o as a userspace binary Sam Caccavale
2019-06-24 14:24 ` [PATCH v3 2/5] Emulate simple x86 instructions in userspace Sam Caccavale
2019-06-24 14:24 ` [PATCH v3 3/5] Demonstrating unit testing via simple-harness Sam Caccavale
2019-06-24 14:24 ` [PATCH v3 4/5] Added build and install scripts Sam Caccavale
2019-06-27 16:57 ` Alexander Graf
2019-06-28 7:59 ` samcacc
2019-06-28 8:17 ` Paolo Bonzini
2019-06-28 8:27 ` samcacc
2019-06-24 14:24 ` Sam Caccavale [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190624142414.22096-6-samcacc@amazon.de \
--to=samcacc@amazon.de \
--cc=JBeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=anirudhkaushik@google.com \
--cc=bp@alien8.de \
--cc=dwmw@amazon.co.uk \
--cc=graf@amazon.de \
--cc=hpa@zytor.com \
--cc=karahmed@amazon.de \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=mpohlack@amazon.de \
--cc=nmanthey@amazon.de \
--cc=paullangton4@gmail.com \
--cc=pbonzini@redhat.com \
--cc=rkrcmar@redhat.com \
--cc=samcaccavale@gmail.com \
--cc=tglx@linutronix.de \
--cc=wipawel@amazon.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox