summaryrefslogtreecommitdiffstats
path: root/chromium/patches/017-musl-tid-caching.patch
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/patches/017-musl-tid-caching.patch')
-rw-r--r--chromium/patches/017-musl-tid-caching.patch85
1 files changed, 85 insertions, 0 deletions
diff --git a/chromium/patches/017-musl-tid-caching.patch b/chromium/patches/017-musl-tid-caching.patch
new file mode 100644
index 0000000..498ce82
--- /dev/null
+++ b/chromium/patches/017-musl-tid-caching.patch
@@ -0,0 +1,85 @@
1the sandbox caching of thread id's only works with glibc
2see: https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/32356
3see: https://gitlab.alpinelinux.org/alpine/aports/-/issues/13579
4--
5--- a/sandbox/linux/services/namespace_sandbox.cc
6+++ b/sandbox/linux/services/namespace_sandbox.cc
7@@ -209,6 +209,70 @@
8 return base::LaunchProcess(argv, launch_options_copy);
9 }
10
11+#if defined(__aarch64__)
12+#define TLS_ABOVE_TP
13+#endif
14+
15+struct musl_pthread
16+{
17+ /* Part 1 -- these fields may be external or
18+ * internal (accessed via asm) ABI. Do not change. */
19+ struct pthread *self;
20+#ifndef TLS_ABOVE_TP
21+ uintptr_t *dtv;
22+#endif
23+ struct pthread *prev, *next; /* non-ABI */
24+ uintptr_t sysinfo;
25+#ifndef TLS_ABOVE_TP
26+#ifdef CANARY_PAD
27+ uintptr_t canary_pad;
28+#endif
29+ uintptr_t canary;
30+#endif
31+
32+/* Part 2 -- implementation details, non-ABI. */
33+ int tid;
34+ int errno_val;
35+ volatile int detach_state;
36+ volatile int cancel;
37+ volatile unsigned char canceldisable, cancelasync;
38+ unsigned char tsd_used:1;
39+ unsigned char dlerror_flag:1;
40+ unsigned char *map_base;
41+ size_t map_size;
42+ void *stack;
43+ size_t stack_size;
44+ size_t guard_size;
45+ void *result;
46+ struct __ptcb *cancelbuf;
47+ void **tsd;
48+ struct {
49+ volatile void *volatile head;
50+ long off;
51+ volatile void *volatile pending;
52+ } robust_list;
53+ int h_errno_val;
54+ volatile int timer_id;
55+ locale_t locale;
56+ volatile int killlock[1];
57+ char *dlerror_buf;
58+ void *stdio_locks;
59+
60+ /* Part 3 -- the positions of these fields relative to
61+ * the end of the structure is external and internal ABI. */
62+#ifdef TLS_ABOVE_TP
63+ uintptr_t canary;
64+ uintptr_t *dtv;
65+#endif
66+};
67+
68+void MaybeUpdateMuslTidCache()
69+{
70+ pid_t real_tid = sys_gettid();
71+ pid_t* cached_tid_location = &reinterpret_cast<struct musl_pthread*>(pthread_self())->tid;
72+ *cached_tid_location = real_tid;
73+}
74+
75 // static
76 pid_t NamespaceSandbox::ForkInNewPidNamespace(bool drop_capabilities_in_child) {
77 const pid_t pid =
78@@ -226,6 +290,7 @@
79 #if defined(LIBC_GLIBC)
80 MaybeUpdateGlibcTidCache();
81 #endif
82+ MaybeUpdateMuslTidCache();
83 return 0;
84 }
85