Title: [289334] branches/safari-613-branch/Source/WebKit
Revision
289334
Author
[email protected]
Date
2022-02-07 18:57:09 -0800 (Mon, 07 Feb 2022)

Log Message

Cherry-pick r288898. rdar://problem/87785042

    Protect NetworkConnectionToWebProcess::createFetchTask from a null service worker connection
    https://bugs.webkit.org/show_bug.cgi?id=235878
    <rdar://87785042>

    Reviewed by Chris Dumez.

    After https://bugs.webkit.org/show_bug.cgi?id=234179, there is no guarantee that we have a SWServer/SWServerConnection per session ID.
    This is only guaranteed if there is a corresponding network session.
    We add null pointer checks to NetworkConnectionToWebProcess::swConnection() which now returns a pointer.

    * NetworkProcess/NetworkConnectionToWebProcess.cpp:
    (WebKit::NetworkConnectionToWebProcess::createFetchTask):
    (WebKit::NetworkConnectionToWebProcess::swConnection):
    * NetworkProcess/NetworkConnectionToWebProcess.h:
    * NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.cpp:
    (WebKit::ServiceWorkerFetchTask::softUpdateIfNeeded):

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@288898 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-613-branch/Source/WebKit/ChangeLog (289333 => 289334)


--- branches/safari-613-branch/Source/WebKit/ChangeLog	2022-02-08 02:57:06 UTC (rev 289333)
+++ branches/safari-613-branch/Source/WebKit/ChangeLog	2022-02-08 02:57:09 UTC (rev 289334)
@@ -1,5 +1,48 @@
 2022-02-07  Russell Epstein  <[email protected]>
 
+        Cherry-pick r288898. rdar://problem/87785042
+
+    Protect NetworkConnectionToWebProcess::createFetchTask from a null service worker connection
+    https://bugs.webkit.org/show_bug.cgi?id=235878
+    <rdar://87785042>
+    
+    Reviewed by Chris Dumez.
+    
+    After https://bugs.webkit.org/show_bug.cgi?id=234179, there is no guarantee that we have a SWServer/SWServerConnection per session ID.
+    This is only guaranteed if there is a corresponding network session.
+    We add null pointer checks to NetworkConnectionToWebProcess::swConnection() which now returns a pointer.
+    
+    * NetworkProcess/NetworkConnectionToWebProcess.cpp:
+    (WebKit::NetworkConnectionToWebProcess::createFetchTask):
+    (WebKit::NetworkConnectionToWebProcess::swConnection):
+    * NetworkProcess/NetworkConnectionToWebProcess.h:
+    * NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.cpp:
+    (WebKit::ServiceWorkerFetchTask::softUpdateIfNeeded):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@288898 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-02-01  Youenn Fablet  <[email protected]>
+
+            Protect NetworkConnectionToWebProcess::createFetchTask from a null service worker connection
+            https://bugs.webkit.org/show_bug.cgi?id=235878
+            <rdar://87785042>
+
+            Reviewed by Chris Dumez.
+
+            After https://bugs.webkit.org/show_bug.cgi?id=234179, there is no guarantee that we have a SWServer/SWServerConnection per session ID.
+            This is only guaranteed if there is a corresponding network session.
+            We add null pointer checks to NetworkConnectionToWebProcess::swConnection() which now returns a pointer.
+
+            * NetworkProcess/NetworkConnectionToWebProcess.cpp:
+            (WebKit::NetworkConnectionToWebProcess::createFetchTask):
+            (WebKit::NetworkConnectionToWebProcess::swConnection):
+            * NetworkProcess/NetworkConnectionToWebProcess.h:
+            * NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.cpp:
+            (WebKit::ServiceWorkerFetchTask::softUpdateIfNeeded):
+
+2022-02-07  Russell Epstein  <[email protected]>
+
         Cherry-pick r288864. rdar://problem/87192657
 
     [iOS] Don't register undo actions in undoManager overridden by WKWebView client

Modified: branches/safari-613-branch/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp (289333 => 289334)


--- branches/safari-613-branch/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp	2022-02-08 02:57:06 UTC (rev 289333)
+++ branches/safari-613-branch/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp	2022-02-08 02:57:09 UTC (rev 289334)
@@ -500,7 +500,10 @@
 #if ENABLE(SERVICE_WORKER)
 std::unique_ptr<ServiceWorkerFetchTask> NetworkConnectionToWebProcess::createFetchTask(NetworkResourceLoader& loader, const ResourceRequest& request)
 {
-    return swConnection().createFetchTask(loader, request);
+    auto* swConnection = this->swConnection();
+    if (!swConnection)
+        return nullptr;
+    return swConnection->createFetchTask(loader, request);
 }
 #endif
 
@@ -1198,11 +1201,11 @@
     m_swContextConnection = nullptr;
 }
 
-WebSWServerConnection& NetworkConnectionToWebProcess::swConnection()
+WebSWServerConnection* NetworkConnectionToWebProcess::swConnection()
 {
     if (!m_swConnection)
         establishSWServerConnection();
-    return *m_swConnection;
+    return m_swConnection.get();
 }
 #endif
 

Modified: branches/safari-613-branch/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h (289333 => 289334)


--- branches/safari-613-branch/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h	2022-02-08 02:57:06 UTC (rev 289333)
+++ branches/safari-613-branch/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h	2022-02-08 02:57:09 UTC (rev 289334)
@@ -178,7 +178,7 @@
 
 #if ENABLE(SERVICE_WORKER)
     void serverToContextConnectionNoLongerNeeded();
-    WebSWServerConnection& swConnection();
+    WebSWServerConnection* swConnection();
     std::unique_ptr<ServiceWorkerFetchTask> createFetchTask(NetworkResourceLoader&, const WebCore::ResourceRequest&);
 #endif
 

Modified: branches/safari-613-branch/Source/WebKit/NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.cpp (289333 => 289334)


--- branches/safari-613-branch/Source/WebKit/NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.cpp	2022-02-08 02:57:06 UTC (rev 289333)
+++ branches/safari-613-branch/Source/WebKit/NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.cpp	2022-02-08 02:57:09 UTC (rev 289334)
@@ -352,7 +352,10 @@
     SWFETCH_RELEASE_LOG("softUpdateIfNeeded: (m_shouldSoftUpdate=%d)", m_shouldSoftUpdate);
     if (!m_shouldSoftUpdate)
         return;
-    if (auto* registration = m_loader.connectionToWebProcess().swConnection().server().getRegistration(m_serviceWorkerRegistrationIdentifier))
+    auto* swConnection = m_loader.connectionToWebProcess().swConnection();
+    if (!swConnection)
+        return;
+    if (auto* registration = swConnection->server().getRegistration(m_serviceWorkerRegistrationIdentifier))
         registration->scheduleSoftUpdate(m_loader.isAppInitiated() ? WebCore::IsAppInitiated::Yes : WebCore::IsAppInitiated::No);
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to