2004 Commits

Author SHA1 Message Date
Samuel Karp
5558f3aa0e Merge pull request #13626 from samuelkarp/june-18-combined-main
Patches
2026-06-18 16:02:14 -07:00
Chris Henzie
5a91c99584 Merge commit from fork 2026-06-15 21:25:17 -07:00
Esteban Ginez
be3fcf33e8 fix(shim/windows): retry on winio.ErrTimeout in awaitPipeReady
awaitPipeReady retried only when DialPipe returned os.IsNotExist or
context.DeadlineExceeded, but winio.DialPipe converts the per-attempt
deadline into winio.ErrTimeout before returning. A pipe in state 1
(ListenPipe called, Accept not yet called) causes DialPipe to block for
the full per-attempt timeout and return winio.ErrTimeout, which the old
check treated as a fatal error instead of retrying.

Also guard windows.ERROR_PIPE_BUSY explicitly to match the error checks
in containerd/nerdbox#218.

Adds a regression test that forces the state-1 to state-2 transition
race by delaying Accept past the 1-second per-attempt timeout.

Signed-off-by: Esteban Ginez <esteban.ginez@docker.com>
2026-06-10 14:49:50 -07:00
Ben Cressey
0ec1af4cae Do not propagate reserved labels from image configs
Image config labels are copied onto the container by both the CRI
plugin (BuildLabels) and the client's WithImageConfigLabels option
used by `ctr run`. Labels in the containerd.io/* namespace are
interpreted by containerd itself and labels in the io.cri-containerd*
namespace are interpreted by the CRI plugin. An image config is not a
trusted source for labels in either namespace.

Skip labels in both reserved namespaces when copying labels from an
image config to a container, and warn about each label skipped: an
image that tries to set them may be attempting to alter containerd
behavior. Oversized image labels are already skipped this way by
the CRI plugin.

Labels set explicitly by clients, for example via `ctr run --label`
or in the CRI request, are unaffected.

Verified with the CRI plugin and with `ctr run` against an image
whose config carries labels like these: the labels are no longer
present on the created container and a warning is logged for each.

Assisted-by: Claude Code
Signed-off-by: Ben Cressey <ben@cressey.org>
Signed-off-by: Samuel Karp <samuelkarp@google.com>
2026-06-10 13:18:24 -07:00
Sebastiaan van Stijn
633a5be1c9 pkg/oci: WithUser: remove redundant isErrRange utility
`strconv.NumError` implements `Unwrap` (see https://go.dev/cl/194563),
so there's no need to manually assert the type and unwrap.

Updates 9439355c2b

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-05-26 10:14:17 +02:00
LEI WANG
9439355c2b oci: return explicit error for out-of-range USER values
Detect strconv.ErrRange and validate uid/gid bounds to avoid falling back to username/group lookups.

Signed-off-by: LEI WANG <ssst0n3@gmail.com>
2026-05-19 11:36:54 -07:00
Samuel Karp
ae843af785 Merge pull request #13360 from mxpv/task
Fix sandbox task API endpoints for non-runc runtimes
2026-05-19 00:15:24 +00:00
Maksym Pavlenko
b88ab5af4f Wire task address and version fields
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2026-05-18 13:37:19 -07:00
Chris Henzie
7b05ec421d Bound user-database file reads in openUserFile
openUserFile now stats the opened file, refuses anything that is not a
regular file, and wraps the returned fs.File so reads are capped at
maxUserFileBytes (10 MiB). All callers of openUserFile read either
etc/passwd or etc/group; both are regular files on real systems, well
under the cap.

The cap and the regular-file check together bound parser memory use
when reading user-database files of unexpected shape or size.

Adds tests for the cap and for the non-regular file rejection. The cap
test covers three boundary points: a small pad (trailing entry parsed),
a pad placing the entry's last byte exactly on the cap (still parsed),
and a pad past the cap (read returns an "exceeds" error).

Assisted-by: Antigravity
Signed-off-by: Chris Henzie <chrishenzie@gmail.com>
2026-05-16 01:04:01 +00:00
Kir Kolyshkin
899dee1f59 pkg: remove unused nolint annotations
Commit f9c80be1b removed varcheck linter, but some nolint:varcheck
annotations are still there, resulting in golangci-lint warning:

> WARN [runner/nolint_filter] Found unknown linters in //nolint directives: varcheck

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-05-12 11:02:51 -07:00
Maksym Pavlenko
3e0ebf0f6d Deprecate shim.Command
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2026-04-29 10:51:55 -07:00
Sanil2108
f62bce25df pkg/rootfs: remove unused InitRootFS and related helpers
InitRootFS was added in #1477 for potential future use but has no
callers either inside or outside this repository. Remove it along
with the associated Mounter interface, initializerFunc type,
createInitLayer helper, and the platform-specific init files that
only existed to support it.

Fixes #13238

Signed-off-by: Sanil2108 <sanilkhurana7@gmail.com>
2026-04-21 08:59:39 +05:30
Derek McGowan
e07a1aa491 Add configuration for socket directory to the shim manager
Allow the socket directory to be directly configured by the shim manager
with reasonable defaults when not set. The default for root users will
still be the same directory under the default state directory. For
non-root users a temp directory will be used as default if the state
directory is not owned by the user.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2026-04-15 00:21:29 -07:00
Derek McGowan
d806373feb Make shim socket directory use configured state
Send the socket directory from containerd to the shim. The shim still
decides where the socket goes but can use the environment variable
passed from containerd to ensure the socket is placed in the configured
directory with proper permission.

This is needed for some rootless cases which do not have permission to
the default state directory as currently set. The directory being
hardcoded by the shim means it is currently not possible to change the
location the shim will listen at.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2026-04-15 00:21:18 -07:00
Derek McGowan
74b465dcc6 Merge pull request #13208 from dmcgowan/update-bootstrap-log-levels
Update bootstrap API log level definition
2026-04-10 17:01:20 -07:00
Derek McGowan
2c102c6cbe Update bootstrap API log level definition
Avoid using logrus concepts in the API, use slog style log levels with
integer values and 0 meaning the default "info" level.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2026-04-10 15:23:34 -07:00
Esteban Ginez
01e5fa616f fix: address review feedback on awaitPipeReady
- Use time.NewTimer + Stop() instead of time.After to avoid timer leaks
- Treat context.DeadlineExceeded as retryable (pipe busy, not just missing)
- Wrap last dial error instead of os.ErrNotExist for better diagnostics
- Update makeConnection godoc to reflect current BootstrapResult type

Signed-off-by: Esteban Ginez <esteban.ginez@docker.com>
2026-04-09 15:15:32 -07:00
Esteban Ginez
1e98ebaf0e fix(windows): verify pipe readiness before returning shim address
The shim "start" helper returns the named pipe address before the
daemon process has created the pipe via winio.ListenPipe(). On busy
Windows systems, containerd may try to connect before the pipe exists.

Add awaitPipeReady() — the start helper now polls the pipe address
(up to 5s, 10ms intervals) before writing the bootstrap result to
stdout. This follows hcsshim's readiness pattern where the shim
verifies its endpoint is ready before signaling the parent.

As a safety net, also parameterize makeConnection() with a dialer so
binary.Start() uses AnonDialer (retry) for new shims while loadShim()
keeps AnonReconnectDialer (fail-fast) for reconnects per #3659.

On Unix, awaitPipeReady() is a no-op: domain sockets appear atomically.

Signed-off-by: Esteban Ginez <esteban.ginez@docker.com>
2026-04-09 15:07:06 -07:00
Derek McGowan
a755ca16e5 Merge pull request #12865 from dmcgowan/readonly-overlay-erofs-no-mount
Support reading readonly overlays without mounting
2026-04-09 18:37:15 +00:00
Maksym Pavlenko
16b7ce2549 Address code review suggestions
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2026-04-08 08:29:28 -05:00
Maksym Pavlenko
45b7de2837 Limit amount of bytes read from stdin
Co-authored-by: Samuel Karp <me@samuelkarp.com>
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2026-04-08 08:29:28 -05:00
Maksym Pavlenko
3c0e8a55b6 Update comments wording about when to deprecate and remove the old path
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2026-04-08 08:29:28 -05:00
Maksym Pavlenko
9bf65dcf02 Use enums instead of strings for capabilities and log level
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2026-04-08 08:29:28 -05:00
Maksym Pavlenko
9dc864fd0f Switch to proto instead of json
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2026-04-08 08:29:28 -05:00
Maksym Pavlenko
73edc80451 Format code after cherry pick
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2026-04-08 08:29:28 -05:00
Derek McGowan
243cab594e Deprecate old pkg/shim interfaces
Signed-off-by: Derek McGowan <derek@mcg.dev>
2026-04-08 08:29:28 -05:00
Maksym Pavlenko
3fbdb132bf Fix module path
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2026-04-08 08:29:28 -05:00
Maksym Pavlenko
d957b1bf53 Use log level instead of debug flag
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2026-04-08 08:29:28 -05:00
Maksym Pavlenko
31d0bbbad7 Include containerd version when launching shim
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2026-04-08 08:29:28 -05:00
Maksym Pavlenko
f71c2e4211 Reformat and clean proto files
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2026-04-08 08:29:28 -05:00
Maksym Pavlenko
b7ef291edc Provide bootstrap params when launching shims
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2026-04-08 08:29:28 -05:00
Maksym Pavlenko
9e9a095feb Read spec annotations from file
Revert changes related to reading annotations in runc v2 shim,
because this requires a special path for runc shim. This complicates
migration to the new bootstrap API.

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2026-04-08 08:29:28 -05:00
Maksym Pavlenko
fa02acee20 Generate shim CLI flags under Command
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2026-04-08 08:29:28 -05:00
Maksym Pavlenko
fc8062f379 Rename CommandConfig field to better reflect their purpose
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2026-04-08 08:29:28 -05:00
Maksym Pavlenko
3831fc8063 Fix reading from stdin
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2026-04-08 08:29:28 -05:00
Maksym Pavlenko
5ea993b48d Pass runc options as a separate extension
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2026-04-08 08:29:28 -05:00
Maksym Pavlenko
7f39b2d933 Update shim to support new bootstrap api
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2026-04-08 08:29:28 -05:00
Derek McGowan
c61c4e8dab pkg/oci: update fs error handling to use errors.Is
The `os.IsNotExist` documentation is clear that it should only be used to
check the error returned from calls within the os package, calls via
`fs.FS` should use `errors.Is`.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2026-04-06 22:05:47 -07:00
Rob Murray
a5df2782d4 pkg/oci: remove darwin guards from user/group spec opts
Remove `runtime.GOOS == "darwin"` checks from WithUser,
WithAdditionalGIDs, and WithAppendAdditionalGroups. These guards
prevented supplementary group resolution when containerd runs on a
non-Linux host (e.g. macOS or Windows) that creates Linux containers.
The `s.Windows != nil` check for LCOW is retained.

Move user/group tests from spec_opts_linux_test.go to the new
cross-platform spec_opts_user_test.go so they run on all platforms.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2026-04-04 22:37:38 -07:00
Derek McGowan
f384d2eb6c pkg/oci: update OCI with user to try mount for Darwin
Signed-off-by: Derek McGowan <derek@mcg.dev>
2026-04-04 22:37:37 -07:00
Derek McGowan
c1eb9430af pkg/oci: update OCI spec generation to use fsview if available
Signed-off-by: Derek McGowan <derek@mcg.dev>
2026-04-04 22:37:37 -07:00
Maksym Pavlenko
c586bec957 Merge pull request #13036 from cpuguy83/fix_data_digest
content: use descriptor digest algorithm instead of assuming sha256
2026-04-05 01:39:30 +00:00
Maksym Pavlenko
43d906b6ff Merge pull request #13117 from HASidd/log-trace
tracing: add option to inject trace ID into logrus fields
2026-03-31 23:44:09 +00:00
Samuel Karp
b7a467e4f3 Merge pull request #12175 from smira/fix/hide-go-cmp
fix: hide `go-cmp` library from the non-test code path
2026-03-30 20:21:10 +00:00
Hasan Siddiqui
10c30fb74a tracing: add option to inject trace ID into logrus fields
Introduce functional options to NewLogrusHook to allow optional Trace ID
injection into log fields. This enables log-trace correlation via the
[debug] config without breaking existing external consumers of
pkg/tracing.

Signed-off-by: Hasan Siddiqui <hasiddiqui@google.com>
2026-03-24 21:51:27 +00:00
Akihiro Suda
8b1faadb06 Merge pull request #12960 from vvoland/shim-path-perm
pkg/shim: Fix NewSocket directory permissions
2026-03-18 00:35:47 +00:00
Sebastiaan van Stijn
73c96c54ed pkg: modernize: any
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-03-17 11:49:57 +01:00
Andrey Smirnov
ea945443ac fix: hide go-cmp library from the non-test code path
The `go-cmp` library has issues with Go deadcode elimination:

```
github.com/google/go-cmp/cmp/internal/value.appendTypeName reachable from:
         github.com/google/go-cmp/cmp.pathStep.String
         type:github.com/google/go-cmp/cmp.pathStep
         type:github.com/google/go-cmp/cmp.structField
         type:*github.com/google/go-cmp/cmp.structField
         type:github.com/google/go-cmp/cmp.StructField
         go:itab.github.com/google/go-cmp/cmp.StructField,github.com/google/go-cmp/cmp.PathStep
         github.com/google/go-cmp/cmp.Path.String
         type:github.com/google/go-cmp/cmp.Path
         type:github.com/google/go-cmp/cmp.state
         type:*github.com/google/go-cmp/cmp.state
         type:func(*github.com/google/go-cmp/cmp.state, reflect.Type, reflect.Value, reflect.Value) github.com/google/go-cmp/cmp.applicableOption
         type:github.com/google/go-cmp/cmp.Option
         github.com/google/go-cmp/cmp.flattenOptions
         github.com/google/go-cmp/cmp.normalizeOption
         github.com/google/go-cmp/cmp.FilterValues
         github.com/containerd/containerd/v2/pkg/protobuf.init
         github.com/containerd/containerd/v2/pkg/protobuf..inittask
         go:main.inittasks
```

The `pkg/protobuf` is imported unconditionally is
`github.com/containerd/containerd` Go module is imported via init tasks,
so there is no way e.g. to use containerd client without triggering this
import.

It seems that within containerd itself this function is only used from
tests, so hiding it this way allows to import `containerd/client` while
keeping deadcode elimination.

Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
2026-03-17 11:46:12 +04:00
Brian Goff
2a14c42545 pkg/oci: fix fake image digest computation in tests
newFakeImage used digest.NewDigestFromBytes which hex-encodes the raw
bytes rather than hashing them, producing a digest with an invalid
length. This was previously harmless since the embedded data path in
content.ReadBlob never matched, but now that the digest is validated
before use, the invalid digest causes an error.

Use digest.Canonical.FromBytes which correctly hashes the content.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2026-03-16 12:24:47 -07:00
Sebastiaan van Stijn
2fd5da21ed *: modernize: waitgroup
go install golang.org/x/tools/go/analysis/passes/modernize/cmd/modernize@latest
    modernize -waitgroup -fix ./...

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-03-15 18:24:15 +01:00