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

Side by Side Diff: sandbox/linux/seccomp-bpf/syscall_iterator.cc

Issue 11411254: SECCOMP-BPF: Added supported for inspection system call arguments from BPF filters. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Another attempt at fixing the rebase Created 8 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h" 5 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h"
6 #include "sandbox/linux/seccomp-bpf/syscall_iterator.h" 6 #include "sandbox/linux/seccomp-bpf/syscall_iterator.h"
7 7
8 namespace playground2 { 8 namespace playground2 {
9 9
10 uint32_t SyscallIterator::Next() { 10 uint32_t SyscallIterator::Next() {
11 if (done_) { 11 if (done_) {
12 return num_; 12 return num_;
13 } 13 }
14 14
15 uint32_t val; 15 uint32_t val;
16 do { 16 do {
17 // |num_| has been initialized to 0, which we assume is also MIN_SYSCALL. 17 // |num_| has been initialized to 0, which we assume is also MIN_SYSCALL.
18 // This true for supported architectures (Intel and ARM EABI). 18 // This true for supported architectures (Intel and ARM EABI).
19 CHECK_EQ(MIN_SYSCALL, 0u); 19 COMPILE_ASSERT(MIN_SYSCALL == 0u,
20 min_syscall_should_always_be_zero);
20 val = num_; 21 val = num_;
21 22
22 // First we iterate up to MAX_PUBLIC_SYSCALL, which is equal to MAX_SYSCALL 23 // First we iterate up to MAX_PUBLIC_SYSCALL, which is equal to MAX_SYSCALL
23 // on Intel architectures, but leaves room for private syscalls on ARM. 24 // on Intel architectures, but leaves room for private syscalls on ARM.
24 if (num_ <= MAX_PUBLIC_SYSCALL) { 25 if (num_ <= MAX_PUBLIC_SYSCALL) {
25 if (invalid_only_ && num_ < MAX_PUBLIC_SYSCALL) { 26 if (invalid_only_ && num_ < MAX_PUBLIC_SYSCALL) {
26 num_ = MAX_PUBLIC_SYSCALL; 27 num_ = MAX_PUBLIC_SYSCALL;
27 } else { 28 } else {
28 ++num_; 29 ++num_;
29 } 30 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 uint32_t min_syscall = MIN_SYSCALL; 72 uint32_t min_syscall = MIN_SYSCALL;
72 if (num >= min_syscall && num <= MAX_PUBLIC_SYSCALL) { 73 if (num >= min_syscall && num <= MAX_PUBLIC_SYSCALL) {
73 return true; 74 return true;
74 } 75 }
75 if (IsArmPrivate(num)) { 76 if (IsArmPrivate(num)) {
76 return true; 77 return true;
77 } 78 }
78 return false; 79 return false;
79 } 80 }
80 81
82 #if defined(__arm__) && (defined(__thumb__) || defined(__ARM_EABI__))
81 bool SyscallIterator::IsArmPrivate(uint32_t num) { 83 bool SyscallIterator::IsArmPrivate(uint32_t num) {
82 #if defined(__arm__) && (defined(__thumb__) || defined(__ARM_EABI__))
83 return (num >= MIN_PRIVATE_SYSCALL && num <= MAX_PRIVATE_SYSCALL) || 84 return (num >= MIN_PRIVATE_SYSCALL && num <= MAX_PRIVATE_SYSCALL) ||
84 (num >= MIN_GHOST_SYSCALL && num <= MAX_SYSCALL); 85 (num >= MIN_GHOST_SYSCALL && num <= MAX_SYSCALL);
86 }
85 #else 87 #else
88 bool SyscallIterator::IsArmPrivate(uint32_t) {
86 return false; 89 return false;
90 }
87 #endif 91 #endif
88 }
89 92
90 } // namespace 93 } // namespace
91 94
OLDNEW
« no previous file with comments | « sandbox/linux/seccomp-bpf/syscall_iterator.h ('k') | sandbox/linux/seccomp-bpf/syscall_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698