Skip to content

Commit

Permalink
Remove regions that have ever had PR_SET_VMA_ANON_NAME called on them…
Browse files Browse the repository at this point in the history
… from always_free_address_space.
  • Loading branch information
khuey committed Aug 18, 2024
1 parent 03f6446 commit 172b24c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/ReplaySession.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ const ReplaySession::MemoryRanges& ReplaySession::always_free_address_space(
auto frame = tmp_reader.read_frame();
auto event = frame.event();
// If a region was ever mprotected to something that's not PROT_NONE,
// we need to delete it as well.
// or had PR_SET_VMA_ANON_NAME called on it, we need to delete it as well.
if (event.is_syscall_event()) {
auto syscall_event = event.Syscall();
if (is_mprotect_syscall(syscall_event.number, syscall_event.arch()) ||
Expand All @@ -117,6 +117,14 @@ const ReplaySession::MemoryRanges& ReplaySession::always_free_address_space(
delete_range(*result, MemoryRange(start, size));
}
}
if (is_prctl_syscall(syscall_event.number, syscall_event.arch())) {
auto regs = frame.regs();
if (regs.arg2() == PR_SET_VMA_ANON_NAME) {
remote_ptr<void> start = regs.arg3();
size_t size = regs.arg4();
delete_range(*result, MemoryRange(start, size));
}
}
} else if (event.is_syscallbuf_flush_event()) {
auto syscallbuf_flush_event = event.SyscallbufFlush();
for (auto& record : syscallbuf_flush_event.mprotect_records) {
Expand Down

0 comments on commit 172b24c

Please sign in to comment.