[PATCH] [msan] Unpoison siginfo_t and ucontext_t in signal handlers.

Alexey Samsonov samsonov at google.com
Tue Apr 2 08:35:41 PDT 2013



================
Comment at: lib/sanitizer_common/sanitizer_platform_limits_posix.cc:87
@@ +86,3 @@
+    // Check that sa_sigaction and sa_handler are the same.
+    CHECK((void *)&(((struct sigaction *)act)->sa_sigaction) ==
+               (void *)&(((struct sigaction *)act)->sa_handler));
----------------
Please save ((struct sigaction *)act) to a separate variable.

================
Comment at: lib/sanitizer_common/sanitizer_platform_limits_posix.cc:92
@@ +91,3 @@
+  void __sanitizer_set_sigaction_sa_sigaction(void *act, uptr cb) {
+    ((struct sigaction *)act)->sa_sigaction =
+      (void (*)(int, siginfo_t *, void *))cb;
----------------
ditto

================
Comment at: lib/sanitizer_common/sanitizer_platform_limits_posix.cc:96
@@ +95,3 @@
+  bool __sanitizer_get_sigaction_sa_siginfo(void *act) {
+    return (uptr)((struct sigaction *)act)->sa_flags & SA_SIGINFO;
+  }
----------------
ditto

================
Comment at: lib/msan/tests/msan_test.cc:965
@@ +964,3 @@
+
+  static int cnt;
+
----------------
leading spaces?

================
Comment at: lib/msan/msan_interceptors.cc:851
@@ -830,3 +850,3 @@
   // That requires intercepting all of sigemptyset, sigfillset, etc.
-  int res = REAL(sigaction)(signum, act, oldact);
-  if (res == 0) {
+  GenericScopedLock<StaticSpinMutex> lock(&sigactions_mu);
+  uptr old_cb = sigactions[signo];
----------------
Just SpinMutexLock(&sigactions_mu);

================
Comment at: lib/msan/msan_interceptors.cc:856
@@ +855,3 @@
+  if (act) {
+    memcpy(pnew_act, act, __sanitizer::struct_sigaction_sz);
+    uptr cb = __sanitizer::__sanitizer_get_sigaction_sa_sigaction(pnew_act);
----------------
internal_memcpy?

================
Comment at: lib/msan/msan_interceptors.cc:859
@@ +858,3 @@
+    uptr new_cb =
+        __sanitizer::__sanitizer_get_sigaction_sa_siginfo(pnew_act) ? (uptr)
+        SignalAction : (uptr) SignalHandler;
----------------
OMG, line split looks ugly. M.b. we can use (uptr)SignalAction : (uptr)SignalHandler?

================
Comment at: lib/msan/msan_interceptors.cc:876
@@ +875,3 @@
+  ENSURE_MSAN_INITED();
+  GenericScopedLock<StaticSpinMutex> lock(&sigactions_mu);
+  if (cb != __sanitizer::sig_ign && cb != __sanitizer::sig_dfl) {
----------------
SpinMutexLock

================
Comment at: lib/msan/msan_interceptors.cc:881
@@ -834,2 +880,3 @@
   }
+  int res = REAL(signal)(signo, cb);
   return res;
----------------
return REAL(signal)(signo, cb);


http://llvm-reviews.chandlerc.com/D611



More information about the llvm-commits mailing list