Since glibc 2.34, dlsym does
- malloc 1
- malloc 2
- free pointer from malloc 1
- free pointer from malloc 2
These sequence was not handled by trivial dlsym hack.
This fixes https://bugs.llvm.org/show_bug.cgi?id=52278
Paths
| Differential D112588
[sanitizer] Switch dlsym hack to internal_allocator ClosedPublic Authored by vitalybuka on Oct 26 2021, 6:03 PM.
Details Summary Since glibc 2.34, dlsym does
These sequence was not handled by trivial dlsym hack. This fixes https://bugs.llvm.org/show_bug.cgi?id=52278
Diff Detail
Event Timeline
vitalybuka added inline comments.
This revision now requires changes to proceed.Nov 3 2021, 12:36 PM
This revision now requires review to proceed.Nov 3 2021, 5:41 PM vitalybuka retitled this revision from [sanitizer] Avoid memory leak from dlsym in glibc 2.34 to [sanitizer] Switch to dlsym hack to internal_allocator.Nov 10 2021, 6:10 PM vitalybuka retitled this revision from [sanitizer] Switch to dlsym hack to internal_allocator to [sanitizer] Switch dlsym hack to internal_allocator. This revision is now accepted and ready to land.Nov 11 2021, 3:27 PM
This revision was landed with ongoing or failed builds.Nov 12 2021, 4:11 PM Closed by commit rGcb0e14ce6dcd: [sanitizer] Switch dlsym hack to internal_allocator (authored by vitalybuka). · Explain Why This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 386978 compiler-rt/lib/asan/asan_malloc_linux.cpp
compiler-rt/lib/dfsan/dfsan_interceptors.cpp
compiler-rt/lib/hwasan/hwasan_allocation_functions.cpp
compiler-rt/lib/lsan/lsan_common.h
compiler-rt/lib/lsan/lsan_interceptors.cpp
compiler-rt/lib/memprof/memprof_malloc_linux.cpp
compiler-rt/lib/msan/msan_interceptors.cpp
compiler-rt/lib/sanitizer_common/CMakeLists.txt
compiler-rt/lib/sanitizer_common/sanitizer_allocator_dlsym.h
compiler-rt/lib/sanitizer_common/sanitizer_malloc_mac.inc
|
This one is annoying. To keep behavioral closer to original I use root regions.
What I see is that "dlsym hack" allocations contains pointers to later regular dlerror allocations.
it would be nice to investigate if dlerror is special. If so we can remove regions in followup patches
and add dlerror interceptors to lsan and asan.