OLD | NEW |
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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 SandboxBPFDSLPolicy { | 108 class CopyAllArgsOnUnamePolicy : public SandboxBPFDSLPolicy { |
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 virtual ~CopyAllArgsOnUnamePolicy() {} |
112 | 112 |
113 virtual ResultExpr EvaluateSyscall(int sysno) const OVERRIDE { | 113 virtual 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 Loading... |
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 |
OLD | NEW |