[PATCH] D48454: Ignore blacklist when generating __cfi_check_fail.

Evgenii Stepanov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 21 14:05:45 PDT 2018


eugenis created this revision.
eugenis added reviewers: pcc, vlad.tsyrklevich.

Fixes PR37898.


https://reviews.llvm.org/D48454

Files:
  clang/lib/CodeGen/CGExpr.cpp
  clang/test/CodeGen/cfi-check-fail2.c


Index: clang/test/CodeGen/cfi-check-fail2.c
===================================================================
--- clang/test/CodeGen/cfi-check-fail2.c
+++ clang/test/CodeGen/cfi-check-fail2.c
@@ -3,6 +3,12 @@
 // RUN:     -fsanitize=cfi-vcall \
 // RUN:     -emit-llvm -o - %s | FileCheck %s
 
+// Check that blacklist does not affect generated code.
+// RUN: echo "src:*" > %t-all.blacklist
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -O0 -fsanitize-cfi-cross-dso \
+// RUN:     -fsanitize=cfi-vcall -fsanitize-blacklist=%t-all.blacklist \
+// RUN:     -emit-llvm -o - %s | FileCheck %s
+
 void caller(void (*f)()) {
   f();
 }
Index: clang/lib/CodeGen/CGExpr.cpp
===================================================================
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -3120,11 +3120,16 @@
     SanitizerMask Mask = CheckKindMaskPair.second;
     llvm::Value *Cond =
         Builder.CreateICmpNE(CheckKind, llvm::ConstantInt::get(Int8Ty, Kind));
-    if (CGM.getLangOpts().Sanitize.has(Mask))
+    if (CGM.getLangOpts().Sanitize.has(Mask)) {
+      // This sanitizer may have been disabled in blacklist. This function does
+      // not have a source location, but "src:*" would still apply. Enable it
+      // back.
+      SanOpts.Mask |= Mask;
       EmitCheck(std::make_pair(Cond, Mask), SanitizerHandler::CFICheckFail, {},
                 {Data, Addr, ValidVtable});
-    else
+    } else {
       EmitTrapCheck(Cond);
+    }
   }
 
   FinishFunction();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48454.152377.patch
Type: text/x-patch
Size: 1501 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180621/1e978645/attachment.bin>


More information about the cfe-commits mailing list