Commit 65a1513f authored by grt's avatar grt Committed by Commit bot

Remove legacy Module Verifier.

BUG=480352,454716,412045

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

Cr-Commit-Position: refs/heads/master@{#330603}
parent 051aece1
...@@ -130,67 +130,31 @@ void CollectModuleVerificationData( ...@@ -130,67 +130,31 @@ void CollectModuleVerificationData(
size_t num_modules_to_verify, size_t num_modules_to_verify,
ClientIncidentReport_EnvironmentData_Process* process) { ClientIncidentReport_EnvironmentData_Process* process) {
#if !defined(_WIN64) #if !defined(_WIN64)
using ModuleState = ClientIncidentReport_EnvironmentData_Process_ModuleState;
for (size_t i = 0; i < num_modules_to_verify; ++i) { for (size_t i = 0; i < num_modules_to_verify; ++i) {
scoped_ptr<ClientIncidentReport_EnvironmentData_Process_ModuleState> scoped_ptr<ModuleState> module_state(new ModuleState());
module_state(
new ClientIncidentReport_EnvironmentData_Process_ModuleState());
VerificationResult result = NewVerifyModule(modules_to_verify[i], int num_bytes_different = 0;
module_state.get()); bool scan_complete = VerifyModule(modules_to_verify[i],
module_state.get(),
&num_bytes_different);
std::set<std::string> modified_exports; if (module_state->modified_state() == ModuleState::MODULE_STATE_UNMODIFIED)
int num_bytes = 0; continue;
int modified = VerifyModule(modules_to_verify[i],
&modified_exports,
&num_bytes);
if (result.state == MODULE_STATE_MODIFIED) { if (module_state->modified_state() == ModuleState::MODULE_STATE_MODIFIED) {
UMA_HISTOGRAM_COUNTS_10000( UMA_HISTOGRAM_COUNTS_10000(
"ModuleIntegrityVerification.BytesModified.WithoutByteSet", "ModuleIntegrityVerification.BytesModified.WithoutByteSet",
result.num_bytes_different); num_bytes_different);
}
if (modified == MODULE_STATE_MODIFIED) {
UMA_HISTOGRAM_COUNTS_10000(
"ModuleIntegrityVerification.BytesModified.WithByteSet",
num_bytes);
} }
if (modified == MODULE_STATE_MODIFIED || if (!scan_complete) {
result.state == MODULE_STATE_MODIFIED) {
int difference = abs(result.num_bytes_different - num_bytes);
if (result.num_bytes_different > num_bytes) {
UMA_HISTOGRAM_COUNTS_10000(
"ModuleIntegrityVerification.Difference.WithoutByteSet",
difference);
} else if (num_bytes > result.num_bytes_different) {
UMA_HISTOGRAM_COUNTS_10000(
"ModuleIntegrityVerification.Difference.WithByteSet",
difference);
}
}
if (!result.verification_completed) {
UMA_HISTOGRAM_ENUMERATION( UMA_HISTOGRAM_ENUMERATION(
"ModuleIntegrityVerification.RelocationsUnordered", i, "ModuleIntegrityVerification.RelocationsUnordered", i,
num_modules_to_verify); num_modules_to_verify);
} }
if (modified == MODULE_STATE_UNMODIFIED)
continue;
module_state->set_name(base::WideToUTF8(modules_to_verify[i]));
// Add 1 to the ModuleState enum to get the corresponding value in the
// protobuf's ModuleState enum.
module_state->set_modified_state(static_cast<
ClientIncidentReport_EnvironmentData_Process_ModuleState_ModifiedState>(
modified + 1));
for (std::set<std::string>::iterator it = modified_exports.begin();
it != modified_exports.end();
++it) {
module_state->add_modified_export(*it);
}
process->mutable_module_state()->AddAllocated(module_state.release()); process->mutable_module_state()->AddAllocated(module_state.release());
} }
#endif // _WIN64 #endif // _WIN64
......
...@@ -208,7 +208,8 @@ TEST(SafeBrowsingEnvironmentDataCollectionWinTest, VerifyLoadedModules) { ...@@ -208,7 +208,8 @@ TEST(SafeBrowsingEnvironmentDataCollectionWinTest, VerifyLoadedModules) {
ASSERT_LE(1, process_report.module_state_size()); ASSERT_LE(1, process_report.module_state_size());
#if !defined(ADDRESS_SANITIZER) #if !defined(ADDRESS_SANITIZER)
EXPECT_EQ(1, process_report.module_state_size()); EXPECT_EQ(1, process_report.module_state_size());
EXPECT_EQ(1, process_report.module_state(0).modified_export_size()); EXPECT_EQ(1, process_report.module_state(0).modification_size());
EXPECT_TRUE(process_report.module_state(0).modification(0).has_export_name());
#endif #endif
EXPECT_EQ(base::WideToUTF8(kTestDllNames[0]), EXPECT_EQ(base::WideToUTF8(kTestDllNames[0]),
...@@ -219,7 +220,7 @@ TEST(SafeBrowsingEnvironmentDataCollectionWinTest, VerifyLoadedModules) { ...@@ -219,7 +220,7 @@ TEST(SafeBrowsingEnvironmentDataCollectionWinTest, VerifyLoadedModules) {
// See comment above about AddressSantizier. // See comment above about AddressSantizier.
#if !defined(ADDRESS_SANITIZER) #if !defined(ADDRESS_SANITIZER)
EXPECT_EQ(std::string(kTestExportName), EXPECT_EQ(std::string(kTestExportName),
process_report.module_state(0).modified_export(0)); process_report.module_state(0).modification(0).export_name());
#endif #endif
} }
#endif // _WIN64 #endif // _WIN64
......
...@@ -7,11 +7,6 @@ ...@@ -7,11 +7,6 @@
#include <stdint.h> #include <stdint.h>
#include <set>
#include <string>
#include "chrome/common/safe_browsing/csd.pb.h"
namespace base { namespace base {
namespace win { namespace win {
class PEImage; class PEImage;
...@@ -21,21 +16,7 @@ class PEImageAsData; ...@@ -21,21 +16,7 @@ class PEImageAsData;
namespace safe_browsing { namespace safe_browsing {
// This enum defines the possible module states VerifyModule can return. class ClientIncidentReport_EnvironmentData_Process_ModuleState;
enum ModuleState {
MODULE_STATE_UNKNOWN,
MODULE_STATE_UNMODIFIED,
MODULE_STATE_MODIFIED,
};
struct VerificationResult {
ModuleState state;
// The number of bytes with different values on disk and in memory.
int num_bytes_different;
// True if the relocations were ordered and the verification was fully
// completed.
bool verification_completed;
};
// Helper to grab the addresses and size of the code section of a PEImage. // Helper to grab the addresses and size of the code section of a PEImage.
// Returns two addresses: one for the dll loaded as a library, the other for the // Returns two addresses: one for the dll loaded as a library, the other for the
...@@ -46,18 +27,15 @@ bool GetCodeAddrsAndSize(const base::win::PEImage& mem_peimage, ...@@ -46,18 +27,15 @@ bool GetCodeAddrsAndSize(const base::win::PEImage& mem_peimage,
uint8_t** disk_code_addr, uint8_t** disk_code_addr,
uint32_t* code_size); uint32_t* code_size);
// Examines the code section of the given module in memory and on disk, looking
// for unexpected differences. Returns a ModuleState and and a set of the
// possibly modified exports.
ModuleState VerifyModule(const wchar_t* module_name,
std::set<std::string>* modified_exports,
int* num_bytes_different);
// Examines the code section of the given module in memory and on disk, looking // Examines the code section of the given module in memory and on disk, looking
// for unexpected differences and populating |module_state| in the process. // for unexpected differences and populating |module_state| in the process.
VerificationResult NewVerifyModule( // Returns true if the entire image was scanned. |num_bytes_different| is
// populated with the number of differing bytes found, even if the scan failed
// to complete.
bool VerifyModule(
const wchar_t* module_name, const wchar_t* module_name,
ClientIncidentReport_EnvironmentData_Process_ModuleState* module_state); ClientIncidentReport_EnvironmentData_Process_ModuleState* module_state,
int* num_bytes_different);
} // namespace safe_browsing } // namespace safe_browsing
......
...@@ -474,7 +474,7 @@ message ClientIncidentReport { ...@@ -474,7 +474,7 @@ message ClientIncidentReport {
} }
optional string name = 1; optional string name = 1;
optional ModifiedState modified_state = 2; optional ModifiedState modified_state = 2;
repeated string modified_export = 3; repeated string OBSOLETE_modified_export = 3;
message Modification { message Modification {
optional uint32 file_offset = 1; optional uint32 file_offset = 1;
......
...@@ -16446,6 +16446,9 @@ Therefore, the affected-histogram name has to have at least one dot in it. ...@@ -16446,6 +16446,9 @@ Therefore, the affected-histogram name has to have at least one dot in it.
</histogram> </histogram>
<histogram name="ModuleIntegrityVerification.Difference" units="bytes"> <histogram name="ModuleIntegrityVerification.Difference" units="bytes">
<obsolete>
Deprecated and removed from code as of 05/2015.
</obsolete>
<owner>anthonyvd@chromium.org</owner> <owner>anthonyvd@chromium.org</owner>
<summary> <summary>
Represents the difference in bytes deemed modified by the two Represents the difference in bytes deemed modified by the two
...@@ -67783,8 +67786,12 @@ To add a new entry, add it with any value and run test to compute valid value. ...@@ -67783,8 +67786,12 @@ To add a new entry, add it with any value and run test to compute valid value.
label="The version of the Module Integrity Verifier that doesn't use a label="The version of the Module Integrity Verifier that doesn't use a
hash set to track relocations."/> hash set to track relocations."/>
<suffix name="WithByteSet" <suffix name="WithByteSet"
label="The version of the Module Integrity Verifier that uses a hash label="The version of the Module Integrity Verifier that uses a hash set
set to track relocations."/> to track relocations.">
<obsolete>
Deprecated and removed from code as of 05/2015.
</obsolete>
</suffix>
<affected-histogram name="ModuleIntegrityVerification.BytesModified"/> <affected-histogram name="ModuleIntegrityVerification.BytesModified"/>
<affected-histogram name="ModuleIntegrityVerification.Difference"/> <affected-histogram name="ModuleIntegrityVerification.Difference"/>
</histogram_suffixes> </histogram_suffixes>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment