From: Wei Liu <wei.liu2@citrix.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: George Dunlap <George.Dunlap@eu.citrix.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
Wei Liu <wei.liu2@citrix.com>,
Ian Jackson <ian.jackson@eu.citrix.com>,
Jan Beulich <jbeulich@suse.com>
Subject: [PATCH 2/4] tools/fuzz: add AFL stub program for x86 insn emulator fuzzer
Date: Fri, 20 Jan 2017 12:11:05 +0000 [thread overview]
Message-ID: <1484914267-8942-3-git-send-email-wei.liu2@citrix.com> (raw)
In-Reply-To: <1484914267-8942-1-git-send-email-wei.liu2@citrix.com>
This is a basic program to call into the unified fuzzing function.
Hook it up into build system so that we can always build test it.
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: George Dunlap <George.Dunlap@eu.citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
---
.gitignore | 1 +
tools/fuzz/x86_instruction_emulator/Makefile | 9 +++--
.../afl-x86-insn-emulator-fuzzer.c | 42 ++++++++++++++++++++++
3 files changed, 50 insertions(+), 2 deletions(-)
create mode 100644 tools/fuzz/x86_instruction_emulator/afl-x86-insn-emulator-fuzzer.c
diff --git a/.gitignore b/.gitignore
index 7689596..881e7cb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -147,6 +147,7 @@ tools/flask/utils/flask-setenforce
tools/flask/utils/flask-set-bool
tools/flask/utils/flask-label-pci
tools/fuzz/x86_instruction_emulator/x86_emulate*
+tools/fuzz/x86_instruction_emulator/afl-x86-insn-emulator-fuzzer
tools/helpers/_paths.h
tools/helpers/init-xenstore-domain
tools/helpers/xen-init-dom0
diff --git a/tools/fuzz/x86_instruction_emulator/Makefile b/tools/fuzz/x86_instruction_emulator/Makefile
index 6aef3a7..2d1ff78 100644
--- a/tools/fuzz/x86_instruction_emulator/Makefile
+++ b/tools/fuzz/x86_instruction_emulator/Makefile
@@ -3,7 +3,7 @@ include $(XEN_ROOT)/tools/Rules.mk
.PHONY: x86-instruction-emulator-fuzzer-all
ifeq ($(CONFIG_X86_64),y)
-x86-instruction-emulator-fuzzer-all: x86-insn-emulator.a x86-insn-emulator-fuzzer.o
+x86-instruction-emulator-fuzzer-all: x86-insn-emulator.a x86-insn-emulator-fuzzer.o afl
else
x86-instruction-emulator-fuzzer-all:
endif
@@ -23,6 +23,8 @@ x86-insn-emulator-fuzzer.o: x86_emulate.h x86_emulate/x86_emulate.h
x86-insn-emulator.a: x86_emulate.o
$(AR) rc $@ $^
+afl-x86-insn-emulator-fuzzer: afl-x86-insn-emulator-fuzzer.o x86-insn-emulator-fuzzer.o x86_emulate.o
+
# Common targets
.PHONY: all
all: x86-instruction-emulator-fuzzer-all
@@ -33,7 +35,10 @@ distclean: clean
.PHONY: clean
clean:
- rm -f *.a *.o
+ rm -f *.a *.o afl-x86-insn-emulator-fuzzer
.PHONY: install
install: all
+
+.PHONY: afl
+afl: afl-x86-insn-emulator-fuzzer
diff --git a/tools/fuzz/x86_instruction_emulator/afl-x86-insn-emulator-fuzzer.c b/tools/fuzz/x86_instruction_emulator/afl-x86-insn-emulator-fuzzer.c
new file mode 100644
index 0000000..ec5acfb
--- /dev/null
+++ b/tools/fuzz/x86_instruction_emulator/afl-x86-insn-emulator-fuzzer.c
@@ -0,0 +1,42 @@
+#include <assert.h>
+#include <fcntl.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+extern int LLVMFuzzerTestOneInput(const uint8_t *data_p, size_t size);
+
+static uint8_t input[4096];
+
+int main(int argc, char **argv)
+{
+ size_t size;
+ int fd;
+
+ if ( argc != 2 )
+ {
+ printf("Expecting only one argument\n");
+ exit(1);
+ }
+
+ fd = open(argv[1], O_RDONLY, 0);
+ assert(fd != -1);
+ size = read(fd, input, sizeof(input));
+ close(fd);
+
+ LLVMFuzzerTestOneInput(input, size);
+
+ return 0;
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-01-20 12:11 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-20 12:11 [PATCH 0/4] fuzz: basic AFL support Wei Liu
2017-01-20 12:11 ` [PATCH 1/4] tools/fuzz: add missing dependency in x86 insn fuzzer build rule Wei Liu
2017-01-20 12:11 ` Wei Liu [this message]
2017-01-24 10:09 ` [PATCH 2/4] tools/fuzz: add AFL stub program for x86 insn emulator fuzzer Jan Beulich
2017-01-24 16:43 ` Wei Liu
2017-01-24 17:05 ` Ian Jackson
2017-01-24 17:18 ` Wei Liu
2017-01-24 17:22 ` Ian Jackson
2017-01-24 17:25 ` Andrew Cooper
2017-01-24 17:27 ` Wei Liu
2017-01-24 17:30 ` Ian Jackson
2017-01-24 17:37 ` Wei Liu
2017-01-24 17:46 ` Ian Jackson
2017-01-24 17:28 ` Wei Liu
2017-01-20 12:11 ` [PATCH 3/4] tools/fuzz: add AFL stub program for libefl fuzzer Wei Liu
2017-01-24 10:10 ` Jan Beulich
2017-01-20 12:11 ` [PATCH 4/4] tools/fuzz: add README.afl Wei Liu
2017-01-24 19:27 ` Andrew Cooper
2017-01-25 9:49 ` Wei Liu
2017-01-25 9:51 ` George Dunlap
2017-01-25 9:54 ` Wei Liu
2017-01-24 18:18 ` [PATCH 0/4] fuzz: basic AFL support Julien Grall
2017-01-24 18:56 ` Wei Liu
2017-01-24 19:00 ` Stefano Stabellini
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=1484914267-8942-3-git-send-email-wei.liu2@citrix.com \
--to=wei.liu2@citrix.com \
--cc=George.Dunlap@eu.citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=jbeulich@suse.com \
--cc=xen-devel@lists.xenproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.