summaryrefslogtreecommitdiffstats
path: root/sandbox
diff options
context:
space:
mode:
authorjln@chromium.org <jln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-17 02:43:23 +0000
committerjln@chromium.org <jln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-17 02:43:23 +0000
commitccc5ffdba758e05239222ca36551c67ec79df1db (patch)
tree7f561b2b79138f5b25c04a11c11b03bc4ce0ddb5 /sandbox
parenta6236e928eeb6a46abadecd2f776d81795bb12b4 (diff)
downloadchromium_src-ccc5ffdba758e05239222ca36551c67ec79df1db.zip
chromium_src-ccc5ffdba758e05239222ca36551c67ec79df1db.tar.gz
chromium_src-ccc5ffdba758e05239222ca36551c67ec79df1db.tar.bz2
Android: create a generic android_ucontext.h
We now have a generic android_ucontext.h that should work on both ARM and X86. Note: if this needs to be reverted on X86, please only revert the GYP file and send me the error message. (Thanks to Yin Fengwei for his related work in https://chromiumcodereview.appspot.com/11639038/) BUG=166704 NOTRY=true Review URL: https://chromiumcodereview.appspot.com/11971028 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@177321 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sandbox')
-rw-r--r--sandbox/linux/sandbox_linux.gypi2
-rw-r--r--sandbox/linux/seccomp-bpf/sandbox_bpf.cc4
-rw-r--r--sandbox/linux/services/android_arm_ucontext.h21
-rw-r--r--sandbox/linux/services/android_ucontext.h22
-rw-r--r--sandbox/linux/services/android_x86_ucontext.h31
5 files changed, 74 insertions, 6 deletions
diff --git a/sandbox/linux/sandbox_linux.gypi b/sandbox/linux/sandbox_linux.gypi
index a856ca8..ce694a7 100644
--- a/sandbox/linux/sandbox_linux.gypi
+++ b/sandbox/linux/sandbox_linux.gypi
@@ -10,7 +10,7 @@
}, {
'compile_suid_client': 0,
}],
- ['((OS=="linux" or (OS=="android" and target_arch=="arm")) and '
+ ['((OS=="linux" or OS=="android") and '
'(target_arch=="ia32" or target_arch=="x64" or '
'target_arch=="arm"))', {
'compile_seccomp_bpf': 1,
diff --git a/sandbox/linux/seccomp-bpf/sandbox_bpf.cc b/sandbox/linux/seccomp-bpf/sandbox_bpf.cc
index cc2ce1e..dc21b7d 100644
--- a/sandbox/linux/seccomp-bpf/sandbox_bpf.cc
+++ b/sandbox/linux/seccomp-bpf/sandbox_bpf.cc
@@ -18,8 +18,8 @@
#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"
+#if defined(OS_ANDROID)
+#include "sandbox/linux/services/android_ucontext.h"
#endif
namespace {
diff --git a/sandbox/linux/services/android_arm_ucontext.h b/sandbox/linux/services/android_arm_ucontext.h
index 0c21e20..c4d748e 100644
--- a/sandbox/linux/services/android_arm_ucontext.h
+++ b/sandbox/linux/services/android_arm_ucontext.h
@@ -5,10 +5,20 @@
#ifndef SANDBOX_LINUX_SERVICES_ANDROID_ARM_UCONTEXT_H_
#define SANDBOX_LINUX_SERVICES_ANDROID_ARM_UCONTEXT_H_
+#if !defined(__BIONIC_HAVE_UCONTEXT_T)
#include <asm/sigcontext.h>
-typedef long int greg_t;
-typedef unsigned long sigset_t;
+// We also need greg_t for the sandbox, include it in this header as well.
+typedef unsigned long greg_t;
+
+// sigset_t from arch/arm/include/asm/signal.h in the Linux kernel.
+typedef struct {
+ unsigned long sig[64 / 8 / sizeof(long)]; // Always 64 bits (yes we assume
+ // 8 bits per char).
+} android_header_sigset_t; // Change name to avoid collissions if sigset_t
+ // gets defined in newer Android headers.
+
+//typedef unsigned long sigset_t;
typedef struct ucontext {
unsigned long uc_flags;
struct ucontext *uc_link;
@@ -16,9 +26,14 @@ typedef struct ucontext {
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))];
+ int __not_used[32 - (sizeof (android_header_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;
+
+#else
+#include <sys/ucontext.h>
+#endif // __BIONIC_HAVE_UCONTEXT_T
+
#endif // SANDBOX_LINUX_SERVICES_ANDROID_ARM_UCONTEXT_H_
diff --git a/sandbox/linux/services/android_ucontext.h b/sandbox/linux/services/android_ucontext.h
new file mode 100644
index 0000000..ac683b4
--- /dev/null
+++ b/sandbox/linux/services/android_ucontext.h
@@ -0,0 +1,22 @@
+// Copyright (c) 2013 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_UCONTEXT_H_
+#define SANDBOX_LINUX_SERVICES_ANDROID_UCONTEXT_H_
+
+#if defined(__ANDROID__)
+
+#if defined(__arm__)
+#include "sandbox/linux/services/android_arm_ucontext.h"
+#elif defined(__i386__) || defined(__x86_64__)
+#include "sandbox/linux/services/android_x86_ucontext.h"
+#else
+#error "No support for your architecture in Android header"
+#endif
+
+#else // __ANDROID__
+#error "Android header file included on non Android."
+#endif // __ANDROID__
+
+#endif // SANDBOX_LINUX_SERVICES_ANDROID_UCONTEXT_H_
diff --git a/sandbox/linux/services/android_x86_ucontext.h b/sandbox/linux/services/android_x86_ucontext.h
new file mode 100644
index 0000000..a28cd87
--- /dev/null
+++ b/sandbox/linux/services/android_x86_ucontext.h
@@ -0,0 +1,31 @@
+// 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_X86_UCONTEXT_H_
+#define SANDBOX_LINUX_SERVICES_ANDROID_X86_UCONTEXT_H_
+
+// This is basically include/uapi/asm-generic/ucontext.h from the Linux kernel.
+// In theory, Android libc's could expand the structure for its own internal
+// use, but if the libc provides an API that expects this expanded structure,
+// __BIONIC_HAVE_UCONTEXT_T should be defined.
+
+#if !defined(__BIONIC_HAVE_UCONTEXT_T)
+#include <asm/sigcontext.h>
+
+// We also need greg_t for the sandbox, include it in this header as well.
+typedef unsigned long greg_t;
+
+typedef struct ucontext {
+ unsigned long uc_flags;
+ struct ucontext *uc_link;
+ stack_t uc_stack;
+ struct sigcontext uc_mcontext;
+ sigset_t uc_sigmask; /* mask last for extensibility */
+} ucontext_t;
+
+#else
+#include <sys/ucontext.h>
+#endif // __BIONIC_HAVE_UCONTEXT_T
+
+#endif // SANDBOX_LINUX_SERVICES_ANDROID_X86_UCONTEXT_H_