Upstream version 11.40.277.0
[platform/framework/web/crosswalk.git] / src / content / common / sandbox_linux / sandbox_bpf_base_policy_linux.cc
1 // Copyright 2013 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 #include "content/common/sandbox_linux/sandbox_bpf_base_policy_linux.h"
6
7 #include <errno.h>
8
9 #include "base/logging.h"
10 #include "sandbox/linux/bpf_dsl/bpf_dsl.h"
11 #include "sandbox/linux/seccomp-bpf-helpers/baseline_policy.h"
12
13 using sandbox::bpf_dsl::ResultExpr;
14
15 namespace content {
16
17 namespace {
18
19 // The errno used for denied file system access system calls, such as open(2).
20 static const int kFSDeniedErrno = EPERM;
21
22 }  // namespace.
23
24 SandboxBPFBasePolicy::SandboxBPFBasePolicy()
25     : baseline_policy_(new sandbox::BaselinePolicy(kFSDeniedErrno)) {}
26 SandboxBPFBasePolicy::~SandboxBPFBasePolicy() {}
27
28 ResultExpr SandboxBPFBasePolicy::EvaluateSyscall(int system_call_number) const {
29   DCHECK(baseline_policy_);
30   return baseline_policy_->EvaluateSyscall(system_call_number);
31 }
32
33 ResultExpr SandboxBPFBasePolicy::InvalidSyscall() const {
34   DCHECK(baseline_policy_);
35   return baseline_policy_->InvalidSyscall();
36 }
37
38 bool SandboxBPFBasePolicy::PreSandboxHook() {
39   return true;
40 }
41
42 int SandboxBPFBasePolicy::GetFSDeniedErrno() {
43   return kFSDeniedErrno;
44 }
45
46 }  // namespace content.