Skip to content

vendor: github.com/docker/go-connections v0.8.0 - #7121

Merged
thaJeztah merged 1 commit into
docker:masterfrom
thaJeztah:bump_go_connections
Jul 27, 2026
Merged

vendor: github.com/docker/go-connections v0.8.0#7121
thaJeztah merged 1 commit into
docker:masterfrom
thaJeztah:bump_go_connections

Conversation

@thaJeztah

@thaJeztah thaJeztah commented Jul 24, 2026

Copy link
Copy Markdown
Member
  • sockets: set socket permissions without overriding umask
  • sockets: improve abstract Unix socket handling
  • sockets: InmemSocket: add DialContext
  • sockets: remove double error decoration
  • sockets: test-enhancements and improve coverage

full diff: docker/go-connections@v0.7.0...v0.8.0

- What I did

- How I did it

- How to verify it

- Human readable description for the release notes

- A picture of a cute animal (not mandatory but encouraged)

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@docker-agent docker-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟢 APPROVE

The vendored update to github.com/docker/go-connections (v0.7.0 → v0.8.0-dev) looks clean. The changes reviewed:

  • inmem_socket.go: DialContext is correctly implemented with proper context-cancellation handling and cleanup — both ends of the pipe are closed on timeout/cancellation, with no goroutine or connection leaks.
  • unix_socket_unix.go: The new manual socket lifecycle (socket→bind→chmod→listen) is a genuine security improvement over the previous umask-manipulation approach. listen(2) is now only called after permissions are set, so clients can never connect to an under-permissioned socket.
  • unix_socket.go: Abstract socket path handling is correct; ErrUnsupported is properly returned for unsupported options.
  • unix_socket_windows.go: Windows listenUnix now correctly accepts and applies opts, matching unix behaviour.

No bugs found.

- sockets: set socket permissions without overriding umask
- sockets: improve abstract Unix socket handling
- sockets: InmemSocket: add DialContext
- sockets: remove double error decoration
- sockets: test-enhancements and improve coverage

full diff: docker/go-connections@v0.7.0...v0.8.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah
thaJeztah force-pushed the bump_go_connections branch from e548c8b to 4e6e8fe Compare July 25, 2026 17:48
@thaJeztah thaJeztah changed the title vendor: github.com/docker/go-connections main (v0.8.0-dev) vendor: github.com/docker/go-connections v0.8.0 Jul 25, 2026
@thaJeztah
thaJeztah marked this pull request as ready for review July 25, 2026 17:49

@docker-agent docker-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟢 APPROVE

This vendor bump from github.com/docker/go-connections v0.7.0 → v0.8.0 is well-structured. The key improvements — eliminating the umask-manipulation race in socket creation, adding proper abstract Unix socket handling, and adding DialContext with correct context cancellation — are all correctly implemented. One low-confidence observation about @-prefixed path handling on macOS is noted inline.

