[PATCH] Protection against stack-based memory corruption errors using SafeStack: compiler-rt runtime support library

Peter Collingbourne peter at pcc.me.uk
Wed May 6 15:45:56 PDT 2015


================
Comment at: lib/safestack/Makefile.mk:1
@@ +1,2 @@
+#===- lib/safestack/Makefile.mk ------------------------------*- Makefile -*--===#
+#
----------------
kcc wrote:
> I don't think we want to support configure/make
Removed.

================
Comment at: lib/safestack/safestack.cc:56
@@ +55,3 @@
+#if defined(__APPLE__)
+# define safestack_mmap(Args...) mmap(Args)
+# define safestack_munmap(Args...) munmap(Args)
----------------
kcc wrote:
> can this code use more of sanitizer_common?
> (here and in the rest of this file)
Yep, this now uses internal_mmap/internal_munmap and internal_mprotect below.

================
Comment at: lib/safestack/safestack.cc:91
@@ +90,3 @@
+
+  /* On Darwin, we store the unsafe stack pointer in one of the
+   * thread-specific data slots that are reserved for system libraries.
----------------
kcc wrote:
> Why? 
> The recent OSX should support TLS well (or not?)
This now uses a `__thread` variable on all platforms.

According to Laszlo this was done solely for efficiency reasons, so we should be fine using `__thread` at least to begin with. I imagine that if the overhead matters in practice we can try to persuade the relevant people at Apple to allocate a TLS slot for us.

================
Comment at: test/safestack/check-buffer-copy.c:1
@@ +1,2 @@
+// RUN: %clang_safestack %s -o %t
+// RUN: %run %t
----------------
kcc wrote:
> (for all tests) please add a one-line test description 
Done

http://reviews.llvm.org/D6096

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the cfe-commits mailing list