Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HookId trait and types in libafl_qemu #1796

Merged
merged 7 commits into from
Feb 1, 2024

Conversation

rbran
Copy link
Contributor

@rbran rbran commented Jan 13, 2024

fix: #1795

This created HookType and add it to HookId, what allows the function remove_hook to call the proper libafl_qemu_sys::libafl_qemu_remove*_hook function for the received hook.

@andreafioraldi
Copy link
Member

Hi, thank you, hookid is WIP, the plan is to have a type for each hook (InstructionHookId, CmpHookId, PreSyscallHookId, etc...) implementing a trait with a removal method, something like HookId::remove(emu: &Emulator).
In this way, hooks id remain just a wrapper around u64 without taking additional space and they are much better for the type system.
If you want to adapt this PR in this way, I'll be happy to merge it.

@rbran rbran force-pushed the hook-types branch 3 times, most recently from 45e2fd6 to ac3f604 Compare January 16, 2024 15:48
@rbran
Copy link
Contributor Author

rbran commented Jan 16, 2024

Hi, thank you, hookid is WIP, the plan is to have a type for each hook (InstructionHookId, CmpHookId, PreSyscallHookId, etc...) implementing a trait with a removal method, something like HookId::remove(emu: &Emulator). In this way, hooks id remain just a wrapper around u64 without taking additional space and they are much better for the type system. If you want to adapt this PR in this way, I'll be happy to merge it.

I adapted the PR, now it uses a trait and specialized structs. NOTE the trait function is HookId::remove(&self, invalidate_block: bool) -> bool, the emulator reference is not required.

@andreafioraldi
Copy link
Member

ty!

@andreafioraldi andreafioraldi changed the title libafl_qemu fix remove_hook HookId trait and types in libafl_qemu Jan 16, 2024
@domenukk
Copy link
Member

This needs a cargo fmt.
@andreafioraldi merge?

@andreafioraldi andreafioraldi merged commit c96d103 into AFLplusplus:main Feb 1, 2024
@rbran rbran deleted the hook-types branch February 2, 2024 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Syscall hook can't be removed using remove_hook
3 participants