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

More Nyx hypercalls supported in libafl qemu. add tests for filters. #2825

Merged
merged 17 commits into from
Jan 13, 2025

Conversation

rmalmain
Copy link
Member

@rmalmain rmalmain commented Jan 9, 2025

No description provided.

fixed some hypercalls behavior.
filters fixes.
added generic read / write to qemu memory
// let mut val_buf: [u8; size_of::<T>()] = [0; size_of::<T>()];

let mut val_buf: Vec<u8> = Vec::with_capacity(size_of::<T>());
unsafe {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For unsafe blocks (at least if possible), it'd be good if we started adding safety comments like

// # Safety
// The vector's capacity is f the same size. The vector will be filled in `read_mem` below.

This will make it easier to spot bugs later and is good practice in general.

@@ -1259,6 +1259,8 @@ where
impl<ET, S> Drop for EmulatorModules<ET, S> {
fn drop(&mut self) {
// Make the global pointer null at drop time
// # Safety
// There can only be one EmulatorModules.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is racey / not guarded by locks or mutexes though, right? So not really safe..

(new should probably be marked unsafe in this case)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EmulatorModules is not public (only pub(super)), so there should not be race conditions there.
it is only called by Emulator::new, which can only be called once.
i can mark it as unsafe to make it clear

@@ -103,21 +103,15 @@ where

/// High-level `Emulator` modules, using `QemuHooks`.
#[derive(Debug)]
pub struct EmulatorModules<ET, S>
where
Copy link
Member

@tokatoka tokatoka Jan 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! please continue removing this!
if you merged the latest main then nothing will needs UsesInput except for EventManager

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, i'll remove the remaining part in next patch

@rmalmain rmalmain merged commit d8460d1 into main Jan 13, 2025
104 checks passed
@rmalmain rmalmain deleted the nyx_continue_filters branch January 13, 2025 16:32
mzfr pushed a commit to mzfr/LibAFL that referenced this pull request Jan 19, 2025
…FLplusplus#2825)

* more nyx hypercalls implemented, among them:
- panic hypercall
- range filtering hypercall

* fixed some nyx hypercalls behavior.

* added generic read / write to qemu memory

* port linux kernel example to also have nyx API, add better filtering as well.

* make nyx api structs volatile to avoid optimization issues

* Introduce a method create a Vec in place, using a closure.

* use new vec_init function in relevant places.

* removed unused unsafe keywork

* add more allocated memory r/w callbacks

* add more safety notes

* move emulator hooks to separate struct

* update QEMU version
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.

3 participants