debug sandbox/denis13/asan
authorDenis Khalikov <d.khalikov@partner.samsung.com>
Wed, 4 Oct 2017 13:07:02 +0000 (16:07 +0300)
committerDenis Khalikov <d.khalikov@partner.samsung.com>
Thu, 5 Oct 2017 09:27:24 +0000 (12:27 +0300)
Change-Id: I7b3cc2eef9d188a50f3a5931408c7223894f9d83

libsanitizer/asan/asan_linux.cc
libsanitizer/asan/asan_rtl.cc
libsanitizer/sanitizer_common/sanitizer_linux.cc

index 9f058df..5dcb83f 100644 (file)
@@ -113,6 +113,8 @@ void AsanCheckDynamicRTPrereqs() {
 
   // Ensure that dynamic RT is the first DSO in the list
   const char *first_dso_name = nullptr;
+  Printf("call dl_iterate callback \n");
+  /*
   dl_iterate_phdr(FindFirstDSOCallback, &first_dso_name);
   if (first_dso_name && !IsDynamicRTName(first_dso_name)) {
     Report("ASan runtime does not come first in initial library list; "
@@ -120,6 +122,7 @@ void AsanCheckDynamicRTPrereqs() {
            "manually preload it with LD_PRELOAD.\n");
     Die();
   }
+  */
 }
 
 void AsanCheckIncompatibleRT() {
index cda1d58..8c70ccb 100644 (file)
@@ -431,47 +431,67 @@ static void AsanInitInternal() {
   if (LIKELY(asan_inited)) return;
   SanitizerToolName = "AddressSanitizer";
   Printf("INIT ASAN\n");
+  Printf("MayBeMountProcfs\n");
   MaybeMountProcFS();
+  Printf("MabeDisableUlimit\n");
   MaybeDisableUlimit();
   CHECK(!asan_init_is_running && "ASan init calls itself!");
   asan_init_is_running = true;
 
+  Printf("Cache Binary Name\n");
   CacheBinaryName();
 
   // Initialize flags. This must be done early, because most of the
   // initialization steps look at flags().
+  Printf("Init flags\n");
   InitializeFlags();
 
+  Printf("Asan Incompatible RT\n");
   AsanCheckIncompatibleRT();
+  Printf("Asan Check dynamic PTR\n");
   AsanCheckDynamicRTPrereqs();
+  Printf("AvoidCVE\n");
   AvoidCVE_2016_2143();
 
+  Printf("SetCanPoisonMemory\n");
   SetCanPoisonMemory(flags()->poison_heap);
+  Printf("SetMallocontextSize \n");
   SetMallocContextSize(common_flags()->malloc_context_size);
 
+  Printf("InitializePlatrformExceptions\n");
   InitializePlatformExceptionHandlers();
 
+  Printf("InitHighMem\n");
   InitializeHighMemEnd();
 
   // Make sure we are not statically linked.
   AsanDoesNotSupportStaticLinkage();
 
   // Install tool-specific callbacks in sanitizer_common.
+  Printf("Add die callback\n");
   AddDieCallback(AsanDie);
+  Printf("SetcheckFailedCallback\n");
   SetCheckFailedCallback(AsanCheckFailed);
+  Printf("SetPrintfAndReportCallback\n");
   SetPrintfAndReportCallback(AppendToErrorMessageBuffer);
 
+  Printf("SetReport path\n");
   __sanitizer_set_report_path(common_flags()->log_path);
 
+  Printf("stack usage after return\n");
   __asan_option_detect_stack_use_after_return =
       flags()->detect_stack_use_after_return;
 
   // Re-exec ourselves if we need to set additional env or command line args.
+  Printf("Maybe Reexec\n");
   MaybeReexec();
 
+
+  Printf("Slow allocate\n");
   // Setup internal allocator callback.
   SetLowLevelAllocateCallback(OnLowLevelAllocate);
 
+  Printf("Init interceptors\n");
   InitializeAsanInterceptors();
 
   // Enable system log ("adb logcat") on Android.
@@ -479,6 +499,7 @@ static void AsanInitInternal() {
   // AsanInitInternal -> android_log_write -> __interceptor_strcmp
   AndroidLogInit();
 
+  Printf("Replace system malloc \n");
   ReplaceSystemMalloc();
 
   // Set the shadow memory address to uninitialized.
@@ -614,6 +635,7 @@ static void AsanInitInternal() {
   } else {
     Symbolizer::LateInitialize();
   }
+  Printf("ASan INIT done\n");
 
   VReport(1, "AddressSanitizer Init done\n");
 }
index f563d23..9c2d423 100644 (file)
@@ -799,10 +799,10 @@ bool ThreadLister::GetDirectoryEntries() {
 
 uptr GetPageSize() {
 // Android post-M sysconf(_SC_PAGESIZE) crashes if called from .preinit_array.
-#if SANITIZER_ANDROID
+#if SANITIZER_ANDROID ||                                                       \
+    (SANITIZER_LINUX && (defined(__arm__) || defined(__arch64__)))
   return 4096;
-#elif SANITIZER_LINUX && (defined(__x86_64__) || defined(__i386__) ||          \
-                          defined(__arm__) || defined(__arch64__))
+#elif SANITIZER_LINUX && (defined(__x86_64__) || defined(__i386__))
   return EXEC_PAGESIZE;
 #else
   return sysconf(_SC_PAGESIZE);  // EXEC_PAGESIZE may not be trustworthy.