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

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

Issue 681713002: Update from chromium https://crrev.com/301315 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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/verifier.h ('k') | skia/BUILD.gn » ('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/verifier.h" 5 #include "sandbox/linux/seccomp-bpf/verifier.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <limits> 9 #include <limits>
10 10
11 #include "sandbox/linux/bpf_dsl/bpf_dsl.h" 11 #include "sandbox/linux/bpf_dsl/bpf_dsl.h"
12 #include "sandbox/linux/bpf_dsl/bpf_dsl_impl.h" 12 #include "sandbox/linux/bpf_dsl/bpf_dsl_impl.h"
13 #include "sandbox/linux/bpf_dsl/policy.h"
13 #include "sandbox/linux/bpf_dsl/policy_compiler.h" 14 #include "sandbox/linux/bpf_dsl/policy_compiler.h"
14 #include "sandbox/linux/seccomp-bpf/errorcode.h" 15 #include "sandbox/linux/seccomp-bpf/errorcode.h"
15 #include "sandbox/linux/seccomp-bpf/linux_seccomp.h" 16 #include "sandbox/linux/seccomp-bpf/linux_seccomp.h"
16 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h" 17 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h"
17 #include "sandbox/linux/seccomp-bpf/syscall_iterator.h" 18 #include "sandbox/linux/seccomp-bpf/syscall_iterator.h"
18 19
19 namespace sandbox { 20 namespace sandbox {
20 21
21 namespace { 22 namespace {
22 23
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 *err = "Invalid operator in arithmetic operation"; 309 *err = "Invalid operator in arithmetic operation";
309 break; 310 break;
310 } 311 }
311 } 312 }
312 } 313 }
313 314
314 } // namespace 315 } // namespace
315 316
316 bool Verifier::VerifyBPF(bpf_dsl::PolicyCompiler* compiler, 317 bool Verifier::VerifyBPF(bpf_dsl::PolicyCompiler* compiler,
317 const std::vector<struct sock_filter>& program, 318 const std::vector<struct sock_filter>& program,
318 const bpf_dsl::SandboxBPFDSLPolicy& policy, 319 const bpf_dsl::Policy& policy,
319 const char** err) { 320 const char** err) {
320 *err = NULL; 321 *err = NULL;
321 for (uint32_t sysnum : SyscallSet::All()) { 322 for (uint32_t sysnum : SyscallSet::All()) {
322 // We ideally want to iterate over the full system call range and values 323 // We ideally want to iterate over the full system call range and values
323 // just above and just below this range. This gives us the full result set 324 // just above and just below this range. This gives us the full result set
324 // of the "evaluators". 325 // of the "evaluators".
325 // On Intel systems, this can fail in a surprising way, as a cleared bit 30 326 // On Intel systems, this can fail in a surprising way, as a cleared bit 30
326 // indicates either i386 or x86-64; and a set bit 30 indicates x32. And 327 // indicates either i386 or x86-64; and a set bit 30 indicates x32. And
327 // unless we pay attention to setting this bit correctly, an early check in 328 // unless we pay attention to setting this bit correctly, an early check in
328 // our BPF program will make us fail with a misleading error code. 329 // our BPF program will make us fail with a misleading error code.
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 break; 392 break;
392 default: 393 default:
393 *err = "Unexpected instruction in BPF program"; 394 *err = "Unexpected instruction in BPF program";
394 break; 395 break;
395 } 396 }
396 } 397 }
397 return 0; 398 return 0;
398 } 399 }
399 400
400 } // namespace sandbox 401 } // namespace sandbox
OLDNEW
« no previous file with comments | « sandbox/linux/seccomp-bpf/verifier.h ('k') | skia/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698