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

David Chisnall csdavec at swan.ac.uk
Tue Nov 4 01:54:15 PST 2014


================
Comment at: lib/safestack/safestack.cc:42
@@ +41,3 @@
+// all symbols from pthread that we use dynamically
+#define __DECLARE_WRAPPER(fn) __typeof__(fn)* __d_ ## fn = NULL;
+
----------------
kcc wrote:
> Why not simply force -lpthread in the driver? 
The overhead of adding -pthread (-lpthread is non-portable) to single-threaded programs is measurably greater than the overhead of safe stack.  We (current hat: FreeBSD) are willing to ship packages with SSP by default and would be very willing to ship packages with safe-stack, but if it forced -pthread then the overhead would be more than we'd be willing to accept.

================
Comment at: lib/safestack/safestack.cc:51
@@ +50,3 @@
+
+// The unsafe stack pointer is stored in the TCB structure on these platforms
+#if defined(__i386__)
----------------
kcc wrote:
>  I might be missing something, but can't we just use TLS to store the second stack? 
C11 TLS does not have a way of attaching destructors.  C++11 does (although the standard is undefined in the presence of shared library loading and unloading, which makes it less useful), but does not have any way of ordering the destruction.

http://reviews.llvm.org/D6096






More information about the cfe-commits mailing list