Skip to content

Commit

Permalink
Merge branch 'dev' of ssh://github.com/AFLplusplus/AFLplusplus into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
vanhauser-thc committed Oct 21, 2023
2 parents 389c88c + b50b2e8 commit eaa6a17
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
1 change: 1 addition & 0 deletions include/forkserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ typedef struct afl_forkserver {
u32 nyx_id; /* nyx runner id (0 -> master) */
u32 nyx_bind_cpu_id; /* nyx runner cpu id */
char *nyx_aux_string;
u32 nyx_aux_string_len;
bool nyx_use_tmp_workdir;
char *nyx_tmp_workdir_path;
s32 nyx_log_fd;
Expand Down
4 changes: 4 additions & 0 deletions instrumentation/SanitizerCoveragePCGUARD.so.cc
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,11 @@ llvmGetPassPluginInfo() {
#if LLVM_VERSION_MAJOR == 13
using OptimizationLevel = typename PassBuilder::OptimizationLevel;
#endif
#if LLVM_VERSION_MAJOR >= 16
PB.registerOptimizerEarlyEPCallback(
#else
PB.registerOptimizerLastEPCallback(
#endif
[](ModulePassManager &MPM, OptimizationLevel OL) {

MPM.addPass(ModuleSanitizerCoverageAFL());
Expand Down
4 changes: 2 additions & 2 deletions instrumentation/afl-llvm-pass.so.cc
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ bool AFLCoverage::runOnModule(Module &M) {
#endif
{

// load the context ID of the previous function and write to to a
// load the context ID of the previous function and write to a
// local variable on the stack
LoadInst *PrevCtxLoad = IRB.CreateLoad(
#if LLVM_VERSION_MAJOR >= 14
Expand Down Expand Up @@ -634,7 +634,7 @@ bool AFLCoverage::runOnModule(Module &M) {

/* There is a problem with Ubuntu 18.04 and llvm 6.0 (see issue #63).
The inline function successors() is not inlined and also not found at runtime
:-( As I am unable to detect Ubuntu18.04 heree, the next best thing is to
:-( As I am unable to detect Ubuntu18.04 here, the next best thing is to
disable this optional optimization for LLVM 6.0.0 and Linux */
#if !(LLVM_VERSION_MAJOR == 6 && LLVM_VERSION_MINOR == 0) || !defined __linux__
// only instrument if this basic block is the destination of a previous
Expand Down
12 changes: 9 additions & 3 deletions src/afl-forkserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -615,15 +615,21 @@ void afl_fsrv_start(afl_forkserver_t *fsrv, char **argv,

if (getenv("AFL_NYX_AUX_SIZE") != NULL) {

fsrv->nyx_aux_string_len = atoi(getenv("AFL_NYX_AUX_SIZE"));

if (fsrv->nyx_handlers->nyx_config_set_aux_buffer_size(
nyx_config, atoi(getenv("AFL_NYX_AUX_SIZE"))) != 1) {
nyx_config, fsrv->nyx_aux_string_len) != 1) {

NYX_PRE_FATAL(fsrv,
"Invalid AFL_NYX_AUX_SIZE value set (must be a multiple "
"of 4096) ...");

}

} else {

fsrv->nyx_aux_string_len = 0x1000;

}

if (getenv("AFL_NYX_REUSE_SNAPSHOT") != NULL) {
Expand Down Expand Up @@ -697,8 +703,8 @@ void afl_fsrv_start(afl_forkserver_t *fsrv, char **argv,
fsrv->nyx_handlers->nyx_option_set_timeout(fsrv->nyx_runner, 2, 0);
fsrv->nyx_handlers->nyx_option_apply(fsrv->nyx_runner);

fsrv->nyx_aux_string = malloc(0x1000);
memset(fsrv->nyx_aux_string, 0, 0x1000);
fsrv->nyx_aux_string = malloc(fsrv->nyx_aux_string_len);
memset(fsrv->nyx_aux_string, 0, fsrv->nyx_aux_string_len);

/* dry run */
fsrv->nyx_handlers->nyx_set_afl_input(fsrv->nyx_runner, "INIT", 4);
Expand Down
2 changes: 1 addition & 1 deletion src/afl-fuzz-bitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ save_if_interesting(afl_state_t *afl, void *mem, u32 len, u8 fault) {
if (unlikely(fd < 0)) { PFATAL("Unable to create '%s'", fn_log); }

u32 nyx_aux_string_len = afl->fsrv.nyx_handlers->nyx_get_aux_string(
afl->fsrv.nyx_runner, afl->fsrv.nyx_aux_string, 0x1000);
afl->fsrv.nyx_runner, afl->fsrv.nyx_aux_string, afl->fsrv.nyx_aux_string_len);

ck_write(fd, afl->fsrv.nyx_aux_string, nyx_aux_string_len, fn_log);
close(fd);
Expand Down

0 comments on commit eaa6a17

Please sign in to comment.