fuzz: basic AFL support
cover fuzz: basic AFL support
Provide simple stub programs for AFL fuzzer. For usage, please see README.afl.
This series doesn't aim to improve fuzzing targets. It is just demonstration for how we could use the same fuzzing code for both oss-fuzz and AFL.
The stub programs are identical in libefl and x86 emulator at the moment, but they will likely diverge in the future. The duplication of code is deliberate.
Julien, FYI I think the in-tree libfdt could have something similar, too.
Wei.
Wei Liu (4):
tools/fuzz: add missing dependency in x86 insn fuzzer build rule tools/fuzz: add AFL stub program for x86 insn emulator fuzzer tools/fuzz: add AFL stub program for libefl fuzzer tools/fuzz: add README.afl
.gitignore | 2 ++
tools/fuzz/README.afl | 27 ++++++++++++++
tools/fuzz/{README => README.oss-fuzz} | 0
tools/fuzz/libelf/Makefile | 7 +++-
tools/fuzz/libelf/afl-libelf-fuzzer.c | 42 ++++++++++++++++++++++
tools/fuzz/x86_instruction_emulator/Makefile | 11 ++++--
.../afl-x86-insn-emulator-fuzzer.c | 42 ++++++++++++++++++++++
7 files changed, 128 insertions(+), 3 deletions(-)
create mode 100644 tools/fuzz/README.afl
rename tools/fuzz/{README => README.oss-fuzz} (100%)
create mode 100644 tools/fuzz/libelf/afl-libelf-fuzzer.c
create mode 100644 tools/fuzz/x86_instruction_emulator/afl-x86-insn-emulator-fuzzer.cSignature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH 1/4 tools/fuzz: add missing dependency in x86 insn fuzzer build rule
The said file needs the two header files.
---
Cc: Ian Jackson <[email protected]>
--- tools/fuzz/x86_instruction_emulator/Makefile | 2 ++ 1 file changed, 2 insertions(+)
tools/fuzz/x86_instruction_emulator/Makefile +2 -0
@@ -18,6 +18,8 @@ CFLAGS += $(CFLAGS_xeninclude) -D__XEN_TOOLS__ x86_emulate.o: x86_emulate.c x86_emulate.h x86_emulate/x86_emulate.c x86_emulate/x86_emulate.h +x86-insn-emulator-fuzzer.o: x86_emulate.h x86_emulate/x86_emulate.h + x86-insn-emulator.a: x86_emulate.o $(AR) rc $@ $^
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH 2/4 tools/fuzz: add AFL stub program for x86 insn emulator fuzzer
In reply to Wei LiuThis 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.
---
Cc: Andrew Cooper <[email protected]>
Cc: George Dunlap <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Jan Beulich <[email protected]>
--- .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
.gitignore +1 -0
@@ -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
tools/fuzz/x86_instruction_emulator/Makefile +7 -2
@@ -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
tools/fuzz/x86_instruction_emulator/afl-x86-insn-emulator-fuzzer.c new file +42 -0
42 lines not on this page · raw message
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 2/4] tools/fuzz: add AFL stub program for x86 insn emulator fuzzer
tools/fuzz/x86_instruction_emulator/Makefile distclean: clean · line 38
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 20.01.17 at 13:11, <[email protected]> wrote:
tools/fuzz/x86_instruction_emulator/Makefile +1
-1@@ -33,7 +35,10 @@ distclean: clean .PHONY: clean clean: - rm -f *.a *.o + rm -f *.a *.o afl-x86-insn-emulator-fuzzer
Perhaps *-x86-insn-emulator-fuzzer right away?
Quoted 23 lines
tools/fuzz/x86_instruction_emulator/afl-x86-insn-emulator-fuzzer.c new file +20
-0@@ -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 ) + {
tools/fuzz/x86_instruction_emulator/afl-x86-insn-emulator-fuzzer.c line 30
Quoted 10 lines
tools/fuzz/x86_instruction_emulator/afl-x86-insn-emulator-fuzzer.c new file +10
-0+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);
Please handle the case of read() failing (at least in the same way as you do for open()). With that
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 2/4] tools/fuzz: add AFL stub program for x86 insn emulator fuzzer
Quoted 10 lines · Jan Beulich
tools/fuzz/x86_instruction_emulator/Makefile distclean: clean · line 38
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 20.01.17 at 13:11, <[email protected]> wrote:
tools/fuzz/x86_instruction_emulator/Makefile +1
-1@@ -33,7 +35,10 @@ distclean: clean .PHONY: clean clean: - rm -f *.a *.o + rm -f *.a *.o afl-x86-insn-emulator-fuzzerPerhaps *-x86-insn-emulator-fuzzer right away?
OK.
Quoted 28 lines
Quoted 28 lines
tools/fuzz/x86_instruction_emulator/afl-x86-insn-emulator-fuzzer.c new file +25
-0@@ -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 );
Quoted 8 lines
tools/fuzz/x86_instruction_emulator/afl-x86-insn-emulator-fuzzer.c line 30
Quoted 5 lines
tools/fuzz/x86_instruction_emulator/afl-x86-insn-emulator-fuzzer.c new file +5
-0+assert (fd !=-1 ); + size =read (fd, input,sizeof (input)); +close (fd); + +LLVMFuzzerTestOneInput (input, size);Please handle the case of
read()failing (at least in the same way as you do foropen()). With that
OK. I change size to be ssize_t and then assert(size != -1) after read().
Quoted 2 lines
Reviewed-by Jan Beulich <[email protected]>
Thanks for reviewing.
Quoted 2 lines
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 2/4] tools/fuzz: add AFL stub program for x86 insn emulator fuzzer
In reply to Wei LiuWei Liu writes ("[PATCH 2/4] tools/fuzz: add AFL stub program for x86 insn emulator fuzzer"):
Quoted 1 line
This is a basic program to call into the unified fuzzing function.
...
tools/fuzz/x86_instruction_emulator/afl-x86-insn-emulator-fuzzer.c line 27
Quoted 3 lines
tools/fuzz/x86_instruction_emulator/afl-x86-insn-emulator-fuzzer.c new file +3
-0+ fd =open (argv[1 ],O_RDONLY ,0 ); +assert (fd !=-1 ); + size =read (fd, input,sizeof (input));
Why do you use open and read here rather than fopen and fread ?
If you use read you ought to put it in a loop to cope with potential partial reads.
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 2/4] tools/fuzz: add AFL stub program for x86 insn emulator fuzzer
Quoted 9 lines · Ian Jackson
Wei Liu writes ("[PATCH 2/4]
tools/fuzz: add AFL stub program for x86 insn emulator fuzzer"):Quoted 1 line
This is a basic program to call into the unified fuzzing function.
...
tools/fuzz/x86_instruction_emulator/afl-x86-insn-emulator-fuzzer.c line 27
Quoted 3 lines
tools/fuzz/x86_instruction_emulator/afl-x86-insn-emulator-fuzzer.c new file +3
-0+ fd =open (argv[1 ],O_RDONLY ,0 ); +assert (fd !=-1 ); + size =read (fd, input,sizeof (input));Why do you use open and read here rather than fopen and fread ?
No particular reason.
Quoted 3 lines
If you use read you ought to put it in a loop to cope with potential partial reads.
Does fread have better properties than read? I think to deal with short read we would need to stat the file to get actual size for both fread and read, right? If so I will just stick with read and put that in a loop.
Wei.
Quoted 1 line
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 2/4] tools/fuzz: add AFL stub program for x86 insn emulator fuzzer
Wei Liu writes ("Re: [PATCH 2/4] tools/fuzz: add AFL stub program for x86 insn emulator fuzzer"):
Quoted 5 lines · Ian Jackson
Quoted 2 lines
If you use read you ought to put it in a loop to cope with potential partial reads.
Does fread have better properties than read?
Yes. fread is not allowed to give a short read for no particular reason, nor to return with EINTR.
Quoted 2 lines
I think to deal with short read we would need to stat the file to get actual size for both fread and read, right?
No. In both cases, it is possible to detect whether a short read is due to EOF. With read, that would have to be in a loop. With fread you can test feof.
You don't need to test with stat unless you want to support files bigger than your static buffer.
I recommend you:
* use fopen and fread
* complain if fread filled the whole buffer, on the grounds that that means you may be ignoring a longer file than is supported
* check with feof or ferror that the short read was due to eof
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 2/4] tools/fuzz: add AFL stub program for x86 insn emulator fuzzer
Quoted 8 lines · Ian Jackson
Wei Liu writes ("Re: [PATCH 2/4]
tools/fuzz: add AFL stub program for x86 insn emulator fuzzer"):Quoted 4 lines · Ian Jackson
Quoted 2 lines
If you use read you ought to put it in a loop to cope with potential partial reads.
Does fread have better properties than read?
Yes. fread is not allowed to give a short read for no particular reason, nor to return with EINTR.
Quoted 8 lines
Quoted 2 lines
I think to deal with short read we would need to stat the file to get actual size for both fread and read, right?
No. In both cases, it is possible to detect whether a short read is due to EOF. With read, that would have to be in a loop. With fread you can test feof.
You don't need to test with stat unless you want to support files bigger than your static buffer.
It is expected that AFL data will eventually become longer than the fuzzer wishes. You should ignore extraneous data.
Also, remember that AFL prefers to pass data by pipe.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 2/4] tools/fuzz: add AFL stub program for x86 insn emulator fuzzer
Quoted 15 lines · Andrew Cooper
Quoted 14 lines · Ian Jackson
Wei Liu writes ("Re: [PATCH 2/4]
tools/fuzz: add AFL stub program for x86 insn emulator fuzzer"):Quoted 4 lines · Ian Jackson
Quoted 2 lines
If you use read you ought to put it in a loop to cope with potential partial reads.
Does fread have better properties than read?
Yes. fread is not allowed to give a short read for no particular reason, nor to return with EINTR.
Quoted 2 lines
I think to deal with short read we would need to stat the file to get actual size for both fread and read, right?
No. In both cases, it is possible to detect whether a short read is due to EOF. With read, that would have to be in a loop. With fread you can test feof.
Quoted 6 lines
Quoted 2 lines
You don't need to test with stat unless you want to support files bigger than your static buffer.
It is expected that AFL data will eventually become longer than the fuzzer wishes. You should ignore extraneous data.
That's not necessarily true. It depends on how you run the fuzzer.
But yes, ignoring extraneous data is sensible.
Quoted 1 line
Also, remember that AFL prefers to pass data by pipe.
It supports both using file or STDIN.
Using file would be easier for manual retest.
Wei.
Quoted 2 lines
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 2/4] tools/fuzz: add AFL stub program for x86 insn emulator fuzzer
In reply to Andrew CooperAndrew Cooper writes ("Re: [PATCH 2/4] tools/fuzz: add AFL stub program for x86 insn emulator fuzzer"):
Quoted 6 lines · Ian Jackson
Quoted 2 lines
You don't need to test with stat unless you want to support files bigger than your static buffer.
It is expected that AFL data will eventually become longer than the fuzzer wishes. You should ignore extraneous data.
No, you should exit nonzero.
That will signal to fuzzers that this is not a "valid" input and so not interesting. It will signal to other kinds of test code that something is wrong.
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 2/4] tools/fuzz: add AFL stub program for x86 insn emulator fuzzer
Quoted 5 lines · Ian Jackson
Andrew Cooper writes ("Re: [PATCH 2/4]
tools/fuzz: add AFL stub program for x86 insn emulator fuzzer"):Quoted 4 lines · Ian Jackson
Quoted 2 lines
You don't need to test with stat unless you want to support files bigger than your static buffer.
Quoted 9 lines
Quoted 2 lines
It is expected that AFL data will eventually become longer than the fuzzer wishes. You should ignore extraneous data.
No, you should exit nonzero.
That will signal to fuzzers that this is not a "valid" input and so not interesting. It will signal to other kinds of test code that something is wrong.
Hmm... I originally thought exit(1) would cause AFL to think the program has crashed, but I was wrong.
So using exit(1) is more sensible in this case.
Wei.
Quoted 1 line
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 2/4] tools/fuzz: add AFL stub program for x86 insn emulator fuzzer
Wei Liu writes ("Re: [PATCH 2/4] tools/fuzz: add AFL stub program for x86 insn emulator fuzzer"):
Quoted 2 lines
Hmm... I originally thought exit(1) would cause AFL to think the program has crashed, but I was wrong.
Ah. Yes, indeed. Sorry for not explaining that.
Quoted 1 line
So using exit(1) is more sensible in this case.
Right.
Thanks,
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 2/4] tools/fuzz: add AFL stub program for x86 insn emulator fuzzer
In reply to Ian JacksonQuoted 17 lines · Ian Jackson
Wei Liu writes ("Re: [PATCH 2/4]
tools/fuzz: add AFL stub program for x86 insn emulator fuzzer"):Quoted 5 lines · Ian Jackson
Quoted 2 lines
If you use read you ought to put it in a loop to cope with potential partial reads.
Does fread have better properties than read?
Yes. fread is not allowed to give a short read for no particular reason, nor to return with EINTR.
Quoted 2 lines
I think to deal with short read we would need to stat the file to get actual size for both fread and read, right?
No. In both cases, it is possible to detect whether a short read is due to EOF. With read, that would have to be in a loop. With fread you can test feof.
Quoted 9 lines
You don't need to test with stat unless you want to support files bigger than your static buffer.
I recommend you:
* use fopen and fread
* complain if fread filled the whole buffer, on the grounds that that means you may be ignoring a longer file than is supported
* check with feof or ferror that the short read was due to eof
NP. This sounds sensible.
Wei.
Quoted 1 line
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 3/4 tools/fuzz: add AFL stub program for libefl fuzzer
In reply to Wei LiuAnd hook it up into build system.
---
Cc: Andrew Cooper <[email protected]>
Cc: George Dunlap <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Jan Beulich <[email protected]>
--- .gitignore | 1 + tools/fuzz/libelf/Makefile | 7 +++++- tools/fuzz/libelf/afl-libelf-fuzzer.c | 42 +++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 tools/fuzz/libelf/afl-libelf-fuzzer.c
.gitignore +1 -0
@@ -146,6 +146,7 @@ tools/flask/utils/flask-loadpolicy tools/flask/utils/flask-setenforce tools/flask/utils/flask-set-bool tools/flask/utils/flask-label-pci +tools/fuzz/libelf/afl-libelf-fuzzer tools/fuzz/x86_instruction_emulator/x86_emulate* tools/fuzz/x86_instruction_emulator/afl-x86-insn-emulator-fuzzer tools/helpers/_paths.h
tools/fuzz/libelf/Makefile +6 -1
@@ -19,6 +19,8 @@ libelf.a: $(ELF_LIB_OBJS) .PHONY: libelf-fuzzer-all libelf-fuzzer-all: libelf.a libelf-fuzzer.o +afl-libelf-fuzzer: afl-libelf-fuzzer.o libelf-fuzzer.o $(ELF_LIB_OBJS) + # Common targets .PHONY: all all: libelf-fuzzer-all
@@ -28,7 +30,10 @@ distclean: clean .PHONY: clean clean: - rm -f *.o *.a + rm -f *.o *.a afl-libelf-fuzzer .PHONY: install install: all + +.PHONY: afl +afl: afl-libelf-fuzzer
tools/fuzz/libelf/afl-libelf-fuzzer.c new file +42 -0
42 lines not on this page · raw message
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 3/4] tools/fuzz: add AFL stub program for libefl fuzzer
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 20.01.17 at 13:11, <[email protected]> wrote:
And hook it up into build system.
Same comments and same conditional R-b as for the other patch.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 4/4 tools/fuzz: add README.afl
In reply to Wei LiuAnd rename README to README.oss-fuzz.
---
Cc: Andrew Cooper <[email protected]>
Cc: George Dunlap <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Jan Beulich <[email protected]>
---
tools/fuzz/README.afl | 27 +++++++++++++++++++++++++++
tools/fuzz/{README => README.oss-fuzz} | 0
2 files changed, 27 insertions(+)
create mode 100644 tools/fuzz/README.afl
rename tools/fuzz/{README => README.oss-fuzz} (100%)tools/fuzz/README.afl new file +27 -0
@@ -0,0 +1,27 @@ +# OVERVIEW + +Some fuzzing targets have American Fuzzy Lop (AFL) support. + +See also http://lcamtuf.coredump.cx/afl/ + +# HOW IT WORKS + +AFL provides a customised toolchain to build an executable, which in +turn is launched by the fuzzer. + +# HOW TO USE IT + +Use the x86 instruction emulator fuzzer as an example. + +1. download and compile AFL in $AFLPATH. + +2. run the following commands to build: + $ cd tools/fuzz/x86_instruction_emulator + $ make distclean + $ make CC=$AFLPATH/afl-gcc afl # produces afl-x86-insn-emulator-fuzzer + +3. run the fuzzer with AFL: + $ $AFLPATH/afl-fuzz -m none -t 1000 -i testcase_dir -o findings_dir -- \ + ./afl-x86-insn-emulator-fuzzer @@ + +Please see AFL documentation for more information.
tools/fuzz/README.oss-fuzz renamed from tools/fuzz/README +0 -0
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 4/4] tools/fuzz: add README.afl
Quoted 38 lines · Wei Liu
And rename README to README.oss-fuzz.
Signed-off-by Wei Liu <[email protected]>---
Cc: Andrew Cooper <[email protected]>
Cc: George Dunlap <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Jan Beulich <[email protected]>--- tools/fuzz/README.afl | 27 +++++++++++++++++++++++++++ tools/fuzz/{README => README.oss-fuzz} | 0 2 files changed, 27 insertions(+) create mode 100644 tools/fuzz/README.afl rename tools/fuzz/{README => README.oss-fuzz} (100%)tools/fuzz/README.afl new file +17
-0@@ -0,0 +1,27 @@ +# OVERVIEW + +Some fuzzing targets have American Fuzzy Lop (AFL) support. + +See also http://lcamtuf.coredump.cx/afl/ + +# HOW IT WORKS + +AFL provides a customised toolchain to build an executable, which in +turn is launched by the fuzzer. + +# HOW TO USE IT + +Use the x86 instruction emulator fuzzer as an example. + +1. download and compile AFL in $AFLPATH. +
tools/fuzz/README.afl line 27
Quoted 10 lines
tools/fuzz/README.afl new file +10
-0+2. run the following commands to build: + $ cd tools/fuzz/x86_instruction_emulator + $ make distclean + $ make CC=$AFLPATH/afl-gcc afl # produces afl-x86-insn-emulator-fuzzer + +3. run the fuzzer with AFL: + $ $AFLPATH/afl-fuzz -m none -t 1000 -i testcase_dir -o findings_dir -- \ + ./afl-x86-insn-emulator-fuzzer @@ + +Please see AFL documentation for more information.
Having just debugged this README (I totally haven't forgotten how to use AFL, despite all the recent work on it ;p), it is missing the initial test case.
I previously used a ret instruction as the seed testcase.
$ mkdir testcase_dir $ echo -n -e '\xc3' > testcase_dir/ret.bin
after which ALF is happy to start running.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 4/4] tools/fuzz: add README.afl
Quoted 54 lines · Andrew Cooper
Quoted 38 lines · Wei Liu
And rename README to README.oss-fuzz.
Signed-off-by Wei Liu <[email protected]>---
Cc: Andrew Cooper <[email protected]>
Cc: George Dunlap <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Jan Beulich <[email protected]>--- tools/fuzz/README.afl | 27 +++++++++++++++++++++++++++ tools/fuzz/{README => README.oss-fuzz} | 0 2 files changed, 27 insertions(+) create mode 100644 tools/fuzz/README.afl rename tools/fuzz/{README => README.oss-fuzz} (100%)tools/fuzz/README.afl new file +17
-0@@ -0,0 +1,27 @@ +# OVERVIEW + +Some fuzzing targets have American Fuzzy Lop (AFL) support. + +See also http://lcamtuf.coredump.cx/afl/ + +# HOW IT WORKS + +AFL provides a customised toolchain to build an executable, which in +turn is launched by the fuzzer. + +# HOW TO USE IT + +Use the x86 instruction emulator fuzzer as an example. + +1. download and compile AFL in $AFLPATH. +tools/fuzz/README.afl line 27
Quoted 10 lines
tools/fuzz/README.afl new file +10
-0+2. run the following commands to build: + $ cd tools/fuzz/x86_instruction_emulator + $ make distclean + $ make CC=$AFLPATH/afl-gcc afl # produces afl-x86-insn-emulator-fuzzer + +3. run the fuzzer with AFL: + $ $AFLPATH/afl-fuzz -m none -t 1000 -i testcase_dir -o findings_dir -- \ + ./afl-x86-insn-emulator-fuzzer @@ + +Please see AFL documentation for more information.Having just debugged this README (I totally haven't forgotten how to use AFL, despite all the recent work on it ;p), it is missing the initial test case.
Quoted 6 lines
I previously used a ret instruction as the seed testcase.
$ mkdir testcase_dir $ echo -n -e '\xc3' > testcase_dir/ret.binafter which ALF is happy to start running.
Right, I will add this to README.afl.
Wei.
Quoted 2 lines
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 4/4] tools/fuzz: add README.afl
In reply to Andrew CooperQuoted 54 lines · Andrew Cooper
Quoted 38 lines · Wei Liu
And rename README to README.oss-fuzz.
Signed-off-by Wei Liu <[email protected]>---
Cc: Andrew Cooper <[email protected]>
Cc: George Dunlap <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Jan Beulich <[email protected]>--- tools/fuzz/README.afl | 27 +++++++++++++++++++++++++++ tools/fuzz/{README => README.oss-fuzz} | 0 2 files changed, 27 insertions(+) create mode 100644 tools/fuzz/README.afl rename tools/fuzz/{README => README.oss-fuzz} (100%)tools/fuzz/README.afl new file +17
-0@@ -0,0 +1,27 @@ +# OVERVIEW + +Some fuzzing targets have American Fuzzy Lop (AFL) support. + +See also http://lcamtuf.coredump.cx/afl/ + +# HOW IT WORKS + +AFL provides a customised toolchain to build an executable, which in +turn is launched by the fuzzer. + +# HOW TO USE IT + +Use the x86 instruction emulator fuzzer as an example. + +1. download and compile AFL in $AFLPATH. +tools/fuzz/README.afl line 27
Quoted 10 lines
tools/fuzz/README.afl new file +10
-0+2. run the following commands to build: + $ cd tools/fuzz/x86_instruction_emulator + $ make distclean + $ make CC=$AFLPATH/afl-gcc afl # produces afl-x86-insn-emulator-fuzzer + +3. run the fuzzer with AFL: + $ $AFLPATH/afl-fuzz -m none -t 1000 -i testcase_dir -o findings_dir -- \ + ./afl-x86-insn-emulator-fuzzer @@ + +Please see AFL documentation for more information.Having just debugged this README (I totally haven't forgotten how to use AFL, despite all the recent work on it ;p), it is missing the initial test case.
Quoted 6 lines
I previously used a ret instruction as the seed testcase.
$ mkdir testcase_dir $ echo -n -e '\xc3' > testcase_dir/ret.binafter which ALF is happy to start running.
In my own version I had a special option to pass to the binary to generate a set of test cases. Wei, do you have any opinions on this?
One of the things I found was that there were certain "corners" of the code that for some reason AFL had trouble reaching (i.e., after two days of running there were lines that still didn't have any coverage). One of the advantages of generating test cases is that if some of these are identified, we may be able to get a more even coverage more quickly.
-George
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 4/4] tools/fuzz: add README.afl
Quoted 66 lines · George Dunlap
Quoted 54 lines · Andrew Cooper
Quoted 38 lines · Wei Liu
And rename README to README.oss-fuzz.
Signed-off-by Wei Liu <[email protected]>---
Cc: Andrew Cooper <[email protected]>
Cc: George Dunlap <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Jan Beulich <[email protected]>--- tools/fuzz/README.afl | 27 +++++++++++++++++++++++++++ tools/fuzz/{README => README.oss-fuzz} | 0 2 files changed, 27 insertions(+) create mode 100644 tools/fuzz/README.afl rename tools/fuzz/{README => README.oss-fuzz} (100%)tools/fuzz/README.afl new file +17
-0@@ -0,0 +1,27 @@ +# OVERVIEW + +Some fuzzing targets have American Fuzzy Lop (AFL) support. + +See also http://lcamtuf.coredump.cx/afl/ + +# HOW IT WORKS + +AFL provides a customised toolchain to build an executable, which in +turn is launched by the fuzzer. + +# HOW TO USE IT + +Use the x86 instruction emulator fuzzer as an example. + +1. download and compile AFL in $AFLPATH. +tools/fuzz/README.afl line 27
Quoted 10 lines
tools/fuzz/README.afl new file +10
-0+2. run the following commands to build: + $ cd tools/fuzz/x86_instruction_emulator + $ make distclean + $ make CC=$AFLPATH/afl-gcc afl # produces afl-x86-insn-emulator-fuzzer + +3. run the fuzzer with AFL: + $ $AFLPATH/afl-fuzz -m none -t 1000 -i testcase_dir -o findings_dir -- \ + ./afl-x86-insn-emulator-fuzzer @@ + +Please see AFL documentation for more information.Having just debugged this README (I totally haven't forgotten how to use AFL, despite all the recent work on it ;p), it is missing the initial test case.
Quoted 6 lines
I previously used a ret instruction as the seed testcase.
$ mkdir testcase_dir $ echo -n -e '\xc3' > testcase_dir/ret.binafter which ALF is happy to start running.
In my own version I had a special option to pass to the binary to generate a set of test cases. Wei, do you have any opinions on this?
Quoted 7 lines
One of the things I found was that there were certain "corners" of the code that for some reason AFL had trouble reaching (i.e., after two days of running there were lines that still didn't have any coverage). One of the advantages of generating test cases is that if some of these are identified, we may be able to get a more even coverage more quickly.
I haven't read that version in detailed, but I agree with you that having ability to generate tailored test case is a good idea.
Wei.
Quoted 1 line
-George
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Hi Wei,
Quoted 9 lines · Wei Liu
Provide simple stub programs for AFL fuzzer. For usage, please see README.afl.
This series doesn't aim to improve fuzzing targets. It is just demonstration for how we could use the same fuzzing code for both oss-fuzz and AFL.
The stub programs are identical in libefl and x86 emulator at the moment, but they will likely diverge in the future. The duplication of code is deliberate.
Julien, FYI I think the in-tree libfdt could have something similar, too.
I am not sure if it would be useful. We know that libfdt is not protected against rogue device-tree and therefore fuzzing will likely break it. Any device-tree used are expected to be trusted (this is documented in the tools).
Anyway, it would be nice to get libfdt fixed and provide patch the upstream version [1].
Cheers,
[1] https://git.kernel.org/cgit/utils/dtc/dtc.git
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Quoted 11 lines · Julien Grall
Hi Wei,
Quoted 8 lines · Wei Liu
Provide simple stub programs for AFL fuzzer. For usage, please see README.afl.
This series doesn't aim to improve fuzzing targets. It is just demonstration for how we could use the same fuzzing code for both oss-fuzz and AFL.
The stub programs are identical in libefl and x86 emulator at the moment, but they will likely diverge in the future. The duplication of code is deliberate.
Quoted 7 lines
Quoted 1 line
Julien, FYI I think the in-tree libfdt could have something similar, too.
I am not sure if it would be useful. We know that libfdt is not protected against rogue device-tree and therefore fuzzing will likely break it. Any device-tree used are expected to be trusted (this is documented in the tools).
OK. In that case we don't need to run AFL against libfdt.
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 14 lines · Wei Liu
Quoted 13 lines · Julien Grall
Hi Wei,
Quoted 9 lines · Wei Liu
Provide simple stub programs for AFL fuzzer. For usage, please see README.afl.
This series doesn't aim to improve fuzzing targets. It is just demonstration for how we could use the same fuzzing code for both oss-fuzz and AFL.
The stub programs are identical in libefl and x86 emulator at the moment, but they will likely diverge in the future. The duplication of code is deliberate.
Julien, FYI I think the in-tree libfdt could have something similar, too.
Quoted 7 lines
Quoted 5 lines
I am not sure if it would be useful. We know that libfdt is not protected against rogue device-tree and therefore fuzzing will likely break it. Any device-tree used are expected to be trusted (this is documented in the tools).
OK. In that case we don't need to run AFL against libfdt.
I agree.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel