Skip to content

fix(runtime): close ExecNotWait connection, guard NetworkInspect error path#3148

Open
Aprazor wants to merge 1 commit intosrl-labs:mainfrom
Aprazor:fix/docker-exec-leak-and-inspect-fallthrough
Open

fix(runtime): close ExecNotWait connection, guard NetworkInspect error path#3148
Aprazor wants to merge 1 commit intosrl-labs:mainfrom
Aprazor:fix/docker-exec-leak-and-inspect-fallthrough

Conversation

@Aprazor
Copy link
Copy Markdown
Contributor

@Aprazor Aprazor commented Mar 30, 2026

Summary

Three runtime correctness fixes:

1. TCP connection leak in ExecNotWait (Docker)

ContainerExecAttach returns a types.HijackedResponse holding a TCP connection and bufio reader. The normal Exec() method properly calls defer rsp.Close(), but ExecNotWait discards the response with _, leaking a TCP socket on every call.

Fix: Capture the response and close it after attach.

2. NetworkInspect error fallthrough (Docker)

In WithMgmtNet, after NetworkInspect fails, the code sets MTU to 1500 and logs the error, but falls through to access netRes.Options on the zero-value NetworkResource. While Go nil-map reads don't panic (returns zero value), this is accidentally correct and fragile.

Fix: Use else if so netRes.Options is only accessed when inspect succeeded.

3. CreateContainer accesses result on error (Podman)

After CreateWithSpec fails, the code accesses res.ID and res.Warnings in the log statement and returns res.ID to callers. This returns a potentially invalid container ID that callers may try to use.

Fix: Check error first and return a wrapped error without accessing the result.

Testing

  • go vet ./runtime/docker/... — clean
  • go test -race ./runtime/docker/... — all pass
  • Podman changes cannot be compiled on this machine (missing C libs), but the fix follows the same early-return pattern

…r path

Three runtime fixes:

- runtime/docker/docker.go (ExecNotWait): ContainerExecAttach returns a
  HijackedResponse holding a TCP connection. The response was discarded
  with _, leaking a TCP socket on every call. Close it after attach.

- runtime/docker/docker.go (WithMgmtNet): after NetworkInspect fails,
  the code falls through to access netRes.Options on the zero-value
  response. While Go nil-map reads don't panic, this is accidentally
  correct. Use else-if to only access the result on success.

- runtime/podman/podman.go (CreateContainer): on CreateWithSpec error,
  the code accessed res.ID in the log and returned it to callers. Check
  err first and return a wrapped error instead of a potentially invalid
  container ID.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant