[PATCH] Protection against stack-based memory corruption errors using SafeStack: compiler-rt runtime support library
Peter Collingbourne
peter at pcc.me.uk
Fri May 29 17:25:35 PDT 2015
I've added more detailed documentation on solutions to the limitations as a TODO in safestack.cc rather than the documentation where it isn't really actionable to a typical reader of the doc who probably just wants to use safe stack.
================
Comment at: lib/safestack/safestack.cc:174
@@ +173,3 @@
+ if (initialized)
+ return;
+
----------------
jfb wrote:
> ksvladimir wrote:
> > pcc wrote:
> > > jfb wrote:
> > > > Is this initialization check useful if `__attribute__((constructor(0)))` was used? Can this be done concurrently, or is it just called multiple times from the same thread of execution? If concurrent then initialization is racy.
> > > > Is this initialization check useful if __attribute__((constructor(0))) was used?
> > >
> > > I don't think it is. Removed.
> > >
> > > (Regarding Vova's comment, we don't currently support linking SafeStack into DSOs.)
> > The primary reason for this check is to handle cases when libsafestack is linked into multiple DSOs and __safestack_init ends up being on multiple constructor lists. It can only be called concurrently if multiple DSOs are being dlopen'ed in parallel. I think that dlopen itself isn't thread-safe and shouldn't be used that way but, perhaps, for extra safety it's useful to make this code non-racy using atomics.
> Gotcha. Would it be useful to have nothing here for now (@pcc just deleted the code), but add a comment explaining @ksvladimir's point?
I don't think we need to add an explanation here. It would only make sense to do so if we supported multiple copies of the library in multiple DSOs, which isn't necessarily something we'll even want to support.
http://reviews.llvm.org/D6096
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the cfe-commits
mailing list