Skip to content

Commit

Permalink
Os(Linux): Make trap_thread set protections appropriately
Browse files Browse the repository at this point in the history
  • Loading branch information
cursey committed Mar 17, 2024
1 parent dd08b6b commit 4420034
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/os.linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,11 @@ SystemInfo system_info() {

void trap_threads([[maybe_unused]] uint8_t* from, [[maybe_unused]] uint8_t* to, [[maybe_unused]] size_t len,
const std::function<void()>& run_fn) {
auto from_protect = vm_protect(from, len, VM_ACCESS_RWX).value_or(0);
auto to_protect = vm_protect(to, len, VM_ACCESS_RWX).value_or(0);
run_fn();
vm_protect(to, len, to_protect);
vm_protect(from, len, from_protect);
}

void fix_ip([[maybe_unused]] ThreadContext ctx, [[maybe_unused]] uint8_t* old_ip, [[maybe_unused]] uint8_t* new_ip) {
Expand Down

0 comments on commit 4420034

Please sign in to comment.