Apply LOCAL_PATCHES and remove not used ones.
authorMartin Liska <mliska@suse.cz>
Wed, 31 Oct 2018 11:16:17 +0000 (12:16 +0100)
committerMartin Liska <marxin@gcc.gnu.org>
Wed, 31 Oct 2018 11:16:17 +0000 (11:16 +0000)
2018-10-31  Martin Liska  <mliska@suse.cz>

* LOCAL_PATCHES: Update patch list.
* asan/asan_globals.cc (CheckODRViolationViaIndicator): Apply
patches from GCC's trunk.
(CheckODRViolationViaPoisoning): Likewise.
(RegisterGlobal): Likewise.
* sanitizer_common/sanitizer_mac.cc (defined): Likewise.
* sanitizer_common/sanitizer_stacktrace.cc (GetCanonicFrame): Likewise.
* ubsan/ubsan_handlers.cc (__ubsan::__ubsan_handle_cfi_bad_icall): Likewise.
(__ubsan::__ubsan_handle_cfi_bad_icall_abort): Likewise.
* ubsan/ubsan_handlers.h (struct CFIBadIcallData): Likewise.
(struct CFICheckFailData): Likewise.
(RECOVERABLE): Likewise.

From-SVN: r265667

libsanitizer/ChangeLog
libsanitizer/LOCAL_PATCHES
libsanitizer/asan/asan_globals.cc
libsanitizer/sanitizer_common/sanitizer_mac.cc
libsanitizer/sanitizer_common/sanitizer_stacktrace.cc
libsanitizer/ubsan/ubsan_handlers.cc
libsanitizer/ubsan/ubsan_handlers.h

index 31c6377056c61396db3cc38b353f10eed9842f9a..ba0c30f06e47d99d358e36b2abc0a217e43b289d 100644 (file)
@@ -1,3 +1,18 @@
+2018-10-31  Martin Liska  <mliska@suse.cz>
+
+       * LOCAL_PATCHES: Update patch list.
+       * asan/asan_globals.cc (CheckODRViolationViaIndicator): Apply
+       patches from GCC's trunk.
+       (CheckODRViolationViaPoisoning): Likewise.
+       (RegisterGlobal): Likewise.
+       * sanitizer_common/sanitizer_mac.cc (defined): Likewise.
+       * sanitizer_common/sanitizer_stacktrace.cc (GetCanonicFrame): Likewise.
+       * ubsan/ubsan_handlers.cc (__ubsan::__ubsan_handle_cfi_bad_icall): Likewise.
+       (__ubsan::__ubsan_handle_cfi_bad_icall_abort): Likewise.
+       * ubsan/ubsan_handlers.h (struct CFIBadIcallData): Likewise.
+       (struct CFICheckFailData): Likewise.
+       (RECOVERABLE): Likewise.
+
 2018-10-31  Martin Liska  <mliska@suse.cz>
 
        * config.h.in: Regenerate.
index 822e2f34ad9a75363aa8c7e3e2667764189e61ca..69544c33a8996d747612cf7996a4ee1cd888a8c9 100644 (file)
@@ -1,6 +1,4 @@
-r241978
 r241980
 r241981
 r242478
 r242633
-r243014
index 34963156346224d0442517fe1f4abe0b8aa053ab..a59a2dc27a47be412fe91e04e013bf4a60b4018c 100644 (file)
@@ -147,23 +147,6 @@ static void CheckODRViolationViaIndicator(const Global *g) {
   }
 }
 
-// Check ODR violation for given global G by checking if it's already poisoned.
-// We use this method in case compiler doesn't use private aliases for global
-// variables.
-static void CheckODRViolationViaPoisoning(const Global *g) {
-  if (__asan_region_is_poisoned(g->beg, g->size_with_redzone)) {
-    // This check may not be enough: if the first global is much larger
-    // the entire redzone of the second global may be within the first global.
-    for (ListOfGlobals *l = list_of_all_globals; l; l = l->next) {
-      if (g->beg == l->g->beg &&
-          (flags()->detect_odr_violation >= 2 || g->size != l->g->size) &&
-          !IsODRViolationSuppressed(g->name))
-        ReportODRViolation(g, FindRegistrationSite(g),
-                           l->g, FindRegistrationSite(l->g));
-    }
-  }
-}
-
 // Clang provides two different ways for global variables protection:
 // it can poison the global itself or its private alias. In former
 // case we may poison same symbol multiple times, that can help us to
@@ -211,8 +194,6 @@ static void RegisterGlobal(const Global *g) {
     // where two globals with the same name are defined in different modules.
     if (UseODRIndicator(g))
       CheckODRViolationViaIndicator(g);
-    else
-      CheckODRViolationViaPoisoning(g);
   }
   if (CanPoisonMemory())
     PoisonRedZones(*g);
index df7a897e45a09ca7052c8680aef6fa1c36c75730..28b2906e226b14599b1b15a428ba757b9c134566 100644 (file)
@@ -35,7 +35,7 @@
 extern char **environ;
 #endif
 
-#if defined(__has_include) && __has_include(<os/trace.h>)
+#if defined(__has_include) && __has_include(<os/trace.h>) && defined(__BLOCKS__)
 #define SANITIZER_OS_TRACE 1
 #include <os/trace.h>
 #else
index db51f5926d20f9bdef09449a225e5a6dd71d2590..699fd9fdce07b670a903745fb6603e0867a0fc8c 100644 (file)
@@ -59,8 +59,8 @@ static inline uhwptr *GetCanonicFrame(uptr bp,
   // Nope, this does not look right either. This means the frame after next does
   // not have a valid frame pointer, but we can still extract the caller PC.
   // Unfortunately, there is no way to decide between GCC and LLVM frame
-  // layouts. Assume LLVM.
-  return bp_prev;
+  // layouts. Assume GCC.
+  return bp_prev - 1;
 #else
   return (uhwptr*)bp;
 #endif
index 927ad4c95312627268506933d0c3ab9295c725c8..f67b9e30fb9f2b7031dfc46b7c050fc032626edc 100644 (file)
@@ -771,6 +771,21 @@ void __ubsan_handle_cfi_bad_type(CFICheckFailData *Data, ValueHandle Vtable,
 
 }  // namespace __ubsan
 
+void __ubsan::__ubsan_handle_cfi_bad_icall(CFIBadIcallData *CallData,
+                                           ValueHandle Function) {
+  GET_REPORT_OPTIONS(false);
+  CFICheckFailData Data = {CFITCK_ICall, CallData->Loc, CallData->Type};
+  handleCFIBadIcall(&Data, Function, Opts);
+}
+
+void __ubsan::__ubsan_handle_cfi_bad_icall_abort(CFIBadIcallData *CallData,
+                                                 ValueHandle Function) {
+  GET_REPORT_OPTIONS(true);
+  CFICheckFailData Data = {CFITCK_ICall, CallData->Loc, CallData->Type};
+  handleCFIBadIcall(&Data, Function, Opts);
+  Die();
+}
+
 void __ubsan::__ubsan_handle_cfi_check_fail(CFICheckFailData *Data,
                                             ValueHandle Value,
                                             uptr ValidVtable) {
index 56e664c751be16186dda84f660acf8e01a55addf..87e3c3439b60b044040b5f9a6a60178ecfef85a5 100644 (file)
@@ -202,12 +202,20 @@ enum CFITypeCheckKind : unsigned char {
   CFITCK_VMFCall,
 };
 
+struct CFIBadIcallData {
+  SourceLocation Loc;
+  const TypeDescriptor &Type;
+};
+
 struct CFICheckFailData {
   CFITypeCheckKind CheckKind;
   SourceLocation Loc;
   const TypeDescriptor &Type;
 };
 
+/// \brief Handle control flow integrity failure for indirect function calls.
+RECOVERABLE(cfi_bad_icall, CFIBadIcallData *Data, ValueHandle Function)
+
 /// \brief Handle control flow integrity failures.
 RECOVERABLE(cfi_check_fail, CFICheckFailData *Data, ValueHandle Function,
             uptr VtableIsValid)