Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2341)

Unified Diff: chrome/installer/setup/setup_main.cc

Issue 2559053002: Instrument setup.exe in the SyzyAsan builds.
Patch Set: Fix the component build Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/installer/setup/setup_main.cc
diff --git a/chrome/installer/setup/setup_main.cc b/chrome/installer/setup/setup_main.cc
index b8d66b6b4d596eb278d0ee5245f344064b7ba2fe..6b80ef657f7451089ed5704e9540adc4c67e85c8 100644
--- a/chrome/installer/setup/setup_main.cc
+++ b/chrome/installer/setup/setup_main.cc
@@ -82,6 +82,10 @@
#include "components/crash/content/app/run_as_crashpad_handler_win.h"
#include "content/public/common/content_switches.h"
+#if defined(SYZYASAN)
+#include "base/debug/asan_invalid_access.h"
+#endif
+
using installer::InstallerState;
using installer::InstallationState;
using installer::MasterPreferences;
@@ -1042,6 +1046,21 @@ bool HandleNonInstallCmdLineOptions(const base::FilePath& setup_exe,
cmd_line.GetSwitchValueNative(
installer::switches::kSetDisplayVersionValue));
*exit_code = OverwriteDisplayVersions(registry_product, registry_value);
+#if defined(SYZYASAN)
+ } else if (cmd_line.HasSwitch(installer::switches::kInduceAsanCrash)) {
+ std::string crash_type =
+ cmd_line.GetSwitchValueASCII(installer::switches::kInduceAsanCrash);
+ if (crash_type == installer::switches::kAsanUseAfterFree) {
+ base::debug::AsanHeapUseAfterFree();
+ } else if (crash_type == installer::switches::kAsanHeapOverflow) {
+ base::debug::AsanHeapOverflow();
+ } else if (crash_type == installer::switches::kAsanHeapUnderflow) {
+ base::debug::AsanHeapUnderflow();
+ } else {
+ LOG(ERROR) << "Invalid Asan error type: " << crash_type;
+ handled = false;
+ }
+#endif
} else {
handled = false;
}
@@ -1049,6 +1068,24 @@ bool HandleNonInstallCmdLineOptions(const base::FilePath& setup_exe,
return handled;
}
+#if defined(SYZYASAN)
+// Initialize the SyzyAsan crash reporter. This should only be called once the
+// crash reporter has been initialized. There should be only one call to this
+// function.
+void SetupSyzyAsan() {
+ using SyzyAsanInitializeCrashReporterFn = VOID(WINAPI*)();
+ HMODULE syzyasan_handle = ::GetModuleHandle(L"syzyasan_rtl.dll");
+ if (!syzyasan_handle)
+ return;
+
+ SyzyAsanInitializeCrashReporterFn syzyasan_init_crash_reporter =
+ reinterpret_cast<SyzyAsanInitializeCrashReporterFn>(
+ ::GetProcAddress(syzyasan_handle, "asan_InitializeCrashReporter"));
+ if (syzyasan_init_crash_reporter)
+ syzyasan_init_crash_reporter();
+}
+#endif
+
} // namespace
namespace installer {
@@ -1364,6 +1401,10 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE prev_instance,
installer::SetInitialCrashKeys(installer_state);
installer::SetCrashKeysFromCommandLine(cmd_line);
+#if defined(SYZYASAN)
+ SetupSyzyAsan();
+#endif
+
// Make sure the process exits cleanly on unexpected errors.
base::EnableTerminationOnHeapCorruption();
base::EnableTerminationOnOutOfMemory();

Powered by Google App Engine
This is Rietveld 408576698