mirror of
https://github.com/chromium/crashpad.git
synced 2024-12-27 15:21:13 +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;
|
||||
ProcessSnapshotSanitized sanitized;
|
||||
std::vector<std::string> annotations_whitelist;
|
||||
std::vector<std::pair<VMAddress, VMAddress>> memory_range_whitelist;
|
||||
if (info.sanitization_information_address) {
|
||||
SanitizationInformation sanitization_info;
|
||||
ProcessMemoryRange range;
|
||||
@ -272,14 +270,17 @@ bool CrashReportExceptionHandler::HandleExceptionWithConnection(
|
||||
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(
|
||||
range,
|
||||
sanitization_info.annotations_whitelist_address,
|
||||
&annotations_whitelist) ||
|
||||
annotations_whitelist.get()) ||
|
||||
!ReadMemoryRangeWhitelist(
|
||||
range,
|
||||
sanitization_info.memory_range_whitelist_address,
|
||||
&memory_range_whitelist)) {
|
||||
memory_range_whitelist.get())) {
|
||||
Metrics::ExceptionCaptureResult(
|
||||
Metrics::CaptureResult::kSanitizationInitializationFailed);
|
||||
return false;
|
||||
@ -287,9 +288,9 @@ bool CrashReportExceptionHandler::HandleExceptionWithConnection(
|
||||
|
||||
if (!sanitized.Initialize(&process_snapshot,
|
||||
sanitization_info.annotations_whitelist_address
|
||||
? &annotations_whitelist
|
||||
? std::move(annotations_whitelist)
|
||||
: nullptr,
|
||||
&memory_range_whitelist,
|
||||
std::move(memory_range_whitelist),
|
||||
sanitization_info.target_module_address,
|
||||
sanitization_info.sanitize_stacks)) {
|
||||
Metrics::ExceptionCaptureResult(
|
||||
|
@ -84,13 +84,14 @@ ProcessSnapshotSanitized::~ProcessSnapshotSanitized() = default;
|
||||
|
||||
bool ProcessSnapshotSanitized::Initialize(
|
||||
const ProcessSnapshot* snapshot,
|
||||
const std::vector<std::string>* annotations_whitelist,
|
||||
const std::vector<std::pair<VMAddress, VMAddress>>* memory_range_whitelist,
|
||||
std::unique_ptr<const std::vector<std::string>> annotations_whitelist,
|
||||
std::unique_ptr<const std::vector<std::pair<VMAddress, VMAddress>>>
|
||||
memory_range_whitelist,
|
||||
VMAddress target_module_address,
|
||||
bool sanitize_stacks) {
|
||||
INITIALIZATION_STATE_SET_INITIALIZING(initialized_);
|
||||
snapshot_ = snapshot;
|
||||
annotations_whitelist_ = annotations_whitelist;
|
||||
annotations_whitelist_ = std::move(annotations_whitelist);
|
||||
sanitize_stacks_ = sanitize_stacks;
|
||||
|
||||
if (target_module_address) {
|
||||
@ -141,7 +142,7 @@ bool ProcessSnapshotSanitized::Initialize(
|
||||
if (annotations_whitelist_) {
|
||||
for (const auto module : snapshot_->Modules()) {
|
||||
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_);
|
||||
return true;
|
||||
|
@ -61,12 +61,13 @@ class ProcessSnapshotSanitized final : public ProcessSnapshot {
|
||||
//! internal::StackSnapshotSanitized.
|
||||
//! \return `false` if \a snapshot does not meet sanitization requirements and
|
||||
//! should be filtered entirely. Otherwise `true`.
|
||||
bool Initialize(const ProcessSnapshot* snapshot,
|
||||
const std::vector<std::string>* annotations_whitelist,
|
||||
const std::vector<std::pair<VMAddress, VMAddress>>*
|
||||
memory_range_whitelist,
|
||||
VMAddress target_module_address,
|
||||
bool sanitize_stacks);
|
||||
bool Initialize(
|
||||
const ProcessSnapshot* snapshot,
|
||||
std::unique_ptr<const std::vector<std::string>> annotations_whitelist,
|
||||
std::unique_ptr<const std::vector<std::pair<VMAddress, VMAddress>>>
|
||||
memory_range_whitelist,
|
||||
VMAddress target_module_address,
|
||||
bool sanitize_stacks);
|
||||
|
||||
// ProcessSnapshot:
|
||||
|
||||
@ -99,7 +100,7 @@ class ProcessSnapshotSanitized final : public ProcessSnapshot {
|
||||
RangeSet address_ranges_;
|
||||
const ProcessSnapshot* snapshot_;
|
||||
ProcessMemorySanitized process_memory_;
|
||||
const std::vector<std::string>* annotations_whitelist_;
|
||||
std::unique_ptr<const std::vector<std::string>> annotations_whitelist_;
|
||||
bool sanitize_stacks_;
|
||||
InitializationStateDcheck initialized_;
|
||||
|
||||
|
@ -271,17 +271,18 @@ class SanitizeTest : public MultiprocessExec {
|
||||
addrs.string_address,
|
||||
/* sanitized= */ false);
|
||||
|
||||
std::vector<std::string> annotations_whitelist;
|
||||
annotations_whitelist.push_back(kWhitelistedAnnotationName);
|
||||
auto annotations_whitelist = std::make_unique<std::vector<std::string>>();
|
||||
annotations_whitelist->push_back(kWhitelistedAnnotationName);
|
||||
|
||||
std::vector<std::pair<VMAddress, VMAddress>> memory_ranges_whitelist;
|
||||
memory_ranges_whitelist.push_back(
|
||||
auto memory_ranges_whitelist =
|
||||
std::make_unique<std::vector<std::pair<VMAddress, VMAddress>>>();
|
||||
memory_ranges_whitelist->push_back(
|
||||
std::make_pair(addrs.string_address, addrs.string_address + 1));
|
||||
|
||||
ProcessSnapshotSanitized sanitized;
|
||||
ASSERT_TRUE(sanitized.Initialize(&snapshot,
|
||||
&annotations_whitelist,
|
||||
&memory_ranges_whitelist,
|
||||
std::move(annotations_whitelist),
|
||||
std::move(memory_ranges_whitelist),
|
||||
addrs.module_address,
|
||||
true));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user