• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_BPF_DSL_VERIFIER_H__
6 #define SANDBOX_LINUX_BPF_DSL_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 
20 namespace bpf_dsl {
21 
22 // TODO(mdempsky): This class doesn't perform any verification any more, so it
23 // deserves a new name.
24 class SANDBOX_EXPORT Verifier {
25  public:
26   // Evaluate a given BPF program for a particular set of system call
27   // parameters. If evaluation failed for any reason, "err" will be set to
28   // a non-NULL error string. Otherwise, the BPF program's result will be
29   // returned by the function and "err" is NULL.
30   // We do not actually implement the full BPF state machine, but only the
31   // parts that can actually be generated by our BPF compiler. If this code
32   // is used for purposes other than verifying the output of the sandbox's
33   // BPF compiler, we might have to extend this BPF interpreter.
34   static uint32_t EvaluateBPF(const std::vector<struct sock_filter>& program,
35                               const struct arch_seccomp_data& data,
36                               const char** err);
37 
38  private:
39   DISALLOW_IMPLICIT_CONSTRUCTORS(Verifier);
40 };
41 
42 }  // namespace bpf_dsl
43 }  // namespace sandbox
44 
45 #endif  // SANDBOX_LINUX_BPF_DSL_VERIFIER_H__
46