summaryrefslogtreecommitdiffstats
path: root/sandbox
diff options
context:
space:
mode:
authorjln@chromium.org <jln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-20 01:28:52 +0000
committerjln@chromium.org <jln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-20 01:28:52 +0000
commit1bf415567c28c5ea0cc3529f160496648ea162da (patch)
treee30dc17291040b51935bff4ab5f25619f87fb7af /sandbox
parent082261b9911da811ba57fa172dcad8677e716e35 (diff)
downloadchromium_src-1bf415567c28c5ea0cc3529f160496648ea162da.zip
chromium_src-1bf415567c28c5ea0cc3529f160496648ea162da.tar.gz
chromium_src-1bf415567c28c5ea0cc3529f160496648ea162da.tar.bz2
Linux Sandbox: get everything to compile on Android.
We define our own android_arm_ucontext.h file since signal.h doesn't define ucontext_t on Android. BUG=166704 NOTRY=true Review URL: https://chromiumcodereview.appspot.com/11618010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@174070 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sandbox')
-rw-r--r--sandbox/linux/sandbox_linux.gypi11
-rw-r--r--sandbox/linux/seccomp-bpf/sandbox_bpf.cc12
-rw-r--r--sandbox/linux/seccomp-bpf/sandbox_bpf.h4
-rw-r--r--sandbox/linux/seccomp-bpf/sandbox_bpf_unittest.cc6
-rw-r--r--sandbox/linux/services/android_arm_ucontext.h21
5 files changed, 47 insertions, 7 deletions
diff --git a/sandbox/linux/sandbox_linux.gypi b/sandbox/linux/sandbox_linux.gypi
index 936b3f6..bffa7d4 100644
--- a/sandbox/linux/sandbox_linux.gypi
+++ b/sandbox/linux/sandbox_linux.gypi
@@ -25,12 +25,6 @@
['OS == "android"', {
'sources/': [
['include', '^linux/'],
- # TODO(jln): some files don't yet even compile on Android.
- # crbug.com/166704
- ['exclude', 'errorcode_unittest\\.cc$'],
- ['exclude', 'sandbox_bpf\\.cc$'],
- ['exclude', 'sandbox_bpf_unittest\\.cc$'],
- ['exclude', 'syscall_unittest\\.cc$'],
],
}],
],
@@ -101,6 +95,11 @@
'seccomp-bpf/syscall_unittest.cc',
],
}],
+ ['OS == "android" and gtest_target_type == "shared_library"', {
+ 'dependencies': [
+ '../testing/android/native_test.gyp:native_test_native_code',
+ ]
+ }],
],
},
{
diff --git a/sandbox/linux/seccomp-bpf/sandbox_bpf.cc b/sandbox/linux/seccomp-bpf/sandbox_bpf.cc
index 740320f..366706f 100644
--- a/sandbox/linux/seccomp-bpf/sandbox_bpf.cc
+++ b/sandbox/linux/seccomp-bpf/sandbox_bpf.cc
@@ -2,6 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <signal.h>
+#include <sys/prctl.h>
+#include <sys/syscall.h>
+
#ifndef SECCOMP_BPF_STANDALONE
#include "base/logging.h"
#include "base/posix/eintr_wrapper.h"
@@ -13,6 +17,11 @@
#include "sandbox/linux/seccomp-bpf/syscall_iterator.h"
#include "sandbox/linux/seccomp-bpf/verifier.h"
+// Android's signal.h doesn't define ucontext etc.
+#if defined(OS_ANDROID) && defined(__arm__)
+#include "sandbox/linux/services/android_arm_ucontext.h"
+#endif
+
namespace {
void WriteFailedStderrSetupMessage(int out_fd) {
@@ -40,7 +49,8 @@ void WriteFailedStderrSetupMessage(int out_fd) {
// way to mark a signal as allocated. So, the potential for collision is
// possibly even worse.
bool GetIsInSigHandler(const ucontext_t *ctx) {
- return sigismember(&ctx->uc_sigmask, SIGBUS);
+ // Note: on Android, sigismember does not take a pointer to const.
+ return sigismember(const_cast<sigset_t*>(&ctx->uc_sigmask), SIGBUS);
}
void SetIsInSigHandler() {
diff --git a/sandbox/linux/seccomp-bpf/sandbox_bpf.h b/sandbox/linux/seccomp-bpf/sandbox_bpf.h
index a551a52..aee03fa 100644
--- a/sandbox/linux/seccomp-bpf/sandbox_bpf.h
+++ b/sandbox/linux/seccomp-bpf/sandbox_bpf.h
@@ -85,6 +85,10 @@
#endif
// For prctl.h
+#ifndef PR_SET_SECCOMP
+#define PR_SET_SECCOMP 22
+#define PR_GET_SECCOMP 21
+#endif
#ifndef PR_SET_NO_NEW_PRIVS
#define PR_SET_NO_NEW_PRIVS 38
#define PR_GET_NO_NEW_PRIVS 39
diff --git a/sandbox/linux/seccomp-bpf/sandbox_bpf_unittest.cc b/sandbox/linux/seccomp-bpf/sandbox_bpf_unittest.cc
index 25b6655..dd5ece0 100644
--- a/sandbox/linux/seccomp-bpf/sandbox_bpf_unittest.cc
+++ b/sandbox/linux/seccomp-bpf/sandbox_bpf_unittest.cc
@@ -15,6 +15,12 @@
#include "sandbox/linux/services/linux_syscalls.h"
#include "testing/gtest/include/gtest/gtest.h"
+// Workaround for Android's prctl.h file.
+#if !defined(PR_CAPBSET_READ)
+#define PR_CAPBSET_READ 23
+#define PR_CAPBSET_DROP 24
+#endif
+
using namespace playground2;
using sandbox::BrokerProcess;
diff --git a/sandbox/linux/services/android_arm_ucontext.h b/sandbox/linux/services/android_arm_ucontext.h
new file mode 100644
index 0000000..c35da17
--- /dev/null
+++ b/sandbox/linux/services/android_arm_ucontext.h
@@ -0,0 +1,21 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SANDBOX_LINUX_SERVICES_ANDROID_ARM_UCONTEXT_H_
+#define SANDBOX_LINUX_SERVICES_ANDROID_ARM_UCONTEXT_H_
+typedef long int greg_t;
+typedef unsigned long sigset_t;
+typedef struct ucontext {
+ unsigned long uc_flags;
+ struct ucontext *uc_link;
+ stack_t uc_stack;
+ struct sigcontext uc_mcontext;
+ sigset_t uc_sigmask;
+ /* Allow for uc_sigmask growth. Glibc uses a 1024-bit sigset_t. */
+ int __not_used[32 - (sizeof (sigset_t) / sizeof (int))];
+ /* Last for extensibility. Eight byte aligned because some
+ coprocessors require eight byte alignment. */
+ unsigned long uc_regspace[128] __attribute__((__aligned__(8)));
+} ucontext_t;
+#endif // SANDBOX_LINUX_SERVICES_ANDROID_ARM_UCONTEXT_H_