Commit 6ef32965 authored by Joshua Peraza's avatar Joshua Peraza Committed by Commit Bot

Update Crashpad to 58e4bbecc246543b60e4bc4bbdccd2e24d3157c9

9c89cd99f335 gn: add templates for executables and loadable_modules
6b23575b34bd linux: verify whether a broker has been successfully forked
5754f608cb57 android: unset source filters to use linux files
58e4bbecc246 win, gn: use new lists when using templated targets

Bug: crashpad:30
Change-Id: I0902c600b7257a419b8b0d770ac4f40fc6a808e6
Reviewed-on: https://chromium-review.googlesource.com/981690Reviewed-by: default avatarMark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Cr-Commit-Position: refs/heads/master@{#546219}
parent 0286755c
......@@ -2,7 +2,7 @@ Name: Crashpad
Short Name: crashpad
URL: https://crashpad.chromium.org/
Version: unknown
Revision: 6d4626090db24cc4c05946c3b43962596e522d9a
Revision: 58e4bbecc246543b60e4bc4bbdccd2e24d3157c9
License: Apache 2.0
License File: crashpad/LICENSE
Security Critical: yes
......
......@@ -60,3 +60,45 @@ if (crashpad_is_in_chromium) {
crashpad_is_clang = mini_chromium_is_clang
}
template("crashpad_executable") {
executable(target_name) {
forward_variables_from(invoker, "*", [ "configs", "remove_configs" ])
if (defined(invoker.remove_configs)) {
configs -= invoker.remove_configs
}
if (defined(invoker.configs)) {
configs += invoker.configs
}
if (!defined(deps)) {
deps = []
}
if (crashpad_is_in_chromium) {
deps += [ "//build/config:exe_and_shlib_deps" ]
}
}
}
template("crashpad_loadable_module") {
loadable_module(target_name) {
forward_variables_from(invoker, "*", [ "configs", "remove_configs" ])
if (defined(invoker.remove_configs)) {
configs -= invoker.remove_configs
}
if (defined(invoker.configs)) {
configs += invoker.configs
}
if (!defined(deps)) {
deps = []
}
if (crashpad_is_in_chromium) {
deps += [ "//build/config:exe_and_shlib_deps" ]
}
}
}
......@@ -44,6 +44,7 @@ static_library("client") {
}
if (crashpad_is_linux || crashpad_is_android) {
set_sources_assignment_filter([])
sources += [
"crashpad_client_linux.cc",
"simulate_crash_linux.h",
......
......@@ -40,6 +40,7 @@ static_library("handler") {
}
if (crashpad_is_linux || crashpad_is_android) {
set_sources_assignment_filter([])
sources += [
"linux/crash_report_exception_handler.cc",
"linux/crash_report_exception_handler.h",
......@@ -115,7 +116,7 @@ source_set("handler_test") {
}
}
executable("crashpad_handler") {
crashpad_executable("crashpad_handler") {
sources = [
"main.cc",
]
......@@ -147,18 +148,18 @@ executable("crashpad_handler") {
if (crashpad_is_win) {
if (crashpad_is_in_chromium) {
configs -= [ "//build/config/win:console" ]
configs += [ "//build/config/win:windowed" ]
remove_configs = [ "//build/config/win:console" ]
configs = [ "//build/config/win:windowed" ]
} else {
configs -=
remove_configs =
[ "//third_party/mini_chromium/mini_chromium/build:win_console" ]
configs +=
configs =
[ "//third_party/mini_chromium/mini_chromium/build:win_windowed" ]
}
}
}
executable("crashpad_handler_test_extended_handler") {
crashpad_executable("crashpad_handler_test_extended_handler") {
testonly = true
sources = [
......@@ -176,7 +177,7 @@ executable("crashpad_handler_test_extended_handler") {
}
if (crashpad_is_win) {
executable("crashpad_handler_com") {
crashpad_executable("crashpad_handler_com") {
sources = [
"main.cc",
]
......@@ -206,7 +207,7 @@ if (crashpad_is_win) {
]
}
executable("crash_other_program") {
crashpad_executable("crash_other_program") {
testonly = true
sources = [
......@@ -221,7 +222,7 @@ if (crashpad_is_win) {
]
}
executable("crashy_program") {
crashpad_executable("crashy_program") {
testonly = true
sources = [
......@@ -234,7 +235,7 @@ if (crashpad_is_win) {
]
}
executable("crashy_signal") {
crashpad_executable("crashy_signal") {
testonly = true
sources = [
......@@ -249,7 +250,7 @@ if (crashpad_is_win) {
]
}
executable("fake_handler_that_crashes_at_startup") {
crashpad_executable("fake_handler_that_crashes_at_startup") {
testonly = true
sources = [
......@@ -257,7 +258,7 @@ if (crashpad_is_win) {
]
}
executable("hanging_program") {
crashpad_executable("hanging_program") {
testonly = true
sources = [
......@@ -270,7 +271,7 @@ if (crashpad_is_win) {
]
}
loadable_module("loader_lock_dll") {
crashpad_loadable_module("loader_lock_dll") {
testonly = true
sources = [
......@@ -278,7 +279,7 @@ if (crashpad_is_win) {
]
}
executable("self_destroying_program") {
crashpad_executable("self_destroying_program") {
testonly = true
sources = [
......@@ -295,7 +296,7 @@ if (crashpad_is_win) {
if (current_cpu == "x86") {
# Cannot create an x64 DLL with embedded debug info.
executable("crashy_z7_loader") {
crashpad_executable("crashy_z7_loader") {
testonly = true
sources = [
......
......@@ -63,7 +63,7 @@ bool CrashReportExceptionHandler::HandleExceptionWithBroker(
Metrics::ExceptionEncountered();
PtraceClient client;
if (client.Initialize(broker_sock, client_process_id)) {
if (!client.Initialize(broker_sock, client_process_id)) {
Metrics::ExceptionCaptureResult(
Metrics::CaptureResult::kBrokeredPtraceFailed);
return false;
......
......@@ -126,8 +126,10 @@ class PtraceStrategyDeciderImpl : public PtraceStrategyDecider {
Strategy ChooseStrategy(int sock, const ucred& client_credentials) override {
switch (GetPtraceScope()) {
case PtraceScope::kClassic:
return getuid() == client_credentials.uid ? Strategy::kDirectPtrace
: Strategy::kForkBroker;
if (getuid() == client_credentials.uid) {
return Strategy::kDirectPtrace;
}
return TryForkingBroker(sock);
case PtraceScope::kRestricted:
if (!SendMessageToClient(sock,
......@@ -143,7 +145,7 @@ class PtraceStrategyDeciderImpl : public PtraceStrategyDecider {
if (status != 0) {
errno = status;
PLOG(ERROR) << "Handler Client SetPtracer";
return Strategy::kForkBroker;
return TryForkingBroker(sock);
}
return Strategy::kDirectPtrace;
......@@ -163,6 +165,26 @@ class PtraceStrategyDeciderImpl : public PtraceStrategyDecider {
DCHECK(false);
}
private:
static Strategy TryForkingBroker(int client_sock) {
if (!SendMessageToClient(client_sock,
ServerToClientMessage::kTypeForkBroker)) {
return Strategy::kError;
}
Errno status;
if (!LoggingReadFileExactly(client_sock, &status, sizeof(status))) {
return Strategy::kError;
}
if (status != 0) {
errno = status;
PLOG(ERROR) << "Handler Client ForkBroker";
return Strategy::kNoPtrace;
}
return Strategy::kUseBroker;
}
};
} // namespace
......@@ -427,12 +449,7 @@ bool ExceptionHandlerServer::HandleCrashDumpRequest(
client_info.exception_information_address);
break;
case PtraceStrategyDecider::Strategy::kForkBroker:
if (!SendMessageToClient(client_sock,
ServerToClientMessage::kTypeForkBroker)) {
return false;
}
case PtraceStrategyDecider::Strategy::kUseBroker:
delegate_->HandleExceptionWithBroker(
client_process_id,
client_info.exception_information_address,
......
......@@ -46,8 +46,8 @@ class PtraceStrategyDecider {
//! \brief The handler should `ptrace`-attach the client directly.
kDirectPtrace,
//! \brief The client should `fork` a PtraceBroker for the handler.
kForkBroker,
//! \brief The client has `fork`ed a PtraceBroker for the handler.
kUseBroker,
};
//! \brief Chooses an appropriate `ptrace` strategy.
......
......@@ -289,7 +289,7 @@ TEST_F(ExceptionHandlerServerTest, RequestCrashDumpNoPtrace) {
}
TEST_F(ExceptionHandlerServerTest, RequestCrashDumpForkBroker) {
ExpectCrashDumpUsingStrategy(PtraceStrategyDecider::Strategy::kForkBroker,
ExpectCrashDumpUsingStrategy(PtraceStrategyDecider::Strategy::kUseBroker,
true);
}
......
......@@ -104,6 +104,7 @@ static_library("snapshot") {
}
if (crashpad_is_linux || crashpad_is_android) {
set_sources_assignment_filter([])
sources += [
"linux/cpu_context_linux.cc",
"linux/cpu_context_linux.h",
......@@ -401,7 +402,7 @@ source_set("snapshot_test") {
}
}
loadable_module("crashpad_snapshot_test_module") {
crashpad_loadable_module("crashpad_snapshot_test_module") {
testonly = true
sources = [
"crashpad_info_client_options_test_module.cc",
......@@ -412,7 +413,7 @@ loadable_module("crashpad_snapshot_test_module") {
]
}
loadable_module("crashpad_snapshot_test_module_large") {
crashpad_loadable_module("crashpad_snapshot_test_module_large") {
testonly = true
sources = [
"crashpad_info_size_test_module.cc",
......@@ -428,7 +429,7 @@ loadable_module("crashpad_snapshot_test_module_large") {
deps += [ "../third_party/mini_chromium:base" ]
}
loadable_module("crashpad_snapshot_test_module_small") {
crashpad_loadable_module("crashpad_snapshot_test_module_small") {
testonly = true
sources = [
"crashpad_info_size_test_module.cc",
......@@ -445,7 +446,7 @@ loadable_module("crashpad_snapshot_test_module_small") {
}
if (crashpad_is_linux || crashpad_is_android || crashpad_is_fuchsia) {
loadable_module("crashpad_snapshot_test_both_dt_hash_styles") {
crashpad_loadable_module("crashpad_snapshot_test_both_dt_hash_styles") {
testonly = true
sources = [
"hash_types_test.cc",
......@@ -457,14 +458,14 @@ if (crashpad_is_linux || crashpad_is_android || crashpad_is_fuchsia) {
}
if (crashpad_is_mac) {
loadable_module("crashpad_snapshot_test_module_crashy_initializer") {
crashpad_loadable_module("crashpad_snapshot_test_module_crashy_initializer") {
testonly = true
sources = [
"mac/mach_o_image_annotations_reader_test_module_crashy_initializer.cc",
]
}
executable("crashpad_snapshot_test_no_op") {
crashpad_executable("crashpad_snapshot_test_no_op") {
testonly = true
sources = [
"mac/mach_o_image_annotations_reader_test_no_op.cc",
......@@ -473,7 +474,7 @@ if (crashpad_is_mac) {
}
if (crashpad_is_win) {
executable("crashpad_snapshot_test_annotations") {
crashpad_executable("crashpad_snapshot_test_annotations") {
testonly = true
sources = [
"win/crashpad_snapshot_test_annotations.cc",
......@@ -485,7 +486,7 @@ if (crashpad_is_win) {
]
}
executable("crashpad_snapshot_test_crashing_child") {
crashpad_executable("crashpad_snapshot_test_crashing_child") {
testonly = true
sources = [
"win/crashpad_snapshot_test_crashing_child.cc",
......@@ -498,7 +499,7 @@ if (crashpad_is_win) {
]
}
executable("crashpad_snapshot_test_dump_without_crashing") {
crashpad_executable("crashpad_snapshot_test_dump_without_crashing") {
testonly = true
sources = [
"win/crashpad_snapshot_test_dump_without_crashing.cc",
......@@ -511,7 +512,7 @@ if (crashpad_is_win) {
]
}
executable("crashpad_snapshot_test_extra_memory_ranges") {
crashpad_executable("crashpad_snapshot_test_extra_memory_ranges") {
testonly = true
sources = [
"win/crashpad_snapshot_test_extra_memory_ranges.cc",
......@@ -523,7 +524,7 @@ if (crashpad_is_win) {
]
}
executable("crashpad_snapshot_test_image_reader") {
crashpad_executable("crashpad_snapshot_test_image_reader") {
testonly = true
sources = [
"win/crashpad_snapshot_test_image_reader.cc",
......@@ -538,13 +539,13 @@ if (crashpad_is_win) {
if (symbol_level == 0) {
# The tests that use this executable rely on at least minimal debug
# info.
configs -= [ "//build/config/compiler:default_symbols" ]
configs += [ "//build/config/compiler:minimal_symbols" ]
remove_configs = [ "//build/config/compiler:default_symbols" ]
configs = [ "//build/config/compiler:minimal_symbols" ]
}
}
}
loadable_module("crashpad_snapshot_test_image_reader_module") {
crashpad_loadable_module("crashpad_snapshot_test_image_reader_module") {
testonly = true
sources = [
"win/crashpad_snapshot_test_image_reader_module.cc",
......@@ -556,8 +557,8 @@ if (crashpad_is_win) {
if (crashpad_is_in_chromium) {
if (symbol_level == 0) {
# The tests that use this module rely on at least minimal debug info.
configs -= [ "//build/config/compiler:default_symbols" ]
configs += [ "//build/config/compiler:minimal_symbols" ]
remove_configs = [ "//build/config/compiler:default_symbols" ]
configs = [ "//build/config/compiler:minimal_symbols" ]
}
}
}
......
......@@ -69,6 +69,7 @@ static_library("test") {
}
if (crashpad_is_linux || crashpad_is_android) {
set_sources_assignment_filter([])
sources += [
"linux/fake_ptrace_connection.cc",
"linux/fake_ptrace_connection.h",
......@@ -171,7 +172,7 @@ source_set("test_test") {
]
}
executable("crashpad_test_test_multiprocess_exec_test_child") {
crashpad_executable("crashpad_test_test_multiprocess_exec_test_child") {
sources = [
"multiprocess_exec_test_child.cc",
]
......
......@@ -27,7 +27,7 @@ source_set("tool_support") {
]
}
executable("crashpad_database_util") {
crashpad_executable("crashpad_database_util") {
sources = [
"crashpad_database_util.cc",
]
......@@ -42,7 +42,7 @@ executable("crashpad_database_util") {
]
}
executable("crashpad_http_upload") {
crashpad_executable("crashpad_http_upload") {
sources = [
"crashpad_http_upload.cc",
]
......@@ -56,7 +56,7 @@ executable("crashpad_http_upload") {
]
}
executable("generate_dump") {
crashpad_executable("generate_dump") {
sources = [
"generate_dump.cc",
]
......@@ -92,7 +92,7 @@ executable("generate_dump") {
}
if (crashpad_is_mac) {
executable("catch_exception_tool") {
crashpad_executable("catch_exception_tool") {
sources = [
"mac/catch_exception_tool.cc",
]
......@@ -105,7 +105,7 @@ if (crashpad_is_mac) {
]
}
executable("exception_port_tool") {
crashpad_executable("exception_port_tool") {
sources = [
"mac/exception_port_tool.cc",
]
......@@ -130,7 +130,7 @@ if (crashpad_is_mac) {
]
}
executable("on_demand_service_tool") {
crashpad_executable("on_demand_service_tool") {
sources = [
"mac/on_demand_service_tool.mm",
]
......@@ -148,7 +148,7 @@ if (crashpad_is_mac) {
]
}
executable("run_with_crashpad") {
crashpad_executable("run_with_crashpad") {
sources = [
"mac/run_with_crashpad.cc",
]
......
......@@ -260,6 +260,7 @@ static_library("util") {
}
if (crashpad_is_linux || crashpad_is_android) {
set_sources_assignment_filter([])
sources += [
"linux/address_types.h",
"linux/auxiliary_vector.cc",
......@@ -548,6 +549,7 @@ source_set("util_test") {
}
if (crashpad_is_linux || crashpad_is_android) {
set_sources_assignment_filter([])
sources += [
"linux/auxiliary_vector_test.cc",
"linux/memory_map_test.cc",
......@@ -617,14 +619,14 @@ source_set("util_test") {
}
if (crashpad_is_win) {
executable("crashpad_util_test_process_info_test_child") {
crashpad_executable("crashpad_util_test_process_info_test_child") {
testonly = true
sources = [
"win/process_info_test_child.cc",
]
}
executable("crashpad_util_test_safe_terminate_process_test_child") {
crashpad_executable("crashpad_util_test_safe_terminate_process_test_child") {
testonly = true
sources = [
"win/safe_terminate_process_test_child.cc",
......
......@@ -22,6 +22,7 @@
#include "base/bit_cast.h"
#include "base/macros.h"
#include "build/build_config.h"
#include "gtest/gtest.h"
#include "test/errors.h"
#include "test/multiprocess.h"
......@@ -31,9 +32,13 @@
#include "util/numeric/int128.h"
#include "util/process/process_memory_linux.h"
#if !defined(OS_ANDROID)
// TODO(jperaza): This symbol isn't defined when building in chromium for
// Android. There may be another symbol to use.
extern "C" {
extern void _start();
} // extern "C"
#endif
namespace crashpad {
namespace test {
......@@ -63,9 +68,11 @@ void TestAgainstCloneOrSelf(pid_t pid) {
ASSERT_TRUE(aux.GetValue(AT_BASE, &interp_base));
EXPECT_TRUE(mappings.FindMapping(interp_base));
#if !defined(OS_ANDROID)
LinuxVMAddress entry_addr;
ASSERT_TRUE(aux.GetValue(AT_ENTRY, &entry_addr));
EXPECT_EQ(entry_addr, FromPointerCast<LinuxVMAddress>(_start));
#endif
uid_t uid;
ASSERT_TRUE(aux.GetValue(AT_UID, &uid));
......
......@@ -112,11 +112,14 @@ int ExceptionHandlerClient::WaitForCrashDumpComplete() {
Signals::InstallDefaultHandler(SIGCHLD);
pid_t pid = fork();
if (pid < 0) {
Errno error = errno;
if (pid <= 0) {
Errno error = pid < 0 ? errno : 0;
if (!WriteFile(server_sock_, &error, sizeof(error))) {
return errno;
}
}
if (pid < 0) {
continue;
}
......
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