// socket.
func WithChown(uid, gid int) SockOption {
return func(path string) error {
if isAbstractSocket(path) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[low] isAbstractSocket treats @-prefixed paths as abstract on all Unix platforms, potentially breaking WithChown/WithChmod on macOS/BSD for @-prefixed filesystem socket paths

isAbstractSocket returns true for any path beginning with @ or \x00. On Linux this is correct — Go translates a leading @ to the kernel's abstract-socket NUL prefix. However, @ carries no special meaning on macOS or BSD; a Unix socket whose literal filesystem path begins with @ is an ordinary file-backed socket on those platforms.

WithChown and WithChmod are exported option functions (callers may use them independently of NewUnixSocketWithOpts). With this PR's added guard, any caller on macOS/BSD who passes one of these options for a socket path that happens to start with @ will receive ErrUnsupported instead of the option being applied. Before this PR, the check did not exist and the option would execute normally.

In practice, @-prefixed filesystem socket paths are very rare on macOS. The high-level entry point NewUnixSocketWithOpts also gates @ paths with supportsAbstractSockets before opts are applied, so the regression is only reachable when WithChown/WithChmod are called directly. Consider guarding the abstract-socket check with runtime.GOOS == "linux" (or an internal supportsAbstractSockets constant) inside WithChown and WithChmod to limit the ErrUnsupported path to Linux only.

Confidence Score
🟡 moderate 62/100

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is intentional; code using @some-socket may make the assumption that it's creating an abstract socket, but silently getting a regular socket.

It's a breaking change if someone would depend on obscure socket names with a @ at the start of the filename, but that would be a very corner-case.

For nul-prefixed sockets; these would already fail when attempting to use, but the error would be obscure.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a fair design choice — thanks for clarifying the intent. Erroring explicitly on backtick-at-prefixed paths across all platforms prevents callers from accidentally creating a filesystem socket when they expected an abstract one (which would be a silent misbehavior).

The breaking change for obscure backtick-at-prefixed filesystem socket names on macOS/BSD is indeed a corner case, and the explicit error is better than the subtle semantic difference. I agree that NUL-prefixed paths would already fail obscurely during use, so detecting them early improves the error message.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

backtick-at-prefixed paths

Your use of backtick-at-prefixed instead of @ is ... cute 😂

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate the correction — and yes, that was an unintentional escape attempt on my part! I should have just written @-prefixed. Thanks for catching it (and for the patience with my over-cautious markdown handling). 😊

The intentional cross-platform guard makes sense for preventing silent semantic mismatches, especially when callers expect abstract socket behavior.

@thaJeztah
thaJeztah requested a review from vvoland July 25, 2026 18:09

@docker-agent docker-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟢 APPROVE

This vendor bump from github.com/docker/go-connections v0.7.0 → v0.8.0 introduces well-structured improvements to Unix socket handling:

  • Permission race fix (unix_socket_unix.go): The new listenUnix implementation manually calls socket(2), bind(2), applies permissions/ownership options, then listen(2) — eliminating the previous umask(0777) hack that had a process-wide side effect window. The fd ownership pattern (using os.NewFile + fd = -1 sentinel + net.FileListener internal dup) is a well-established Go stdlib idiom and is correct.

  • Abstract socket support (unix_socket.go): Clean gating with isAbstractSocket helper, Linux-only enforcement, and correct early-return of errors.ErrUnsupported for incompatible options (WithChown/WithChmod) on platforms that don't support them.

  • DialContext addition (inmem_socket.go): The DialContext implementation handles all three select branches correctly — successful send to listener, context cancellation, and listener close — with explicit cleanup of both pipe ends in the error paths. No resource leaks.

  • Backlog helpers (unix_socket_linux.go, unix_socket_nolinux.go): Mirror the stdlib implementations faithfully with appropriate platform-specific sysctls and fallbacks.

  • Named return cleanup in listenUnix: The retErr named return correctly gates the Unlink defer — Go's spec guarantees that explicit return nil, err assigns retErr = err before deferred functions execute.

No bugs found in the changed code.

@docker-agent docker-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟢 APPROVE

This vendor bump of github.com/docker/go-connections v0.7.0 → v0.8.0 introduces several well-implemented improvements to the sockets package:

  • DialContext on InmemSocket: correctly uses net.Pipe() with proper context-cancellation handling and cleanup of both pipe ends on cancellation.
  • Unix socket permission fix: refactored to use raw syscalls (socket/bind/listen) rather than net.Listen with umask manipulation, closing a TOCTOU race on socket permissions.
  • Abstract Unix socket handling: correctly gated per platform with appropriate unsupported errors for WithChown/WithChmod on abstract sockets.
  • fd lifecycle in listenUnix: ownership transfer from the raw fd → os.Filenet.FileListener is handled correctly, with deferred cleanup on error and SetUnlinkOnClose(true) for success paths.
  • Error handling: removed double error decoration; error paths consistently unlink socket files.

No bugs were found in the introduced changes. The code is well-structured with correct resource management.

@thaJeztah
thaJeztah merged commit 977f889 into docker:master Jul 27, 2026
111 checks passed
@thaJeztah
thaJeztah deleted the bump_go_connections branch July 27, 2026 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants