Add www-client/chromium musl patches.

This commit is contained in:
inference 2022-06-17 21:34:33 +01:00
parent 75bef0c660
commit d46ac208e3
21 changed files with 785 additions and 0 deletions

View File

@ -0,0 +1,10 @@
--- a/third_party/crashpad/crashpad/util/linux/ptracer.cc
+++ b/third_party/crashpad/crashpad/util/linux/ptracer.cc
@@ -26,6 +26,7 @@
#if defined(ARCH_CPU_X86_FAMILY)
#include <asm/ldt.h>
+#include <asm/ptrace-abi.h>
#endif
namespace crashpad {

View File

@ -0,0 +1,32 @@
diff --git a/base/threading/platform_thread_linux.cc b/base/threading/platform_thread_linux.cc
index 095c49b..5044bb8 100644
--- a/base/threading/platform_thread_linux.cc
+++ b/base/threading/platform_thread_linux.cc
@@ -186,7 +186,7 @@ void TerminateOnThread() {}
size_t GetDefaultThreadStackSize(const pthread_attr_t& attributes) {
#if !defined(THREAD_SANITIZER)
- return 0;
+ return (1 << 23);
#else
// ThreadSanitizer bloats the stack heavily. Evidence has been that the
// default stack size isn't enough for some browser tests.
diff --git a/chrome/browser/shutdown_signal_handlers_posix.cc b/chrome/browser/shutdown_signal_handlers_posix.cc
index ccc39d4..3c0ff8d 100644
--- a/chrome/browser/shutdown_signal_handlers_posix.cc
+++ b/chrome/browser/shutdown_signal_handlers_posix.cc
@@ -187,11 +187,11 @@ void InstallShutdownSignalHandlers(
g_shutdown_pipe_read_fd = pipefd[0];
g_shutdown_pipe_write_fd = pipefd[1];
#if !defined(ADDRESS_SANITIZER)
- const size_t kShutdownDetectorThreadStackSize = PTHREAD_STACK_MIN * 2;
+ const size_t kShutdownDetectorThreadStackSize = PTHREAD_STACK_MIN * 2 * 8;
#else
// ASan instrumentation bloats the stack frames, so we need to increase the
// stack size to avoid hitting the guard page.
- const size_t kShutdownDetectorThreadStackSize = PTHREAD_STACK_MIN * 4;
+ const size_t kShutdownDetectorThreadStackSize = PTHREAD_STACK_MIN * 4 * 8;
#endif
ShutdownDetector* detector = new ShutdownDetector(
g_shutdown_pipe_read_fd, std::move(shutdown_callback), task_runner);

View File

@ -0,0 +1,175 @@
diff --git a/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc b/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc
index a8f860f..4becce0 100644
--- a/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc
+++ b/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc
@@ -138,21 +138,11 @@ namespace sandbox {
// present (as in newer versions of posix_spawn).
ResultExpr RestrictCloneToThreadsAndEPERMFork() {
const Arg<unsigned long> flags(0);
-
- // TODO(mdempsky): Extend DSL to support (flags & ~mask1) == mask2.
- const uint64_t kAndroidCloneMask = CLONE_VM | CLONE_FS | CLONE_FILES |
- CLONE_SIGHAND | CLONE_THREAD |
- CLONE_SYSVSEM;
- const uint64_t kObsoleteAndroidCloneMask = kAndroidCloneMask | CLONE_DETACHED;
-
- const uint64_t kGlibcPthreadFlags =
- CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | CLONE_THREAD |
- CLONE_SYSVSEM | CLONE_SETTLS | CLONE_PARENT_SETTID | CLONE_CHILD_CLEARTID;
- const BoolExpr glibc_test = flags == kGlibcPthreadFlags;
-
- const BoolExpr android_test =
- AnyOf(flags == kAndroidCloneMask, flags == kObsoleteAndroidCloneMask,
- flags == kGlibcPthreadFlags);
+ const int required = CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND |
+ CLONE_THREAD | CLONE_SYSVSEM;
+ const int safe = CLONE_SETTLS | CLONE_PARENT_SETTID | CLONE_CHILD_CLEARTID |
+ CLONE_DETACHED;
+ const BoolExpr thread_clone_ok = (flags&~safe)==required;
// The following two flags are the two important flags in any vfork-emulating
// clone call. EPERM any clone call that contains both of them.
@@ -162,7 +152,7 @@ ResultExpr RestrictCloneToThreadsAndEPERMFork() {
AnyOf((flags & (CLONE_VM | CLONE_THREAD)) == 0,
(flags & kImportantCloneVforkFlags) == kImportantCloneVforkFlags);
- return If(IsAndroid() ? android_test : glibc_test, Allow())
+ return If(thread_clone_ok, Allow())
.ElseIf(is_fork_or_clone_vfork, Error(EPERM))
.Else(CrashSIGSYSClone());
}
diff --git a/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc b/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc
index 96c9f49..225823c 100644
--- a/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc
+++ b/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc
@@ -417,6 +417,7 @@ bool SyscallSets::IsAllowedProcessStartOrDeath(int sysno) {
#if defined(__i386__)
case __NR_waitpid:
#endif
+ case __NR_set_tid_address:
return true;
case __NR_clone: // Should be parameter-restricted.
case __NR_setns: // Privileged.
@@ -429,7 +430,6 @@ bool SyscallSets::IsAllowedProcessStartOrDeath(int sysno) {
#if defined(__i386__) || defined(__x86_64__) || defined(__mips__)
case __NR_set_thread_area:
#endif
- case __NR_set_tid_address:
case __NR_unshare:
#if !defined(__mips__) && !defined(__aarch64__)
case __NR_vfork:
@@ -543,6 +543,8 @@ bool SyscallSets::IsAllowedAddressSpaceAccess(int sysno) {
case __NR_mlock:
case __NR_munlock:
case __NR_munmap:
+ case __NR_mremap:
+ case __NR_membarrier:
return true;
case __NR_madvise:
case __NR_mincore:
@@ -560,7 +562,6 @@ bool SyscallSets::IsAllowedAddressSpaceAccess(int sysno) {
case __NR_modify_ldt:
#endif
case __NR_mprotect:
- case __NR_mremap:
case __NR_msync:
case __NR_munlockall:
case __NR_readahead:
diff --git a/sandbox/linux/system_headers/arm64_linux_syscalls.h b/sandbox/linux/system_headers/arm64_linux_syscalls.h
index ab86b36..60d8743 100644
--- a/sandbox/linux/system_headers/arm64_linux_syscalls.h
+++ b/sandbox/linux/system_headers/arm64_linux_syscalls.h
@@ -1215,4 +1215,8 @@
#define __NR_landlock_restrict_self 446
#endif
+#if !defined(__NR_membarrier)
+#define __NR_membarrier 283
+#endif
+
#endif // SANDBOX_LINUX_SYSTEM_HEADERS_ARM64_LINUX_SYSCALLS_H_
diff --git a/sandbox/linux/system_headers/arm_linux_syscalls.h b/sandbox/linux/system_headers/arm_linux_syscalls.h
index 9c44368..40c6186 100644
--- a/sandbox/linux/system_headers/arm_linux_syscalls.h
+++ b/sandbox/linux/system_headers/arm_linux_syscalls.h
@@ -1617,6 +1617,10 @@
#define __NR_landlock_restrict_self (__NR_SYSCALL_BASE + 446)
#endif
+#if !defined(__NR_membarrier)
+#define __NR_membarrier (__NR_SYSCALL_BASE+389)
+#endif
+
// ARM private syscalls.
#if !defined(__ARM_NR_BASE)
#define __ARM_NR_BASE (__NR_SYSCALL_BASE + 0xF0000)
diff --git a/sandbox/linux/system_headers/linux_syscalls.h b/sandbox/linux/system_headers/linux_syscalls.h
index 2b78a0c..b6fedb5 100644
--- a/sandbox/linux/system_headers/linux_syscalls.h
+++ b/sandbox/linux/system_headers/linux_syscalls.h
@@ -10,6 +10,7 @@
#define SANDBOX_LINUX_SYSTEM_HEADERS_LINUX_SYSCALLS_H_
#include "build/build_config.h"
+#include <sys/syscall.h>
#if defined(__x86_64__)
#include "sandbox/linux/system_headers/x86_64_linux_syscalls.h"
diff --git a/sandbox/linux/system_headers/mips64_linux_syscalls.h b/sandbox/linux/system_headers/mips64_linux_syscalls.h
index ae7cb48..4ce8142 100644
--- a/sandbox/linux/system_headers/mips64_linux_syscalls.h
+++ b/sandbox/linux/system_headers/mips64_linux_syscalls.h
@@ -1415,4 +1415,8 @@
#define __NR_landlock_restrict_self (__NR_Linux + 446)
#endif
+#if !defined(__NR_membarrier)
+#define __NR_membarrier (__NR_Linux 318)
+#endif
+
#endif // SANDBOX_LINUX_SYSTEM_HEADERS_MIPS64_LINUX_SYSCALLS_H_
diff --git a/sandbox/linux/system_headers/mips_linux_syscalls.h b/sandbox/linux/system_headers/mips_linux_syscalls.h
index 0937782..f5c014e 100644
--- a/sandbox/linux/system_headers/mips_linux_syscalls.h
+++ b/sandbox/linux/system_headers/mips_linux_syscalls.h
@@ -1697,4 +1697,8 @@
#define __NR_landlock_restrict_self (__NR_Linux + 446)
#endif
+#if !defined(__NR_membarrier)
+#define __NR_membarrier (__NR_Linux 358)
+#endif
+
#endif // SANDBOX_LINUX_SYSTEM_HEADERS_MIPS_LINUX_SYSCALLS_H_
diff --git a/sandbox/linux/system_headers/x86_64_linux_syscalls.h b/sandbox/linux/system_headers/x86_64_linux_syscalls.h
index e618c62..dc6fa8d 100644
--- a/sandbox/linux/system_headers/x86_64_linux_syscalls.h
+++ b/sandbox/linux/system_headers/x86_64_linux_syscalls.h
@@ -1438,5 +1438,9 @@
#define __NR_landlock_restrict_self 446
#endif
+#if !defined(__NR_membarrier)
+#define __NR_membarrier 324
+#endif
+
#endif // SANDBOX_LINUX_SYSTEM_HEADERS_X86_64_LINUX_SYSCALLS_H_
diff --git a/sandbox/policy/linux/bpf_renderer_policy_linux.cc b/sandbox/policy/linux/bpf_renderer_policy_linux.cc
index f789e92..1a84c2c 100644
--- a/sandbox/policy/linux/bpf_renderer_policy_linux.cc
+++ b/sandbox/policy/linux/bpf_renderer_policy_linux.cc
@@ -97,11 +97,11 @@ ResultExpr RendererProcessPolicy::EvaluateSyscall(int sysno) const {
case __NR_sysinfo:
case __NR_times:
case __NR_uname:
- return Allow();
- case __NR_sched_getaffinity:
case __NR_sched_getparam:
case __NR_sched_getscheduler:
case __NR_sched_setscheduler:
+ return Allow();
+ case __NR_sched_getaffinity:
return RestrictSchedTarget(GetPolicyPid(), sysno);
case __NR_prlimit64:
// See crbug.com/662450 and setrlimit comment above.

View File

@ -0,0 +1,83 @@
diff --git a/sandbox/linux/services/namespace_sandbox.cc b/sandbox/linux/services/namespace_sandbox.cc
index d46ea08..fbedde1 100644
--- a/sandbox/linux/services/namespace_sandbox.cc
+++ b/sandbox/linux/services/namespace_sandbox.cc
@@ -209,6 +209,70 @@ base::Process NamespaceSandbox::LaunchProcessWithOptions(
return base::LaunchProcess(argv, launch_options_copy);
}
+#if defined(__aarch64__)
+#define TLS_ABOVE_TP
+#endif
+
+struct musl_pthread
+{
+ /* Part 1 -- these fields may be external or
+ * internal (accessed via asm) ABI. Do not change. */
+ struct pthread *self;
+#ifndef TLS_ABOVE_TP
+ uintptr_t *dtv;
+#endif
+ struct pthread *prev, *next; /* non-ABI */
+ uintptr_t sysinfo;
+#ifndef TLS_ABOVE_TP
+#ifdef CANARY_PAD
+ uintptr_t canary_pad;
+#endif
+ uintptr_t canary;
+#endif
+
+/* Part 2 -- implementation details, non-ABI. */
+ int tid;
+ int errno_val;
+ volatile int detach_state;
+ volatile int cancel;
+ volatile unsigned char canceldisable, cancelasync;
+ unsigned char tsd_used:1;
+ unsigned char dlerror_flag:1;
+ unsigned char *map_base;
+ size_t map_size;
+ void *stack;
+ size_t stack_size;
+ size_t guard_size;
+ void *result;
+ struct __ptcb *cancelbuf;
+ void **tsd;
+ struct {
+ volatile void *volatile head;
+ long off;
+ volatile void *volatile pending;
+ } robust_list;
+ int h_errno_val;
+ volatile int timer_id;
+ locale_t locale;
+ volatile int killlock[1];
+ char *dlerror_buf;
+ void *stdio_locks;
+
+ /* Part 3 -- the positions of these fields relative to
+ * the end of the structure is external and internal ABI. */
+#ifdef TLS_ABOVE_TP
+ uintptr_t canary;
+ uintptr_t *dtv;
+#endif
+};
+
+void MaybeUpdateMuslTidCache()
+{
+ pid_t real_tid = sys_gettid();
+ pid_t* cached_tid_location = &reinterpret_cast<struct musl_pthread*>(pthread_self())->tid;
+ *cached_tid_location = real_tid;
+}
+
// static
pid_t NamespaceSandbox::ForkInNewPidNamespace(bool drop_capabilities_in_child) {
const pid_t pid =
@@ -226,6 +290,7 @@ pid_t NamespaceSandbox::ForkInNewPidNamespace(bool drop_capabilities_in_child) {
#if defined(LIBC_GLIBC)
MaybeUpdateGlibcTidCache();
#endif
+ MaybeUpdateMuslTidCache();
return 0;
}

View File

@ -0,0 +1,20 @@
diff --git a/base/files/scoped_file_linux.cc b/base/files/scoped_file_linux.cc
index 26bc18e62..7d7b29b29 100644
--- a/base/files/scoped_file_linux.cc
+++ b/base/files/scoped_file_linux.cc
@@ -77,15 +77,3 @@ bool IsFDOwned(int fd) {
}
} // namespace base
-
-extern "C" {
-
-int __close(int);
-
-__attribute__((visibility("default"), noinline)) int close(int fd) {
- if (base::IsFDOwned(fd) && g_is_ownership_enforced)
- CrashOnFdOwnershipViolation();
- return __close(fd);
-}
-
-} // extern "C"

View File

@ -0,0 +1,13 @@
diff --git a/third_party/nasm/config/config-linux.h b/third_party/nasm/config/config-linux.h
index 9e59df4f00..b96673ac0c 100644
--- a/third_party/nasm/config/config-linux.h
+++ b/third_party/nasm/config/config-linux.h
@@ -139,7 +139,7 @@
#define HAVE_ACCESS 1
/* Define to 1 if you have the `canonicalize_file_name' function. */
-#define HAVE_CANONICALIZE_FILE_NAME 1
+/* #undef HAVE_CANONICALIZE_FILE_NAME */
/* Define to 1 if you have the `cpu_to_le16' intrinsic function. */
/* #undef HAVE_CPU_TO_LE16 */

View File

@ -0,0 +1,20 @@
diff --git a/sandbox/linux/suid/sandbox.c b/sandbox/linux/suid/sandbox.c
index 5fdb4817af..88bd478903 100644
--- a/sandbox/linux/suid/sandbox.c
+++ b/sandbox/linux/suid/sandbox.c
@@ -42,6 +42,15 @@
#define CLONE_NEWNET 0x40000000
#endif
+#ifndef TEMP_FAILURE_RETRY
+#define TEMP_FAILURE_RETRY(expression) \
+ (__extension__ \
+ ({ long int __result; \
+ do __result = (long int) (expression); \
+ while (__result == -1L && errno == EINTR); \
+ __result; }))
+#endif
+
static bool DropRoot();
#define HANDLE_EINTR(x) TEMP_FAILURE_RETRY(x)

View File

@ -0,0 +1,25 @@
diff --git a/net/dns/BUILD.gn b/net/dns/BUILD.gn
index c398d8a..0ce15f3 100644
--- a/net/dns/BUILD.gn
+++ b/net/dns/BUILD.gn
@@ -110,11 +110,6 @@ source_set("dns") {
"dns_config_service_android.cc",
"dns_config_service_android.h",
]
- } else if (is_linux) {
- sources += [
- "dns_config_service_linux.cc",
- "dns_config_service_linux.h",
- ]
} else if (is_posix) {
sources += [
"dns_config_service_posix.cc",
@@ -416,8 +411,6 @@ source_set("tests") {
if (is_android) {
sources += [ "dns_config_service_android_unittest.cc" ]
- } else if (is_linux) {
- sources += [ "dns_config_service_linux_unittest.cc" ]
} else if (is_posix) {
sources += [ "dns_config_service_posix_unittest.cc" ]
}

View File

@ -0,0 +1,88 @@
diff --git a/net/dns/dns_config_service_posix.cc b/net/dns/dns_config_service_posix.cc
index 2de1457..66c4803 100644
--- a/net/dns/dns_config_service_posix.cc
+++ b/net/dns/dns_config_service_posix.cc
@@ -32,6 +32,10 @@
#include "net/dns/dns_config_watcher_mac.h"
#endif
+#if defined(OS_LINUX) && !defined(__GLIBC__)
+#include "net/dns/resolv_compat.h"
+#endif
+
namespace net {
namespace internal {
diff --git a/net/dns/dns_reloader.cc b/net/dns/dns_reloader.cc
index 0672e71..252fcc2 100644
--- a/net/dns/dns_reloader.cc
+++ b/net/dns/dns_reloader.cc
@@ -17,6 +17,10 @@
#include "base/threading/thread_local.h"
#include "net/base/network_change_notifier.h"
+#if defined(OS_LINUX) && !defined(__GLIBC__)
+#include "net/dns/resolv_compat.h"
+#endif
+
namespace net {
namespace {
diff --git a/net/dns/public/resolv_reader.cc b/net/dns/public/resolv_reader.cc
index 5686762..34c3d1a 100644
--- a/net/dns/public/resolv_reader.cc
+++ b/net/dns/public/resolv_reader.cc
@@ -17,6 +17,10 @@
#include "base/check_op.h"
#include "net/base/ip_endpoint.h"
+#if defined(OS_LINUX) && !defined(__GLIBC__)
+#include "net/dns/resolv_compat.h"
+#endif
+
namespace net {
std::unique_ptr<struct __res_state> ResolvReader::GetResState() {
diff --git a/net/dns/public/scoped_res_state.cc b/net/dns/public/scoped_res_state.cc
index 9706d18..b28d7a2 100644
--- a/net/dns/public/scoped_res_state.cc
+++ b/net/dns/public/scoped_res_state.cc
@@ -10,6 +10,10 @@
#include "base/check.h"
#include "build/build_config.h"
+#if defined(OS_LINUX) && !defined(__GLIBC__)
+#include "net/dns/resolv_compat.h"
+#endif
+
namespace net {
ScopedResState::ScopedResState() {
diff --git a/net/dns/resolv_compat.h b/net/dns/resolv_compat.h
new file mode 100644
index 0000000..0f03b32
--- /dev/null
+++ b/net/dns/resolv_compat.h
@@ -0,0 +1,22 @@
+#if !defined(__GLIBC__)
+#include <string.h>
+
+static inline int res_ninit(res_state statp)
+{
+ int rc = res_init();
+ if (statp != &_res) {
+ memcpy(statp, &_res, sizeof(*statp));
+ }
+ return rc;
+}
+
+static inline int res_nclose(res_state statp)
+{
+ if (!statp)
+ return -1;
+ if (statp != &_res) {
+ memset(statp, 0, sizeof(*statp));
+ }
+ return 0;
+}
+#endif

View File

@ -0,0 +1,27 @@
--- a/base/BUILD.gn
+++ b/base/BUILD.gn
@@ -1345,6 +1345,10 @@ component("base") {
libs = []
frameworks = []
+ if (is_posix) {
+ libs += [ "execinfo" ]
+ }
+
configs += [
":base_implementation",
":memory_tagging",
--- a/v8/BUILD.gn
+++ b/v8/BUILD.gn
@@ -4624,6 +4624,10 @@
"src/tracing/trace-categories.h",
]
}
+
+ if (v8_enable_debugging_features || dcheck_always_on) {
+ libs += [ "execinfo" ]
+ }
}
group("v8_base") {

View File

@ -0,0 +1,13 @@
diff --git a/third_party/breakpad/BUILD.gn b/third_party/breakpad/BUILD.gn
index a0c3bf4..14b2fde 100644
--- a/third_party/breakpad/BUILD.gn
+++ b/third_party/breakpad/BUILD.gn
@@ -661,7 +661,7 @@ if (is_linux || is_chromeos || is_android) {
cflags = [ "-marm" ]
}
- libs = [ "dl" ]
+ libs = [ "dl", "ucontext" ]
include_dirs = [
".",

View File

@ -0,0 +1,23 @@
diff --git a/chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.cc b/chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.cc
index 618fcb065..9994e66d3 100644
--- a/chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.cc
+++ b/chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.cc
@@ -59,7 +59,9 @@
// TODO(crbug.com/1052397): Revisit the macro expression once build flag switch
// of lacros-chrome is complete.
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)
+#if defined(__GLIBC__)
#include <gnu/libc-version.h>
+#endif
#include "base/linux_util.h"
#include "base/strings/string_split.h"
@@ -321,7 +323,7 @@ void RecordLinuxDistro() {
void RecordLinuxGlibcVersion() {
// TODO(crbug.com/1052397): Revisit the macro expression once build flag switch
// of lacros-chrome is complete.
-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)
+#if defined(__GLIBC__) || BUILDFLAG(IS_CHROMEOS_LACROS)
base::Version version(gnu_get_libc_version());
UMALinuxGlibcVersion glibc_version_result = UMA_LINUX_GLIBC_NOT_PARSEABLE;

View File

@ -0,0 +1,77 @@
diff --git a/base/process/process_metrics_posix.cc b/base/process/process_metrics_posix.cc
index ae6d3a6..ad68860 100644
--- a/base/process/process_metrics_posix.cc
+++ b/base/process/process_metrics_posix.cc
@@ -114,12 +114,14 @@ size_t GetMallocUsageMallinfo() {
#define MALLINFO2_FOUND_IN_LIBC
struct mallinfo2 minfo = mallinfo2();
#endif
-#endif // defined(__GLIBC__) && defined(__GLIBC_PREREQ)
#if !defined(MALLINFO2_FOUND_IN_LIBC)
struct mallinfo minfo = mallinfo();
#endif
#undef MALLINFO2_FOUND_IN_LIBC
return minfo.hblkhd + minfo.arena;
+#else
+ return 0;
+#endif // defined(__GLIBC__) && defined(__GLIBC_PREREQ)
}
} // namespace
diff --git a/third_party/tflite/src/tensorflow/lite/profiling/memory_info.cc b/third_party/tflite/src/tensorflow/lite/profiling/memory_info.cc
index 6a4438f480..161eacef80 100644
--- a/third_party/tflite/src/tensorflow/lite/profiling/memory_info.cc
+++ b/third_party/tflite/src/tensorflow/lite/profiling/memory_info.cc
@@ -40,13 +40,15 @@
if (getrusage(RUSAGE_SELF, &res) == 0) {
result.max_rss_kb = res.ru_maxrss;
}
-#if defined(__GLIBC__) && __GLIBC_MINOR__ >= 33
+#if defined(__GLIBC__)
+#if __GLIBC_MINOR__ >= 33
const auto mem = mallinfo2();
#else
const auto mem = mallinfo();
#endif
result.total_allocated_bytes = mem.arena;
result.in_use_allocated_bytes = mem.uordblks;
+#endif // defined(__GLIBC__)
#endif
return result;
}
diff --git a/base/allocator/allocator_shim_default_dispatch_to_partition_alloc.cc b/base/allocator/allocator_shim_default_dispatch_to_partition_alloc.cc
index e92a0fc..b289e7c 100644
--- a/base/allocator/allocator_shim_default_dispatch_to_partition_alloc.cc
+++ b/base/allocator/allocator_shim_default_dispatch_to_partition_alloc.cc
@@ -663,7 +663,7 @@ SHIM_ALWAYS_EXPORT int mallopt(int cmd, int value) __THROW {
#endif // !BUILDFLAG(IS_APPLE) && !BUILDFLAG(IS_ANDROID)
-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
+#if BUILDFLAG(IS_LINUX) && defined(__GLIBC__) || BUILDFLAG(IS_CHROMEOS)
SHIM_ALWAYS_EXPORT struct mallinfo mallinfo(void) __THROW {
base::SimplePartitionStatsDumper allocator_dumper;
Allocator()->DumpStats("malloc", true, &allocator_dumper);
diff --git a/base/trace_event/malloc_dump_provider.cc b/base/trace_event/malloc_dump_provider.cc
index 22edeeca4f..da280da606 100644
--- a/base/trace_event/malloc_dump_provider.cc
+++ b/base/trace_event/malloc_dump_provider.cc
@@ -174,7 +174,7 @@ void ReportAppleAllocStats(size_t* total_virtual_size,
#if (BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && BUILDFLAG(IS_ANDROID)) || \
(!BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && !BUILDFLAG(IS_WIN) && \
- !BUILDFLAG(IS_APPLE) && !BUILDFLAG(IS_WIN) && !BUILDFLAG(IS_FUCHSIA))
+ !BUILDFLAG(IS_APPLE) && !BUILDFLAG(IS_WIN) && !BUILDFLAG(IS_FUCHSIA)) && !(BUILDFLAG(IS_LINUX) && !defined(__GLIBC__))
void ReportMallinfoStats(ProcessMemoryDump* pmd,
size_t* total_virtual_size,
size_t* resident_size,
@@ -337,7 +337,7 @@ bool MallocDumpProvider::OnMemoryDump(const MemoryDumpArgs& args,
ReportWinHeapStats(args.level_of_detail, nullptr, &total_virtual_size,
&resident_size, &allocated_objects_size,
&allocated_objects_count);
-#elif BUILDFLAG(IS_FUCHSIA)
+#elif BUILDFLAG(IS_FUCHSIA) || BUILDFLAG(IS_LINUX) && !defined(__GLIBC__)
// TODO(fuchsia): Port, see https://crbug.com/706592.
#else
ReportMallinfoStats(/*pmd=*/nullptr, &total_virtual_size, &resident_size,

View File

@ -0,0 +1,18 @@
diff --git a/third_party/lss/linux_syscall_support.h b/third_party/lss/linux_syscall_support.h
index 8d4e4d2a18..634baff404 100644
--- a/third_party/lss/linux_syscall_support.h
+++ b/third_party/lss/linux_syscall_support.h
@@ -173,6 +173,13 @@ extern "C" {
# undef __NR_waitpid
#endif
+#ifdef pread64
+#undef pread64
+#endif
+#ifdef pwrite64
+#undef pwrite64
+#endif
+
/* As glibc often provides subtly incompatible data structures (and implicit
* wrapper functions that convert them), we provide our own kernel data
* structures for use by the system calls.

View File

@ -0,0 +1,13 @@
diff --git a/net/socket/udp_socket_posix.cc b/net/socket/udp_socket_posix.cc
index 47f31493a4..8beda760a3 100644
--- a/net/socket/udp_socket_posix.cc
+++ b/net/socket/udp_socket_posix.cc
@@ -1162,7 +1162,7 @@ SendResult UDPSocketPosixSender::InternalSendmmsgBuffers(
msg_iov->push_back({const_cast<char*>(buffer->data()), buffer->length()});
msgvec->reserve(buffers.size());
for (size_t j = 0; j < buffers.size(); j++)
- msgvec->push_back({{nullptr, 0, &msg_iov[j], 1, nullptr, 0, 0}, 0});
+ msgvec->push_back({{nullptr, 0, &msg_iov[j], 1, 0, nullptr, 0, 0, 0}, 0});
int result = HANDLE_EINTR(Sendmmsg(fd, &msgvec[0], buffers.size(), 0));
SendResult send_result(0, 0, std::move(buffers));
if (result < 0) {

View File

@ -0,0 +1,13 @@
diff --git a/sandbox/linux/seccomp-bpf/trap.cc b/sandbox/linux/seccomp-bpf/trap.cc
index f5b86a73ac..709b575419 100644
--- a/sandbox/linux/seccomp-bpf/trap.cc
+++ b/sandbox/linux/seccomp-bpf/trap.cc
@@ -174,7 +174,7 @@ void Trap::SigSys(int nr, LinuxSigInfo* info, ucontext_t* ctx) {
// If the version of glibc doesn't include this information in
// siginfo_t (older than 2.17), we need to explicitly copy it
// into an arch_sigsys structure.
- memcpy(&sigsys, &info->_sifields, sizeof(sigsys));
+ memcpy(&sigsys, &info->__si_fields, sizeof(sigsys));
#endif
#if defined(__mips__)

View File

@ -0,0 +1,40 @@
diff --git a/third_party/blink/renderer/platform/wtf/stack_util.cc b/third_party/blink/renderer/platform/wtf/stack_util.cc
index 2ea9916..589b109 100644
--- a/third_party/blink/renderer/platform/wtf/stack_util.cc
+++ b/third_party/blink/renderer/platform/wtf/stack_util.cc
@@ -29,7 +29,7 @@ size_t GetUnderestimatedStackSize() {
// FIXME: On Mac OSX and Linux, this method cannot estimate stack size
// correctly for the main thread.
-#elif defined(__GLIBC__) || BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FREEBSD) || \
+#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FREEBSD) || \
BUILDFLAG(IS_FUCHSIA)
// pthread_getattr_np() can fail if the thread is not invoked by
// pthread_create() (e.g., the main thread of blink_unittests).
@@ -55,6 +55,9 @@ size_t GetUnderestimatedStackSize() {
pthread_attr_destroy(&attr);
#endif
+#if BUILDFLAG(IS_LINUX) && !defined(__GLIBC__)
+ return 128 * 1024;
+#else
// Return a 512k stack size, (conservatively) assuming the following:
// - that size is much lower than the pthreads default (x86 pthreads has a 2M
// default.)
@@ -62,6 +65,7 @@ size_t GetUnderestimatedStackSize() {
// low as 512k.
//
return 512 * 1024;
+#endif // BUILDFLAG(IS_LINUX) && !defined(__GLIBC__)
#elif BUILDFLAG(IS_MAC)
// pthread_get_stacksize_np() returns too low a value for the main thread on
// OSX 10.9,
@@ -97,7 +101,7 @@ size_t GetUnderestimatedStackSize() {
}
void* GetStackStart() {
-#if defined(__GLIBC__) || BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FREEBSD) || \
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FREEBSD) || \
BUILDFLAG(IS_FUCHSIA)
pthread_attr_t attr;
int error;

View File

@ -0,0 +1,14 @@
diff --git a/content/public/common/socket_permission_request.h b/content/public/common/socket_permission_request.h
index 7316621275..6171219631 100644
--- a/content/public/common/socket_permission_request.h
+++ b/content/public/common/socket_permission_request.h
@@ -9,6 +9,9 @@
#include <string>
+#ifdef TCP_LISTEN
+#undef TCP_LISTEN
+#endif
namespace content {

View File

@ -0,0 +1,13 @@
diff --git a/sandbox/linux/services/credentials.h b/sandbox/linux/services/credentials.h
index 189d161..122be4f 100644
--- a/sandbox/linux/services/credentials.h
+++ b/sandbox/linux/services/credentials.h
@@ -13,6 +13,7 @@
#include <string>
#include <vector>
+#include <pwd.h>
#include "base/compiler_specific.h"
#include "sandbox/linux/system_headers/capability.h"

View File

@ -0,0 +1,22 @@
diff --git a/third_party/perfetto/include/perfetto/ext/base/thread_utils.h b/third_party/perfetto/include/perfetto/ext/base/thread_utils.h
index 2e9c4e54ef..dfcbd222d8 100644
--- a/third_party/perfetto/include/perfetto/ext/base/thread_utils.h
+++ b/third_party/perfetto/include/perfetto/ext/base/thread_utils.h
@@ -57,16 +57,7 @@ inline bool MaybeSetThreadName(const std::string& name) {
}
inline bool GetThreadName(std::string& out_result) {
- char buf[16] = {};
-#if PERFETTO_BUILDFLAG(PERFETTO_OS_ANDROID)
- if (prctl(PR_GET_NAME, buf) != 0)
- return false;
-#else
- if (pthread_getname_np(pthread_self(), buf, sizeof(buf)) != 0)
- return false;
-#endif
- out_result = std::string(buf);
- return true;
+ return false;
}
#else

View File

@ -0,0 +1,46 @@
diff --git a/base/files/file_util_linux.cc b/base/files/file_util_linux.cc
index b123dd2..b230fd9 100644
--- a/base/files/file_util_linux.cc
+++ b/base/files/file_util_linux.cc
@@ -30,7 +30,7 @@ bool GetFileSystemType(const FilePath& path, FileSystemType* type) {
case EXT2_SUPER_MAGIC: // Also ext3 and ext4
case MSDOS_SUPER_MAGIC:
case REISERFS_SUPER_MAGIC:
- case static_cast<int>(BTRFS_SUPER_MAGIC):
+ case BTRFS_SUPER_MAGIC:
case 0x5346544E: // NTFS
case 0x58465342: // XFS
case 0x3153464A: // JFS
@@ -40,14 +40,14 @@ bool GetFileSystemType(const FilePath& path, FileSystemType* type) {
*type = FILE_SYSTEM_NFS;
break;
case SMB_SUPER_MAGIC:
- case static_cast<int>(0xFF534D42): // CIFS
+ case 0xFF534D42: // CIFS
*type = FILE_SYSTEM_SMB;
break;
case CODA_SUPER_MAGIC:
*type = FILE_SYSTEM_CODA;
break;
- case static_cast<int>(HUGETLBFS_MAGIC):
- case static_cast<int>(RAMFS_MAGIC):
+ case HUGETLBFS_MAGIC:
+ case RAMFS_MAGIC:
case TMPFS_MAGIC:
*type = FILE_SYSTEM_MEMORY;
break;
diff --git a/base/system/sys_info_posix.cc b/base/system/sys_info_posix.cc
index 672c72f..a0d3465 100644
--- a/base/system/sys_info_posix.cc
+++ b/base/system/sys_info_posix.cc
@@ -102,8 +102,8 @@ bool IsStatsZeroIfUnlimited(const base::FilePath& path) {
switch (stats.f_type) {
case TMPFS_MAGIC:
- case static_cast<int>(HUGETLBFS_MAGIC):
- case static_cast<int>(RAMFS_MAGIC):
+ case HUGETLBFS_MAGIC:
+ case RAMFS_MAGIC:
return true;
}
return false;