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

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

Issue 935743003: bpf_dsl: move Verifier into PolicyCompiler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Respond to jln feedback Created 5 years, 10 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.cc ('k') | sandbox/linux/seccomp-bpf/verifier.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef SANDBOX_LINUX_SECCOMP_BPF_VERIFIER_H__
6 #define SANDBOX_LINUX_SECCOMP_BPF_VERIFIER_H__
7
8 #include <stdint.h>
9
10 #include <vector>
11
12 #include "base/macros.h"
13 #include "sandbox/sandbox_export.h"
14
15 struct sock_filter;
16
17 namespace sandbox {
18 struct arch_seccomp_data;
19 namespace bpf_dsl {
20 class Policy;
21 class PolicyCompiler;
22 }
23
24 class SANDBOX_EXPORT Verifier {
25 public:
26 // Evaluate the BPF program for all possible inputs and verify that it
27 // computes the correct result. We use the "evaluators" to determine
28 // the full set of possible inputs that we have to iterate over.
29 // Returns success, if the BPF filter accurately reflects the rules
30 // set by the "evaluators".
31 // Upon success, "err" is set to NULL. Upon failure, it contains a static
32 // error message that does not need to be free()'d.
33 static bool VerifyBPF(bpf_dsl::PolicyCompiler* compiler,
34 const std::vector<struct sock_filter>& program,
35 const bpf_dsl::Policy& policy,
36 const char** err);
37
38 // Evaluate a given BPF program for a particular set of system call
39 // parameters. If evaluation failed for any reason, "err" will be set to
40 // a non-NULL error string. Otherwise, the BPF program's result will be
41 // returned by the function and "err" is NULL.
42 // We do not actually implement the full BPF state machine, but only the
43 // parts that can actually be generated by our BPF compiler. If this code
44 // is used for purposes other than verifying the output of the sandbox's
45 // BPF compiler, we might have to extend this BPF interpreter.
46 static uint32_t EvaluateBPF(const std::vector<struct sock_filter>& program,
47 const struct arch_seccomp_data& data,
48 const char** err);
49
50 private:
51 DISALLOW_IMPLICIT_CONSTRUCTORS(Verifier);
52 };
53
54 } // namespace sandbox
55
56 #endif // SANDBOX_LINUX_SECCOMP_BPF_VERIFIER_H__
OLDNEW
« no previous file with comments | « sandbox/linux/seccomp-bpf/sandbox_bpf.cc ('k') | sandbox/linux/seccomp-bpf/verifier.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698