Commit 92b61eb4 authored by Jan Wilken Dörrie's avatar Jan Wilken Dörrie Committed by Chromium LUCI CQ

Update Crashpad to b858473d9c3db5b190505b3d427f427bc8d7c544

37dd8f83def8 Fix compilation issue on arm64 with Debian's glibc 2.19
564d5f340f99 [c16lcpy] Use std::char_traits<base::char16> in c16lcpy
2d2e46b2ac34 ios: Fix iOS14 detection of _UIGestureEnvironmentUpdate
             sinkholes
2a777a4d4fb0 compat: Remove non-Mac dependency on third_party/xnu
b858473d9c3d compat: Remove unused deps

Bug: 911896
Change-Id: I211044fee163098123619910206c72dad4937edc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2642264
Commit-Queue: Jan Wilken Dörrie <jdoerrie@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
Auto-Submit: Jan Wilken Dörrie <jdoerrie@chromium.org>
Reviewed-by: default avatarMark Mentovai <mark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#845607}
parent c289f118
......@@ -2,7 +2,7 @@ Name: Crashpad
Short Name: crashpad
URL: https://crashpad.chromium.org/
Version: unknown
Revision: 0f70d9477ea844a7a88c9449d231fc5a71f2cc4e
Revision: b858473d9c3db5b190505b3d427f427bc8d7c544
License: Apache 2.0
License File: crashpad/LICENSE
Security Critical: yes
......
......@@ -19,8 +19,6 @@ config("compat_config") {
if (crashpad_is_mac || crashpad_is_ios) {
include_dirs += [ "mac" ]
} else {
include_dirs += [ "non_mac" ]
}
if (crashpad_is_ios) {
......@@ -40,10 +38,6 @@ config("compat_config") {
} else {
include_dirs += [ "non_win" ]
}
if (!crashpad_is_linux && !crashpad_is_android && !crashpad_is_fuchsia) {
include_dirs += [ "non_elf" ]
}
}
template("compat_target") {
......@@ -81,12 +75,7 @@ compat_target("compat") {
"mac/sys/resource.h",
]
} else {
sources += [
"non_mac/mach-o/loader.h",
"non_mac/mach/mach.h",
"non_mac/mach/machine.h",
"non_mac/mach/vm_prot.h",
]
sources += [ "non_mac/mach/mach.h" ]
}
if (crashpad_is_ios) {
......@@ -150,10 +139,6 @@ compat_target("compat") {
]
}
if (!crashpad_is_linux && !crashpad_is_android && !crashpad_is_fuchsia) {
sources += [ "non_elf/elf.h" ]
}
public_configs = [
":compat_config",
"..:crashpad_config",
......@@ -165,15 +150,7 @@ compat_target("compat") {
deps = [ "../util:no_cfi_icall" ]
if (!crashpad_is_mac) {
deps += [ "../third_party/xnu" ]
}
if (crashpad_is_win) {
deps += [ "../third_party/getopt" ]
}
if (!crashpad_is_linux && !crashpad_is_android && !crashpad_is_fuchsia) {
deps += [ "../third_party/glibc" ]
}
}
......@@ -20,8 +20,11 @@
#include <features.h>
// glibc for 64-bit ARM uses different names for these structs prior to 2.20.
// However, Debian's glibc 2.19-8 backported the change so it's not sufficient
// to only test the version. user_pt_regs and user_fpsimd_state are actually
// defined in <asm/ptrace.h> so we use the include guard here.
#if defined(__aarch64__) && defined(__GLIBC__)
#if !__GLIBC_PREREQ(2, 20)
#if !__GLIBC_PREREQ(2, 20) && defined(__ASM_PTRACE_H)
using user_regs_struct = user_pt_regs;
using user_fpsimd_struct = user_fpsimd_state;
#endif
......
......@@ -35,6 +35,7 @@
#include "base/bit_cast.h"
#include "base/logging.h"
#include "base/memory/free_deleter.h"
#include "base/strings/sys_string_conversions.h"
#include "build/build_config.h"
......@@ -215,7 +216,7 @@ id ObjcExceptionPreprocessor(id exception) {
// Check if the function is one that is known to obscure (by way of
// catch-and-rethrow) exception stack traces. If it is, sinkhole it
// by crashing here at the point of throw.
constexpr const char* kExceptionSymbolNameSinkholes[] = {
static constexpr const char* kExceptionSymbolNameSinkholes[] = {
// The two CF symbol names will also be captured by the CoreFoundation
// library path check below, but for completeness they are listed here,
// since they appear unredacted.
......@@ -232,7 +233,7 @@ id ObjcExceptionPreprocessor(id exception) {
// On iOS, function names are often reported as "<redacted>", although they
// do appear when attached to the debugger. When this happens, use the path
// of the image to determine if the handler is an exception sinkhole.
constexpr const char* kExceptionLibraryPathSinkholes[] = {
static constexpr const char* kExceptionLibraryPathSinkholes[] = {
// Everything in this library is a sinkhole, specifically
// _dispatch_client_callout. Both are needed here depending on whether
// the debugger is attached (introspection only appears when a simulator
......@@ -258,35 +259,45 @@ id ObjcExceptionPreprocessor(id exception) {
// Some <redacted> sinkholes are harder to find. _UIGestureEnvironmentUpdate
// in UIKitCore is an example. UIKitCore can't be added to
// kExceptionLibraryPathSinkholes because it uses Objective-C exceptions
// internally and also has has non-sinkhole handlers. Since
// _UIGestureEnvironmentUpdate is always called from
// -[UIGestureEnvironment _deliverEvent:toGestureRecognizers:usingBlock:],
// inspect the caller frame info to match the sinkhole.
constexpr const char* kUIKitCorePath =
// internally and also has has non-sinkhole handlers. While all the
// calling methods in UIKit are marked <redacted> starting in iOS14, it's
// currently true that all callers to _UIGestureEnvironmentUpdate are within
// UIGestureEnvironment. That means a very hacky way to detect this are to
// check if the calling method IMP is within the range of all
// UIGestureEnvironment methods.
static constexpr const char kUIKitCorePath[] =
"/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore";
if (ModulePathMatchesSinkhole(dl_info.dli_fname, kUIKitCorePath)) {
unw_proc_info_t caller_frame_info;
if (LoggingUnwStep(&cursor) > 0 &&
unw_get_proc_info(&cursor, &caller_frame_info) == UNW_ESUCCESS) {
static IMP uigesture_deliver_event_imp = [] {
IMP imp = class_getMethodImplementation(
NSClassFromString(@"UIGestureEnvironment"),
NSSelectorFromString(
@"_deliverEvent:toGestureRecognizers:usingBlock:"));
// From 10.15.0 objc4-779.1/runtime/objc-class.mm
// class_getMethodImplementation returns nil or _objc_msgForward on
// failure.
if (!imp || imp == _objc_msgForward) {
LOG(WARNING) << "Unable to find -[UIGestureEnvironment "
"_deliverEvent:toGestureRecognizers:usingBlock:]";
return bit_cast<IMP>(nullptr); // IMP is a function pointer type.
auto uigestureimp_lambda = [](IMP* max) {
IMP min = *max = bit_cast<IMP>(nullptr);
unsigned int method_count = 0;
std::unique_ptr<Method[], base::FreeDeleter> method_list(
class_copyMethodList(NSClassFromString(@"UIGestureEnvironment"),
&method_count));
if (method_count > 0) {
min = *max = method_getImplementation(method_list[0]);
for (unsigned int method_index = 1; method_index < method_count;
method_index++) {
IMP method_imp =
method_getImplementation(method_list[method_index]);
*max = std::max(method_imp, *max);
min = std::min(method_imp, min);
}
}
return imp;
}();
return min;
};
if (uigesture_deliver_event_imp ==
reinterpret_cast<IMP>(caller_frame_info.start_ip)) {
static IMP gesture_environment_max_imp;
static IMP gesture_environment_min_imp =
uigestureimp_lambda(&gesture_environment_max_imp);
IMP caller = reinterpret_cast<IMP>(caller_frame_info.start_ip);
if (gesture_environment_min_imp && gesture_environment_max_imp &&
caller >= gesture_environment_min_imp &&
caller <= gesture_environment_max_imp) {
TerminatingFromUncaughtNSException(exception,
"_UIGestureEnvironmentUpdate");
}
......
......@@ -25,17 +25,21 @@ namespace {
using IOSExceptionProcessor = PlatformTest;
// TODO(crbug.com/crashpad/358): Re-enable once iOS14 redacted symbol issue is
// fixed.
TEST_F(IOSExceptionProcessor, DISABLED_SelectorExists) {
IMP uigesture_deliver_event_imp = class_getMethodImplementation(
NSClassFromString(@"UIGestureEnvironment"),
NSSelectorFromString(@"_deliverEvent:toGestureRecognizers:usingBlock:"));
TEST_F(IOSExceptionProcessor, SelectorExists) {
IMP init_imp =
class_getMethodImplementation(NSClassFromString(@"UIGestureEnvironment"),
NSSelectorFromString(@"init"));
IMP destruct_imp =
class_getMethodImplementation(NSClassFromString(@"UIGestureEnvironment"),
NSSelectorFromString(@".cxx_destruct"));
// From 10.15.0 objc4-779.1/runtime/objc-class.mm
// class_getMethodImplementation returns nil or _objc_msgForward on failure.
ASSERT_TRUE(uigesture_deliver_event_imp);
ASSERT_NE(uigesture_deliver_event_imp, _objc_msgForward);
ASSERT_TRUE(init_imp);
EXPECT_NE(init_imp, _objc_msgForward);
ASSERT_TRUE(destruct_imp);
EXPECT_NE(destruct_imp, _objc_msgForward);
}
} // namespace
......
......@@ -14,42 +14,22 @@
#include "util/stdlib/strlcpy.h"
#include "base/check.h"
#include "build/build_config.h"
#if defined(OS_WIN) && defined(WCHAR_T_IS_UTF16)
#include <strsafe.h>
#endif
#include <string>
namespace crashpad {
#if defined(OS_WIN) && defined(WCHAR_T_IS_UTF16)
size_t c16lcpy(base::char16* destination,
const base::char16* source,
size_t length) {
const wchar_t* wsource = reinterpret_cast<const wchar_t*>(source);
HRESULT result =
StringCchCopyW(reinterpret_cast<wchar_t*>(destination), length, wsource);
CHECK(result == S_OK || result == STRSAFE_E_INSUFFICIENT_BUFFER);
return wcslen(wsource);
}
#elif defined(WCHAR_T_IS_UTF32)
size_t c16lcpy(base::char16* destination,
const base::char16* source,
size_t length) {
size_t source_length = base::c16len(source);
size_t source_length = std::char_traits<base::char16>::length(source);
if (source_length < length) {
base::c16memcpy(destination, source, source_length + 1);
std::char_traits<base::char16>::copy(
destination, source, source_length + 1);
} else if (length != 0) {
base::c16memcpy(destination, source, length - 1);
std::char_traits<base::char16>::copy(destination, source, length - 1);
destination[length - 1] = '\0';
}
return source_length;
}
#endif // WCHAR_T_IS_UTF32
} // namespace crashpad
......@@ -29,27 +29,13 @@ namespace crashpad {
namespace test {
namespace {
// The base::c16 functions only exist if WCHAR_T_IS_UTF32.
#if defined(WCHAR_T_IS_UTF32)
size_t C16Len(const base::char16* s) {
return base::c16len(s);
return std::char_traits<base::char16>::length(s);
}
int C16Memcmp(const base::char16* s1, const base::char16* s2, size_t n) {
return base::c16memcmp(s1, s2, n);
return std::char_traits<base::char16>::compare(s1, s2, n);
}
#elif defined(WCHAR_T_IS_UTF16)
size_t C16Len(const base::char16* s) {
return wcslen(reinterpret_cast<const wchar_t*>(s));
}
int C16Memcmp(const base::char16* s1, const base::char16* s2, size_t n) {
return wmemcmp(reinterpret_cast<const wchar_t*>(s1),
reinterpret_cast<const wchar_t*>(s2),
n);
}
#endif
TEST(strlcpy, c16lcpy) {
// Use a destination buffer that’s larger than the length passed to c16lcpy.
......
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