Skip to content

Commit 1851492

Browse files
authored
Merge pull request #1934 from yingcong-wu/yc/0806-exclude-shadow-from-coredump
[DeviceSanitizer] Exclude shadow memory from coredump file for CPU device.
2 parents 2af159d + d619bcd commit 1851492

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

source/loader/layers/sanitizer/asan_shadow_setup.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ ur_result_t SetupShadowMemory(uptr &ShadowBegin, uptr &ShadowEnd) {
2929
if (SHADOW_BEGIN == 0) {
3030
return UR_RESULT_ERROR_OUT_OF_HOST_MEMORY;
3131
}
32+
DontCoredumpRange(SHADOW_BEGIN, SHADOW_SIZE);
3233
SHADOW_END = SHADOW_BEGIN + SHADOW_SIZE;
3334
IsShadowMemInited = true;
3435
return UR_RESULT_SUCCESS;

source/loader/layers/sanitizer/common.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ bool IsInASanContext();
157157

158158
uptr MmapNoReserve(uptr Addr, uptr Size);
159159
bool Munmap(uptr Addr, uptr Size);
160+
bool DontCoredumpRange(uptr Addr, uptr Size);
160161

161162
void *GetMemFunctionPointer(const char *);
162163

source/loader/layers/sanitizer/linux/sanitizer_utils.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ uptr MmapNoReserve(uptr Addr, uptr Size) {
3737

3838
bool Munmap(uptr Addr, uptr Size) { return munmap((void *)Addr, Size) == 0; }
3939

40+
bool DontCoredumpRange(uptr Addr, uptr Size) {
41+
Size = RoundUpTo(Size, EXEC_PAGESIZE);
42+
Addr = RoundDownTo(Addr, EXEC_PAGESIZE);
43+
return madvise((void *)Addr, Size, MADV_DONTDUMP) == 0;
44+
}
45+
4046
void *GetMemFunctionPointer(const char *FuncName) {
4147
void *handle = dlopen(LIBC_SO, RTLD_LAZY | RTLD_NOLOAD);
4248
if (!handle) {

0 commit comments

Comments
 (0)