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

Unified Diff: components/nacl/loader/nonsfi/nonsfi_sandbox.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 | « no previous file | components/nacl/loader/nonsfi/nonsfi_sandbox_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/nacl/loader/nonsfi/nonsfi_sandbox.cc
diff --git a/components/nacl/loader/nonsfi/nonsfi_sandbox.cc b/components/nacl/loader/nonsfi/nonsfi_sandbox.cc
index 260dd7509331d5ecbc5431f6bb24386f8e8c5cd7..a6664a321d87347afb60ace1e692d0ff776aefc2 100644
--- a/components/nacl/loader/nonsfi/nonsfi_sandbox.cc
+++ b/components/nacl/loader/nonsfi/nonsfi_sandbox.cc
@@ -6,6 +6,7 @@
#include <errno.h>
#include <fcntl.h>
+#include <linux/futex.h>
#include <linux/net.h>
#include <sys/prctl.h>
#include <sys/ptrace.h>
@@ -35,6 +36,20 @@ namespace nacl {
namespace nonsfi {
namespace {
+ErrorCode RestrictFutexCommands(SandboxBPF* sb) {
+ // For now, we allow non-PRIVATE FUTEX_WAIT for lll_wait_tid in
+ // glibc's pthread_join.
+ // TODO(hamaji): Disallow FUTEX_WAIT by switching to newlib or
+ // detaching threads.
+ return sb->Cond(1, ErrorCode::TP_32BIT,
+ ErrorCode::OP_EQUAL, FUTEX_WAIT,
+ ErrorCode(ErrorCode::ERR_ALLOWED),
+ sb->Cond(1, ErrorCode::TP_32BIT,
+ ErrorCode::OP_HAS_ALL_BITS, FUTEX_PRIVATE_FLAG,
+ ErrorCode(ErrorCode::ERR_ALLOWED),
+ sb->Trap(sandbox::CrashSIGSYS_Handler, NULL)));
+}
+
ErrorCode RestrictFcntlCommands(SandboxBPF* sb) {
ErrorCode::ArgType mask_long_type;
if (sizeof(long) == 8) {
@@ -226,8 +241,6 @@ ErrorCode NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl(
#elif defined(__x86_64__)
case __NR_fstat:
#endif
- // TODO(hamaji): Allow only FUTEX_PRIVATE_FLAG.
- case __NR_futex:
// TODO(hamaji): Remove the need of gettid. Currently, this is
// called from PlatformThread::CurrentId().
case __NR_gettid:
@@ -263,6 +276,9 @@ ErrorCode NaClNonSfiBPFSandboxPolicy::EvaluateSyscallImpl(
#endif
return RestrictFcntlCommands(sb);
+ case __NR_futex:
+ return RestrictFutexCommands(sb);
+
#if defined(__x86_64__)
case __NR_mmap:
#endif
« no previous file with comments | « no previous file | components/nacl/loader/nonsfi/nonsfi_sandbox_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698