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

Side by Side Diff: content/browser/child_process_security_policy_impl.h

Issue 2831683002: Introduce support for origins that require process isolation. (Closed)
Patch Set: Rebase Created 3 years, 7 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 #ifndef CONTENT_BROWSER_CHILD_PROCESS_SECURITY_POLICY_IMPL_H_ 5 #ifndef CONTENT_BROWSER_CHILD_PROCESS_SECURITY_POLICY_IMPL_H_
6 #define CONTENT_BROWSER_CHILD_PROCESS_SECURITY_POLICY_IMPL_H_ 6 #define CONTENT_BROWSER_CHILD_PROCESS_SECURITY_POLICY_IMPL_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <set> 10 #include <set>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
15 #include "base/gtest_prod_util.h" 15 #include "base/gtest_prod_util.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/singleton.h" 17 #include "base/memory/singleton.h"
18 #include "base/synchronization/lock.h" 18 #include "base/synchronization/lock.h"
19 #include "content/public/browser/child_process_security_policy.h" 19 #include "content/public/browser/child_process_security_policy.h"
20 #include "content/public/common/resource_type.h" 20 #include "content/public/common/resource_type.h"
21 #include "storage/common/fileapi/file_system_types.h" 21 #include "storage/common/fileapi/file_system_types.h"
22 #include "url/origin.h"
22 23
23 class GURL; 24 class GURL;
24 25
25 namespace base { 26 namespace base {
26 class FilePath; 27 class FilePath;
27 } 28 }
28 29
29 namespace storage { 30 namespace storage {
30 class FileSystemURL; 31 class FileSystemURL;
31 } 32 }
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 164
164 // Register FileSystem type and permission policy which should be used 165 // Register FileSystem type and permission policy which should be used
165 // for the type. The |policy| must be a bitwise-or'd value of 166 // for the type. The |policy| must be a bitwise-or'd value of
166 // storage::FilePermissionPolicy. 167 // storage::FilePermissionPolicy.
167 void RegisterFileSystemPermissionPolicy(storage::FileSystemType type, 168 void RegisterFileSystemPermissionPolicy(storage::FileSystemType type,
168 int policy); 169 int policy);
169 170
170 // Returns true if sending system exclusive messages is allowed. 171 // Returns true if sending system exclusive messages is allowed.
171 bool CanSendMidiSysExMessage(int child_id); 172 bool CanSendMidiSysExMessage(int child_id);
172 173
174 // Add an origin to the list of origins that require process isolation.
175 // When making process model decisions for such origins, the full
176 // scheme+host+port tuple rather than scheme and eTLD+1 will be used.
177 // SiteInstances for these origins will also use the full origin as site URL.
178 //
179 // Note that |origin| must not be unique. URLs that render with
180 // unique origins, such as data: URLs, are not supported. Suborigins and
Charlie Reis 2017/05/19 00:10:18 Might clarify what you mean by suborigins, since i
alexmos 2017/05/24 00:19:56 Ah, good call - I didn't realize there might be su
181 // non-standard schemes are also not supported. Sandboxed frames (e.g.,
182 // <iframe sandbox>) *are* supported, since process placement decisions will
183 // be based on the URLs such frames navigate to, and not the origin of
184 // committed documents (which might be unique). If an isolated origin opens
185 // an about:blank popup, it will stay in the isolated origin's process.
186 // Nested URLs (filesystem: and blob:) retain process isolation behavior of
187 // their inner origin.
188 void AddIsolatedOrigin(const url::Origin& origin);
189
190 // Register a set of isolated origins as specified on the command line with
191 // the --isolate-origins flag. |origin_list| is the flag's value, which
192 // contains the list of comma-separated scheme-host-port origins. See
193 // AddIsolatedOrigin for definition of an isolated origin.
194 void AddIsolatedOriginsFromCommandLine(const std::string& origin_list);
195
196 // Helper to check whether an origin requires origin-wide process isolation.
197 bool IsIsolatedOrigin(const url::Origin& origin);
198
173 private: 199 private:
174 friend class ChildProcessSecurityPolicyInProcessBrowserTest; 200 friend class ChildProcessSecurityPolicyInProcessBrowserTest;
175 friend class ChildProcessSecurityPolicyTest; 201 friend class ChildProcessSecurityPolicyTest;
176 FRIEND_TEST_ALL_PREFIXES(ChildProcessSecurityPolicyInProcessBrowserTest, 202 FRIEND_TEST_ALL_PREFIXES(ChildProcessSecurityPolicyInProcessBrowserTest,
177 NoLeak); 203 NoLeak);
178 FRIEND_TEST_ALL_PREFIXES(ChildProcessSecurityPolicyTest, FilePermissions); 204 FRIEND_TEST_ALL_PREFIXES(ChildProcessSecurityPolicyTest, FilePermissions);
205 FRIEND_TEST_ALL_PREFIXES(ChildProcessSecurityPolicyTest,
206 IsolateOriginsFromCommandLine);
179 207
180 class SecurityState; 208 class SecurityState;
181 209
182 typedef std::set<std::string> SchemeSet; 210 typedef std::set<std::string> SchemeSet;
183 typedef std::map<int, std::unique_ptr<SecurityState>> SecurityStateMap; 211 typedef std::map<int, std::unique_ptr<SecurityState>> SecurityStateMap;
184 typedef std::map<int, int> WorkerToMainProcessMap; 212 typedef std::map<int, int> WorkerToMainProcessMap;
185 typedef std::map<storage::FileSystemType, int> FileSystemPermissionPolicyMap; 213 typedef std::map<storage::FileSystemType, int> FileSystemPermissionPolicyMap;
186 214
187 // Obtain an instance of ChildProcessSecurityPolicyImpl via GetInstance(). 215 // Obtain an instance of ChildProcessSecurityPolicyImpl via GetInstance().
188 ChildProcessSecurityPolicyImpl(); 216 ChildProcessSecurityPolicyImpl();
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 // owned by this object and are protected by |lock_|. References to them must 281 // owned by this object and are protected by |lock_|. References to them must
254 // not escape this class. 282 // not escape this class.
255 SecurityStateMap security_state_; 283 SecurityStateMap security_state_;
256 284
257 // This maps keeps the record of which js worker thread child process 285 // This maps keeps the record of which js worker thread child process
258 // corresponds to which main js thread child process. 286 // corresponds to which main js thread child process.
259 WorkerToMainProcessMap worker_map_; 287 WorkerToMainProcessMap worker_map_;
260 288
261 FileSystemPermissionPolicyMap file_system_policy_map_; 289 FileSystemPermissionPolicyMap file_system_policy_map_;
262 290
291 // Protects access to isolated_origins_. This has to be a separate lock from
292 // |lock_|, because it's possible to attempt access to isolated_origins_ via
293 // IsIsolatedOrigin() from outside ChildProcessSecurityPolicy while already
294 // holding |lock_|. A scenario where this happens is
295 // CanAccessDataForOrigin() (grabs lock_) -> SiteInstance::GetSiteForURL() ->
296 // IsIsolatedOrigin().
alexmos 2017/05/16 17:26:38 This cycle is nasty, and I'm not sure this is a go
Charlie Reis 2017/05/19 00:10:19 Ooh, this is tough. Let's find a chance to chat a
Charlie Reis 2017/05/19 16:54:07 What if we moved the GetSiteForURL call from Secur
alexmos 2017/05/24 00:19:56 Thanks for the suggestion! I went ahead and follo
297 base::Lock isolated_origins_lock_;
298
299 // Tracks origins for which the entire origin should be treated as a site
300 // when making process model decisions, rather than the origin's scheme and
301 // eTLD+1. Each of these origins requires a dedicated process. This set is
302 // protected by |isolated_origins_lock_|.
303 std::set<url::Origin> isolated_origins_;
304
263 DISALLOW_COPY_AND_ASSIGN(ChildProcessSecurityPolicyImpl); 305 DISALLOW_COPY_AND_ASSIGN(ChildProcessSecurityPolicyImpl);
264 }; 306 };
265 307
266 } // namespace content 308 } // namespace content
267 309
268 #endif // CONTENT_BROWSER_CHILD_PROCESS_SECURITY_POLICY_IMPL_H_ 310 #endif // CONTENT_BROWSER_CHILD_PROCESS_SECURITY_POLICY_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698