LibAFL
LibAFL copied to clipboard
Qemu helpers & hooks refactoring
It's a first draft addressing issue #1985 and PR #1784.
Main changes of this PR:
- Rename Helper into Tool, so
QemuHelperbecomesEmulatorTool,QemuHelperTuplebecomesEmulatorToolTuple, etc... - Hooks have been separated into a low-level and high-level part, like for QEMU:
qemu/hooks.rscontains the low-level (stateless in the rust part) structQemuHooksandemu/hooks.rsthe low-level (with a rust state) counterpart,EmulatorHooksandEmulatorTools. - The high-level static hook variables have been centralized in the
EmulatorHooksstruct. - A lot of hook-related types now have dedicated names for readability (check the
create_hook_typesmacro) -
EmulatorToolsownsEmulatorToolTuple, andEmulatorownsEmulatorTools. - The Qemu Executor now contains a ref to
Emulator, notQemuHooks. The Stateful Executor now gives access toEmulatoras the second argument of the harness (still through the state, I need to change this) (check theqemu_systemmodeclassic example to see how it changes) - And a lot of smaller changes I probably forgot.
What remains to do:
- [ ] We still need to decide on a fitting name for
Emulatorthat represents the fact it's a high level abstraction ofQemu. - [ ] Not sure if we should call the
EmulatorToolTuplecallbacks in the executor or in the emulator run function. For now I kept it in Executor as it was before, we can easily move this now sinceEmulatorowns the tuple. - [ ] Change the
Ebound toEHbound for exit handlers to avoid the collision with the Executor generic. - [ ] Change the
QTbound toET(orETT?) to keep consistent withEmulatorToolTuple. Didn't do it yet to confirmEmulatorToolis a correct name. - [ ] Should we make
StatefulQemuExecutorthe new defaultQemuExecutorwith this new organization? Since it gives access toEmulator, it sounds like something we always want, even ifEmulatoris an empty shell only instantiated to use QEMU low-level API. - [ ] Revamp of the
Emulatorbuilder.TypedBuilderhas some flaws that make it unusable with generic members. We now need it to work correctly sinceEmulatorwill most likely be used everywhere.
i guess https://github.com/AFLplusplus/LibAFL/pull/1784 is superseded by this, closing
i'll merge the PR in its current state. There could be other things to add, but i believe it's already big enough like this. let's address the other points in separate PRs.