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

Unified Diff: chrome/browser/chrome_elf_init_win.cc

Issue 174013007: Add UMA stats to record when DLLs are successfully blocked in the Browser. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fix dll_hash.gypi Created 6 years, 10 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/browser/chrome_elf_init_win.cc
diff --git a/chrome/browser/chrome_elf_init_win.cc b/chrome/browser/chrome_elf_init_win.cc
index 424f533c34090c07e8e58d6aeaa504a016c7a57b..f4a7bbcbb25920b8c23f73d725bfec0e014cfc42 100644
--- a/chrome/browser/chrome_elf_init_win.cc
+++ b/chrome/browser/chrome_elf_init_win.cc
@@ -2,12 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/bind.h"
#include "base/metrics/field_trial.h"
#include "base/metrics/histogram.h"
+#include "base/metrics/sparse_histogram.h"
#include "base/strings/utf_string_conversions.h"
#include "base/win/registry.h"
#include "chrome/browser/chrome_elf_init_win.h"
#include "chrome_elf/blacklist/blacklist.h"
+#include "chrome_elf/dll_hash_for_uma/dll_hash.h"
+#include "content/public/browser/browser_thread.h"
#include "version.h" // NOLINT
namespace {
@@ -15,6 +19,10 @@ namespace {
const char kBrowserBlacklistTrialName[] = "BrowserBlacklist";
const char kBrowserBlacklistTrialEnabledGroupName[] = "Enabled";
+// How long to wait, in seconds, before reporting for the second (and last
+// time), what dlls were blocked from the browser process.
+const int kBlacklistReportingDelaySec = 600;
+
// This enum is used to define the buckets for an enumerated UMA histogram.
// Hence,
// (a) existing enumerated constants should never be deleted or reordered, and
@@ -46,6 +54,29 @@ void RecordBlacklistSetupEvent(BlacklistSetupEventType blacklist_setup_event) {
BLACKLIST_SETUP_EVENT_MAX);
}
+// Report which DLLs were prevented from being loaded.
+void ReportSuccessfulBlocks() {
+ // Figure out how many dlls were blocked.
+ int num_blocked_dlls = 0;
+ blacklist::SuccessfullyBlocked(NULL, &num_blocked_dlls);
+
+ if (num_blocked_dlls == 0)
+ return;
+
+ // Now retrieve the list of blocked dlls.
+ std::vector<const wchar_t*> blocked_dlls(num_blocked_dlls);
+ blacklist::SuccessfullyBlocked(&blocked_dlls[0], &num_blocked_dlls);
+
+ // Send up the hashes of the blocked dlls via UMA.
+ for (size_t i = 0; i < blocked_dlls.size(); ++i) {
+ std::string dll_name_utf8;
+ base::WideToUTF8(blocked_dlls[i], wcslen(blocked_dlls[i]), &dll_name_utf8);
+ int uma_hash = DllNameToHash(dll_name_utf8);
+
+ UMA_HISTOGRAM_SPARSE_SLOWLY("Blacklist.Blocked", uma_hash);
+ }
+}
+
} // namespace
void InitializeChromeElf() {
@@ -57,6 +88,18 @@ void InitializeChromeElf() {
base::win::RegKey blacklist_registry_key(HKEY_CURRENT_USER);
blacklist_registry_key.DeleteKey(blacklist::kRegistryBeaconPath);
}
+
+ // Report all successful blacklist interceptions.
+ ReportSuccessfulBlocks();
+
+ // Schedule another task to report all sucessful interceptions later.
+ // This time delay should be long enough to catch any dlls that attempt to
+ // inject after Chrome has started up.
+ content::BrowserThread::PostDelayedTask(
+ content::BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(&ReportSuccessfulBlocks),
+ base::TimeDelta::FromSeconds(kBlacklistReportingDelaySec));
}
void BrowserBlacklistBeaconSetup() {

Powered by Google App Engine
This is Rietveld 408576698