Skip to content

Commit

Permalink
Merge pull request #10107 from dra27/afl
Browse files Browse the repository at this point in the history
Always allow linking AFL-instrumented modules

(cherry picked from commit 15c5679)
  • Loading branch information
dra27 committed Apr 14, 2021
1 parent c470a23 commit d96c13e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
5 changes: 5 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@ OCaml 4.12, maintenance version

### Bug fixes:

- #10107: Ensure modules compiled with -afl-instrument can still link on
platforms without AFL support.
(David Allsopp, review by Xavier Leroy)

- #10294, #10295: fix an assert-failure in pattern-matching compilation
(Gabriel Scherer, review by Thomas Refis and Luc Maranget,
report by Nicolás Ojeda Bär)


OCaml 4.12.0 (24 February 2021)
-------------------------------

Expand Down
16 changes: 11 additions & 5 deletions runtime/afl.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
/* Runtime support for afl-fuzz */
#include "caml/config.h"

/* Values used by the instrumentation logic (see cmmgen.ml) */
static unsigned char afl_area_initial[1 << 16];
unsigned char* caml_afl_area_ptr = afl_area_initial;
uintnat caml_afl_prev_loc;

#if !defined(HAS_SYS_SHM_H) || !defined(HAS_SHMAT)

#include "caml/mlvalues.h"
Expand All @@ -29,6 +34,12 @@ CAMLprim value caml_reset_afl_instrumentation(value unused)
return Val_unit;
}

CAMLexport value caml_setup_afl(value unit)
{
/* AFL is not supported */
return Val_unit;
}

#else

#include <unistd.h>
Expand All @@ -50,11 +61,6 @@ static int afl_initialised = 0;
to count a testcase as "crashing" */
extern int caml_abort_on_uncaught_exn;

/* Values used by the instrumentation logic (see cmmgen.ml) */
static unsigned char afl_area_initial[1 << 16];
unsigned char* caml_afl_area_ptr = afl_area_initial;
uintnat caml_afl_prev_loc;

/* File descriptors used to synchronise with afl-fuzz */
#define FORKSRV_FD_READ 198
#define FORKSRV_FD_WRITE 199
Expand Down

0 comments on commit d96c13e

Please sign in to comment.