Skip to content

Commit

Permalink
Properly handle mmap calls without any protection mask:
Browse files Browse the repository at this point in the history
Newly created heap (alloc_new_heap) is created by glibc without any protection flags
and they are adjusted by `mprotect` once the `mmap` succeeds:
https://github.com/bminor/glibc/blob/master/malloc/arena.c#L404-L441

Fixes: fasterthanlime#8
  • Loading branch information
marxin committed Jan 31, 2024
1 parent 9b864e1 commit de28934
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion crates/mevi/src/tracer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,11 @@ impl Tracee {

if fd == -1
&& addr_in == 0
&& prot_flags.contains(ProtFlags::PROT_READ | ProtFlags::PROT_WRITE)
// Newly created heap (alloc_new_heap) is created by glibc without any protection flags
// and they are adjusted by `mprotect` once the `mmap` succeeds:
// https://github.com/bminor/glibc/blob/master/malloc/arena.c#L404-L441
// && prot_flags.contains(ProtFlags::PROT_READ | ProtFlags::PROT_WRITE)
//
// && map_flags.contains(MapFlags::MAP_PRIVATE | MapFlags::MAP_ANONYMOUS)
&& map_flags.contains(MapFlags::MAP_ANONYMOUS)
{
Expand Down

0 comments on commit de28934

Please sign in to comment.