From cee64fd3e5383a388b58d570c5d16d95de30f1be Mon Sep 17 00:00:00 2001 From: "zelidrag@chromium.org" Date: Mon, 2 May 2011 18:59:07 +0000 Subject: blob_storage_controller.cc assert from this bug was caused by the fact that worker thread actually run in a different renderer process from the main page JS thread. chrome.fileBrowserPrivate.* methods grant access to files through ChildProcessSecurityPolicy class, but such file permissions would end up associated with renderer process of the main thread only. When worker tries to register blobs representing such files, ChildProcessSecurityPolicy check would reject it since its client process id has nothing to do with main renderer's id. This CL adds mapping between worker and main renderer processes and uses that to ensure that worker thread renderer process file permissions are "inherited" from its main JS thread renderer child process. BUG=chromium-os:14680 TEST=added extra tests to ChildProcessSecurityPolicyTest.FilePermissions Review URL: http://codereview.chromium.org/6893145 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@83754 0039d316-1c4b-4281-b951-d872f2087c98 --- .../child_process_security_policy_unittest.cc | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'content/browser/child_process_security_policy_unittest.cc') diff --git a/content/browser/child_process_security_policy_unittest.cc b/content/browser/child_process_security_policy_unittest.cc index 53799b7..0ee30f8 100644 --- a/content/browser/child_process_security_policy_unittest.cc +++ b/content/browser/child_process_security_policy_unittest.cc @@ -27,6 +27,7 @@ class ChildProcessSecurityPolicyTest : public testing::Test { }; static int kRendererID = 42; +static int kWorkerRendererID = kRendererID + 1; TEST_F(ChildProcessSecurityPolicyTest, IsWebSafeSchemeTest) { ChildProcessSecurityPolicy* p = ChildProcessSecurityPolicy::GetInstance(); @@ -349,6 +350,28 @@ TEST_F(ChildProcessSecurityPolicyTest, FilePermissions) { EXPECT_FALSE(p->HasPermissionsForFile(kRendererID, file, base::PLATFORM_FILE_TEMPORARY)); p->Remove(kRendererID); + + // Grant file permissions for the file to main thread renderer process, + // make sure its worker thread renderer process inherits those. + p->Add(kRendererID); + p->GrantPermissionsForFile(kRendererID, file, base::PLATFORM_FILE_OPEN | + base::PLATFORM_FILE_READ); + EXPECT_TRUE(p->HasPermissionsForFile(kRendererID, file, + base::PLATFORM_FILE_OPEN | + base::PLATFORM_FILE_READ)); + EXPECT_FALSE(p->HasPermissionsForFile(kRendererID, file, + base::PLATFORM_FILE_WRITE)); + p->AddWorker(kWorkerRendererID, kRendererID); + EXPECT_TRUE(p->HasPermissionsForFile(kWorkerRendererID, file, + base::PLATFORM_FILE_OPEN | + base::PLATFORM_FILE_READ)); + EXPECT_FALSE(p->HasPermissionsForFile(kWorkerRendererID, file, + base::PLATFORM_FILE_WRITE)); + p->Remove(kRendererID); + EXPECT_FALSE(p->HasPermissionsForFile(kWorkerRendererID, file, + base::PLATFORM_FILE_OPEN | + base::PLATFORM_FILE_READ)); + p->Remove(kWorkerRendererID); } TEST_F(ChildProcessSecurityPolicyTest, CanServiceWebUIBindings) { -- cgit v1.1