Skip to content

Commit 27333f9

Browse files
authored
libafl_bolts fix potentially unaligned ucontexts in signal handler (#1520)
When entering a signal handler, the ucontext_t is not necessarily 0x10-aligned, so we need to use read_unaligned instead of dereferencing.
1 parent 6d0d4e2 commit 27333f9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

libafl_bolts/src/os/unix_signals.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,11 @@ unsafe fn handle_signal(sig: c_int, info: siginfo_t, void: *mut c_void) {
390390
None => return,
391391
}
392392
};
393-
handler.handle(*signal, info, &mut *(void as *mut ucontext_t));
393+
handler.handle(
394+
*signal,
395+
info,
396+
&mut ptr::read_unaligned(void as *mut ucontext_t),
397+
);
394398
}
395399

396400
/// Setup signal handlers in a somewhat rusty way.

0 commit comments

Comments
 (0)