[PATCH] D40657: [sanitizer] Introduce a vDSO aware time function, and use it in the allocator

Kostya Kortchinsky via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 30 11:54:22 PST 2017


cryptoad added inline comments.


================
Comment at: lib/sanitizer_common/sanitizer_linux.cc:466
+// is not null (it can be mangled so we can't use it directly). Bionic's
+// clock_gettime actually falls back to the syscall in the same situation.
+extern "C" SANITIZER_WEAK_ATTRIBUTE
----------------
alekseyshl wrote:
> It feels fragile to depend on the implementation, but I don't really see what else can we do. Have a test to check that it works from preinit_array on Android?
I have `test/scudo/preinit.c` that I could enable again on Android (it crashes on N for another reason due to a Bionic bug).
Otherwise ASan has a few tests that leverage the preinit_array, I am going to check if they actually end up calling the function.



================
Comment at: lib/sanitizer_common/sanitizer_linux.cc:470
+bool CanUseVDSO() {
+  return SANITIZER_ANDROID || (&__vdso_clock_gettime && __vdso_clock_gettime);
+}
----------------
alekseyshl wrote:
> What about __kernel_clock_gettime?
So it turns out that `__kernel_clock_gettime at version` is the vDSO symbol name.
The glibc looks it up, and stores it in `__vdso_clock_gettime` (without appendix, glibc symbol, not vDSO): https://github.com/lattera/glibc/blob/a2f34833b1042d5d8eeb263b4cf4caaea138c4ad/sysdeps/unix/sysv/linux/s390/init-first.c#L42 (example for s390).
What we really want is to make sure that the glibc symbol isn't null.


https://reviews.llvm.org/D40657





More information about the llvm-commits mailing list