Skip to content

Commit

Permalink
Link chrome_elf.dll instead of statically linking the blacklist code
Browse files Browse the repository at this point in the history
This ensure that the dll code is referenced, instead of the target
making its own copy.

TBR=sky@chromium.org
BUG=329023

Review URL: https://codereview.chromium.org/181373003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@253847 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
csharp@chromium.org committed Feb 27, 2014
1 parent 66c12e8 commit e5890e1
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 39 deletions.
2 changes: 1 addition & 1 deletion chrome/browser/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ include_rules = [
"+ash",
"+chrome/app",
"+chrome/installer",
"+chrome_elf/blacklist",
"+chrome_elf/chrome_elf_constants.h",
"+chrome_elf/create_file",
"+chromeos",
"+components/autofill/content/browser",
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/chrome_elf_init_unittest_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "base/strings/utf_string_conversions.h"
#include "base/test/test_reg_util_win.h"
#include "chrome/common/chrome_version_info.h"
#include "chrome_elf/blacklist/blacklist.h"
#include "chrome_elf/chrome_elf_constants.h"
#include "testing/gtest/include/gtest/gtest.h"

class ChromeBlacklistTrialTest : public testing::Test {
Expand Down
6 changes: 5 additions & 1 deletion chrome/browser/chrome_elf_init_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#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/chrome_elf_constants.h"
#include "version.h" // NOLINT

namespace {
Expand Down Expand Up @@ -64,6 +64,10 @@ void BrowserBlacklistBeaconSetup() {
blacklist::kRegistryBeaconPath,
KEY_QUERY_VALUE | KEY_SET_VALUE);

// No point in trying to continue if the registry key isn't valid.
if (!blacklist_registry_key.Valid())
return;

// Find the last recorded blacklist version.
base::string16 blacklist_version;
blacklist_registry_key.ReadValue(blacklist::kBeaconVersion,
Expand Down
3 changes: 2 additions & 1 deletion chrome/chrome_browser.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -3399,7 +3399,8 @@
'chrome_process_finder',
'installer_util_strings',
'../chrome/chrome.gyp:chrome_version_header',
'../chrome_elf/chrome_elf.gyp:blacklist',
'../chrome_elf/chrome_elf.gyp:chrome_elf',
'../chrome_elf/chrome_elf.gyp:chrome_elf_constants',
'../google_update/google_update.gyp:google_update',
'../third_party/iaccessible2/iaccessible2.gyp:iaccessible2',
'../third_party/isimpledom/isimpledom.gyp:isimpledom',
Expand Down
7 changes: 1 addition & 6 deletions chrome/renderer/chrome_content_renderer_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -365,12 +365,7 @@ void ChromeContentRendererClient::RenderThreadStarted() {
// Report if the renderer process has been patched by chrome_elf.
// TODO(csharp): Remove once the renderer is no longer getting
// patched this way.
typedef bool(*IsBlacklistInitializedFunc)();
IsBlacklistInitializedFunc is_blacklist_initialized =
reinterpret_cast<IsBlacklistInitializedFunc>(
GetProcAddress(GetModuleHandle(L"chrome_elf.dll"),
"IsBlacklistInitialized"));
if (is_blacklist_initialized && is_blacklist_initialized())
if (blacklist::IsBlacklistInitialized())
UMA_HISTOGRAM_BOOLEAN("Blacklist.PatchedInRenderer", true);
#endif
}
Expand Down
1 change: 1 addition & 0 deletions chrome_elf/blacklist.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
'../base/base.gyp:base_static',
'../chrome/chrome.gyp:chrome_version_header',
'../chrome_elf/chrome_elf.gyp:chrome_elf_breakpad',
'../chrome_elf/chrome_elf.gyp:chrome_elf_constants',
'../sandbox/sandbox.gyp:sandbox',
],
},
Expand Down
5 changes: 1 addition & 4 deletions chrome_elf/blacklist/blacklist.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "base/basictypes.h"
#include "chrome_elf/blacklist/blacklist_interceptions.h"
#include "chrome_elf/chrome_elf_constants.h"
#include "sandbox/win/src/interception_internal.h"
#include "sandbox/win/src/internal_types.h"
#include "sandbox/win/src/sandbox_utils.h"
Expand All @@ -28,10 +29,6 @@ const wchar_t* g_troublesome_dlls[kTroublesomeDllsMaxCount] = {
NULL,
};

const wchar_t kRegistryBeaconPath[] = L"SOFTWARE\\Google\\Chrome\\BLBeacon";
const wchar_t kBeaconVersion[] = L"version";
const wchar_t kBeaconState[] = L"state";

} // namespace blacklist

// Allocate storage for thunks in a page of this module to save on doing
Expand Down
24 changes: 0 additions & 24 deletions chrome_elf/blacklist/blacklist.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,6 @@ const int kTroublesomeDllsMaxCount = 64;
// The DLL blacklist.
extern const wchar_t* g_troublesome_dlls[kTroublesomeDllsMaxCount];

// The registry path of the blacklist beacon.
extern const wchar_t kRegistryBeaconPath[];

// The properties for the blacklist beacon.
extern const wchar_t kBeaconVersion[];
extern const wchar_t kBeaconState[];

// The states for the blacklist setup code.
enum BlacklistState {
BLACKLIST_DISABLED = 0,
BLACKLIST_ENABLED,
// The blacklist setup code is running. If this is still set at startup,
// it means the last setup crashed.
BLACKLIST_SETUP_RUNNING,
// The blacklist thunk setup code is running. If this is still set at startup,
// it means the last setup crashed during thunk setup.
BLACKLIST_THUNK_SETUP,
// The blacklist code is currently intercepting MapViewOfSection. If this is
// still set at startup, it means we crashed during interception.
BLACKLIST_INTERCEPTING,
// Always keep this at the end.
BLACKLIST_STATE_MAX,
};

#if defined(_WIN64)
extern NtMapViewOfSectionFunction g_nt_map_view_of_section_func;
#endif
Expand Down
1 change: 1 addition & 0 deletions chrome_elf/blacklist/test/blacklist_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "base/win/registry.h"
#include "chrome_elf/blacklist/blacklist.h"
#include "chrome_elf/blacklist/test/blacklist_test_main_dll.h"
#include "chrome_elf/chrome_elf_constants.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "version.h" // NOLINT

Expand Down
23 changes: 22 additions & 1 deletion chrome_elf/chrome_elf.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,35 @@
],
},
{
'target_name': 'chrome_elf_common',
'target_name': 'chrome_elf_constants',
'type': 'static_library',
'include_dirs': [
'..',
],
'sources': [
'chrome_elf_constants.cc',
'chrome_elf_constants.h',
],
'conditions': [
['component=="shared_library"', {
# In component builds, all targets depend on chrome_redirects by
# default. Remove it here so we are able to test it.
'dependencies!': [
'../chrome_elf/chrome_elf.gyp:chrome_redirects',
],
}],
],
},
{
'target_name': 'chrome_elf_common',
'type': 'static_library',
'dependencies': [
'chrome_elf_constants',
],
'include_dirs': [
'..',
],
'sources': [
'chrome_elf_types.h',
'chrome_elf_util.cc',
'chrome_elf_util.h',
Expand Down
7 changes: 7 additions & 0 deletions chrome_elf/chrome_elf_constants.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,10 @@ const wchar_t kLocalStateFilename[] = L"Local State";
const wchar_t kPreferencesFilename[] = L"Preferences";
const wchar_t kUserDataDirName[] = L"User Data";

namespace blacklist {

const wchar_t kRegistryBeaconPath[] = L"SOFTWARE\\Google\\Chrome\\BLBeacon";
const wchar_t kBeaconVersion[] = L"version";
const wchar_t kBeaconState[] = L"state";

} // namespace blacklist
28 changes: 28 additions & 0 deletions chrome_elf/chrome_elf_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,32 @@ extern const wchar_t kLocalStateFilename[];
extern const wchar_t kPreferencesFilename[];
extern const wchar_t kUserDataDirName[];

namespace blacklist {

// The registry path of the blacklist beacon.
extern const wchar_t kRegistryBeaconPath[];

// The properties for the blacklist beacon.
extern const wchar_t kBeaconVersion[];
extern const wchar_t kBeaconState[];

// The states for the blacklist setup code.
enum BlacklistState {
BLACKLIST_DISABLED = 0,
BLACKLIST_ENABLED,
// The blacklist setup code is running. If this is still set at startup,
// it means the last setup crashed.
BLACKLIST_SETUP_RUNNING,
// The blacklist thunk setup code is running. If this is still set at startup,
// it means the last setup crashed during thunk setup.
BLACKLIST_THUNK_SETUP,
// The blacklist code is currently intercepting MapViewOfSection. If this is
// still set at startup, it means we crashed during interception.
BLACKLIST_INTERCEPTING,
// Always keep this at the end.
BLACKLIST_STATE_MAX,
};

} // namespace blacklist

#endif // CHROME_ELF_CHROME_ELF_CONSTANTS_H_

0 comments on commit e5890e1

Please sign in to comment.