Merge "Add permitted_when_isolated_path to linker namespaces"
diff --git a/libc/Android.mk b/libc/Android.mk
index ba3e5aa..456527a 100644
--- a/libc/Android.mk
+++ b/libc/Android.mk
@@ -697,6 +697,9 @@
include $(CLEAR_VARS)
LOCAL_SRC_FILES := bionic/__stack_chk_fail.cpp
+# On x86, the __set_tls implementation is complex enough that
+# -fstack-protector-strong inserts a check.
+LOCAL_SRC_FILES_x86 := arch-x86/bionic/__set_tls.c
LOCAL_CFLAGS := $(libc_common_cflags) -fno-stack-protector
LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
LOCAL_CPPFLAGS := $(libc_common_cppflags)
diff --git a/libc/arch-x86/x86.mk b/libc/arch-x86/x86.mk
index b4056bb..1d717aa 100644
--- a/libc/arch-x86/x86.mk
+++ b/libc/arch-x86/x86.mk
@@ -109,7 +109,6 @@
arch-x86/bionic/libgcc_compat.c \
arch-x86/bionic/__restore.S \
arch-x86/bionic/setjmp.S \
- arch-x86/bionic/__set_tls.c \
arch-x86/bionic/syscall.S \
arch-x86/bionic/vfork.S \
diff --git a/libc/bionic/libc_init_common.cpp b/libc/bionic/libc_init_common.cpp
index 8f1ee95..b0c62d6 100644
--- a/libc/bionic/libc_init_common.cpp
+++ b/libc/bionic/libc_init_common.cpp
@@ -79,6 +79,10 @@
static pthread_internal_t main_thread;
+ // The x86 -fstack-protector implementation uses TLS, so make sure that's
+ // set up before we call any function that might get a stack check inserted.
+ __set_tls(main_thread.tls);
+
// Tell the kernel to clear our tid field when we exit, so we're like any other pthread.
// As a side-effect, this tells us our pid (which is the same as the main thread's tid).
main_thread.tid = __set_tid_address(&main_thread.tid);
@@ -97,7 +101,6 @@
__init_thread(&main_thread);
__init_tls(&main_thread);
- __set_tls(main_thread.tls);
// Store a pointer to the kernel argument block in a TLS slot to be
// picked up by the libc constructor.
diff --git a/linker/linker.cpp b/linker/linker.cpp
index 3b67625..66955da 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -37,7 +37,6 @@
#include <string.h>
#include <sys/mman.h>
#include <sys/param.h>
-#include <sys/prctl.h>
#include <unistd.h>
#include <new>
@@ -555,13 +554,6 @@
static bool realpath_fd(int fd, std::string* realpath) {
std::vector<char> buf(PATH_MAX), proc_self_fd(PATH_MAX);
__libc_format_buffer(&proc_self_fd[0], proc_self_fd.size(), "/proc/self/fd/%d", fd);
- // set DUMPABLE to 1 to access /proc/self/fd
- int dumpable = prctl(PR_GET_DUMPABLE, 0, 0, 0, 0);
- prctl(PR_SET_DUMPABLE, 1, 0, 0, 0);
- auto guard = make_scope_guard([&]() {
- // restore dumpable
- prctl(PR_SET_DUMPABLE, dumpable, 0, 0, 0);
- });
if (readlink(&proc_self_fd[0], &buf[0], buf.size()) == -1) {
PRINT("readlink('%s') failed: %s [fd=%d]", &proc_self_fd[0], strerror(errno), fd);
return false;