Skip to content

Commit

Permalink
i#3799: Fix leak and false trigger on DR reload (#3800)
Browse files Browse the repository at this point in the history
Adds ignoring of kernels labeling DR's .bss as "[heap]", to avoid
unnecessary reloading at startup.

Fixes failures to unmap the executable's headers on a reload.

Fixes #3799
  • Loading branch information
derekbruening authored Aug 22, 2019
1 parent 00ae95b commit 80d2bc8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions core/unix/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -1629,6 +1629,8 @@ dynamorio_lib_gap_empty(void)
while (memquery_iterator_next(&iter) && iter.vm_start < dr_end) {
if (iter.vm_start >= dr_start && iter.vm_end <= dr_end &&
iter.comment[0] != '\0' &&
/* i#3799: ignore the kernel labeling DR's .bss as "[heap]". */
strcmp(iter.comment, "[heap]") != 0 &&
strcmp(iter.comment, dynamorio_library_path) != 0) {
/* There's a non-anon mapping inside: probably vvar and/or vdso. */
res = false;
Expand Down Expand Up @@ -1877,6 +1879,7 @@ privload_early_inject(void **sp, byte *old_libdr_base, size_t old_libdr_size)
/* i#1227: on a conflict with the app (+ room for the brk): reload ourselves */
if (get_dynamorio_dll_start() < exe_end + APP_BRK_GAP &&
get_dynamorio_dll_end() > exe_map) {
elf_loader_destroy(&exe_ld);
reload_dynamorio(sp, exe_map, exe_end + APP_BRK_GAP);
ASSERT_NOT_REACHED();
}
Expand All @@ -1887,6 +1890,7 @@ privload_early_inject(void **sp, byte *old_libdr_base, size_t old_libdr_size)
* very often.
*/
if (!dynamorio_lib_gap_empty()) {
elf_loader_destroy(&exe_ld);
reload_dynamorio(sp, get_dynamorio_dll_start(), get_dynamorio_dll_end());
ASSERT_NOT_REACHED();
}
Expand Down

0 comments on commit 80d2bc8

Please sign in to comment.