[PATCH] D55711: Don't trigger sanitizer initialization from `sysctlbyname` interceptor.

Vitaly Buka via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 14 11:25:09 PST 2018


vitalybuka added a comment.

If we are going to support this use-case we need a test.

I think you can clone/update sysctl.cc, and define all possible __*san_default_options as following:

  __tsan_default_options() {
    test_sysctl();
    test_sysctlbyname();
    test_sysctlnametomib();
  }

This is probably early enough.
Please check that the new test fail without your patch.



================
Comment at: lib/sanitizer_common/sanitizer_common_interceptors.inc:7542
   void *ctx;
   COMMON_INTERCEPTOR_ENTER(ctx, sysctl, name, namelen, oldp, oldlenp, newp,
                            newlen);
----------------
Could you please update all 3



================
Comment at: lib/sanitizer_common/sanitizer_common_interceptors.inc:7564
   void *ctx;
+  if (UNLIKELY(COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED)) {
+    // On Darwin iOS simulators `sysctlbyname` gets called early
----------------
Please remove UNLIKELY for consistency with the rest


================
Comment at: lib/sanitizer_common/sanitizer_common_interceptors.inc:7571
+    // from elsewhere.
+    return REAL(sysctlbyname)(sname, oldp, oldlenp, newp, newlen);
+  }
----------------
I guess this will work only on Darwin
Ptr to REAL() is not yet initialized
It must be internal_sysctlbyname



Repository:
  rCRT Compiler Runtime

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55711/new/

https://reviews.llvm.org/D55711





More information about the llvm-commits mailing list