Changeset 250354 in webkit
- Timestamp:
- Sep 25, 2019 12:43:02 PM (5 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r250352 r250354 1 2019-09-25 Alex Christensen <achristensen@webkit.org> 2 3 Don't fall back to default session if session can't be found for cookie operations 4 https://bugs.webkit.org/show_bug.cgi?id=202222 5 6 Reviewed by Geoff Garen. 7 8 Apparently, during teardown of private browsing sessions, there is sometimes a race condition and cookies from a torn-down session are requested. 9 In this case, just fail like we do all other operations in this file. Otherwise, it's a breach of privacy. 10 11 * NetworkProcess/NetworkConnectionToWebProcess.cpp: 12 (WebKit::NetworkConnectionToWebProcess::storageSession): 13 (WebKit::NetworkConnectionToWebProcess::cookiesForDOM): 14 (WebKit::NetworkConnectionToWebProcess::setCookiesFromDOM): 15 (WebKit::NetworkConnectionToWebProcess::cookiesEnabled): 16 (WebKit::NetworkConnectionToWebProcess::cookieRequestHeaderFieldValue): 17 (WebKit::NetworkConnectionToWebProcess::getRawCookies): 18 (WebKit::NetworkConnectionToWebProcess::deleteCookie): 19 * NetworkProcess/NetworkConnectionToWebProcess.h: 20 1 21 2019-09-25 Alex Christensen <achristensen@webkit.org> 2 22 -
trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp
r250193 r250354 495 495 } 496 496 497 NetworkStorageSession& NetworkConnectionToWebProcess::storageSession() 498 { 499 if (m_sessionID != PAL::SessionID::defaultSessionID()) { 500 if (auto* storageSession = networkProcess().storageSession(m_sessionID)) 501 return *storageSession; 502 503 // Some requests with private browsing mode requested may still be coming shortly after NetworkProcess was told to destroy its session. 504 // FIXME: Find a way to track private browsing sessions more rigorously. 497 NetworkStorageSession* NetworkConnectionToWebProcess::storageSession() 498 { 499 auto* session = networkProcess().storageSession(m_sessionID); 500 if (!session) 505 501 LOG_ERROR("Non-default storage session was requested, but there was no session for it. Please file a bug unless you just disabled private browsing, in which case it's an expected race."); 506 } 507 return networkProcess().defaultStorageSession(); 502 return session; 508 503 } 509 504 … … 534 529 void NetworkConnectionToWebProcess::cookiesForDOM(const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, Optional<FrameIdentifier> frameID, Optional<PageIdentifier> pageID, IncludeSecureCookies includeSecureCookies, CompletionHandler<void(String cookieString, bool secureCookiesAccessed)>&& completionHandler) 535 530 { 536 auto& networkStorageSession = storageSession(); 537 auto result = networkStorageSession.cookiesForDOM(firstParty, sameSiteInfo, url, frameID, pageID, includeSecureCookies); 531 auto* networkStorageSession = storageSession(); 532 if (!networkStorageSession) 533 return completionHandler({ }, false); 534 auto result = networkStorageSession->cookiesForDOM(firstParty, sameSiteInfo, url, frameID, pageID, includeSecureCookies); 538 535 #if ENABLE(RESOURCE_LOAD_STATISTICS) && !RELEASE_LOG_DISABLED 539 536 if (auto* session = networkSession()) { 540 537 if (session->shouldLogCookieInformation()) 541 NetworkResourceLoader::logCookieInformation(*this, "NetworkConnectionToWebProcess::cookiesForDOM", reinterpret_cast<const void*>(this), networkStorageSession, firstParty, sameSiteInfo, url, emptyString(), frameID, pageID, WTF::nullopt);538 NetworkResourceLoader::logCookieInformation(*this, "NetworkConnectionToWebProcess::cookiesForDOM", reinterpret_cast<const void*>(this), *networkStorageSession, firstParty, sameSiteInfo, url, emptyString(), frameID, pageID, WTF::nullopt); 542 539 } 543 540 #endif … … 547 544 void NetworkConnectionToWebProcess::setCookiesFromDOM(const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, Optional<WebCore::FrameIdentifier> frameID, Optional<PageIdentifier> pageID, const String& cookieString) 548 545 { 549 auto& networkStorageSession = storageSession(); 550 networkStorageSession.setCookiesFromDOM(firstParty, sameSiteInfo, url, frameID, pageID, cookieString); 546 auto* networkStorageSession = storageSession(); 547 if (!networkStorageSession) 548 return; 549 networkStorageSession->setCookiesFromDOM(firstParty, sameSiteInfo, url, frameID, pageID, cookieString); 551 550 #if ENABLE(RESOURCE_LOAD_STATISTICS) && !RELEASE_LOG_DISABLED 552 551 if (auto* session = networkSession()) { 553 552 if (session->shouldLogCookieInformation()) 554 NetworkResourceLoader::logCookieInformation(*this, "NetworkConnectionToWebProcess::setCookiesFromDOM", reinterpret_cast<const void*>(this), networkStorageSession, firstParty, sameSiteInfo, url, emptyString(), frameID, pageID, WTF::nullopt);553 NetworkResourceLoader::logCookieInformation(*this, "NetworkConnectionToWebProcess::setCookiesFromDOM", reinterpret_cast<const void*>(this), *networkStorageSession, firstParty, sameSiteInfo, url, emptyString(), frameID, pageID, WTF::nullopt); 555 554 } 556 555 #endif … … 559 558 void NetworkConnectionToWebProcess::cookiesEnabled(CompletionHandler<void(bool)>&& completionHandler) 560 559 { 561 completionHandler(storageSession().cookiesEnabled()); 560 auto* networkStorageSession = storageSession(); 561 if (!networkStorageSession) 562 return completionHandler(false); 563 completionHandler(networkStorageSession->cookiesEnabled()); 562 564 } 563 565 564 566 void NetworkConnectionToWebProcess::cookieRequestHeaderFieldValue(const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, Optional<FrameIdentifier> frameID, Optional<PageIdentifier> pageID, IncludeSecureCookies includeSecureCookies, CompletionHandler<void(String, bool)>&& completionHandler) 565 567 { 566 auto result = storageSession().cookieRequestHeaderFieldValue(firstParty, sameSiteInfo, url, frameID, pageID, includeSecureCookies); 568 auto* networkStorageSession = storageSession(); 569 if (!networkStorageSession) 570 return completionHandler({ }, false); 571 auto result = networkStorageSession->cookieRequestHeaderFieldValue(firstParty, sameSiteInfo, url, frameID, pageID, includeSecureCookies); 567 572 completionHandler(WTFMove(result.first), result.second); 568 573 } … … 570 575 void NetworkConnectionToWebProcess::getRawCookies(const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, Optional<FrameIdentifier> frameID, Optional<PageIdentifier> pageID, CompletionHandler<void(Vector<WebCore::Cookie>&&)>&& completionHandler) 571 576 { 577 auto* networkStorageSession = storageSession(); 578 if (!networkStorageSession) 579 return completionHandler({ }); 572 580 Vector<WebCore::Cookie> result; 573 storageSession().getRawCookies(firstParty, sameSiteInfo, url, frameID, pageID, result);581 networkStorageSession->getRawCookies(firstParty, sameSiteInfo, url, frameID, pageID, result); 574 582 completionHandler(WTFMove(result)); 575 583 } … … 577 585 void NetworkConnectionToWebProcess::deleteCookie(const URL& url, const String& cookieName) 578 586 { 579 storageSession().deleteCookie(url, cookieName); 587 auto* networkStorageSession = storageSession(); 588 if (!networkStorageSession) 589 return; 590 networkStorageSession->deleteCookie(url, cookieName); 580 591 } 581 592 -
trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h
r250193 r250354 160 160 161 161 void didFinishPreconnection(uint64_t preconnectionIdentifier, const WebCore::ResourceError&); 162 WebCore::NetworkStorageSession &storageSession();162 WebCore::NetworkStorageSession* storageSession(); 163 163 164 164 // IPC::Connection::Client
Note: See TracChangeset
for help on using the changeset viewer.