LibAFL icon indicating copy to clipboard operation
LibAFL copied to clipboard

Rewrite InProcessExecutors

Open tokatoka opened this issue 11 months ago • 6 comments

  • We should use builder pattern instead of current constructors that has 90% same code
  • Redesign crash, timeout hooks.

tokatoka avatar Jan 21 '25 17:01 tokatoka

Can we change this to "rewrite executors"? There is too much technical debt here.

addisoncrump avatar Jan 21 '25 20:01 addisoncrump

While we're at it, I'm not sure why run_target gets a reference to the Fuzzer. Last I checked, this was only used in some InProcessExecutors to retrieve observers, and I think you already have/can get a reference to those by directly passing the observers to the executor during creation. This is just a cyclical dependency, which is never great. Stuff like passing self to a function on another struct raises some alarm bells for me:

https://github.com/AFLplusplus/LibAFL/blob/c5b7c7c23514c79c5b5df50d6c577b2d23fec430/libafl/src/fuzzer/mod.rs#L936

riesentoaster avatar Jan 23 '25 20:01 riesentoaster

While we're at it, I'm not sure why run_target gets a reference to the Fuzzer

this is for crash handler. When you crash in a inproc handler, you have to continue execution from a signal handler. This signal handler has to know the pointer to 4 things, the executor, the fuzzer, the state, and the event manager.

We write the pointer to these object before executions, so we need the references.

Last I checked, this was only used in some InProcessExecutors to retrieve observers, and I think you already have/can get a reference to those by directly passing the observers to the executor during creation.

In the crash handler, we need to get fuzzer.objectives() so that's why we need fuzzer.

tokatoka avatar Jan 24 '25 22:01 tokatoka

In the crash handler, we need to get fuzzer.objectives() so that's why we need fuzzer.

The only thing ever needed from the fuzzer are the objectives, right? In that case: Why not just pass the OT instead of the entire fuzzer?

riesentoaster avatar Jan 24 '25 22:01 riesentoaster

So I've tried it, and at least the libafl crate builds: #2892

riesentoaster avatar Jan 25 '25 14:01 riesentoaster

Alright, it works. Ready to merge from my side.

This doesn't mean this issue is to be closed, but at least the executors are a bit more disentangled from fuzzer.

riesentoaster avatar Jan 25 '25 18:01 riesentoaster