Title: [289608] trunk/Source/WebKit
Revision
289608
Author
carlo...@webkit.org
Date
2022-02-11 00:32:35 -0800 (Fri, 11 Feb 2022)

Log Message

[WPE][GTK] BubblewrapLauncher leaks D-Bus proxy sockets
https://bugs.webkit.org/show_bug.cgi?id=201771

Reviewed by Michael Catanzaro.

xdg-dbus-proxy removes the socket when the sync fd is closed by the application. In most of the cases the
xdg-dbus-proxy process is killed before the sync fd is closed and the socket file is leaked. We should
explicitly close the sync fd.

* UIProcess/Launcher/glib/XDGDBusProxy.cpp:
(WebKit::XDGDBusProxy::XDGDBusProxy): Save the sync fd.
(WebKit::XDGDBusProxy::~XDGDBusProxy): Close the sync fd is needed.
(WebKit::XDGDBusProxy::launch const): Return the sync fd.
* UIProcess/Launcher/glib/XDGDBusProxy.h:

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (289607 => 289608)


--- trunk/Source/WebKit/ChangeLog	2022-02-11 08:25:05 UTC (rev 289607)
+++ trunk/Source/WebKit/ChangeLog	2022-02-11 08:32:35 UTC (rev 289608)
@@ -1,3 +1,20 @@
+2022-02-11  Carlos Garcia Campos  <cgar...@igalia.com>
+
+        [WPE][GTK] BubblewrapLauncher leaks D-Bus proxy sockets
+        https://bugs.webkit.org/show_bug.cgi?id=201771
+
+        Reviewed by Michael Catanzaro.
+
+        xdg-dbus-proxy removes the socket when the sync fd is closed by the application. In most of the cases the
+        xdg-dbus-proxy process is killed before the sync fd is closed and the socket file is leaked. We should
+        explicitly close the sync fd.
+
+        * UIProcess/Launcher/glib/XDGDBusProxy.cpp:
+        (WebKit::XDGDBusProxy::XDGDBusProxy): Save the sync fd.
+        (WebKit::XDGDBusProxy::~XDGDBusProxy): Close the sync fd is needed.
+        (WebKit::XDGDBusProxy::launch const): Return the sync fd.
+        * UIProcess/Launcher/glib/XDGDBusProxy.h:
+
 2022-02-10  Simon Fraser  <simon.fra...@apple.com>
 
         Separate out setVolatile() from setNonVolatile() on IOSurface-backed buffers

Modified: trunk/Source/WebKit/UIProcess/Launcher/glib/XDGDBusProxy.cpp (289607 => 289608)


--- trunk/Source/WebKit/UIProcess/Launcher/glib/XDGDBusProxy.cpp	2022-02-11 08:25:05 UTC (rev 289607)
+++ trunk/Source/WebKit/UIProcess/Launcher/glib/XDGDBusProxy.cpp	2022-02-11 08:32:35 UTC (rev 289608)
@@ -74,9 +74,15 @@
         m_path = CString(path, pathEnd - path);
     }
 
-    launch(allowPortals);
+    m_syncFD = launch(allowPortals);
 }
 
+XDGDBusProxy::~XDGDBusProxy()
+{
+    if (m_syncFD != -1)
+        close(m_syncFD);
+}
+
 CString XDGDBusProxy::makeProxy() const
 {
     GUniquePtr<char> appRunDir(g_build_filename(g_get_user_runtime_dir(), BASE_DIRECTORY, nullptr));
@@ -106,7 +112,7 @@
     return proxySocketTemplate.get();
 }
 
-void XDGDBusProxy::launch(bool allowPortals) const
+int XDGDBusProxy::launch(bool allowPortals) const
 {
     int syncFds[2];
     if (pipe(syncFds) == -1)
@@ -203,6 +209,8 @@
     char out;
     if (read(syncFds[0], &out, 1) != 1)
         g_error("Failed to fully launch dbus-proxy: %s", g_strerror(errno));
+
+    return syncFds[0];
 }
 
 } // namespace WebKit

Modified: trunk/Source/WebKit/UIProcess/Launcher/glib/XDGDBusProxy.h (289607 => 289608)


--- trunk/Source/WebKit/UIProcess/Launcher/glib/XDGDBusProxy.h	2022-02-11 08:25:05 UTC (rev 289607)
+++ trunk/Source/WebKit/UIProcess/Launcher/glib/XDGDBusProxy.h	2022-02-11 08:32:35 UTC (rev 289608)
@@ -37,6 +37,7 @@
 public:
     enum class Type { SessionBus, AccessibilityBus };
     XDGDBusProxy(Type, bool = false);
+    ~XDGDBusProxy();
 
     const CString& proxyPath() const { return m_proxyPath; }
     const CString& path() const { return m_path; }
@@ -43,12 +44,13 @@
 
 private:
     CString makeProxy() const;
-    void launch(bool) const;
+    int launch(bool) const;
 
     Type m_type;
     CString m_dbusAddress;
     CString m_proxyPath;
     CString m_path;
+    int m_syncFD { -1 };
 };
 
 } // namespace WebKit
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to