Skip to content

Commit

Permalink
Use indirect system calls in the mmap malloc hooks.
Browse files Browse the repository at this point in the history
sys_{mmap|munmap|mremap}(...) calls are replaced with
syscall(SYS_{mmap|munmap|mremap}, ...).
  • Loading branch information
Gabriel Marin authored and alk committed Aug 5, 2018
1 parent 3af509d commit 73ee9b1
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/malloc_hook_mmap_linux.h 100755 → 100644
Expand Up @@ -61,7 +61,7 @@
static inline void* do_mmap64(void *start, size_t length,
int prot, int flags,
int fd, __off64_t offset) __THROW {
return sys_mmap(start, length, prot, flags, fd, offset);
return (void*)syscall(SYS_mmap, start, length, prot, flags, fd, offset);
}

#define MALLOC_HOOK_HAVE_DO_MMAP64 1
Expand Down Expand Up @@ -189,7 +189,7 @@ extern "C" int munmap(void* start, size_t length) __THROW {
MallocHook::InvokeMunmapHook(start, length);
int result;
if (!MallocHook::InvokeMunmapReplacement(start, length, &result)) {
result = sys_munmap(start, length);
result = syscall(SYS_munmap, start, length);
}
return result;
}
Expand All @@ -200,7 +200,8 @@ extern "C" void* mremap(void* old_addr, size_t old_size, size_t new_size,
va_start(ap, flags);
void *new_address = va_arg(ap, void *);
va_end(ap);
void* result = sys_mremap(old_addr, old_size, new_size, flags, new_address);
void* result = (void*)syscall(SYS_mremap, old_addr, old_size, new_size, flags,
new_address);
MallocHook::InvokeMremapHook(result, old_addr, old_size, new_size, flags,
new_address);
return result;
Expand Down

0 comments on commit 73ee9b1

Please sign in to comment.