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

Side by Side Diff: content/browser/loader/resource_dispatcher_host_impl.cc

Issue 2442793002: Extra browser-side validation of transferred_request_child_id / request_id. (Closed)
Patch Set: Fixing incorrect conflict resolution in content/browser/bad_message.h Created 4 years, 1 month 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 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc e-loading 5 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc e-loading
6 6
7 #include "content/browser/loader/resource_dispatcher_host_impl.h" 7 #include "content/browser/loader/resource_dispatcher_host_impl.h"
8 8
9 #include <stddef.h> 9 #include <stddef.h>
10 10
(...skipping 1177 matching lines...) Expand 10 before | Expand all | Expand 10 after
1188 if (!handler->SanityCheckIsSameContext(filter_->service_worker_context())) { 1188 if (!handler->SanityCheckIsSameContext(filter_->service_worker_context())) {
1189 bad_message::ReceivedBadMessage( 1189 bad_message::ReceivedBadMessage(
1190 filter_, bad_message::RDHI_WRONG_STORAGE_PARTITION); 1190 filter_, bad_message::RDHI_WRONG_STORAGE_PARTITION);
1191 } else { 1191 } else {
1192 handler->CompleteCrossSiteTransfer( 1192 handler->CompleteCrossSiteTransfer(
1193 child_id, request_data.service_worker_provider_id); 1193 child_id, request_data.service_worker_provider_id);
1194 } 1194 }
1195 } 1195 }
1196 } 1196 }
1197 1197
1198 void ResourceDispatcherHostImpl::CompleteTransfer(
1199 int request_id,
1200 const ResourceRequest& request_data,
1201 int route_id) {
1202 // Caller should ensure that |request_data| is associated with a transfer.
1203 DCHECK(request_data.transferred_request_child_id != -1 ||
1204 request_data.transferred_request_request_id != -1);
1205
1206 bool is_navigational_request =
1207 request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME ||
1208 request_data.resource_type == RESOURCE_TYPE_SUB_FRAME;
1209 if (!is_navigational_request) {
1210 // Transfers apply only to navigational requests - the renderer seems to
1211 // have sent bogus IPC data.
1212 bad_message::ReceivedBadMessage(
1213 filter_, bad_message::RDH_TRANSFERRING_NONNAVIGATIONAL_REQUEST);
1214 return;
1215 }
1216
1217 // Attempt to find a loader associated with the deferred transfer request.
1218 LoaderMap::iterator it = pending_loaders_.find(
1219 GlobalRequestID(request_data.transferred_request_child_id,
1220 request_data.transferred_request_request_id));
1221 if (it == pending_loaders_.end()) {
1222 // Renderer sent transferred_request_request_id and/or
1223 // transferred_request_child_id that doesn't have a corresponding entry on
1224 // the browser side.
1225 bad_message::ReceivedBadMessage(
1226 filter_, bad_message::RDH_TRANSFERRING_REQUEST_NOT_FOUND);
1227 return;
1228 }
1229 ResourceLoader* pending_loader = it->second.get();
1230
1231 if (!pending_loader->is_transferring()) {
1232 // Renderer sent transferred_request_request_id and/or
1233 // transferred_request_child_id that doesn't correspond to an actually
1234 // transferring loader on the browser side.
1235 base::debug::Alias(pending_loader);
1236 bad_message::ReceivedBadMessage(filter_,
1237 bad_message::RDH_REQUEST_NOT_TRANSFERRING);
1238 return;
1239 }
mmenke 2016/10/25 20:23:47 Random drive-by question: How concerned are we ab
Charlie Reis 2016/10/25 20:30:07 Yes, good point. Łukasz was asking about this the
1240
1241 // If the request is transferring to a new process, we can update our
1242 // state and let it resume with its existing ResourceHandlers.
1243 UpdateRequestForTransfer(filter_->child_id(), route_id, request_id,
1244 request_data, it);
1245 pending_loader->CompleteTransfer();
1246 }
1247
1198 void ResourceDispatcherHostImpl::BeginRequest( 1248 void ResourceDispatcherHostImpl::BeginRequest(
1199 int request_id, 1249 int request_id,
1200 const ResourceRequest& request_data, 1250 const ResourceRequest& request_data,
1201 const SyncLoadResultCallback& sync_result_handler, // only valid for sync 1251 const SyncLoadResultCallback& sync_result_handler, // only valid for sync
1202 int route_id, 1252 int route_id,
1203 mojo::InterfaceRequest<mojom::URLLoader> mojo_request, 1253 mojo::InterfaceRequest<mojom::URLLoader> mojo_request,
1204 mojom::URLLoaderClientPtr url_loader_client) { 1254 mojom::URLLoaderClientPtr url_loader_client) {
1205 int process_type = filter_->process_type(); 1255 int process_type = filter_->process_type();
1206 int child_id = filter_->child_id(); 1256 int child_id = filter_->child_id();
1207 1257
(...skipping 24 matching lines...) Expand all
1232 } 1282 }
1233 1283
1234 // If we crash here, figure out what URL the renderer was requesting. 1284 // If we crash here, figure out what URL the renderer was requesting.
1235 // http://crbug.com/91398 1285 // http://crbug.com/91398
1236 char url_buf[128]; 1286 char url_buf[128];
1237 base::strlcpy(url_buf, request_data.url.spec().c_str(), arraysize(url_buf)); 1287 base::strlcpy(url_buf, request_data.url.spec().c_str(), arraysize(url_buf));
1238 base::debug::Alias(url_buf); 1288 base::debug::Alias(url_buf);
1239 1289
1240 // If the request that's coming in is being transferred from another process, 1290 // If the request that's coming in is being transferred from another process,
1241 // we want to reuse and resume the old loader rather than start a new one. 1291 // we want to reuse and resume the old loader rather than start a new one.
1242 LoaderMap::iterator it = pending_loaders_.find( 1292 if (request_data.transferred_request_child_id != -1 ||
1243 GlobalRequestID(request_data.transferred_request_child_id, 1293 request_data.transferred_request_request_id != -1) {
1244 request_data.transferred_request_request_id));
1245 if (it != pending_loaders_.end()) {
1246 // TODO(yhirano): Make mojo work for this case. 1294 // TODO(yhirano): Make mojo work for this case.
1247 DCHECK(!url_loader_client); 1295 DCHECK(!url_loader_client);
1248 1296
1249 // If the request is transferring to a new process, we can update our 1297 CompleteTransfer(request_id, request_data, route_id);
1250 // state and let it resume with its existing ResourceHandlers.
1251 if (it->second->is_transferring()) {
1252 ResourceLoader* deferred_loader = it->second.get();
1253 UpdateRequestForTransfer(child_id, route_id, request_id,
1254 request_data, it);
1255 deferred_loader->CompleteTransfer();
1256 } else {
1257 bad_message::ReceivedBadMessage(
1258 filter_, bad_message::RDH_REQUEST_NOT_TRANSFERRING);
1259 }
1260 return; 1298 return;
1261 } 1299 }
1262 1300
1263 ResourceContext* resource_context = NULL; 1301 ResourceContext* resource_context = NULL;
1264 net::URLRequestContext* request_context = NULL; 1302 net::URLRequestContext* request_context = NULL;
1265 filter_->GetContexts(request_data.resource_type, &resource_context, 1303 filter_->GetContexts(request_data.resource_type, &resource_context,
1266 &request_context); 1304 &request_context);
1267 1305
1268 // Parse the headers before calling ShouldServiceRequest, so that they are 1306 // Parse the headers before calling ShouldServiceRequest, so that they are
1269 // available to be validated. 1307 // available to be validated.
(...skipping 1469 matching lines...) Expand 10 before | Expand all | Expand 10 after
2739 &throttles); 2777 &throttles);
2740 if (!throttles.empty()) { 2778 if (!throttles.empty()) {
2741 handler.reset(new ThrottlingResourceHandler(std::move(handler), request, 2779 handler.reset(new ThrottlingResourceHandler(std::move(handler), request,
2742 std::move(throttles))); 2780 std::move(throttles)));
2743 } 2781 }
2744 } 2782 }
2745 return handler; 2783 return handler;
2746 } 2784 }
2747 2785
2748 } // namespace content 2786 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader/resource_dispatcher_host_impl.h ('k') | content/renderer/render_frame_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698