Chromium Code Reviews| 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 122 #endif | 122 #endif |
| 123 case __NR_sysinfo: // https://crbug.com/655277 | 123 case __NR_sysinfo: // https://crbug.com/655277 |
| 124 case __NR_uname: | 124 case __NR_uname: |
| 125 | 125 |
| 126 // Permit socket operations so that renderers can connect to logd and | 126 // Permit socket operations so that renderers can connect to logd and |
| 127 // debuggerd. The arguments to socket() are further restricted below. | 127 // debuggerd. The arguments to socket() are further restricted below. |
| 128 // Note that on i386, both of these calls map to __NR_socketcall, which | 128 // Note that on i386, both of these calls map to __NR_socketcall, which |
| 129 // is demultiplexed below. | 129 // is demultiplexed below. |
| 130 #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \ | 130 #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \ |
| 131 defined(__mips__) | 131 defined(__mips__) |
| 132 case __NR_getsockopt: | 132 case __NR_getsockopt: |
|
Robert Sesek
2017/02/03 10:58:50
This was the regression.
| |
| 133 case __NR_connect: | 133 case __NR_connect: |
| 134 case __NR_socket: | 134 case __NR_socket: |
| 135 #endif | 135 #endif |
| 136 | 136 |
| 137 // Ptrace is allowed so the Breakpad Microdumper can fork in a renderer | 137 // Ptrace is allowed so the Breakpad Microdumper can fork in a renderer |
| 138 // and then ptrace the parent. | 138 // and then ptrace the parent. |
| 139 case __NR_ptrace: | 139 case __NR_ptrace: |
| 140 override_and_allow = true; | 140 override_and_allow = true; |
| 141 break; | 141 break; |
| 142 } | 142 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 174 } | 174 } |
| 175 | 175 |
| 176 // https://crbug.com/655300 | 176 // https://crbug.com/655300 |
| 177 if (sysno == __NR_getsockname) { | 177 if (sysno == __NR_getsockname) { |
| 178 // Rather than blocking with SIGSYS, just return an error. This is not | 178 // Rather than blocking with SIGSYS, just return an error. This is not |
| 179 // documented to be a valid errno, but we will use it anyways. | 179 // documented to be a valid errno, but we will use it anyways. |
| 180 return Error(EPERM); | 180 return Error(EPERM); |
| 181 } | 181 } |
| 182 | 182 |
| 183 // https://crbug.com/682488 | 183 // https://crbug.com/682488 |
| 184 if (sysno == __NR_getsockopt || sysno == __NR_setsockopt) { | 184 if (sysno == __NR_setsockopt) { |
| 185 // The baseline policy applies other restrictions to these syscalls. | 185 // The baseline policy applies other restrictions to setsockopt. |
| 186 const Arg<int> level(1); | 186 const Arg<int> level(1); |
| 187 const Arg<int> option(2); | 187 const Arg<int> option(2); |
| 188 return If(AllOf(level == SOL_SOCKET, option == SO_SNDTIMEO), Allow()) | 188 return If(AllOf(level == SOL_SOCKET, option == SO_SNDTIMEO), Allow()) |
| 189 .Else(SandboxBPFBasePolicy::EvaluateSyscall(sysno)); | 189 .Else(SandboxBPFBasePolicy::EvaluateSyscall(sysno)); |
| 190 } | 190 } |
| 191 #elif defined(__i386__) | 191 #elif defined(__i386__) |
| 192 if (sysno == __NR_socketcall) { | 192 if (sysno == __NR_socketcall) { |
| 193 // The baseline policy allows other socketcall sub-calls. | 193 // The baseline policy allows other socketcall sub-calls. |
| 194 const Arg<int> socketcall(0); | 194 const Arg<int> socketcall(0); |
| 195 return Switch(socketcall) | 195 return Switch(socketcall) |
| 196 .CASES((SYS_CONNECT, | 196 .CASES((SYS_CONNECT, |
| 197 SYS_SOCKET, | 197 SYS_SOCKET, |
| 198 SYS_SETSOCKOPT, | 198 SYS_SETSOCKOPT, |
| 199 SYS_GETSOCKOPT), | 199 SYS_GETSOCKOPT), |
| 200 Allow()) | 200 Allow()) |
| 201 .Default(SandboxBPFBasePolicy::EvaluateSyscall(sysno)); | 201 .Default(SandboxBPFBasePolicy::EvaluateSyscall(sysno)); |
| 202 } | 202 } |
| 203 #endif | 203 #endif |
| 204 | 204 |
| 205 if (override_and_allow) | 205 if (override_and_allow) |
| 206 return Allow(); | 206 return Allow(); |
| 207 | 207 |
| 208 return SandboxBPFBasePolicy::EvaluateSyscall(sysno); | 208 return SandboxBPFBasePolicy::EvaluateSyscall(sysno); |
| 209 } | 209 } |
| 210 | 210 |
| 211 } // namespace content | 211 } // namespace content |
| OLD | NEW |