summaryrefslogtreecommitdiffstats
path: root/sandbox/linux
diff options
context:
space:
mode:
authorglider <glider@chromium.org>2015-07-23 04:03:18 -0700
committerCommit bot <commit-bot@chromium.org>2015-07-23 11:03:55 +0000
commiteccffe499e5a28eeaa68a135008ddd7a8534bdf7 (patch)
treeffcf41d724d9fa0fce603d81e136506ee281e818 /sandbox/linux
parentdbcfb120974345eb846b92bf224fef89426b30cf (diff)
downloadchromium_src-eccffe499e5a28eeaa68a135008ddd7a8534bdf7.zip
chromium_src-eccffe499e5a28eeaa68a135008ddd7a8534bdf7.tar.gz
chromium_src-eccffe499e5a28eeaa68a135008ddd7a8534bdf7.tar.bz2
Revert of Set a new TLS when using CLONE_VM. (patchset #4 id:80001 of https://codereview.chromium.org/1248673004/)
Reason for revert: This CL has broken ASan Linux (sandboxed) tests: basically every test from browser_tests, content_browsertests, interactive_ui_tests times out: http://build.chromium.org/p/chromium.memory/builders/Linux%20ASan%20Tests%20%28sandboxed%29/builds/15502 Original issue's description: > Set a new TLS when using CLONE_VM. > > On some libcs, clone writes to the new child's TLS before returning, so > we set a new TLS to avoid corrupting the parent process's TLS. > > On glibc, this caused an assertion failure inside of > pthread_getattr_np(pthread_self(), &attr). > > BUG=512623 > > Committed: https://crrev.com/d2516cf1c3843541c920a476315e2a6f10cb0f92 > Cr-Commit-Position: refs/heads/master@{#340025} TBR=jln@chromium.org,rickyz@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=512623 Review URL: https://codereview.chromium.org/1256533002 Cr-Commit-Position: refs/heads/master@{#340069}
Diffstat (limited to 'sandbox/linux')
-rw-r--r--sandbox/linux/services/credentials.cc22
-rw-r--r--sandbox/linux/services/credentials_unittest.cc27
2 files changed, 3 insertions, 46 deletions
diff --git a/sandbox/linux/services/credentials.cc b/sandbox/linux/services/credentials.cc
index 014ae13..dc62f1b 100644
--- a/sandbox/linux/services/credentials.cc
+++ b/sandbox/linux/services/credentials.cc
@@ -54,9 +54,6 @@ bool GetRESIds(uid_t* resuid, gid_t* resgid) {
const int kExitSuccess = 0;
int ChrootToSelfFdinfo(void*) {
- // This function can be run from a vforked child, so it should not write to
- // any memory other than the stack or errno. Reads from TLS may be different
- // from in the parent process.
RAW_CHECK(sys_chroot("/proc/self/fdinfo/") == 0);
// CWD is essentially an implicit file descriptor, so be careful to not
@@ -94,22 +91,9 @@ bool ChrootToSafeEmptyDir() {
#error "Unsupported architecture"
#endif
- int clone_flags = CLONE_FS | LINUX_SIGCHLD;
- void* tls = nullptr;
-#if defined(ARCH_CPU_X86_64) || defined(ARCH_CPU_ARM_FAMILY)
- // Use CLONE_VM | CLONE_VFORK as an optimization to avoid copying page tables.
- // Since clone writes to the new child's TLS before returning, we must set a
- // new TLS to avoid corrupting the current process's TLS. On ARCH_CPU_X86,
- // glibc performs syscalls by calling a function pointer in TLS, so we do not
- // attempt this optimization.
- clone_flags |= CLONE_VM | CLONE_VFORK | CLONE_SETTLS;
-
- char tls_buf[PTHREAD_STACK_MIN] = {0};
- tls = tls_buf;
-#endif
-
- pid = clone(ChrootToSelfFdinfo, stack, clone_flags, nullptr, nullptr, tls,
- nullptr);
+ pid = clone(ChrootToSelfFdinfo, stack,
+ CLONE_VM | CLONE_VFORK | CLONE_FS | LINUX_SIGCHLD, nullptr,
+ nullptr, nullptr, nullptr);
PCHECK(pid != -1);
int status = -1;
diff --git a/sandbox/linux/services/credentials_unittest.cc b/sandbox/linux/services/credentials_unittest.cc
index 39fd6a7..6b93c86 100644
--- a/sandbox/linux/services/credentials_unittest.cc
+++ b/sandbox/linux/services/credentials_unittest.cc
@@ -6,8 +6,6 @@
#include <errno.h>
#include <fcntl.h>
-#include <pthread.h>
-#include <signal.h>
#include <stdio.h>
#include <sys/capability.h>
#include <sys/stat.h>
@@ -239,31 +237,6 @@ SANDBOX_TEST(Credentials, SetCapabilitiesMatchesLibCap2) {
CHECK_EQ(0, cap_compare(expected_cap.get(), actual_cap.get()));
}
-volatile sig_atomic_t signal_handler_called;
-void SignalHandler(int sig) {
- signal_handler_called = 1;
-}
-
-// Disabled on ASAN because of crbug.com/451603.
-SANDBOX_TEST(Credentials, DISABLE_ON_ASAN(DropFileSystemAccessPreservesTLS)) {
- // Probably missing kernel support.
- if (!Credentials::MoveToNewUserNS()) return;
- CHECK(Credentials::DropFileSystemAccess(ProcUtil::OpenProc().get()));
-
- // In glibc, pthread_getattr_np makes an assertion about the cached PID/TID in
- // TLS.
- pthread_attr_t attr;
- EXPECT_EQ(0, pthread_getattr_np(pthread_self(), &attr));
-
- // raise also uses the cached TID in glibc.
- struct sigaction action = {};
- action.sa_handler = &SignalHandler;
- PCHECK(sigaction(SIGUSR1, &action, nullptr) == 0);
-
- PCHECK(raise(SIGUSR1) == 0);
- CHECK_EQ(1, signal_handler_called);
-}
-
} // namespace.
} // namespace sandbox.