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

Side by Side Diff: content/browser/blob_storage/blob_dispatcher_host.cc

Issue 2214293002: [BlobStorage] Added back security policy for files in blobs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/browser/blob_storage/blob_dispatcher_host.h" 5 #include "content/browser/blob_storage/blob_dispatcher_host.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
11 #include "content/browser/bad_message.h" 11 #include "content/browser/bad_message.h"
12 #include "content/browser/blob_storage/chrome_blob_storage_context.h" 12 #include "content/browser/blob_storage/chrome_blob_storage_context.h"
13 #include "content/browser/child_process_security_policy_impl.h"
13 #include "content/common/fileapi/webblob_messages.h" 14 #include "content/common/fileapi/webblob_messages.h"
14 #include "ipc/ipc_platform_file.h" 15 #include "ipc/ipc_platform_file.h"
15 #include "storage/browser/blob/blob_storage_context.h" 16 #include "storage/browser/blob/blob_storage_context.h"
16 #include "storage/browser/blob/blob_transport_result.h" 17 #include "storage/browser/blob/blob_transport_result.h"
17 #include "storage/common/blob_storage/blob_item_bytes_request.h" 18 #include "storage/common/blob_storage/blob_item_bytes_request.h"
18 #include "storage/common/blob_storage/blob_item_bytes_response.h" 19 #include "storage/common/blob_storage/blob_item_bytes_response.h"
19 #include "storage/common/data_element.h" 20 #include "storage/common/data_element.h"
20 #include "url/gurl.h" 21 #include "url/gurl.h"
21 22
22 using storage::BlobStorageContext; 23 using storage::BlobStorageContext;
23 using storage::BlobStorageRegistry; 24 using storage::BlobStorageRegistry;
24 using storage::BlobTransportResult; 25 using storage::BlobTransportResult;
26 using storage::DataElement;
25 using storage::IPCBlobCreationCancelCode; 27 using storage::IPCBlobCreationCancelCode;
26 28
27 namespace content { 29 namespace content {
28 namespace { 30 namespace {
29 31
30 // These are used for UMA stats, don't change. 32 // These are used for UMA stats, don't change.
31 enum RefcountOperation { 33 enum RefcountOperation {
32 BDH_DECREMENT = 0, 34 BDH_DECREMENT = 0,
33 BDH_INCREMENT, 35 BDH_INCREMENT,
34 BDH_TRACING_ENUM_LAST 36 BDH_TRACING_ENUM_LAST
35 }; 37 };
36 38
37 } // namespace 39 } // namespace
38 40
39 BlobDispatcherHost::BlobDispatcherHost( 41 BlobDispatcherHost::BlobDispatcherHost(int process_id,
40 ChromeBlobStorageContext* blob_storage_context) 42 ChromeBlobStorageContext* blob_storage_context)
41 : BrowserMessageFilter(BlobMsgStart), 43 : BrowserMessageFilter(BlobMsgStart),
44 process_id_(process_id),
45 security_policy_(ChildProcessSecurityPolicyImpl::GetInstance()),
42 blob_storage_context_(blob_storage_context) {} 46 blob_storage_context_(blob_storage_context) {}
43 47
44 BlobDispatcherHost::~BlobDispatcherHost() { 48 BlobDispatcherHost::~BlobDispatcherHost() {
45 ClearHostFromBlobStorageContext(); 49 ClearHostFromBlobStorageContext();
46 } 50 }
47 51
48 void BlobDispatcherHost::OnChannelClosing() { 52 void BlobDispatcherHost::OnChannelClosing() {
49 ClearHostFromBlobStorageContext(); 53 ClearHostFromBlobStorageContext();
50 public_blob_urls_.clear(); 54 public_blob_urls_.clear();
51 blobs_inuse_map_.clear(); 55 blobs_inuse_map_.clear();
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 context); 133 context);
130 Send(new BlobStorageMsg_CancelBuildingBlob( 134 Send(new BlobStorageMsg_CancelBuildingBlob(
131 uuid, IPCBlobCreationCancelCode::BLOB_DEREFERENCED_WHILE_BUILDING)); 135 uuid, IPCBlobCreationCancelCode::BLOB_DEREFERENCED_WHILE_BUILDING));
132 } 136 }
133 return; 137 return;
134 } 138 }
135 if (!async_builder_.IsBeingBuilt(uuid)) { 139 if (!async_builder_.IsBeingBuilt(uuid)) {
136 SendIPCResponse(uuid, BlobTransportResult::BAD_IPC); 140 SendIPCResponse(uuid, BlobTransportResult::BAD_IPC);
137 return; 141 return;
138 } 142 }
143
144 for (const DataElement& item : descriptions) {
145 if (item.type() == storage::DataElement::TYPE_FILE &&
146 !security_policy_->CanReadFile(process_id_, item.path())) {
kinuko 2016/08/05 00:39:36 I think we used to have the same / similar check f
dmurph 2016/08/05 01:15:51 Oops! Yep, done, added.
147 async_builder_.CancelBuildingBlob(
148 uuid, IPCBlobCreationCancelCode::FILE_WRITE_FAILED, context);
149 Send(new BlobStorageMsg_CancelBuildingBlob(
150 uuid, IPCBlobCreationCancelCode::FILE_WRITE_FAILED));
151 return;
152 }
153 }
154
139 // |this| owns async_builder_ so using base::Unretained(this) is safe. 155 // |this| owns async_builder_ so using base::Unretained(this) is safe.
140 BlobTransportResult result = async_builder_.StartBuildingBlob( 156 BlobTransportResult result = async_builder_.StartBuildingBlob(
141 uuid, descriptions, context->memory_available(), context, 157 uuid, descriptions, context->memory_available(), context,
142 base::Bind(&BlobDispatcherHost::SendMemoryRequest, base::Unretained(this), 158 base::Bind(&BlobDispatcherHost::SendMemoryRequest, base::Unretained(this),
143 uuid)); 159 uuid));
144 SendIPCResponse(uuid, result); 160 SendIPCResponse(uuid, result);
145 } 161 }
146 162
147 void BlobDispatcherHost::OnMemoryItemResponse( 163 void BlobDispatcherHost::OnMemoryItemResponse(
148 const std::string& uuid, 164 const std::string& uuid,
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 context->RevokePublicBlobURL(url); 377 context->RevokePublicBlobURL(url);
362 } 378 }
363 for (const auto& uuid_refnum_pair : blobs_inuse_map_) { 379 for (const auto& uuid_refnum_pair : blobs_inuse_map_) {
364 for (int i = 0; i < uuid_refnum_pair.second; ++i) 380 for (int i = 0; i < uuid_refnum_pair.second; ++i)
365 context->DecrementBlobRefCount(uuid_refnum_pair.first); 381 context->DecrementBlobRefCount(uuid_refnum_pair.first);
366 } 382 }
367 async_builder_.CancelAll(context); 383 async_builder_.CancelAll(context);
368 } 384 }
369 385
370 } // namespace content 386 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/blob_storage/blob_dispatcher_host.h ('k') | content/browser/blob_storage/blob_dispatcher_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698