r321647 - Revert "ASan+operator new[]: Fix operator new[] cookie poisoning"

Filipe Cabecinhas via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 2 05:46:12 PST 2018


Author: filcab
Date: Tue Jan  2 05:46:12 2018
New Revision: 321647

URL: http://llvm.org/viewvc/llvm-project?rev=321647&view=rev
Log:
Revert "ASan+operator new[]: Fix operator new[] cookie poisoning"

This reverts r321645.

I missed a compiler-rt test that needs updating.

Modified:
    cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
    cfe/trunk/test/CodeGen/address-sanitizer-and-array-cookie.cpp

Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=321647&r1=321646&r2=321647&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Tue Jan  2 05:46:12 2018
@@ -1847,7 +1847,8 @@ Address ItaniumCXXABI::InitializeArrayCo
   llvm::Instruction *SI = CGF.Builder.CreateStore(NumElements, NumElementsPtr);
 
   // Handle the array cookie specially in ASan.
-  if (CGM.getLangOpts().Sanitize.has(SanitizerKind::Address) && AS == 0) {
+  if (CGM.getLangOpts().Sanitize.has(SanitizerKind::Address) && AS == 0 &&
+      expr->getOperatorNew()->isReplaceableGlobalAllocationFunction()) {
     // The store to the CookiePtr does not need to be instrumented.
     CGM.getSanitizerMetadata()->disableSanitizerForInstruction(SI);
     llvm::FunctionType *FTy =

Modified: cfe/trunk/test/CodeGen/address-sanitizer-and-array-cookie.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/address-sanitizer-and-array-cookie.cpp?rev=321647&r1=321646&r2=321647&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/address-sanitizer-and-array-cookie.cpp (original)
+++ cfe/trunk/test/CodeGen/address-sanitizer-and-array-cookie.cpp Tue Jan  2 05:46:12 2018
@@ -7,7 +7,7 @@ namespace std {
   std::nothrow_t nothrow;
 }
 void *operator new[](size_t, const std::nothrow_t &) throw();
-void *operator new[](size_t, void *);
+void *operator new[](size_t, char *);
 
 struct C {
   int x;
@@ -53,11 +53,3 @@ C *CallPlacementNew() {
 }
 // ASAN-LABEL: CallPlacementNew
 // ASAN-NOT: __asan_poison_cxx_array_cookie
-
-void *operator new[](size_t n, int);
-
-C *CallNewWithArgs() {
-// ASAN-LABEL: CallNewWithArgs
-// ASAN: call void @__asan_poison_cxx_array_cookie
-  return new (123) C[20];
-}




More information about the cfe-commits mailing list