Skip to content

Commit 987f153

Browse files
committed
[msan] Fix sigaltstack false positive.
struct stack_t on Linux x86_64 has internal padding which may be left uninitialized. The check should be replaced with multiple checks for individual fields of the struct. For now, remove the check altogether.
1 parent 2b4027f commit 987f153

File tree

2 files changed

+1
-9
lines changed

2 files changed

+1
-9
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9735,9 +9735,6 @@ INTERCEPTOR(void, qsort_r, void *base, SIZE_T nmemb, SIZE_T size,
97359735
INTERCEPTOR(int, sigaltstack, void *ss, void *oss) {
97369736
void *ctx;
97379737
COMMON_INTERCEPTOR_ENTER(ctx, sigaltstack, ss, oss);
9738-
if (ss != nullptr) {
9739-
COMMON_INTERCEPTOR_READ_RANGE(ctx, ss, struct_stack_t_sz);
9740-
}
97419738
int r = REAL(sigaltstack)(ss, oss);
97429739
if (r == 0 && oss != nullptr) {
97439740
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, oss, struct_stack_t_sz);

compiler-rt/test/msan/sigaltstack.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clangxx_msan -O0 -g %s -o %t && not %run %t
1+
// RUN: %clangxx_msan -O0 -g %s -o %t && %run %t
22
//
33
#include <signal.h>
44
#include <assert.h>
@@ -11,10 +11,5 @@ int main(void) {
1111
assert(sigaltstack(nullptr, &old_ss) == 0);
1212
__msan_check_mem_is_initialized(&old_ss, sizeof(stack_t));
1313

14-
stack_t ss;
15-
sigaltstack(&ss, nullptr);
16-
// CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value
17-
// CHECK: in main {{.*}}sigaltstack.cpp:15
18-
1914
return 0;
2015
}

0 commit comments

Comments
 (0)