@@ -122,7 +122,9 @@ define_run_client!(state, mgr, fuzzer_dir, core_id, opt, is_main_node, {
122
122
let mut shmem = shmem_provider
123
123
. new_shmem( opt. map_size. unwrap_or( AFL_DEFAULT_MAP_SIZE ) )
124
124
. unwrap( ) ;
125
- shmem. write_to_env( SHMEM_ENV_VAR ) . unwrap( ) ;
125
+ unsafe {
126
+ shmem. write_to_env( SHMEM_ENV_VAR ) . unwrap( ) ;
127
+ }
126
128
let shmem_buf = shmem. as_slice_mut( ) ;
127
129
128
130
// If we are in Nyx Mode, we need to use a different map observer.
@@ -300,14 +302,17 @@ define_run_client!(state, mgr, fuzzer_dir, core_id, opt, is_main_node, {
300
302
301
303
// Set LD_PRELOAD (Linux) && DYLD_INSERT_LIBRARIES (OSX) for target.
302
304
if let Some ( preload_env) = & opt. afl_preload {
303
- std:: env:: set_var( "LD_PRELOAD" , preload_env) ;
304
- std:: env:: set_var( "DYLD_INSERT_LIBRARIES" , preload_env) ;
305
+ // TODO: Audit that the environment access only happens in single-threaded code.
306
+ unsafe { std:: env:: set_var( "LD_PRELOAD" , preload_env) } ;
307
+ // TODO: Audit that the environment access only happens in single-threaded code.
308
+ unsafe { std:: env:: set_var( "DYLD_INSERT_LIBRARIES" , preload_env) } ;
305
309
}
306
310
307
311
// Insert appropriate shared libraries if frida_mode
308
312
if opt. frida_mode {
309
313
if opt. frida_asan {
310
- std:: env:: set_var( "ASAN_OPTIONS" , "detect_leaks=false" ) ;
314
+ // TODO: Audit that the environment access only happens in single-threaded code.
315
+ unsafe { std:: env:: set_var( "ASAN_OPTIONS" , "detect_leaks=false" ) } ;
311
316
}
312
317
let frida_bin = find_afl_binary( "afl-frida-trace.so" , Some ( opt. executable. clone( ) ) ) ?
313
318
. display( )
@@ -317,8 +322,10 @@ define_run_client!(state, mgr, fuzzer_dir, core_id, opt, is_main_node, {
317
322
} else {
318
323
frida_bin
319
324
} ;
320
- std:: env:: set_var( "LD_PRELOAD" , & preload) ;
321
- std:: env:: set_var( "DYLD_INSERT_LIBRARIES" , & preload) ;
325
+ // TODO: Audit that the environment access only happens in single-threaded code.
326
+ unsafe { std:: env:: set_var( "LD_PRELOAD" , & preload) } ;
327
+ // TODO: Audit that the environment access only happens in single-threaded code.
328
+ unsafe { std:: env:: set_var( "DYLD_INSERT_LIBRARIES" , & preload) } ;
322
329
}
323
330
#[ cfg( feature = "nyx" ) ]
324
331
let mut executor = {
@@ -456,7 +463,7 @@ define_run_client!(state, mgr, fuzzer_dir, core_id, opt, is_main_node, {
456
463
// We only run cmplog on the main node
457
464
let cmplog_executable_path = match & opt. cmplog {
458
465
None => "-" ,
459
- Some ( ref p) => match p. as_str( ) {
466
+ Some ( p) => match p. as_str( ) {
460
467
"0" => opt. executable. to_str( ) . unwrap( ) ,
461
468
_ => p,
462
469
} ,
@@ -468,7 +475,9 @@ define_run_client!(state, mgr, fuzzer_dir, core_id, opt, is_main_node, {
468
475
let mut cmplog_shmem = shmem_provider. uninit_on_shmem:: <AFLppCmpLogMap >( ) . unwrap( ) ;
469
476
470
477
// Let the Forkserver know the CmpLog shared memory map ID.
471
- cmplog_shmem. write_to_env( "__AFL_CMPLOG_SHM_ID" ) . unwrap( ) ;
478
+ unsafe {
479
+ cmplog_shmem. write_to_env( "__AFL_CMPLOG_SHM_ID" ) . unwrap( ) ;
480
+ }
472
481
let cmpmap = unsafe { OwnedRefMut :: from_shmem( & mut cmplog_shmem) } ;
473
482
474
483
// Create the CmpLog observer.
0 commit comments