[PATCH] Protection against stack-based memory corruption errors using SafeStack: Clang command line option and function attribute

Alexey Samsonov vonosmas at gmail.com
Thu May 7 17:13:01 PDT 2015


I understand that you probably need `no_safe_stack` attribute for Chromium/FreeBSD integration *right now*, and rather proceed with this and not wait until someone implements generic `no_sanitize` attribute, but... maybe we should at least not document it?


================
Comment at: lib/CodeGen/CodeGenModule.cpp:765
@@ -763,1 +764,3 @@
+        !D->hasAttr<NoSafeStackAttr>())
+      B.addAttribute(llvm::Attribute::SafeStack);
   }
----------------
Do you also need to add it to `CodeGenModule::CreateGlobalInitOrDestructFunction`?

================
Comment at: lib/Driver/Tools.cpp:2354
@@ +2353,3 @@
+  if (SanArgs.needsSafeStackRt()) {
+    if (Args.hasArg(options::OPT_shared)) {
+      // This is a temporary limitation caused by linking issues.
----------------
This code is now dead - presence of `-shared` is checked at the top of this function. Can we silently discard `-fsanitize=safe-stack` while linking DSO?

================
Comment at: lib/Driver/Tools.cpp:6251
@@ +6250,3 @@
+    getMachOToolChain().AddLinkRuntimeLib(Args, CmdArgs,
+                                          "libclang_rt.safestack_osx.a");
+
----------------
Looks like you should set `AlwaysLink` argument of `AddLinkRuntimeLib` to `true`.

http://reviews.llvm.org/D6095

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






More information about the cfe-commits mailing list