Skip to content

Commit bd1eec7

Browse files
authored
Fuzzer: fix JIT fuzzing (#322)
* include config, enrich differential output * fix additional misunderstanding * improve output for clarity * ignore callout errors * support 8-, 16-, and 32-bit modes * try to enable MSAN support with JIT * expand stack size implicitly * use 256MB stack (!) to avoid overflow with link-size 4 * try to make some dictionaries for 16-, 32-bit modes * add to options * disable recurseloop check in fuzzer
1 parent aa51f00 commit bd1eec7

11 files changed

+449
-91
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ pcre2posix_test.exe
5050
pcre2posix_test.log
5151
pcre2posix_test.trs
5252
pcre2demo
53-
pcre2fuzzcheck
53+
pcre2fuzzcheck-*
54+
pcre2fuzzer-*
5455
pcre2grep
5556
pcre2grep.exe
5657
pcre2test

Makefile.am

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -540,28 +540,64 @@ if WITH_GCOV
540540
pcre2grep_CFLAGS += $(GCOV_CFLAGS)
541541
pcre2grep_LDADD += $(GCOV_LIBS)
542542
endif # WITH_GCOV
543+
endif # WITH_PCRE2_8
543544

544545
## If fuzzer support is enabled, build a non-distributed library containing the
545546
## fuzzing function. Also build the standalone checking binary from the same
546547
## source but using -DSTANDALONE.
547548

548549
if WITH_FUZZ_SUPPORT
549-
noinst_LIBRARIES = .libs/libpcre2-fuzzsupport.a
550+
noinst_LIBRARIES =
551+
if WITH_PCRE2_8
552+
noinst_LIBRARIES += .libs/libpcre2-fuzzsupport.a
550553
_libs_libpcre2_fuzzsupport_a_SOURCES = src/pcre2_fuzzsupport.c
551554
_libs_libpcre2_fuzzsupport_a_CFLAGS = $(AM_CFLAGS)
552555
_libs_libpcre2_fuzzsupport_a_LIBADD =
553556

554-
noinst_PROGRAMS += pcre2fuzzcheck
555-
pcre2fuzzcheck_SOURCES = src/pcre2_fuzzsupport.c
556-
pcre2fuzzcheck_CFLAGS = -DSTANDALONE $(AM_CFLAGS)
557-
pcre2fuzzcheck_LDADD = libpcre2-8.la
557+
noinst_PROGRAMS += pcre2fuzzcheck-8
558+
pcre2fuzzcheck_8_SOURCES = src/pcre2_fuzzsupport.c
559+
pcre2fuzzcheck_8_CFLAGS = -DSTANDALONE $(AM_CFLAGS)
560+
pcre2fuzzcheck_8_LDADD = libpcre2-8.la
558561
if WITH_GCOV
559-
pcre2fuzzcheck_CFLAGS += $(GCOV_CFLAGS)
560-
pcre2fuzzcheck_LDADD += $(GCOV_LIBS)
562+
pcre2fuzzcheck_8_CFLAGS += $(GCOV_CFLAGS)
563+
pcre2fuzzcheck_8_LDADD += $(GCOV_LIBS)
561564
endif # WITH_GCOV
562-
endif # WITH FUZZ_SUPPORT
563565
endif # WITH_PCRE2_8
564566

567+
if WITH_PCRE2_16
568+
noinst_LIBRARIES += .libs/libpcre2-fuzzsupport-16.a
569+
_libs_libpcre2_fuzzsupport_16_a_SOURCES = src/pcre2_fuzzsupport.c
570+
_libs_libpcre2_fuzzsupport_16_a_CFLAGS = $(AM_CFLAGS) -DPCRE2_CODE_UNIT_WIDTH=16
571+
_libs_libpcre2_fuzzsupport_16_a_LIBADD =
572+
573+
noinst_PROGRAMS += pcre2fuzzcheck-16
574+
pcre2fuzzcheck_16_SOURCES = src/pcre2_fuzzsupport.c
575+
pcre2fuzzcheck_16_CFLAGS = -DSTANDALONE $(AM_CFLAGS) -DPCRE2_CODE_UNIT_WIDTH=16
576+
pcre2fuzzcheck_16_LDADD = libpcre2-16.la
577+
if WITH_GCOV
578+
pcre2fuzzcheck_16_CFLAGS += $(GCOV_CFLAGS)
579+
pcre2fuzzcheck_16_LDADD += $(GCOV_LIBS)
580+
endif # WITH_GCOV
581+
endif # WITH_PCRE2_16
582+
583+
if WITH_PCRE2_32
584+
noinst_LIBRARIES += .libs/libpcre2-fuzzsupport-32.a
585+
_libs_libpcre2_fuzzsupport_32_a_SOURCES = src/pcre2_fuzzsupport.c
586+
_libs_libpcre2_fuzzsupport_32_a_CFLAGS = $(AM_CFLAGS) -DPCRE2_CODE_UNIT_WIDTH=32
587+
_libs_libpcre2_fuzzsupport_32_a_LIBADD =
588+
589+
noinst_PROGRAMS += pcre2fuzzcheck-32
590+
pcre2fuzzcheck_32_SOURCES = src/pcre2_fuzzsupport.c
591+
pcre2fuzzcheck_32_CFLAGS = -DSTANDALONE $(AM_CFLAGS) -DPCRE2_CODE_UNIT_WIDTH=32
592+
pcre2fuzzcheck_32_LDADD = libpcre2-32.la
593+
if WITH_GCOV
594+
pcre2fuzzcheck_32_CFLAGS += $(GCOV_CFLAGS)
595+
pcre2fuzzcheck_32_LDADD += $(GCOV_LIBS)
596+
endif # WITH_GCOV
597+
endif # WITH_PCRE2_32
598+
599+
endif # WITH_FUZZ_SUPPORT
600+
565601
## -------- Testing ----------
566602

567603
## If the 8-bit library is enabled, build the POSIX wrapper test program and

pcre2_fuzzer_16.dict

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# This is attempt at a fuzzer dictionary for PCRE2.
2+
3+
"\\\x00A\x00"
4+
"\\\x00b\x00"
5+
"\\\x00B\x00"
6+
"\\\x00d\x00"
7+
"\\\x00D\x00"
8+
"\\\x00h\x00"
9+
"\\\x00H\x00"
10+
"\\\x00n\x00"
11+
"\\\x00N\x00"
12+
"\\\x00s\x00"
13+
"\\\x00S\x00"
14+
"\\\x00w\x00"
15+
"\\\x00W\x00"
16+
"\\\x00z\x00"
17+
"\\\x00Z\x00"
18+
19+
"(\x00?\x00"
20+
"(\x00?\x00:\x00"
21+
"(\x00?\x00>\x00"
22+
"(\x00?\x00=\x00"
23+
"(\x00?\x00!\x00"
24+
"(\x00?\x00<\x00=\x00"
25+
"(\x00?\x00<\x00!\x00"
26+
"(\x00?\x00|\x00"
27+
28+
"[\x00:\x00a\x00l\x00n\x00u\x00m\x00:\x00]\x00"
29+
"[\x00:\x00a\x00l\x00p\x00h\x00a\x00:\x00]\x00"
30+
"[\x00:\x00a\x00s\x00c\x00i\x00i\x00:\x00]\x00"
31+
"[\x00:\x00b\x00l\x00a\x00n\x00k\x00:\x00]\x00"
32+
"[\x00:\x00c\x00n\x00t\x00r\x00l\x00:\x00]\x00"
33+
"[\x00:\x00d\x00i\x00g\x00i\x00t\x00:\x00]\x00"
34+
"[\x00:\x00g\x00r\x00a\x00p\x00h\x00:\x00]\x00"
35+
"[\x00:\x00l\x00o\x00w\x00e\x00r\x00:\x00]\x00"
36+
"[\x00:\x00p\x00r\x00i\x00n\x00t\x00:\x00]\x00"
37+
"[\x00:\x00p\x00u\x00n\x00c\x00t\x00:\x00]\x00"
38+
"[\x00:\x00s\x00p\x00a\x00c\x00e\x00:\x00]\x00"
39+
"[\x00:\x00u\x00p\x00p\x00e\x00r\x00:\x00]\x00"
40+
"[\x00:\x00w\x00o\x00r\x00d\x00:\x00]\x00"
41+
"[\x00:\x00x\x00d\x00i\x00g\x00i\x00t\x00:\x00]\x00"
42+
43+
"(\x00*\x00A\x00C\x00C\x00E\x00P\x00T\x00)\x00"
44+
"(\x00*\x00F\x00A\x00I\x00L\x00)\x00"
45+
"(\x00*\x00C\x00O\x00M\x00M\x00I\x00T\x00)\x00"
46+
"(\x00*\x00P\x00R\x00U\x00N\x00E\x00)\x00"
47+
"(\x00*\x00S\x00K\x00I\x00P\x00)\x00"
48+
"(\x00*\x00T\x00H\x00E\x00N\x00)\x00"
49+
50+
# End

pcre2_fuzzer_16.options

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[libfuzzer]
2+
dict = pcre2_fuzzer_16.dict

pcre2_fuzzer_32.dict

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# This is attempt at a fuzzer dictionary for PCRE2.
2+
3+
"\\\x00\x00\x00A\x00\x00\x00"
4+
"\\\x00\x00\x00b\x00\x00\x00"
5+
"\\\x00\x00\x00B\x00\x00\x00"
6+
"\\\x00\x00\x00d\x00\x00\x00"
7+
"\\\x00\x00\x00D\x00\x00\x00"
8+
"\\\x00\x00\x00h\x00\x00\x00"
9+
"\\\x00\x00\x00H\x00\x00\x00"
10+
"\\\x00\x00\x00n\x00\x00\x00"
11+
"\\\x00\x00\x00N\x00\x00\x00"
12+
"\\\x00\x00\x00s\x00\x00\x00"
13+
"\\\x00\x00\x00S\x00\x00\x00"
14+
"\\\x00\x00\x00w\x00\x00\x00"
15+
"\\\x00\x00\x00W\x00\x00\x00"
16+
"\\\x00\x00\x00z\x00\x00\x00"
17+
"\\\x00\x00\x00Z\x00\x00\x00"
18+
19+
"(\x00\x00\x00?\x00\x00\x00"
20+
"(\x00\x00\x00?\x00\x00\x00:\x00\x00\x00"
21+
"(\x00\x00\x00?\x00\x00\x00>\x00\x00\x00"
22+
"(\x00\x00\x00?\x00\x00\x00=\x00\x00\x00"
23+
"(\x00\x00\x00?\x00\x00\x00!\x00\x00\x00"
24+
"(\x00\x00\x00?\x00\x00\x00<\x00\x00\x00=\x00\x00\x00"
25+
"(\x00\x00\x00?\x00\x00\x00<\x00\x00\x00!\x00\x00\x00"
26+
"(\x00\x00\x00?\x00\x00\x00|\x00\x00\x00"
27+
28+
"[\x00\x00\x00:\x00\x00\x00a\x00\x00\x00l\x00\x00\x00n\x00\x00\x00u\x00\x00\x00m\x00\x00\x00:\x00\x00\x00]\x00\x00\x00"
29+
"[\x00\x00\x00:\x00\x00\x00a\x00\x00\x00l\x00\x00\x00p\x00\x00\x00h\x00\x00\x00a\x00\x00\x00:\x00\x00\x00]\x00\x00\x00"
30+
"[\x00\x00\x00:\x00\x00\x00a\x00\x00\x00s\x00\x00\x00c\x00\x00\x00i\x00\x00\x00i\x00\x00\x00:\x00\x00\x00]\x00\x00\x00"
31+
"[\x00\x00\x00:\x00\x00\x00b\x00\x00\x00l\x00\x00\x00a\x00\x00\x00n\x00\x00\x00k\x00\x00\x00:\x00\x00\x00]\x00\x00\x00"
32+
"[\x00\x00\x00:\x00\x00\x00c\x00\x00\x00n\x00\x00\x00t\x00\x00\x00r\x00\x00\x00l\x00\x00\x00:\x00\x00\x00]\x00\x00\x00"
33+
"[\x00\x00\x00:\x00\x00\x00d\x00\x00\x00i\x00\x00\x00g\x00\x00\x00i\x00\x00\x00t\x00\x00\x00:\x00\x00\x00]\x00\x00\x00"
34+
"[\x00\x00\x00:\x00\x00\x00g\x00\x00\x00r\x00\x00\x00a\x00\x00\x00p\x00\x00\x00h\x00\x00\x00:\x00\x00\x00]\x00\x00\x00"
35+
"[\x00\x00\x00:\x00\x00\x00l\x00\x00\x00o\x00\x00\x00w\x00\x00\x00e\x00\x00\x00r\x00\x00\x00:\x00\x00\x00]\x00\x00\x00"
36+
"[\x00\x00\x00:\x00\x00\x00p\x00\x00\x00r\x00\x00\x00i\x00\x00\x00n\x00\x00\x00t\x00\x00\x00:\x00\x00\x00]\x00\x00\x00"
37+
"[\x00\x00\x00:\x00\x00\x00p\x00\x00\x00u\x00\x00\x00n\x00\x00\x00c\x00\x00\x00t\x00\x00\x00:\x00\x00\x00]\x00\x00\x00"
38+
"[\x00\x00\x00:\x00\x00\x00s\x00\x00\x00p\x00\x00\x00a\x00\x00\x00c\x00\x00\x00e\x00\x00\x00:\x00\x00\x00]\x00\x00\x00"
39+
"[\x00\x00\x00:\x00\x00\x00u\x00\x00\x00p\x00\x00\x00p\x00\x00\x00e\x00\x00\x00r\x00\x00\x00:\x00\x00\x00]\x00\x00\x00"
40+
"[\x00\x00\x00:\x00\x00\x00w\x00\x00\x00o\x00\x00\x00r\x00\x00\x00d\x00\x00\x00:\x00\x00\x00]\x00\x00\x00"
41+
"[\x00\x00\x00:\x00\x00\x00x\x00\x00\x00d\x00\x00\x00i\x00\x00\x00g\x00\x00\x00i\x00\x00\x00t\x00\x00\x00:\x00\x00\x00]\x00\x00\x00"
42+
43+
"(\x00\x00\x00*\x00\x00\x00A\x00\x00\x00C\x00\x00\x00C\x00\x00\x00E\x00\x00\x00P\x00\x00\x00T\x00\x00\x00)\x00\x00\x00"
44+
"(\x00\x00\x00*\x00\x00\x00F\x00\x00\x00A\x00\x00\x00I\x00\x00\x00L\x00\x00\x00)\x00\x00\x00"
45+
"(\x00\x00\x00*\x00\x00\x00C\x00\x00\x00O\x00\x00\x00M\x00\x00\x00M\x00\x00\x00I\x00\x00\x00T\x00\x00\x00)\x00\x00\x00"
46+
"(\x00\x00\x00*\x00\x00\x00P\x00\x00\x00R\x00\x00\x00U\x00\x00\x00N\x00\x00\x00E\x00\x00\x00)\x00\x00\x00"
47+
"(\x00\x00\x00*\x00\x00\x00S\x00\x00\x00K\x00\x00\x00I\x00\x00\x00P\x00\x00\x00)\x00\x00\x00"
48+
"(\x00\x00\x00*\x00\x00\x00T\x00\x00\x00H\x00\x00\x00E\x00\x00\x00N\x00\x00\x00)\x00\x00\x00"
49+
50+
# End

pcre2_fuzzer_32.options

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[libfuzzer]
2+
dict = pcre2_fuzzer_32.dict

0 commit comments

Comments
 (0)