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

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

Issue 817653003: Update from https://crrev.com/309717 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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 unified diff | Download patch
« no previous file with comments | « sandbox/linux/seccomp-bpf/sandbox_bpf_test_runner.h ('k') | sandbox/linux/seccomp-bpf/trap.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/syscall.h" 5 #include "sandbox/linux/seccomp-bpf/syscall.h"
6 6
7 #include <asm/unistd.h> 7 #include <asm/unistd.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <sys/mman.h> 9 #include <sys/mman.h>
10 #include <sys/syscall.h> 10 #include <sys/syscall.h>
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 std::vector<uint64_t>* const seen_syscall_args = 101 std::vector<uint64_t>* const seen_syscall_args =
102 static_cast<std::vector<uint64_t>*>(aux); 102 static_cast<std::vector<uint64_t>*>(aux);
103 BPF_ASSERT(arraysize(args.args) == 6); 103 BPF_ASSERT(arraysize(args.args) == 6);
104 seen_syscall_args->assign(args.args, args.args + arraysize(args.args)); 104 seen_syscall_args->assign(args.args, args.args + arraysize(args.args));
105 return -ENOMEM; 105 return -ENOMEM;
106 } 106 }
107 107
108 class CopyAllArgsOnUnamePolicy : public bpf_dsl::Policy { 108 class CopyAllArgsOnUnamePolicy : public bpf_dsl::Policy {
109 public: 109 public:
110 explicit CopyAllArgsOnUnamePolicy(std::vector<uint64_t>* aux) : aux_(aux) {} 110 explicit CopyAllArgsOnUnamePolicy(std::vector<uint64_t>* aux) : aux_(aux) {}
111 virtual ~CopyAllArgsOnUnamePolicy() {} 111 ~CopyAllArgsOnUnamePolicy() override {}
112 112
113 virtual ResultExpr EvaluateSyscall(int sysno) const override { 113 ResultExpr EvaluateSyscall(int sysno) const override {
114 DCHECK(SandboxBPF::IsValidSyscallNumber(sysno)); 114 DCHECK(SandboxBPF::IsValidSyscallNumber(sysno));
115 if (sysno == __NR_uname) { 115 if (sysno == __NR_uname) {
116 return Trap(CopySyscallArgsToAux, aux_); 116 return Trap(CopySyscallArgsToAux, aux_);
117 } else { 117 } else {
118 return Allow(); 118 return Allow();
119 } 119 }
120 } 120 }
121 121
122 private: 122 private:
123 std::vector<uint64_t>* aux_; 123 std::vector<uint64_t>* aux_;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 232
233 // Clean up 233 // Clean up
234 EXPECT_EQ(0, Syscall::Call(__NR_munmap, addr2, 8192L)); 234 EXPECT_EQ(0, Syscall::Call(__NR_munmap, addr2, 8192L));
235 EXPECT_EQ(0, Syscall::Call(__NR_munmap, addr3, 4096L)); 235 EXPECT_EQ(0, Syscall::Call(__NR_munmap, addr3, 4096L));
236 EXPECT_EQ(0, IGNORE_EINTR(Syscall::Call(__NR_close, fd))); 236 EXPECT_EQ(0, IGNORE_EINTR(Syscall::Call(__NR_close, fd)));
237 } 237 }
238 238
239 } // namespace 239 } // namespace
240 240
241 } // namespace sandbox 241 } // namespace sandbox
OLDNEW
« no previous file with comments | « sandbox/linux/seccomp-bpf/sandbox_bpf_test_runner.h ('k') | sandbox/linux/seccomp-bpf/trap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698