-
-
Notifications
You must be signed in to change notification settings - Fork 293
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
Frida Refactor: Split FridaHelper into each Runtime #368
Conversation
I think I should split helper, and make a CoverageRuntime |
libafl_frida/src/helper.rs
Outdated
fn generate_maybe_log_blob(&mut self) -> Box<[u8]> { | ||
macro_rules! maybe_log{ | ||
($ops:ident) => {dynasm!($ops | ||
; .arch x64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don’t really need the macro, do we?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No 😉 we don't need macro
I plan to move this to CoverageRuntime.
Yes splitting out CoverageRuntime is a good idea. It might also be worth moving the |
Also it doesn’t look like you used your new function anywhere, did you? It should be called only once and the result cached. |
no, I can't use it yet. |
Cool. Makes sense. I’ll let you work. ;) |
This change already works on amd64 |
how about moving |
Good idea. Do you want to do it in this PR or in another? |
The fix would be simple. I would do it in this pr. |
Ok. Go ahead. |
Let me know when you want me to test on aarch64. |
This reverts commit c7afc78.
I come to feel that I should do these in seperate prs... |
so that I can track down my mistakes if I broke something. |
I checked building for aarch64. |
I would like to get this merged and work on remaining issues in other prs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few nitpicks... but otherwise lgtm!
libafl_frida/src/coverage_rt.rs
Outdated
|
||
pub struct CoverageRuntime { | ||
map: [u8; MAP_SIZE], | ||
previous_pc: [u64; 1], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this an array?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it was an array before ;)
but i'll fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Didn't realize... Yeah if you can fix...
libafl_frida/src/coverage_rt.rs
Outdated
self.generate_maybe_log_blob(); | ||
} | ||
|
||
pub fn map_ptr(&mut self) -> *mut u8 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this be map_ptr_mut
to stick to the normal rust conventions?
libafl_frida/src/coverage_rt.rs
Outdated
; ldr x2, #0x38 | ||
; ldr x4, [x2] | ||
; eor x4, x4, x0 | ||
; and x4, x4, 0xffff |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be MAP_SIZE - 1
instead of 0xffff
libafl_frida/src/coverage_rt.rs
Outdated
; stp x1, x2, [sp, -0x10]! | ||
; stp x3, x4, [sp, -0x10]! | ||
; ldr x1, >map_addr | ||
; ldr x2, #0x38 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be >previous_loc
I fixed all, but didn't test how aarch64 build goes with the change. |
I fixed a minor issue which was breaking aarch64 compilation, but running on aarch64 blows up for some reason. I'm debugging now. |
Can you maybe try to add the build to CI whole you do? |
It requires adding/installing an ndk... which I don't know how to do under CI in a way that won't be very time-expensive. |
We already build parts of it, see LibAFL/.github/workflows/build_and_test.yml Line 209 in 9ab8663
|
Hrm. I'll try to look into it. |
I observe that arm64 run is broken on main branch too. (with segmentation fault) |
mine fails at this
but I'm not turning asan on.... 🤔 |
I think the coverage is broken. Haven't had a moment to debug today... Hopefully will get to it a little later. |
I confirmed that this error already occurs back at f0daeb3 this commit, (just before amd64 asan) |
Is it possible that the machine you are running on doesn't have memory over-commit? |
Oh, ... it is possible. |
I don't think it's possible, they should be normal Linux OSses with normal configuration. BTW @tokatoka in case you are spawning instances mainly for libafl dev, let us know, I'm sure we have some leftover gsoc funds for that or something :) |
it's ok. |
Should I merge? |
no aarch64 run is broken, let's wait s1341 |
* dynasm maybe_log * create coverage_rt, trim helper * add * amd64 working * aarch64 instrumentation, untested * asan dir * Revert "asan dir" This reverts commit c7afc78. * non x86_64 fix * clippy * change * change * fix * Fix aarch64-linux-android build * Fix aarch64 execution * Fix fmt Co-authored-by: s1341 <github@shmarya.net>
This pr includes several frida refactoring
#307