File tree Expand file tree Collapse file tree 3 files changed +16
-16
lines changed
source/loader/layers/sanitizer Expand file tree Collapse file tree 3 files changed +16
-16
lines changed Original file line number Diff line number Diff line change 14
14
#include " asan_interceptor.hpp"
15
15
#include " ur_sanitizer_layer.hpp"
16
16
17
- #include < dlfcn.h>
18
-
19
17
namespace ur_sanitizer_layer {
20
18
21
19
namespace {
@@ -365,20 +363,7 @@ ur_result_t SanitizerInterceptor::enqueueMemSetShadow(
365
363
366
364
// Poison shadow memory outside of asan runtime is not allowed, so we
367
365
// need to avoid memset's call from being intercepted.
368
- static void *memset_ptr = []() {
369
- void *handle = dlopen (" libc.so.6" , RTLD_LAZY);
370
- if (!handle) {
371
- context.logger .error (" dlopen failed: {}" , dlerror ());
372
- return (void *)nullptr ;
373
- }
374
- void *ptr = dlsym (handle, " memset" );
375
- if (!ptr) {
376
- context.logger .error (" dlsym failed: {}" , dlerror ());
377
- return (void *)nullptr ;
378
- }
379
- return ptr;
380
- }();
381
-
366
+ static void *memset_ptr = GetMemFunctionPointer (" memset" );
382
367
assert (nullptr != memset_ptr);
383
368
((void *(*)(void *, int , size_t ))memset_ptr)(
384
369
(void *)ShadowBegin, Value, ShadowEnd - ShadowBegin + 1 );
Original file line number Diff line number Diff line change @@ -105,4 +105,6 @@ bool SetupShadowMem();
105
105
106
106
bool DestroyShadowMem ();
107
107
108
+ void *GetMemFunctionPointer (const char *);
109
+
108
110
} // namespace ur_sanitizer_layer
Original file line number Diff line number Diff line change 13
13
14
14
#include " common.hpp"
15
15
#include < asm/param.h>
16
+ #include < dlfcn.h>
16
17
#include < sys/mman.h>
17
18
18
19
extern " C" __attribute__((weak)) void __asan_init (void );
@@ -67,4 +68,16 @@ bool DestroyShadowMem() {
67
68
return true ;
68
69
}
69
70
71
+ void *GetMemFunctionPointer (const char *FuncName) {
72
+ void *handle = dlopen (" libc.so.6" , RTLD_LAZY);
73
+ if (!handle) {
74
+ return (void *)nullptr ;
75
+ }
76
+ void *ptr = dlsym (handle, FuncName);
77
+ if (!ptr) {
78
+ return (void *)nullptr ;
79
+ }
80
+ return ptr;
81
+ }
82
+
70
83
} // namespace ur_sanitizer_layer
You can’t perform that action at this time.
0 commit comments