[PATCH] D145613: [hwasan] Suppress leaks from dlsym with hwasan+lsan just like with asan+lsan
Leonard Chan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 8 13:55:38 PST 2023
leonardchan created this revision.
leonardchan added reviewers: kstoimenov, vitalybuka.
leonardchan added a project: Sanitizers.
Herald added a subscriber: Enna1.
Herald added a project: All.
leonardchan requested review of this revision.
Herald added a subscriber: Sanitizers.
We should follow suite with how asan handles this now that lsan also works with hwasan.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D145613
Files:
compiler-rt/lib/hwasan/hwasan_allocation_functions.cpp
Index: compiler-rt/lib/hwasan/hwasan_allocation_functions.cpp
===================================================================
--- compiler-rt/lib/hwasan/hwasan_allocation_functions.cpp
+++ compiler-rt/lib/hwasan/hwasan_allocation_functions.cpp
@@ -24,6 +24,18 @@
struct DlsymAlloc : public DlSymAllocator<DlsymAlloc> {
static bool UseImpl() { return !hwasan_inited; }
+ static void OnAllocate(const void *ptr, uptr size) {
+# if CAN_SANITIZE_LEAKS
+ // Suppress leaks from dlerror(). Previously dlsym hack on global array was
+ // used by leak sanitizer as a root region.
+ __lsan_register_root_region(ptr, size);
+# endif
+ }
+ static void OnFree(const void *ptr, uptr size) {
+# if CAN_SANITIZE_LEAKS
+ __lsan_unregister_root_region(ptr, size);
+# endif
+ }
};
extern "C" {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145613.503506.patch
Type: text/x-patch
Size: 810 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230308/a3eb701a/attachment.bin>
More information about the llvm-commits
mailing list