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 "content/common/sandbox_linux/android/sandbox_bpf_base_policy_android.h
" | 5 #include "content/common/sandbox_linux/android/sandbox_bpf_base_policy_android.h
" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <linux/net.h> | 9 #include <linux/net.h> |
10 #include <sys/socket.h> | 10 #include <sys/socket.h> |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 const int kSockFlags = SOCK_CLOEXEC | SOCK_NONBLOCK; | 43 const int kSockFlags = SOCK_CLOEXEC | SOCK_NONBLOCK; |
44 return AllOf(domain == AF_UNIX, | 44 return AllOf(domain == AF_UNIX, |
45 AnyOf((type & ~kSockFlags) == SOCK_DGRAM, | 45 AnyOf((type & ~kSockFlags) == SOCK_DGRAM, |
46 (type & ~kSockFlags) == SOCK_STREAM), | 46 (type & ~kSockFlags) == SOCK_STREAM), |
47 protocol == 0); | 47 protocol == 0); |
48 } | 48 } |
49 | 49 |
50 } // namespace | 50 } // namespace |
51 | 51 |
52 SandboxBPFBasePolicyAndroid::SandboxBPFBasePolicyAndroid() | 52 SandboxBPFBasePolicyAndroid::SandboxBPFBasePolicyAndroid() |
53 : SandboxBPFBasePolicy() {} | 53 : SandboxBPFBasePolicy(), |
| 54 pid_(getpid()) {} |
54 | 55 |
55 SandboxBPFBasePolicyAndroid::~SandboxBPFBasePolicyAndroid() {} | 56 SandboxBPFBasePolicyAndroid::~SandboxBPFBasePolicyAndroid() {} |
56 | 57 |
57 ResultExpr SandboxBPFBasePolicyAndroid::EvaluateSyscall(int sysno) const { | 58 ResultExpr SandboxBPFBasePolicyAndroid::EvaluateSyscall(int sysno) const { |
58 bool override_and_allow = false; | 59 bool override_and_allow = false; |
59 | 60 |
60 switch (sysno) { | 61 switch (sysno) { |
61 // TODO(rsesek): restrict clone parameters. | 62 // TODO(rsesek): restrict clone parameters. |
62 case __NR_clone: | 63 case __NR_clone: |
63 case __NR_epoll_pwait: | 64 case __NR_epoll_pwait: |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 case __NR_socket: | 116 case __NR_socket: |
116 #endif | 117 #endif |
117 | 118 |
118 // Ptrace is allowed so the Breakpad Microdumper can fork in a renderer | 119 // Ptrace is allowed so the Breakpad Microdumper can fork in a renderer |
119 // and then ptrace the parent. | 120 // and then ptrace the parent. |
120 case __NR_ptrace: | 121 case __NR_ptrace: |
121 override_and_allow = true; | 122 override_and_allow = true; |
122 break; | 123 break; |
123 } | 124 } |
124 | 125 |
| 126 // https://crbug.com/644759 |
| 127 if (sysno == __NR_rt_tgsigqueueinfo) { |
| 128 const Arg<pid_t> tgid(0); |
| 129 return If(tgid == pid_, Allow()) |
| 130 .Else(Error(EPERM)); |
| 131 } |
| 132 |
125 #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \ | 133 #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \ |
126 defined(__mips__) | 134 defined(__mips__) |
127 if (sysno == __NR_socket) { | 135 if (sysno == __NR_socket) { |
128 const Arg<int> domain(0); | 136 const Arg<int> domain(0); |
129 const Arg<int> type(1); | 137 const Arg<int> type(1); |
130 const Arg<int> protocol(2); | 138 const Arg<int> protocol(2); |
131 return If(RestrictSocketArguments(domain, type, protocol), Allow()) | 139 return If(RestrictSocketArguments(domain, type, protocol), Allow()) |
132 .Else(Error(EPERM)); | 140 .Else(Error(EPERM)); |
133 } | 141 } |
134 #elif defined(__i386__) | 142 #elif defined(__i386__) |
(...skipping 11 matching lines...) Expand all Loading... |
146 } | 154 } |
147 #endif | 155 #endif |
148 | 156 |
149 if (override_and_allow) | 157 if (override_and_allow) |
150 return Allow(); | 158 return Allow(); |
151 | 159 |
152 return SandboxBPFBasePolicy::EvaluateSyscall(sysno); | 160 return SandboxBPFBasePolicy::EvaluateSyscall(sysno); |
153 } | 161 } |
154 | 162 |
155 } // namespace content | 163 } // namespace content |
OLD | NEW |