mirror of
https://github.com/chromium/crashpad.git
synced 2025-01-14 09:17:57 +08:00
Move whitelist ownership to ProcessSnapshotSanitized
Change-Id: Ie57117229520e52aeff83d0cbf95057690894e5b Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1773772 Reviewed-by: Mark Mentovai <mark@chromium.org> Commit-Queue: Joshua Peraza <jperaza@chromium.org>
This commit is contained in:
parent
1c7023875b
commit
7b5a55c3b1
@ -258,8 +258,6 @@ bool CrashReportExceptionHandler::HandleExceptionWithConnection(
|
|||||||
|
|
||||||
ProcessSnapshot* snapshot = nullptr;
|
ProcessSnapshot* snapshot = nullptr;
|
||||||
ProcessSnapshotSanitized sanitized;
|
ProcessSnapshotSanitized sanitized;
|
||||||
std::vector<std::string> annotations_whitelist;
|
|
||||||
std::vector<std::pair<VMAddress, VMAddress>> memory_range_whitelist;
|
|
||||||
if (info.sanitization_information_address) {
|
if (info.sanitization_information_address) {
|
||||||
SanitizationInformation sanitization_info;
|
SanitizationInformation sanitization_info;
|
||||||
ProcessMemoryRange range;
|
ProcessMemoryRange range;
|
||||||
@ -272,14 +270,17 @@ bool CrashReportExceptionHandler::HandleExceptionWithConnection(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto annotations_whitelist = std::make_unique<std::vector<std::string>>();
|
||||||
|
auto memory_range_whitelist =
|
||||||
|
std::make_unique<std::vector<std::pair<VMAddress, VMAddress>>>();
|
||||||
if (!ReadAnnotationsWhitelist(
|
if (!ReadAnnotationsWhitelist(
|
||||||
range,
|
range,
|
||||||
sanitization_info.annotations_whitelist_address,
|
sanitization_info.annotations_whitelist_address,
|
||||||
&annotations_whitelist) ||
|
annotations_whitelist.get()) ||
|
||||||
!ReadMemoryRangeWhitelist(
|
!ReadMemoryRangeWhitelist(
|
||||||
range,
|
range,
|
||||||
sanitization_info.memory_range_whitelist_address,
|
sanitization_info.memory_range_whitelist_address,
|
||||||
&memory_range_whitelist)) {
|
memory_range_whitelist.get())) {
|
||||||
Metrics::ExceptionCaptureResult(
|
Metrics::ExceptionCaptureResult(
|
||||||
Metrics::CaptureResult::kSanitizationInitializationFailed);
|
Metrics::CaptureResult::kSanitizationInitializationFailed);
|
||||||
return false;
|
return false;
|
||||||
@ -287,9 +288,9 @@ bool CrashReportExceptionHandler::HandleExceptionWithConnection(
|
|||||||
|
|
||||||
if (!sanitized.Initialize(&process_snapshot,
|
if (!sanitized.Initialize(&process_snapshot,
|
||||||
sanitization_info.annotations_whitelist_address
|
sanitization_info.annotations_whitelist_address
|
||||||
? &annotations_whitelist
|
? std::move(annotations_whitelist)
|
||||||
: nullptr,
|
: nullptr,
|
||||||
&memory_range_whitelist,
|
std::move(memory_range_whitelist),
|
||||||
sanitization_info.target_module_address,
|
sanitization_info.target_module_address,
|
||||||
sanitization_info.sanitize_stacks)) {
|
sanitization_info.sanitize_stacks)) {
|
||||||
Metrics::ExceptionCaptureResult(
|
Metrics::ExceptionCaptureResult(
|
||||||
|
@ -84,13 +84,14 @@ ProcessSnapshotSanitized::~ProcessSnapshotSanitized() = default;
|
|||||||
|
|
||||||
bool ProcessSnapshotSanitized::Initialize(
|
bool ProcessSnapshotSanitized::Initialize(
|
||||||
const ProcessSnapshot* snapshot,
|
const ProcessSnapshot* snapshot,
|
||||||
const std::vector<std::string>* annotations_whitelist,
|
std::unique_ptr<const std::vector<std::string>> annotations_whitelist,
|
||||||
const std::vector<std::pair<VMAddress, VMAddress>>* memory_range_whitelist,
|
std::unique_ptr<const std::vector<std::pair<VMAddress, VMAddress>>>
|
||||||
|
memory_range_whitelist,
|
||||||
VMAddress target_module_address,
|
VMAddress target_module_address,
|
||||||
bool sanitize_stacks) {
|
bool sanitize_stacks) {
|
||||||
INITIALIZATION_STATE_SET_INITIALIZING(initialized_);
|
INITIALIZATION_STATE_SET_INITIALIZING(initialized_);
|
||||||
snapshot_ = snapshot;
|
snapshot_ = snapshot;
|
||||||
annotations_whitelist_ = annotations_whitelist;
|
annotations_whitelist_ = std::move(annotations_whitelist);
|
||||||
sanitize_stacks_ = sanitize_stacks;
|
sanitize_stacks_ = sanitize_stacks;
|
||||||
|
|
||||||
if (target_module_address) {
|
if (target_module_address) {
|
||||||
@ -141,7 +142,7 @@ bool ProcessSnapshotSanitized::Initialize(
|
|||||||
if (annotations_whitelist_) {
|
if (annotations_whitelist_) {
|
||||||
for (const auto module : snapshot_->Modules()) {
|
for (const auto module : snapshot_->Modules()) {
|
||||||
modules_.emplace_back(std::make_unique<internal::ModuleSnapshotSanitized>(
|
modules_.emplace_back(std::make_unique<internal::ModuleSnapshotSanitized>(
|
||||||
module, annotations_whitelist_));
|
module, annotations_whitelist_.get()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,7 +159,7 @@ bool ProcessSnapshotSanitized::Initialize(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
process_memory_.Initialize(snapshot_->Memory(), memory_range_whitelist);
|
process_memory_.Initialize(snapshot_->Memory(), memory_range_whitelist.get());
|
||||||
|
|
||||||
INITIALIZATION_STATE_SET_VALID(initialized_);
|
INITIALIZATION_STATE_SET_VALID(initialized_);
|
||||||
return true;
|
return true;
|
||||||
|
@ -61,12 +61,13 @@ class ProcessSnapshotSanitized final : public ProcessSnapshot {
|
|||||||
//! internal::StackSnapshotSanitized.
|
//! internal::StackSnapshotSanitized.
|
||||||
//! \return `false` if \a snapshot does not meet sanitization requirements and
|
//! \return `false` if \a snapshot does not meet sanitization requirements and
|
||||||
//! should be filtered entirely. Otherwise `true`.
|
//! should be filtered entirely. Otherwise `true`.
|
||||||
bool Initialize(const ProcessSnapshot* snapshot,
|
bool Initialize(
|
||||||
const std::vector<std::string>* annotations_whitelist,
|
const ProcessSnapshot* snapshot,
|
||||||
const std::vector<std::pair<VMAddress, VMAddress>>*
|
std::unique_ptr<const std::vector<std::string>> annotations_whitelist,
|
||||||
memory_range_whitelist,
|
std::unique_ptr<const std::vector<std::pair<VMAddress, VMAddress>>>
|
||||||
VMAddress target_module_address,
|
memory_range_whitelist,
|
||||||
bool sanitize_stacks);
|
VMAddress target_module_address,
|
||||||
|
bool sanitize_stacks);
|
||||||
|
|
||||||
// ProcessSnapshot:
|
// ProcessSnapshot:
|
||||||
|
|
||||||
@ -99,7 +100,7 @@ class ProcessSnapshotSanitized final : public ProcessSnapshot {
|
|||||||
RangeSet address_ranges_;
|
RangeSet address_ranges_;
|
||||||
const ProcessSnapshot* snapshot_;
|
const ProcessSnapshot* snapshot_;
|
||||||
ProcessMemorySanitized process_memory_;
|
ProcessMemorySanitized process_memory_;
|
||||||
const std::vector<std::string>* annotations_whitelist_;
|
std::unique_ptr<const std::vector<std::string>> annotations_whitelist_;
|
||||||
bool sanitize_stacks_;
|
bool sanitize_stacks_;
|
||||||
InitializationStateDcheck initialized_;
|
InitializationStateDcheck initialized_;
|
||||||
|
|
||||||
|
@ -271,17 +271,18 @@ class SanitizeTest : public MultiprocessExec {
|
|||||||
addrs.string_address,
|
addrs.string_address,
|
||||||
/* sanitized= */ false);
|
/* sanitized= */ false);
|
||||||
|
|
||||||
std::vector<std::string> annotations_whitelist;
|
auto annotations_whitelist = std::make_unique<std::vector<std::string>>();
|
||||||
annotations_whitelist.push_back(kWhitelistedAnnotationName);
|
annotations_whitelist->push_back(kWhitelistedAnnotationName);
|
||||||
|
|
||||||
std::vector<std::pair<VMAddress, VMAddress>> memory_ranges_whitelist;
|
auto memory_ranges_whitelist =
|
||||||
memory_ranges_whitelist.push_back(
|
std::make_unique<std::vector<std::pair<VMAddress, VMAddress>>>();
|
||||||
|
memory_ranges_whitelist->push_back(
|
||||||
std::make_pair(addrs.string_address, addrs.string_address + 1));
|
std::make_pair(addrs.string_address, addrs.string_address + 1));
|
||||||
|
|
||||||
ProcessSnapshotSanitized sanitized;
|
ProcessSnapshotSanitized sanitized;
|
||||||
ASSERT_TRUE(sanitized.Initialize(&snapshot,
|
ASSERT_TRUE(sanitized.Initialize(&snapshot,
|
||||||
&annotations_whitelist,
|
std::move(annotations_whitelist),
|
||||||
&memory_ranges_whitelist,
|
std::move(memory_ranges_whitelist),
|
||||||
addrs.module_address,
|
addrs.module_address,
|
||||||
true));
|
true));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user