gracefully handle invalid "extra-hosts" for containers#52275
Merged
vvoland merged 3 commits intomoby:masterfrom Apr 1, 2026
Merged
gracefully handle invalid "extra-hosts" for containers#52275vvoland merged 3 commits intomoby:masterfrom
vvoland merged 3 commits intomoby:masterfrom
Conversation
Make sure we use the same function to validate as we use to parse the IP-address. Signed-off-by: Sebastiaan van Stijn <[email protected]>
Older daemons were more permissive when handling whitespace, which
can cause the daemon to panic when handling existing container-configs;
```
goroutine 767 [running]:
net/netip.MustParseAddr(...)
/usr/local/go/src/net/netip/netip.go:136
github.com/moby/moby/v2/daemon.buildSandboxOptions(0xc0009c2008, 0xc000b8c588)
/root/build-deb/engine/daemon/container_operations.go:93 +0x1994
github.com/moby/moby/v2/daemon.(*Daemon).initializeNetworking(0xc0009a4c88, {0x5563cdcda848, 0xc000f6e810}, 0xc0009c2008, 0xc000b8c588)
/root/build-deb/engine/daemon/container_operations.go:473 +0x33c
github.com/moby/moby/v2/daemon.(*Daemon).containerStart(0xc0009a4c88, {0x5563cdcda810, 0x5563cf72ec20}, 0xc0009c2008, 0xc000b8c588, {0x0, 0x0}, {0x0, 0x0}, 0x1)
/root/build-deb/engine/daemon/start.go:134 +0x8d8
github.com/moby/moby/v2/daemon.(*Daemon).restore.func4(0xc000b8c588, 0xc000312d90)
/root/build-deb/engine/daemon/daemon.go:632 +0x430
created by github.com/moby/moby/v2/daemon.(*Daemon).restore in goroutine 1
/root/build-deb/engine/daemon/daemon.go:606 +0x7ff
```
Migrate existing configs to more gracefully handle startup after upgrading
from an older version of the daemon.
Signed-off-by: Sebastiaan van Stijn <[email protected]>
This is mostly a defense in-depth for handling containers that were created with an older version of docker. Log a warning instead of panicking on invalid values. Signed-off-by: Sebastiaan van Stijn <[email protected]>
vvoland
reviewed
Apr 1, 2026
Comment on lines
299
to
301
| // IP address, and returns the value in normalized form. Leading and trailing | ||
| // whitespace is allowed, but it does not allow IPv6 addresses surrounded by | ||
| // square brackets ("[::1]"). |
Contributor
There was a problem hiding this comment.
-// IP address, and returns the value in normalized form. Leading and trailing
-// whitespace is allowed, but it does not allow IPv6 addresses surrounded by
-// square brackets ("[::1]").
+// IP address, and returns the value in normalized form.
+// Leading and trailing whitespace is not allowed.
vvoland
approved these changes
Apr 1, 2026
Member
Author
|
The "vm" test keeps failing; very likely unrelated, but if you can double-check? Otherwise we should just merge probably. |
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.
daemon/pkg/opts: ValidateIPAddress: use netip.Parse
Make sure we use the same function to validate as we use to parse
the IP-address.
daemon: Daemon.restore: trim whitespace in extra-hosts
Older daemons were more permissive when handling whitespace, which
can cause the daemon to panic when handling existing container-configs;
Migrate existing configs to more gracefully handle startup after upgrading
from an older version of the daemon.
daemon: buildSandboxOptions: warn, not panic on invalid extra host
This is mostly a defense in-depth for handling containers that were
created with an older version of docker. Log a warning instead of
panicking on invalid values.
- Human readable description for the release notes
- A picture of a cute animal (not mandatory but encouraged)