Skip to content

Conversation

@mcatanzaro
Copy link
Contributor

@mcatanzaro mcatanzaro commented Jun 20, 2024

23af623

[WPE][GTK] IPC socket should use SOCK_CLOEXEC on Linux
https://bugs.webkit.org/show_bug.cgi?id=275690

Reviewed by Carlos Garcia Campos.

Instead of creating the IPC socket without CLOEXEC and then setting it
afterwards if requested, instead create the socket with CLOEXEC and
unset it afterwards if not requested. This closes the race window where
the socket may leak into a subprocess spawned by another thread (which
seems unlikely, but you never know what applications will do).

In practice, this ensures the server socket will never leak to a
subprocess. The client socket might still get leaked because CLOEXEC has
to get unset at some point for the child process to receive the socket.

* Source/WTF/wtf/UniStdExtras.h:
* Source/WTF/wtf/playstation/UniStdExtrasPlayStation.cpp:
(WTF::unsetCloseOnExec):
* Source/WTF/wtf/unix/UniStdExtrasUnix.cpp:
(WTF::unsetCloseOnExec):
* Source/WebKit/Platform/IPC/unix/ConnectionUnix.cpp:
(IPC::createPlatformConnection):

Canonical link: https://commits.webkit.org/280858@main

6b16754

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 wincairo
✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2 ✅ 🧪 wincairo-tests
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ❌ 🧪 api-wpe
✅ 🧪 ios-wk2-wpt ✅ 🧪 mac-wk1 ✅ 🛠 wpe-cairo
✅ 🛠 🧪 jsc ✅ 🧪 api-ios ✅ 🧪 mac-wk2 ✅ 🛠 gtk
✅ 🛠 🧪 jsc-arm64 ✅ 🛠 vision ✅ 🧪 mac-AS-debug-wk2 ✅ 🧪 gtk-wk2
✅ 🛠 vision-sim ✅ 🧪 mac-wk2-stress ✅ 🧪 api-gtk
✅ 🛠 🧪 merge ✅ 🧪 vision-wk2 ✅ 🛠 jsc-armv7
✅ 🛠 tv ✅ 🧪 jsc-armv7-tests
✅ 🛠 tv-sim
✅ 🛠 watch
✅ 🛠 watch-sim

@mcatanzaro mcatanzaro requested a review from a team as a code owner June 20, 2024 16:39
@mcatanzaro mcatanzaro added the WebKitGTK Bugs related to the Gtk API layer. label Jun 20, 2024
@mcatanzaro mcatanzaro requested a review from carlosgcampos July 10, 2024 22:39
@mcatanzaro mcatanzaro force-pushed the eng/WPEGTK-IPC-socket-should-use-SOCK_CLOEXEC-on-Linux branch from b84cd5f to 6b16754 Compare July 10, 2024 22:39
@mcatanzaro mcatanzaro self-assigned this Jul 10, 2024
@mcatanzaro mcatanzaro added the merge-queue Applied to send a pull request to merge-queue label Jul 11, 2024
https://bugs.webkit.org/show_bug.cgi?id=275690

Reviewed by Carlos Garcia Campos.

Instead of creating the IPC socket without CLOEXEC and then setting it
afterwards if requested, instead create the socket with CLOEXEC and
unset it afterwards if not requested. This closes the race window where
the socket may leak into a subprocess spawned by another thread (which
seems unlikely, but you never know what applications will do).

In practice, this ensures the server socket will never leak to a
subprocess. The client socket might still get leaked because CLOEXEC has
to get unset at some point for the child process to receive the socket.

* Source/WTF/wtf/UniStdExtras.h:
* Source/WTF/wtf/playstation/UniStdExtrasPlayStation.cpp:
(WTF::unsetCloseOnExec):
* Source/WTF/wtf/unix/UniStdExtrasUnix.cpp:
(WTF::unsetCloseOnExec):
* Source/WebKit/Platform/IPC/unix/ConnectionUnix.cpp:
(IPC::createPlatformConnection):

Canonical link: https://commits.webkit.org/280858@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/WPEGTK-IPC-socket-should-use-SOCK_CLOEXEC-on-Linux branch from 6b16754 to 23af623 Compare July 11, 2024 13:45
@webkit-commit-queue
Copy link
Collaborator

Committed 280858@main (23af623): https://commits.webkit.org/280858@main

Reviewed commits have been landed. Closing PR #30005 and removing active labels.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

WebKitGTK Bugs related to the Gtk API layer.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants