diff options
author | markus@chromium.org <markus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-25 20:49:26 +0000 |
---|---|---|
committer | markus@chromium.org <markus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-25 20:49:26 +0000 |
commit | b92e05de97b1dd960974c78be4f392142871df3d (patch) | |
tree | 9733ce079b84fa84a927484b3746ca41d11cbefb /third_party | |
parent | ef98a5d9fbb4aa55d4bda9318cd40c81feda2930 (diff) | |
download | chromium_src-b92e05de97b1dd960974c78be4f392142871df3d.zip chromium_src-b92e05de97b1dd960974c78be4f392142871df3d.tar.gz chromium_src-b92e05de97b1dd960974c78be4f392142871df3d.tar.bz2 |
Fix a few more places where we need to use our own allocator.
Make tcmalloc compatible with the seccomp sandbox by avoiding making direct system calls from within tcmalloc.
BUG=38973
TEST=none
Review URL: http://codereview.chromium.org/1294001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42667 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party')
-rw-r--r-- | third_party/tcmalloc/chromium/src/base/spinlock_linux-inl.h | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/third_party/tcmalloc/chromium/src/base/spinlock_linux-inl.h b/third_party/tcmalloc/chromium/src/base/spinlock_linux-inl.h index 0df09a3..f7b4a41 100644 --- a/third_party/tcmalloc/chromium/src/base/spinlock_linux-inl.h +++ b/third_party/tcmalloc/chromium/src/base/spinlock_linux-inl.h @@ -33,12 +33,22 @@ #include <sched.h> #include <time.h> -#include "base/linux_syscall_support.h" #define FUTEX_WAIT 0 #define FUTEX_WAKE 1 #define FUTEX_PRIVATE_FLAG 128 +// Note: Instead of making direct system calls that are inlined, we rely +// on the syscall() function in glibc to do the right thing. This +// is necessary to make the code compatible with the seccomp sandbox, +// which needs to be able to find and patch all places where system +// calls are made. Scanning through and patching glibc is fast, but +// doing so on the entire Chrome binary would be prohibitively +// expensive. +// This is a notable change from the upstream version of tcmalloc, +// which prefers direct system calls in order to improve compatibility +// with older toolchains and runtime libraries. + static bool have_futex; static int futex_private_flag = FUTEX_PRIVATE_FLAG; @@ -49,9 +59,9 @@ static struct InitModule { // futexes are ints, so we can use them only when // that's the same size as the lockword_ in SpinLock. have_futex = (sizeof (Atomic32) == sizeof (int) && - sys_futex(&x, FUTEX_WAKE, 1, 0) >= 0); + syscall(__NR_futex, &x, FUTEX_WAKE, 1, 0) >= 0); if (have_futex && - sys_futex(&x, FUTEX_WAKE | futex_private_flag, 1, 0) < 0) { + syscall(__NR_futex, &x, FUTEX_WAKE | futex_private_flag, 1, 0) < 0) { futex_private_flag = 0; } } @@ -67,7 +77,7 @@ static void SpinLockWait(volatile Atomic32 *w) { tm.tv_nsec = 1000000; // 1ms; really we're trying to sleep for one kernel // clock tick while ((value = base::subtle::Acquire_CompareAndSwap(w, 0, 1)) != 0) { - sys_futex(reinterpret_cast<int *>(const_cast<Atomic32 *>(w)), + syscall(__NR_futex, reinterpret_cast<int *>(const_cast<Atomic32 *>(w)), FUTEX_WAIT | futex_private_flag, value, reinterpret_cast<struct kernel_timespec *>(&tm)); } @@ -85,7 +95,7 @@ static void SpinLockWait(volatile Atomic32 *w) { static void SpinLockWake(volatile Atomic32 *w) { if (have_futex) { - sys_futex(reinterpret_cast<int *>(const_cast<Atomic32 *>(w)), + syscall(__NR_futex, reinterpret_cast<int *>(const_cast<Atomic32 *>(w)), FUTEX_WAKE | futex_private_flag, 1, 0); } } |