Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Unified Diff: components/nacl/loader/nonsfi/nonsfi_sandbox_unittest.cc

Issue 243833004: Non-SFI NaCl: Disallow futex call without FUTEX_PRIVATE_FLAG (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/nacl/loader/nonsfi/nonsfi_sandbox.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/nacl/loader/nonsfi/nonsfi_sandbox_unittest.cc
diff --git a/components/nacl/loader/nonsfi/nonsfi_sandbox_unittest.cc b/components/nacl/loader/nonsfi/nonsfi_sandbox_unittest.cc
index 1ba7e530284853da49695a45d12dca8d70633ddc..a58d79277ef185122810bb157146dfe52de63ee0 100644
--- a/components/nacl/loader/nonsfi/nonsfi_sandbox_unittest.cc
+++ b/components/nacl/loader/nonsfi/nonsfi_sandbox_unittest.cc
@@ -6,6 +6,7 @@
#include <errno.h>
#include <fcntl.h>
+#include <linux/futex.h>
#include <pthread.h>
#include <sched.h>
#include <signal.h>
@@ -16,6 +17,7 @@
#include <sys/ptrace.h>
#include <sys/socket.h>
#include <sys/syscall.h>
+#include <sys/time.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
@@ -115,6 +117,36 @@ BPF_DEATH_TEST(NaClNonSfiSandboxTest, clone_for_fork,
DoFork();
}
+BPF_TEST(NaClNonSfiSandboxTest, futex_allowed,
+ nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
+ errno = 0;
+ int v = 0;
+ struct timespec ts;
+ ts.tv_sec = 0;
+ ts.tv_nsec = 1; // 1 nanosecond.
+ BPF_ASSERT_EQ(-1, syscall(__NR_futex, &v,
+ FUTEX_WAIT_PRIVATE, 0, &ts, NULL, 0));
+ BPF_ASSERT_EQ(ETIMEDOUT, errno);
+}
+
+// TODO(hamaji): Disallow non-PRIVATE FUTEX_WAIT.
+BPF_TEST(NaClNonSfiSandboxTest, futex_FUTEX_WAIT_allowed,
+ nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
+ errno = 0;
+ int v = 0;
+ struct timespec ts;
+ ts.tv_sec = 0;
+ ts.tv_nsec = 1; // 1 nanosecond.
+ BPF_ASSERT_EQ(-1, syscall(__NR_futex, &v, FUTEX_WAIT, 0, &ts, NULL, 0));
+ BPF_ASSERT_EQ(ETIMEDOUT, errno);
+}
+
+BPF_DEATH_TEST(NaClNonSfiSandboxTest, futex_FUTEX_WAKE,
+ DEATH_MESSAGE(sandbox::GetErrorMessageContentForTests()),
+ nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
+ syscall(__NR_futex, NULL, FUTEX_WAKE, 0, NULL, NULL, 0);
+}
+
BPF_TEST(NaClNonSfiSandboxTest, prctl_SET_NAME,
nacl::nonsfi::NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl) {
errno = 0;
« no previous file with comments | « components/nacl/loader/nonsfi/nonsfi_sandbox.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698