Skip to content
Permalink
Browse files
[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:


Canonical link: https://commits.webkit.org/247121@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@289608 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
carlosgcampos committed Feb 11, 2022
1 parent a9a0405 commit 68240593d34eb3946bea12965810940228d34129
Showing 3 changed files with 30 additions and 3 deletions.
@@ -1,3 +1,20 @@
2022-02-11 Carlos Garcia Campos <cgarcia@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.fraser@apple.com>

Separate out setVolatile() from setNonVolatile() on IOSurface-backed buffers
@@ -74,7 +74,13 @@ XDGDBusProxy::XDGDBusProxy(Type type, bool allowPortals)
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
@@ -106,7 +112,7 @@ CString XDGDBusProxy::makeProxy() const
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 @@ void XDGDBusProxy::launch(bool allowPortals) const
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
@@ -37,18 +37,20 @@ class XDGDBusProxy {
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; }

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

0 comments on commit 6824059

Please sign in to comment.