Changeset 227789 in webkit
- Timestamp:
- Jan 30, 2018, 9:21:49 AM (7 years ago)
- Location:
- trunk/Source
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r227787 r227789 1 2018-01-30 Chris Dumez <cdumez@apple.com> 2 3 Make sure we never create a WebSWClientConnection with an invalid sessionID 4 https://bugs.webkit.org/show_bug.cgi?id=182276 5 <rdar://problem/36582633> 6 7 Reviewed by Alex Christensen. 8 9 Make sure we never create a WebSWClientConnection with an invalid sessionID as this 10 could corrupt our hash tables. 11 12 * dom/Document.cpp: 13 (WebCore::Document::privateBrowsingStateDidChange): 14 * workers/service/ServiceWorker.cpp: 15 (WebCore::ServiceWorker::postMessage): 16 * workers/service/ServiceWorkerContainer.cpp: 17 (WebCore::ServiceWorkerContainer::ready): 18 (WebCore::ServiceWorkerContainer::getRegistration): 19 (WebCore::ServiceWorkerContainer::didFinishGetRegistrationRequest): 20 (WebCore::ServiceWorkerContainer::getRegistrations): 21 (WebCore::ServiceWorkerContainer::didFinishGetRegistrationsRequest): 22 (WebCore::ServiceWorkerContainer::jobResolvedWithRegistration): 23 (WebCore::ServiceWorkerContainer::ensureSWClientConnection): 24 1 25 2018-01-30 Antti Koivisto <antti@apple.com> 2 26 -
trunk/Source/WebCore/dom/Document.cpp
r227242 r227789 4997 4997 4998 4998 #if ENABLE(SERVICE_WORKER) 4999 if (RuntimeEnabledFeatures::sharedFeatures().serviceWorkerEnabled() && m_serviceWorkerConnection) 4999 ASSERT(sessionID().isValid()); 5000 if (RuntimeEnabledFeatures::sharedFeatures().serviceWorkerEnabled() && m_serviceWorkerConnection && sessionID().isValid()) 5000 5001 setServiceWorkerConnection(&ServiceWorkerProvider::singleton().serviceWorkerConnectionForSession(sessionID())); 5001 5002 #endif -
trunk/Source/WebCore/workers/service/ServiceWorker.cpp
r227425 r227789 96 96 ExceptionOr<void> ServiceWorker::postMessage(ScriptExecutionContext& context, JSC::JSValue messageValue, Vector<JSC::Strong<JSC::JSObject>>&& transfer) 97 97 { 98 if (m_isStopped )98 if (m_isStopped || !context.sessionID().isValid()) 99 99 return Exception { InvalidStateError }; 100 100 -
trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp
r227350 r227789 87 87 m_readyPromise = std::make_unique<ReadyPromise>(); 88 88 89 auto* context = scriptExecutionContext(); 90 if (!context) 89 if (m_isStopped || !scriptExecutionContext()->sessionID().isValid()) 91 90 return *m_readyPromise; 92 91 92 auto& context = *scriptExecutionContext(); 93 93 auto contextIdentifier = this->contextIdentifier(); 94 callOnMainThread([this, connection = makeRef(ensureSWClientConnection()), topOrigin = context ->topOrigin().isolatedCopy(), clientURL = context->url().isolatedCopy(), contextIdentifier]() mutable {94 callOnMainThread([this, connection = makeRef(ensureSWClientConnection()), topOrigin = context.topOrigin().isolatedCopy(), clientURL = context.url().isolatedCopy(), contextIdentifier]() mutable { 95 95 connection->whenRegistrationReady(topOrigin, clientURL, [this, contextIdentifier](auto&& registrationData) { 96 96 ScriptExecutionContext::postTaskTo(contextIdentifier, [this, registrationData = crossThreadCopy(registrationData)](auto&) mutable { 97 if (m_isStopped )97 if (m_isStopped || !scriptExecutionContext()->sessionID().isValid()) 98 98 return; 99 99 … … 250 250 void ServiceWorkerContainer::getRegistration(const String& clientURL, Ref<DeferredPromise>&& promise) 251 251 { 252 if (m_isStopped) { 252 auto* context = scriptExecutionContext(); 253 if (m_isStopped || !context->sessionID().isValid()) { 253 254 promise->reject(Exception { InvalidStateError }); 254 255 return; 255 256 } 256 257 257 ASSERT(scriptExecutionContext()); 258 auto& context = *scriptExecutionContext(); 259 260 URL parsedURL = context.completeURL(clientURL); 261 if (!protocolHostAndPortAreEqual(parsedURL, context.url())) { 258 URL parsedURL = context->completeURL(clientURL); 259 if (!protocolHostAndPortAreEqual(parsedURL, context->url())) { 262 260 promise->reject(Exception { SecurityError, ASCIILiteral("Origin of clientURL is not client's origin") }); 263 261 return; … … 269 267 270 268 auto contextIdentifier = this->contextIdentifier(); 271 callOnMainThread([connection = makeRef(ensureSWClientConnection()), this, topOrigin = context .topOrigin().isolatedCopy(), parsedURL = parsedURL.isolatedCopy(), contextIdentifier, pendingPromiseIdentifier]() mutable {269 callOnMainThread([connection = makeRef(ensureSWClientConnection()), this, topOrigin = context->topOrigin().isolatedCopy(), parsedURL = parsedURL.isolatedCopy(), contextIdentifier, pendingPromiseIdentifier]() mutable { 272 270 connection->matchRegistration(topOrigin, parsedURL, [this, contextIdentifier, pendingPromiseIdentifier] (auto&& result) mutable { 273 271 ScriptExecutionContext::postTaskTo(contextIdentifier, [this, pendingPromiseIdentifier, result = crossThreadCopy(result)](ScriptExecutionContext&) mutable { … … 288 286 return; 289 287 290 ASSERT(!m_isStopped); 288 if (m_isStopped || !scriptExecutionContext()->sessionID().isValid()) { 289 pendingPromise->promise->reject(Exception { InvalidStateError }); 290 return; 291 } 291 292 292 293 if (!result) { … … 317 318 void ServiceWorkerContainer::getRegistrations(Ref<DeferredPromise>&& promise) 318 319 { 319 if (m_isStopped) { 320 auto* context = scriptExecutionContext(); 321 if (m_isStopped || !context->sessionID().isValid()) { 320 322 promise->reject(Exception { InvalidStateError }); 321 323 return; 322 324 } 323 324 ASSERT(scriptExecutionContext());325 auto& context = *scriptExecutionContext();326 325 327 326 uint64_t pendingPromiseIdentifier = ++m_lastPendingPromiseIdentifier; … … 330 329 331 330 auto contextIdentifier = this->contextIdentifier(); 332 auto contextURL = context .url();333 callOnMainThread([connection = makeRef(ensureSWClientConnection()), this, topOrigin = context .topOrigin().isolatedCopy(), contextURL = contextURL.isolatedCopy(), contextIdentifier, pendingPromiseIdentifier]() mutable {331 auto contextURL = context->url(); 332 callOnMainThread([connection = makeRef(ensureSWClientConnection()), this, topOrigin = context->topOrigin().isolatedCopy(), contextURL = contextURL.isolatedCopy(), contextIdentifier, pendingPromiseIdentifier]() mutable { 334 333 connection->getRegistrations(topOrigin, contextURL, [this, contextIdentifier, pendingPromiseIdentifier] (auto&& registrationDatas) mutable { 335 334 ScriptExecutionContext::postTaskTo(contextIdentifier, [this, pendingPromiseIdentifier, registrationDatas = crossThreadCopy(registrationDatas)](ScriptExecutionContext&) mutable { … … 350 349 return; 351 350 352 ASSERT(!m_isStopped); 351 if (m_isStopped || !scriptExecutionContext()->sessionID().isValid()) { 352 pendingPromise->promise->reject(Exception { InvalidStateError }); 353 return; 354 } 353 355 354 356 auto registrations = WTF::map(WTFMove(registrationDatas), [&] (auto&& registrationData) { … … 435 437 436 438 scriptExecutionContext()->postTask([this, protectedThis = makeRef(*this), job = makeRef(job), data = WTFMove(data), notifyWhenResolvedIfNeeded = WTFMove(notifyWhenResolvedIfNeeded)](ScriptExecutionContext& context) mutable { 437 if (isStopped() ) {439 if (isStopped() || !context.sessionID().isValid()) { 438 440 notifyWhenResolvedIfNeeded(); 439 441 return; … … 556 558 SWClientConnection& ServiceWorkerContainer::ensureSWClientConnection() 557 559 { 560 ASSERT(scriptExecutionContext()); 561 ASSERT(scriptExecutionContext()->sessionID().isValid()); 558 562 if (!m_swConnection) { 559 563 ASSERT(scriptExecutionContext()); -
trunk/Source/WebKit/ChangeLog
r227778 r227789 1 2018-01-30 Chris Dumez <cdumez@apple.com> 2 3 Make sure we never create a WebSWClientConnection with an invalid sessionID 4 https://bugs.webkit.org/show_bug.cgi?id=182276 5 <rdar://problem/36582633> 6 7 Reviewed by Alex Christensen. 8 9 Make sure we never create a WebSWClientConnection with an invalid sessionID as this 10 could corrupt our hash tables. 11 12 * StorageProcess/StorageProcess.cpp: 13 (WebKit::StorageProcess::swServerForSession): 14 * UIProcess/WebProcessPool.cpp: 15 (WebKit::WebProcessPool::establishWorkerContextConnectionToStorageProcess): 16 * WebProcess/Storage/WebSWClientConnection.cpp: 17 (WebKit::WebSWClientConnection::WebSWClientConnection): 18 * WebProcess/Storage/WebServiceWorkerProvider.cpp: 19 (WebKit::WebServiceWorkerProvider::serviceWorkerConnectionForSession): 20 (WebKit::WebServiceWorkerProvider::existingServiceWorkerConnectionForSession): 21 * WebProcess/Storage/WebToStorageProcessConnection.cpp: 22 (WebKit::WebToStorageProcessConnection::serviceWorkerConnectionForSession): 23 1 24 2018-01-30 Basuke Suzuki <Basuke.Suzuki@sony.com> 2 25 -
trunk/Source/WebKit/StorageProcess/StorageProcess.cpp
r227425 r227789 405 405 SWServer& StorageProcess::swServerForSession(PAL::SessionID sessionID) 406 406 { 407 ASSERT(sessionID.isValid()); 407 408 auto result = m_swServers.add(sessionID, nullptr); 408 409 if (!result.isNewEntry) { -
trunk/Source/WebKit/UIProcess/WebProcessPool.cpp
r227687 r227789 613 613 auto serviceWorkerProcessProxy = ServiceWorkerProcessProxy::create(*this, *websiteDataStore); 614 614 m_serviceWorkerProcess = serviceWorkerProcessProxy.ptr(); 615 sendToAllProcesses(Messages::WebProcess::RegisterServiceWorkerClients { websiteDataStore->sessionID() }); 615 ASSERT(websiteDataStore->sessionID().isValid()); 616 if (websiteDataStore->sessionID().isValid()) 617 sendToAllProcesses(Messages::WebProcess::RegisterServiceWorkerClients { websiteDataStore->sessionID() }); 616 618 617 619 updateProcessAssertions(); -
trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp
r227751 r227789 54 54 , m_swOriginTable(makeUniqueRef<WebSWOriginTable>()) 55 55 { 56 ASSERT(sessionID.isValid()); 56 57 bool result = sendSync(Messages::StorageToWebProcessConnection::EstablishSWServerConnection(sessionID), Messages::StorageToWebProcessConnection::EstablishSWServerConnection::Reply(m_identifier), Seconds::infinity(), IPC::SendSyncOption::DoNotProcessIncomingMessagesWhenWaitingForSyncReply); 57 58 -
trunk/Source/WebKit/WebProcess/Storage/WebServiceWorkerProvider.cpp
r227709 r227789 57 57 WebCore::SWClientConnection& WebServiceWorkerProvider::serviceWorkerConnectionForSession(SessionID sessionID) 58 58 { 59 ASSERT(sessionID.isValid()); 59 60 return WebProcess::singleton().ensureWebToStorageProcessConnection(sessionID).serviceWorkerConnectionForSession(sessionID); 60 61 } … … 62 63 WebCore::SWClientConnection* WebServiceWorkerProvider::existingServiceWorkerConnectionForSession(SessionID sessionID) 63 64 { 65 ASSERT(sessionID.isValid()); 64 66 auto* webToStorageProcessConnection = WebProcess::singleton().existingWebToStorageProcessConnection(); 65 67 if (!webToStorageProcessConnection) -
trunk/Source/WebKit/WebProcess/Storage/WebToStorageProcessConnection.cpp
r227452 r227789 141 141 WebSWClientConnection& WebToStorageProcessConnection::serviceWorkerConnectionForSession(SessionID sessionID) 142 142 { 143 ASSERT(sessionID.isValid()); 143 144 return *m_swConnectionsBySession.ensure(sessionID, [&] { 144 145 auto connection = WebSWClientConnection::create(m_connection, sessionID);
Note:
See TracChangeset
for help on using the changeset viewer.