Skip to content

Commit 2f80bb1

Browse files
committed
fix Frida
1 parent fc2739f commit 2f80bb1

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

libafl_bolts/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1276,8 +1276,10 @@ mod tests {
12761276
use std::{io::stdout, os::fd::AsRawFd};
12771277

12781278
unsafe { LIBAFL_RAWFD_LOGGER.fd = stdout().as_raw_fd() };
1279+
1280+
let libafl_rawfd_logger_fd = &raw const LIBAFL_RAWFD_LOGGER;
12791281
unsafe {
1280-
log::set_logger(&*&raw const LIBAFL_RAWFD_LOGGER).unwrap();
1282+
log::set_logger(&*libafl_rawfd_logger_fd).unwrap();
12811283
}
12821284
log::set_max_level(log::LevelFilter::Debug);
12831285
log::info!("Test");

libafl_frida/src/cmplog_rt.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,15 +218,15 @@ impl CmpLogRuntime {
218218
; stp x26, x27, [sp, #-0x10]!
219219
; stp x28, x29, [sp, #-0x10]!
220220
; stp x30, xzr, [sp, #-0x10]!
221-
; .dword 0xd53b4218u32 as i32 // mrs x24, nzcv
221+
; .u32 0xd53b4218_u32 // mrs x24, nzcv
222222
// jump to rust based population of the lists
223223
; mov x2, x0
224224
; adr x3, >done
225225
; ldr x4, >populate_lists
226226
; ldr x0, >self_addr
227227
; blr x4
228228
// restore the reg state before returning to the caller
229-
; .dword 0xd51b4218u32 as i32 // msr nzcv, x24
229+
; .u32 0xd51b4218_u32 // msr nzcv, x24
230230
; ldp x30, xzr, [sp], #0x10
231231
; ldp x28, x29, [sp], #0x10
232232
; ldp x26, x27, [sp], #0x10
@@ -244,9 +244,9 @@ impl CmpLogRuntime {
244244
; ldp x2, x3, [sp], #0x10
245245
; b >done
246246
; self_addr:
247-
; .qword core::ptr::from_mut(self) as *mut c_void as i64
247+
; .u64 core::ptr::from_mut(self) as *mut c_void as u64
248248
; populate_lists:
249-
; .qword CmpLogRuntime::populate_lists as *mut c_void as i64
249+
; .u64 CmpLogRuntime::populate_lists as *mut c_void as u64
250250
; done:
251251
);};
252252
}

libafl_frida/src/pthread_hook.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,17 @@ impl PreviousHook {
6363
unsafe impl Sync for PreviousHook {}
6464

6565
// TODO: This could use a RwLock as well
66+
/// The previous hook
6667
static mut PREVIOUS_HOOK: PreviousHook = PreviousHook(std::ptr::null());
6768

69+
/// The currently set hook
6870
static CURRENT_HOOK: RwLock<Option<PthreadIntrospectionHook>> = RwLock::new(None);
6971

72+
/// Get the pointer to the previous hook, mut
73+
fn previous_hook_ptr_mut() -> *mut PreviousHook {
74+
&raw mut PREVIOUS_HOOK
75+
}
76+
7077
extern "C" fn pthread_introspection_hook(
7178
event: libc::c_uint,
7279
thread: libc::pthread_t,
@@ -76,7 +83,7 @@ extern "C" fn pthread_introspection_hook(
7683
if let Some(ref hook) = *CURRENT_HOOK.read().unwrap() {
7784
hook(event.try_into().unwrap(), thread, addr, size);
7885
}
79-
unsafe { PREVIOUS_HOOK.dispatch(event, thread, addr, size) };
86+
unsafe { (*previous_hook_ptr_mut()).dispatch(event, thread, addr, size) };
8087
}
8188

8289
/// Closure type for `pthread_introspection` hooks.
@@ -159,7 +166,7 @@ where
159166
// Allow because we're sure this isn't from a different code generation unit.
160167
if !(prev).is_null() && prev != pthread_introspection_hook as _ {
161168
unsafe {
162-
PREVIOUS_HOOK.set(prev as *const pthread_introspection_hook_t);
169+
(*previous_hook_ptr_mut()).set(prev as *const pthread_introspection_hook_t);
163170
}
164171
}
165172
}
@@ -176,7 +183,9 @@ where
176183
/// # Safety
177184
/// Potential data race when if called at the same time as `install` or `reset` from another thread
178185
pub unsafe fn reset() {
179-
unsafe { PREVIOUS_HOOK.reset() };
186+
unsafe {
187+
(*previous_hook_ptr_mut()).reset();
188+
};
180189
}
181190

182191
/// The following tests fail if they are not run sequentially.

0 commit comments

Comments
 (0)