Commit 37f774b5 authored by Joshua Peraza's avatar Joshua Peraza Committed by Commit Bot

Update Crashpad to bcab7ad54c2ed7df41f22de117657c1ade308434

359fc4a1336d [Windows] Add checks for DLL loader lock
9a312ddff5fa Increase kAllowedOffset for non-optimized build
e01fb92aa9a9 Fix #elif in crrev.com/c/1949846
6b81e8173fa3 Removes the obsolete cq.cfg file
c9f089eee409 linux: update lss
bcab7ad54c2e linux: handle large mapped files

Change-Id: Ia4be884ad545e134ee41e908c5d0a99f2e3d7abf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1954932Reviewed-by: default avatarMark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Cr-Commit-Position: refs/heads/master@{#722339}
parent f2101e47
...@@ -2,7 +2,7 @@ Name: Crashpad ...@@ -2,7 +2,7 @@ Name: Crashpad
Short Name: crashpad Short Name: crashpad
URL: https://crashpad.chromium.org/ URL: https://crashpad.chromium.org/
Version: unknown Version: unknown
Revision: 7fd5226a97ea9161382384b1fa6c6b329933ad27 Revision: bcab7ad54c2ed7df41f22de117657c1ade308434
License: Apache 2.0 License: Apache 2.0
License File: crashpad/LICENSE License File: crashpad/LICENSE
Security Critical: yes Security Critical: yes
......
...@@ -30,7 +30,7 @@ deps = { ...@@ -30,7 +30,7 @@ deps = {
'8bee09f4a57807136593ddc906b0b213c21f9014', '8bee09f4a57807136593ddc906b0b213c21f9014',
'crashpad/third_party/lss/lss': 'crashpad/third_party/lss/lss':
Var('chromium_git') + '/linux-syscall-support.git@' + Var('chromium_git') + '/linux-syscall-support.git@' +
'726d71ec08d15493b94eff456bc31faecf0a5902', '7bde79cc274d06451bf65ae82c012a5d3e476b5a',
'crashpad/third_party/mini_chromium/mini_chromium': 'crashpad/third_party/mini_chromium/mini_chromium':
Var('chromium_git') + '/chromium/mini_chromium@' + Var('chromium_git') + '/chromium/mini_chromium@' +
'cdab1e6263ec7f3f61763efc1dac863f8dc07c80', 'cdab1e6263ec7f3f61763efc1dac863f8dc07c80',
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include "util/win/get_function.h" #include "util/win/get_function.h"
#include "util/win/handle.h" #include "util/win/handle.h"
#include "util/win/initial_client_data.h" #include "util/win/initial_client_data.h"
#include "util/win/loader_lock.h"
#include "util/win/nt_internals.h" #include "util/win/nt_internals.h"
#include "util/win/ntstatus_logging.h" #include "util/win/ntstatus_logging.h"
#include "util/win/process_info.h" #include "util/win/process_info.h"
...@@ -346,6 +347,8 @@ class ScopedCallSetHandlerStartupState { ...@@ -346,6 +347,8 @@ class ScopedCallSetHandlerStartupState {
bool StartHandlerProcess( bool StartHandlerProcess(
std::unique_ptr<BackgroundHandlerStartThreadData> data) { std::unique_ptr<BackgroundHandlerStartThreadData> data) {
CHECK(!IsThreadInLoaderLock());
ScopedCallSetHandlerStartupState scoped_startup_state_caller; ScopedCallSetHandlerStartupState scoped_startup_state_caller;
std::wstring command_line; std::wstring command_line;
......
# Copyright 2017 The Crashpad Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# See https://luci-config.appspot.com/schemas/projects/refs:cq.cfg for the
# documentation of this file format.
version: 1
cq_status_url: "https://chromium-cq-status.appspot.com"
# This is required for gerrit projects.
git_repo_url: "https://chromium.googlesource.com/crashpad/crashpad"
# Crashpad uses gerrit with no special options.
gerrit {}
verifiers {
gerrit_cq_ability {
committer_list: "project-crashpad-tryjob-access"
dry_run_access_list: "project-crashpad-tryjob-access"
}
try_job {
buckets {
name: "luci.crashpad.try"
builders { name: "crashpad_try_mac_dbg" }
builders { name: "crashpad_try_mac_rel" }
builders { name: "crashpad_try_win_dbg" }
builders { name: "crashpad_try_win_rel" }
builders { name: "crashpad_try_linux_dbg" }
builders { name: "crashpad_try_linux_rel" }
builders { name: "crashpad_try_fuchsia_arm64_dbg" }
builders { name: "crashpad_try_fuchsia_arm64_rel" }
builders { name: "crashpad_try_fuchsia_x64_dbg" }
builders { name: "crashpad_try_fuchsia_x64_rel" }
# https://crbug.com/743139 - disabled until we can move these to swarming,
# at which point we can just remove them.
#builders { name: "crashpad_try_win_x86_dbg" }
#builders { name: "crashpad_try_win_x86_rel" }
}
}
}
...@@ -213,6 +213,9 @@ class SimulateDelegate : public ExceptionHandlerServer::Delegate { ...@@ -213,6 +213,9 @@ class SimulateDelegate : public ExceptionHandlerServer::Delegate {
// ASan instrumentation inserts more instructions between the expected // ASan instrumentation inserts more instructions between the expected
// location and what's reported. https://crbug.com/845011. // location and what's reported. https://crbug.com/845011.
constexpr uint64_t kAllowedOffset = 500; constexpr uint64_t kAllowedOffset = 500;
#elif !defined(NDEBUG)
// Debug build is likely not optimized and contains more instructions.
constexpr uint64_t kAllowedOffset = 150;
#else #else
constexpr uint64_t kAllowedOffset = 100; constexpr uint64_t kAllowedOffset = 100;
#endif #endif
......
...@@ -371,6 +371,8 @@ static_library("util") { ...@@ -371,6 +371,8 @@ static_library("util") {
"win/handle.h", "win/handle.h",
"win/initial_client_data.cc", "win/initial_client_data.cc",
"win/initial_client_data.h", "win/initial_client_data.h",
"win/loader_lock.cc",
"win/loader_lock.h",
"win/module_version.cc", "win/module_version.cc",
"win/module_version.h", "win/module_version.h",
"win/nt_internals.cc", "win/nt_internals.cc",
...@@ -666,6 +668,7 @@ source_set("util_test") { ...@@ -666,6 +668,7 @@ source_set("util_test") {
"win/get_function_test.cc", "win/get_function_test.cc",
"win/handle_test.cc", "win/handle_test.cc",
"win/initial_client_data_test.cc", "win/initial_client_data_test.cc",
"win/loader_lock_test.cc",
"win/process_info_test.cc", "win/process_info_test.cc",
"win/registration_protocol_win_test.cc", "win/registration_protocol_win_test.cc",
"win/safe_terminate_process_test.cc", "win/safe_terminate_process_test.cc",
...@@ -718,6 +721,7 @@ source_set("util_test") { ...@@ -718,6 +721,7 @@ source_set("util_test") {
"dbghelp.lib", "dbghelp.lib",
] ]
data_deps += [ data_deps += [
":crashpad_util_test_loader_lock_test",
":crashpad_util_test_process_info_test_child", ":crashpad_util_test_process_info_test_child",
":crashpad_util_test_safe_terminate_process_test_child", ":crashpad_util_test_safe_terminate_process_test_child",
] ]
...@@ -738,4 +742,14 @@ if (crashpad_is_win) { ...@@ -738,4 +742,14 @@ if (crashpad_is_win) {
"win/safe_terminate_process_test_child.cc", "win/safe_terminate_process_test_child.cc",
] ]
} }
crashpad_loadable_module("crashpad_util_test_loader_lock_test") {
testonly = true
sources = [
"win/loader_lock_test_dll.cc",
]
deps = [
":util",
]
}
} }
...@@ -31,33 +31,9 @@ namespace crashpad { ...@@ -31,33 +31,9 @@ namespace crashpad {
namespace { namespace {
// This function is used in this file specfically for signed or unsigned longs.
// longs are typically either int or int64 sized, but pointers to longs are not
// automatically coerced to pointers to ints when they are the same size.
// Simply adding a StringToNumber for longs doesn't work since sometimes long
// and int64_t are actually the same type, resulting in a redefinition error.
template <typename Type>
bool LocalStringToNumber(const std::string& string, Type* number) {
static_assert(sizeof(Type) == sizeof(int) || sizeof(Type) == sizeof(int64_t),
"Unexpected Type size");
char data[sizeof(Type)];
if (sizeof(Type) == sizeof(int)) {
if (!StringToNumber(string, reinterpret_cast<unsigned int*>(data))) {
return false;
}
} else {
if (!StringToNumber(string, reinterpret_cast<uint64_t*>(data))) {
return false;
}
}
*number = bit_cast<Type>(data);
return true;
}
template <typename Type> template <typename Type>
bool HexStringToNumber(const std::string& string, Type* number) { bool HexStringToNumber(const std::string& string, Type* number) {
return LocalStringToNumber("0x" + string, number); return StringToNumber("0x" + string, number);
} }
// The result from parsing a line from the maps file. // The result from parsing a line from the maps file.
...@@ -182,7 +158,7 @@ ParseResult ParseMapsLine(DelimitedFileReader* maps_file_reader, ...@@ -182,7 +158,7 @@ ParseResult ParseMapsLine(DelimitedFileReader* maps_file_reader,
if (maps_file_reader->GetDelim(' ', &field) != if (maps_file_reader->GetDelim(' ', &field) !=
DelimitedFileReader::Result::kSuccess || DelimitedFileReader::Result::kSuccess ||
(field.pop_back(), !LocalStringToNumber(field, &mapping.inode))) { (field.pop_back(), !StringToNumber(field, &mapping.inode))) {
LOG(ERROR) << "format error"; LOG(ERROR) << "format error";
return ParseResult::kError; return ParseResult::kError;
} }
......
...@@ -43,7 +43,7 @@ class MemoryMap { ...@@ -43,7 +43,7 @@ class MemoryMap {
std::string name; std::string name;
CheckedLinuxAddressRange range; CheckedLinuxAddressRange range;
off_t offset; off64_t offset;
dev_t device; dev_t device;
ino_t inode; ino_t inode;
bool readable; bool readable;
......
...@@ -29,7 +29,9 @@ ...@@ -29,7 +29,9 @@
#include "test/linux/fake_ptrace_connection.h" #include "test/linux/fake_ptrace_connection.h"
#include "test/multiprocess.h" #include "test/multiprocess.h"
#include "test/scoped_temp_dir.h" #include "test/scoped_temp_dir.h"
#include "third_party/lss/lss.h"
#include "util/file/file_io.h" #include "util/file/file_io.h"
#include "util/file/scoped_remove_file.h"
#include "util/linux/direct_ptrace_connection.h" #include "util/linux/direct_ptrace_connection.h"
#include "util/misc/clock.h" #include "util/misc/clock.h"
#include "util/misc/from_pointer_cast.h" #include "util/misc/from_pointer_cast.h"
...@@ -39,6 +41,38 @@ namespace crashpad { ...@@ -39,6 +41,38 @@ namespace crashpad {
namespace test { namespace test {
namespace { namespace {
TEST(MemoryMap, SelfLargeFiles) {
// This test is meant to test the handler's ability to understand files
// mapped from large offsets, even if the handler wasn't built with
// _FILE_OFFSET_BITS=64. ScopedTempDir needs to stat files to determine
// whether to recurse into directories, which may will fail without large file
// support. ScopedRemoveFile doesn't have that restriction.
ScopedTempDir dir;
ScopedRemoveFile large_file_path(dir.path().Append("crashpad_test_file"));
ScopedFileHandle handle(
LoggingOpenFileForReadAndWrite(large_file_path.get(),
FileWriteMode::kCreateOrFail,
FilePermissions::kWorldReadable));
ASSERT_TRUE(handle.is_valid());
// sys_fallocate supports large files as long as the kernel supports them,
// regardless of _FILE_OFFSET_BITS.
off64_t off = 1llu + UINT32_MAX;
ASSERT_EQ(sys_fallocate(handle.get(), 0, off, getpagesize()), 0)
<< ErrnoMessage("fallocate");
ScopedMmap mapping;
void* addr = sys_mmap(
nullptr, getpagesize(), PROT_READ, MAP_SHARED, handle.get(), off);
ASSERT_TRUE(addr);
ASSERT_TRUE(mapping.ResetAddrLen(addr, getpagesize()));
FakePtraceConnection connection;
ASSERT_TRUE(connection.Initialize(getpid()));
MemoryMap map;
ASSERT_TRUE(map.Initialize(&connection));
}
TEST(MemoryMap, SelfBasic) { TEST(MemoryMap, SelfBasic) {
ScopedMmap mmapping; ScopedMmap mmapping;
ASSERT_TRUE(mmapping.ResetMmap(nullptr, ASSERT_TRUE(mmapping.ResetMmap(nullptr,
......
// Copyright 2019 The Crashpad Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "util/win/loader_lock.h"
#include <windows.h>
#include "build/build_config.h"
#include "util/win/process_structs.h"
namespace crashpad {
namespace {
#ifdef ARCH_CPU_64_BITS
using NativeTraits = process_types::internal::Traits64;
#else
using NativeTraits = process_types::internal::Traits32;
#endif // ARCH_CPU_64_BITS
using PEB = process_types::PEB<NativeTraits>;
using TEB = process_types::TEB<NativeTraits>;
using RTL_CRITICAL_SECTION = process_types::RTL_CRITICAL_SECTION<NativeTraits>;
TEB* GetTeb() {
return reinterpret_cast<TEB*>(NtCurrentTeb());
}
PEB* GetPeb() {
return reinterpret_cast<PEB*>(GetTeb()->ProcessEnvironmentBlock);
}
} // namespace
bool IsThreadInLoaderLock() {
RTL_CRITICAL_SECTION* loader_lock =
reinterpret_cast<RTL_CRITICAL_SECTION*>(GetPeb()->LoaderLock);
return loader_lock->OwningThread == GetTeb()->ClientId.UniqueThread;
}
} // namespace crashpad
// Copyright 2019 The Crashpad Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef CRASHPAD_UTIL_WIN_LOADER_LOCK_H_
#define CRASHPAD_UTIL_WIN_LOADER_LOCK_H_
namespace crashpad {
//! \return `true` if the current thread holds the loader lock.
bool IsThreadInLoaderLock();
} // namespace crashpad
#endif // CRASHPAD_UTIL_WIN_LOADER_LOCK_H_
// Copyright 2019 The Crashpad Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "util/win/loader_lock.h"
#include "gtest/gtest.h"
#include "util/win/get_function.h"
extern "C" bool LoaderLockDetected();
namespace crashpad {
namespace test {
namespace {
TEST(LoaderLock, Detected) {
EXPECT_FALSE(IsThreadInLoaderLock());
auto* loader_lock_detected = GET_FUNCTION_REQUIRED(
L"crashpad_util_test_loader_lock_test.dll", LoaderLockDetected);
EXPECT_TRUE(loader_lock_detected());
EXPECT_FALSE(IsThreadInLoaderLock());
}
} // namespace
} // namespace test
} // namespace crashpad
// Copyright 2019 The Crashpad Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <windows.h>
#include "util/win/loader_lock.h"
namespace {
bool g_loader_lock_detected = false;
} // namespace
extern "C" {
__declspec(dllexport) bool LoaderLockDetected() {
return g_loader_lock_detected;
}
} // extern "C"
BOOL WINAPI DllMain(HINSTANCE, DWORD reason, LPVOID) {
switch (reason) {
case DLL_PROCESS_ATTACH:
g_loader_lock_detected = crashpad::IsThreadInLoaderLock();
break;
}
return TRUE;
}
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