[compiler-rt] r235581 - tsan: support setuid call
Dmitry Vyukov
dvyukov at google.com
Thu Apr 23 02:33:28 PDT 2015
Author: dvyukov
Date: Thu Apr 23 04:33:27 2015
New Revision: 235581
URL: http://llvm.org/viewvc/llvm-project?rev=235581&view=rev
Log:
tsan: support setuid call
Currently the call hangs because the background thread
does not handle SIGSETXID signal.
Added:
compiler-rt/trunk/test/tsan/setuid.c
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc?rev=235581&r1=235580&r2=235581&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc Thu Apr 23 04:33:27 2015
@@ -915,6 +915,9 @@ void *internal_start_thread(void(*func)(
// Start the thread with signals blocked, otherwise it can steal user signals.
__sanitizer_sigset_t set, old;
internal_sigfillset(&set);
+ // Glibc uses SIGSETXID signal during setuid call. If this signal is blocked
+ // on any thread, setuid call hangs (see test/tsan/setuid.c).
+ internal_sigdelset(&set, 33);
internal_sigprocmask(SIG_SETMASK, &set, &old);
void *th;
real_pthread_create(&th, 0, (void*(*)(void *arg))func, arg);
Added: compiler-rt/trunk/test/tsan/setuid.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/setuid.c?rev=235581&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/setuid.c (added)
+++ compiler-rt/trunk/test/tsan/setuid.c Thu Apr 23 04:33:27 2015
@@ -0,0 +1,26 @@
+// RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
+#include "test.h"
+#include <sys/types.h>
+#include <unistd.h>
+
+// Setuid call used to hang because the background tsan thread did not handle
+// SIGSETXID signal. Note that we don't care whether setuid call succeeds
+// or not.
+
+static void *thread(void *arg) {
+ (void)arg;
+ sleep(1);
+ return 0;
+}
+
+int main() {
+ // Create another thread just for completeness of the picture.
+ pthread_t th;
+ pthread_create(&th, 0, thread, 0);
+ setuid(0);
+ pthread_join(th, 0);
+ fprintf(stderr, "DONE\n");
+ return 0;
+}
+
+// CHECK: DONE
More information about the llvm-commits
mailing list