-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[DFSan] [compiler-rt] leave BufferedStackTrace uninit #102252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
fmayer
wants to merge
3
commits into
users/fmayer/spr/main.dfsan-compiler-rt-leave-bufferedstacktrace-uninit
from
users/fmayer/spr/dfsan-compiler-rt-leave-bufferedstacktrace-uninit
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Created using spr 1.3.4
@llvm/pr-subscribers-compiler-rt-sanitizer Author: Florian Mayer (fmayer) ChangesOtherwise we have to memset 2040 bytes (255 * 8) for each call Full diff: https://github.com/llvm/llvm-project/pull/102252.diff 3 Files Affected:
diff --git a/compiler-rt/lib/dfsan/dfsan.cpp b/compiler-rt/lib/dfsan/dfsan.cpp
index 302e3c3032ac5..360288cb88f34 100644
--- a/compiler-rt/lib/dfsan/dfsan.cpp
+++ b/compiler-rt/lib/dfsan/dfsan.cpp
@@ -195,7 +195,7 @@ static dfsan_origin GetOriginIfTainted(uptr addr, uptr size) {
// random freezes in forking applications as well as in signal handlers.
// DFSan supports only Linux. So we do not restrict the store context size.
#define GET_STORE_STACK_TRACE_PC_BP(pc, bp) \
- BufferedStackTrace stack; \
+ UNINITIALIZED BufferedStackTrace stack; \
stack.Unwind(pc, bp, nullptr, true, flags().store_context_size);
#define PRINT_CALLER_STACK_TRACE \
diff --git a/compiler-rt/lib/dfsan/dfsan_allocator.cpp b/compiler-rt/lib/dfsan/dfsan_allocator.cpp
index 682df8c6e0346..81ea91580a989 100644
--- a/compiler-rt/lib/dfsan/dfsan_allocator.cpp
+++ b/compiler-rt/lib/dfsan/dfsan_allocator.cpp
@@ -95,13 +95,13 @@ static void *DFsanAllocate(uptr size, uptr alignment, bool zeroise) {
size);
return nullptr;
}
- BufferedStackTrace stack;
+ UNINITIALIZED BufferedStackTrace stack;
ReportAllocationSizeTooBig(size, max_malloc_size, &stack);
}
if (UNLIKELY(IsRssLimitExceeded())) {
if (AllocatorMayReturnNull())
return nullptr;
- BufferedStackTrace stack;
+ UNINITIALIZED BufferedStackTrace stack;
ReportRssLimitExceeded(&stack);
}
DFsanThread *t = GetCurrentThread();
@@ -118,7 +118,7 @@ static void *DFsanAllocate(uptr size, uptr alignment, bool zeroise) {
SetAllocatorOutOfMemory();
if (AllocatorMayReturnNull())
return nullptr;
- BufferedStackTrace stack;
+ UNINITIALIZED BufferedStackTrace stack;
ReportOutOfMemory(size, &stack);
}
Metadata *meta =
@@ -175,7 +175,7 @@ void *DFsanCalloc(uptr nmemb, uptr size) {
if (UNLIKELY(CheckForCallocOverflow(size, nmemb))) {
if (AllocatorMayReturnNull())
return nullptr;
- BufferedStackTrace stack;
+ UNINITIALIZED BufferedStackTrace stack;
ReportCallocOverflow(nmemb, size, &stack);
}
return DFsanAllocate(nmemb * size, sizeof(u64), true /*zeroise*/);
@@ -232,7 +232,7 @@ void *dfsan_reallocarray(void *ptr, uptr nmemb, uptr size) {
errno = errno_ENOMEM;
if (AllocatorMayReturnNull())
return nullptr;
- BufferedStackTrace stack;
+ UNINITIALIZED BufferedStackTrace stack;
ReportReallocArrayOverflow(nmemb, size, &stack);
}
return dfsan_realloc(ptr, nmemb * size);
@@ -249,7 +249,7 @@ void *dfsan_pvalloc(uptr size) {
errno = errno_ENOMEM;
if (AllocatorMayReturnNull())
return nullptr;
- BufferedStackTrace stack;
+ UNINITIALIZED BufferedStackTrace stack;
ReportPvallocOverflow(size, &stack);
}
// pvalloc(0) should allocate one page.
@@ -262,7 +262,7 @@ void *dfsan_aligned_alloc(uptr alignment, uptr size) {
errno = errno_EINVAL;
if (AllocatorMayReturnNull())
return nullptr;
- BufferedStackTrace stack;
+ UNINITIALIZED BufferedStackTrace stack;
ReportInvalidAlignedAllocAlignment(size, alignment, &stack);
}
return SetErrnoOnNull(DFsanAllocate(size, alignment, false /*zeroise*/));
@@ -273,7 +273,7 @@ void *dfsan_memalign(uptr alignment, uptr size) {
errno = errno_EINVAL;
if (AllocatorMayReturnNull())
return nullptr;
- BufferedStackTrace stack;
+ UNINITIALIZED BufferedStackTrace stack;
ReportInvalidAllocationAlignment(alignment, &stack);
}
return SetErrnoOnNull(DFsanAllocate(size, alignment, false /*zeroise*/));
@@ -283,7 +283,7 @@ int dfsan_posix_memalign(void **memptr, uptr alignment, uptr size) {
if (UNLIKELY(!CheckPosixMemalignAlignment(alignment))) {
if (AllocatorMayReturnNull())
return errno_EINVAL;
- BufferedStackTrace stack;
+ UNINITIALIZED BufferedStackTrace stack;
ReportInvalidPosixMemalignAlignment(alignment, &stack);
}
void *ptr = DFsanAllocate(size, alignment, false /*zeroise*/);
diff --git a/compiler-rt/lib/dfsan/dfsan_new_delete.cpp b/compiler-rt/lib/dfsan/dfsan_new_delete.cpp
index 7ac906e81077d..4482e22951040 100644
--- a/compiler-rt/lib/dfsan/dfsan_new_delete.cpp
+++ b/compiler-rt/lib/dfsan/dfsan_new_delete.cpp
@@ -30,14 +30,14 @@ enum class align_val_t : size_t {};
#define OPERATOR_NEW_BODY(nothrow) \
void *res = dfsan_malloc(size); \
if (!nothrow && UNLIKELY(!res)) { \
- BufferedStackTrace stack; \
+ UNINITIALIZED BufferedStackTrace stack; \
ReportOutOfMemory(size, &stack); \
} \
return res
#define OPERATOR_NEW_BODY_ALIGN(nothrow) \
void *res = dfsan_memalign((uptr)align, size); \
if (!nothrow && UNLIKELY(!res)) { \
- BufferedStackTrace stack; \
+ UNINITIALIZED BufferedStackTrace stack; \
ReportOutOfMemory(size, &stack); \
} \
return res;
|
vitalybuka
approved these changes
Aug 7, 2024
fmayer
added a commit
that referenced
this pull request
Aug 7, 2024
Otherwise we have to memset 2040 bytes (255 * 8) for each call Pull Request: #102252
fmayer
added a commit
to fmayer/llvm-project
that referenced
this pull request
Sep 13, 2024
Otherwise we have to memset 2040 bytes (255 * 8) for each call Pull Request: llvm#102252
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Otherwise we have to memset 2040 bytes (255 * 8) for each call