Skip to content

Commit d20f3a8

Browse files
committed
fix dumb mistake
1 parent fdc2d52 commit d20f3a8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/tools/miri/src/shims/trace/parent.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ fn handle_segfault(
555555
// - Continue
556556

557557
// Ensure the stack is properly zeroed out!
558-
for a in (ch_stack..ch_stack.strict_add(page_size)).step_by(ARCH_WORD_SIZE) {
558+
for a in (ch_stack..ch_stack.strict_add(FAKE_STACK_SIZE)).step_by(ARCH_WORD_SIZE) {
559559
ptrace::write(pid, std::ptr::with_exposed_provenance_mut(a), 0).unwrap();
560560
}
561561

@@ -601,6 +601,11 @@ fn handle_segfault(
601601
// Also, don't let it continue with unprotected memory if something errors!
602602
let _ = wait::waitid(wait::Id::Pid(pid), WAIT_FLAGS).map_err(|_| ExecError::Died(None))?;
603603

604+
// Zero out again to be safe
605+
for a in (ch_stack..ch_stack.strict_add(FAKE_STACK_SIZE)).step_by(ARCH_WORD_SIZE) {
606+
ptrace::write(pid, std::ptr::with_exposed_provenance_mut(a), 0).unwrap();
607+
}
608+
604609
// Save registers and grab the bytes that were executed. This would
605610
// be really nasty if it was a jump or similar but those thankfully
606611
// won't do memory accesses and so can't trigger this!

0 commit comments

Comments
 (0)