| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/bpf_dsl/bpf_dsl.h" | 5 #include "sandbox/linux/bpf_dsl/bpf_dsl.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 // tree like: | 241 // tree like: |
| 242 // | 242 // |
| 243 // expr = e4 | 243 // expr = e4 |
| 244 // expr = (b3 ? e3 : expr) = (b3 ? e3 : e4) | 244 // expr = (b3 ? e3 : expr) = (b3 ? e3 : e4) |
| 245 // expr = (b2 ? e2 : expr) = (b2 ? e2 : (b3 ? e3 : e4)) | 245 // expr = (b2 ? e2 : expr) = (b2 ? e2 : (b3 ? e3 : e4)) |
| 246 // expr = (b1 ? e1 : expr) = (b1 ? e1 : (b2 ? e2 : (b3 ? e3 : e4))) | 246 // expr = (b1 ? e1 : expr) = (b1 ? e1 : (b2 ? e2 : (b3 ? e3 : e4))) |
| 247 // | 247 // |
| 248 // and end up with an appropriately chained tree. | 248 // and end up with an appropriately chained tree. |
| 249 | 249 |
| 250 ResultExpr expr = else_result; | 250 ResultExpr expr = else_result; |
| 251 for (Cons<Clause>::List it = clause_list_; it; it = it->tail()) { | 251 for (Cons<Clause>::List it = clause_list_; it.get(); it = it->tail()) { |
| 252 Clause clause = it->head(); | 252 Clause clause = it->head(); |
| 253 expr = ResultExpr( | 253 expr = ResultExpr( |
| 254 new const IfThenResultExprImpl(clause.first, clause.second, expr)); | 254 new const IfThenResultExprImpl(clause.first, clause.second, expr)); |
| 255 } | 255 } |
| 256 return expr; | 256 return expr; |
| 257 } | 257 } |
| 258 | 258 |
| 259 ResultExpr SandboxBPFDSLPolicy::InvalidSyscall() const { | 259 ResultExpr SandboxBPFDSLPolicy::InvalidSyscall() const { |
| 260 return Error(ENOSYS); | 260 return Error(ENOSYS); |
| 261 } | 261 } |
| 262 | 262 |
| 263 ErrorCode SandboxBPFDSLPolicy::EvaluateSyscall(SandboxBPF* sb, | 263 ErrorCode SandboxBPFDSLPolicy::EvaluateSyscall(SandboxBPF* sb, |
| 264 int sysno) const { | 264 int sysno) const { |
| 265 return EvaluateSyscall(sysno)->Compile(sb); | 265 return EvaluateSyscall(sysno)->Compile(sb); |
| 266 } | 266 } |
| 267 | 267 |
| 268 ErrorCode SandboxBPFDSLPolicy::InvalidSyscall(SandboxBPF* sb) const { | 268 ErrorCode SandboxBPFDSLPolicy::InvalidSyscall(SandboxBPF* sb) const { |
| 269 return InvalidSyscall()->Compile(sb); | 269 return InvalidSyscall()->Compile(sb); |
| 270 } | 270 } |
| 271 | 271 |
| 272 ResultExpr SandboxBPFDSLPolicy::Trap(::sandbox::Trap::TrapFnc trap_func, | 272 ResultExpr SandboxBPFDSLPolicy::Trap(::sandbox::Trap::TrapFnc trap_func, |
| 273 void* aux) { | 273 void* aux) { |
| 274 return bpf_dsl::Trap(trap_func, aux); | 274 return bpf_dsl::Trap(trap_func, aux); |
| 275 } | 275 } |
| 276 | 276 |
| 277 } // namespace bpf_dsl | 277 } // namespace bpf_dsl |
| 278 } // namespace sandbox | 278 } // namespace sandbox |
| OLD | NEW |