[io_uring] Fix Unix domain socket support for abstract namespace sockets#15876
Merged
Conversation
…kets
Motivation:
The current implementation of `SockaddrIn.setUds()` only supports
file path-based Unix domain sockets. It incorrectly adds a null
terminator for all sockets and always passes `SIZEOF_SOCKADDR_UN`
as the address length to io_uring operations. This breaks abstract
namespace sockets, which are distinguished by having a null byte as ⧉ 1 line selected
the first character and must not have an additional null terminator
appended. According to unix(7), abstract sockets require a precise
address length of `offsetof(sun_path) + actual_name_length`, while
pathname sockets require `offsetof(sun_path) + strlen(path) + 1`.
Modifications:
Modified `SockaddrIn.setUds()` to:
- Detect abstract namespace sockets by checking if the path starts
with '\0'
- Only append null terminator for pathname sockets, not abstract
sockets
- Calculate and return the correct address length based on socket type
- Added comprehensive documentation explaining both socket types
Modified `AbstractIoUringChannel.submitConnect(DomainSocketAddress)` to:
- Capture the address length returned by `setUds()`
- Pass the actual address length to `IoUringIoOps.newConnect()`
instead of the hardcoded `SIZEOF_SOCKADDR_UN`
Result:
Both pathname-based and abstract namespace Unix domain sockets are
now properly supported. Abstract sockets will correctly connect without
spurious null bytes, and the kernel will receive the precise address
length required for each socket type.
82af2e5 to
0689460
Compare
Member
|
@j-bahr nice! Let me check in detail ... do we also need a fix for epoll ? |
normanmaurer
requested changes
Nov 18, 2025
Contributor
Author
Our epoll implementation on top of abstract namespace sockets appears to work fine. We only see issues after changing to io_uring. I did a quick inspection and found that epoll appears to do the same calculation we're doing for io_uring. |
normanmaurer
approved these changes
Nov 19, 2025
…/IoUringDomainSocketAbstractFdTest.java
Member
|
@j-bahr thanks a lot! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation:
The current implementation of
SockaddrIn.setUds()only supports file path based Unix domain sockets. It incorrectly adds a null terminator for all sockets and always passesSIZEOF_SOCKADDR_UNas the address length to io_uring operations. This breaks abstract namespace sockets, which are distinguished by having a null byte as the first character and must not have an additional null terminator appended and included in theaddress_len. According to unix(7), abstract sockets require a precise address length ofoffsetof(sun_path) + actual_name_length, while pathname sockets requireoffsetof(sun_path) + strlen(path) + 1.Modifications:
Modified
SockaddrIn.setUds()to:Modified
AbstractIoUringChannel.submitConnect(DomainSocketAddress)to:setUds()IoUringIoOps.newConnect()instead of the hardcodedSIZEOF_SOCKADDR_UNResult:
Both pathname-based and abstract namespace Unix domain sockets are now properly supported. Abstract sockets will correctly connect without spurious null bytes, and the kernel will receive the precise address length required for each socket type.