Commit Graph

13124 Commits

Author SHA1 Message Date
Akihiro Suda
a7333657af
Merge pull request #9228 from mxpv/cri
🪦 RIP legacy CRI
2023-10-13 08:43:41 +09:00
Akihiro Suda
9c367d09f1
Merge pull request #9223 from dmcgowan/config-migration-v1
Introduce top level config migration
2023-10-13 08:43:13 +09:00
Maksym Pavlenko
1b31993240 Rename sbserver to server
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-10-12 15:46:57 -07:00
Derek McGowan
4edc6c2d99
Add note about configuration versions in releases
Signed-off-by: Derek McGowan <derek@mcg.dev>
2023-10-12 14:52:44 -07:00
Maksym Pavlenko
c5c94dc86c Fix CRI tests panic on CI
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-10-12 14:35:27 -07:00
Maksym Pavlenko
a3c2c1e4da Clean shell scripts
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-10-12 10:30:46 -07:00
Maksym Pavlenko
fa1d3a9ccb Fix dependencies after remove
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-10-12 10:30:46 -07:00
Wei Fu
3742f7f0db idmapped: use pidfd to avoid pid reuse issue
It's followup for #5890.

The containerd-shim process depends on the mount package to init rootfs
for container. For the container enable user namespace, the mount
package needs to fork child process to get the brand-new user namespace.
However, there are two reapers in one process (described by the
following list) and there are race-condition cases.

1. mount package
2. sys.Reaper as global one which watch all the SIGCHLD.

=== [kill(2)][kill] the wrong process ===

Currently, we use pipe to ensure that child process is alive. However,
the pide file descriptor can be hold by other process, which the child
process cannot exit by self. We should use [kill(2)][kill] to ensure the
child process. But we might kill the wrong process if the child process
might be reaped by containerd-shim and the PID might be reused by other
process.

=== [waitid(2)][waitid] on the wrong child process ===

```
containerd-shim process:

Goroutine 1(GetUsernsFD):                   Goroutine 2(Reaper)

1. Ready to wait for child process X

                                            2. Received SIGCHLD from X

                                            3. Reaped the zombie child process X

                                            (X has been reused by other child process)

4. Wait on process X

The goroutine 1 will be stuck until the process X has been terminated.
```

=== open `/proc/X/ns/user` on the wrong child process ===

There is also pid-reused risk between opening `/proc/$pid/ns/user` and
writing `/proc/$pid/u[g]id_map`.

```
containerd-shim process:

Goroutine 1(GetUsernsFD):                   Goroutine 2(Reaper)

1. Fork child process X

2. Write /proc/X/uid_map,gid_map

                                            3. Received SIGCHLD from X

                                            4. Reaped the zombie child process X

                                            (X has been reused by other process)

5. Open /proc/X/ns/user file as usernsFD

The usernsFD links to the wrong X!!!
```

In order to fix the race-condition, we should use [CLONE_PIDFD][clone2] (Since
Linux v5.2).

When we fork child process `X`, the kernel will return a process file
descriptor `X_PIDFD` referencing to child process `X`. With the pidfd, we can
use [pidfd_send_signal(2)][pidfd_send_signal] (Since Linux v5.1)
to send signal(0) to ensure the child process `X` is alive. If the `X` has
terminated and its PID has been recycled for another process. The
pidfd_send_signal fails with the error ESRCH.

Therefore, we can open `/proc/X/{ns/user,uid_map,gid_map}` file
descriptors as first and then use pidfd_send_signal to check the process
is still alive. If so, we can ensure the file descriptors are valid and
reference to the child process `X`. Even if the `X` PID has been reused
after pidfd_send_signal call, the file descriptors are still valid.

```code
X, pidfd = clone2(CLONE_PIDFD)

usernsFD = open /proc/X/ns/user
uidmapFD = open /proc/X/uid_map
gidmapFD = open /proc/X/gid_map

pidfd_send_signal pidfd, signal(0)
  return err if no such process

== When we arrive here, we can ensure usernsFD/uidmapFD/gidmapFD are correct
== even if X has been reused after pidfd_send_signal call.

update uid/gid mapping by uidmapFD/gidmapFD
return usernsFD
```

And the [waitid(2)][waitid] also supports pidfd type (Since Linux 5.4).
We can use pidfd type waitid to ensure we are waiting for the correct
process. All the PID related race-condition issues can be resolved by
pidfd.

```bash
➜  mount git:(followup-idmapped) pwd
/home/fuwei/go/src/github.com/containerd/containerd/mount

➜  mount git:(followup-idmapped) sudo go test -test.root -run TestGetUsernsFD -count=1000 -failfast -p 100  ./...
PASS
ok      github.com/containerd/containerd/mount  3.446s
```

[kill]: <https://man7.org/linux/man-pages/man2/kill.2.html>
[clone2]: <https://man7.org/linux/man-pages/man2/clone.2.html>
[pidfd_send_signal]: <https://man7.org/linux/man-pages/man2/pidfd_send_signal.2.html>
[waitid]: <https://man7.org/linux/man-pages/man2/waitid.2.html>

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2023-10-13 00:56:55 +08:00
Maksym Pavlenko
2332b9ba10 Remove legacy CRI from CI
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-10-12 09:18:55 -07:00
Maksym Pavlenko
536abf1b35 Remove legacy CRI
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-10-12 09:18:45 -07:00
Maksym Pavlenko
33b1a833c6 Move CRI testing package out
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-10-12 09:18:20 -07:00
Maksym Pavlenko
016114ff6f Move bandwidth package out of CRI server
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-10-12 09:12:52 -07:00
Danny Canter
3c1e7ffb80 Integration: Alter TestContainerPids for Windows
The point of this test is to see that we successfully can get all of
the pids running in the container and they match the number expected,
but for Windows this concept is a bit different. Windows containers
essentially go through the usermode boot phase of the operating system,
and have quite a few processes and system services running outside of
the "init" process you specify. Because of this, there's not a great
way to say "there should only be N processes running" like we can ensure
for Linux. So, on Windows check that we're at least greater than one.

Signed-off-by: Danny Canter <danny@dcantah.dev>
2023-10-12 01:04:17 -07:00
Derek McGowan
8f013bb717
Add migration for older configuration versions
Signed-off-by: Derek McGowan <derek@mcg.dev>
2023-10-11 20:28:50 -07:00
Samuel Karp
420503072e
Merge pull request #9027 from akhilerm/fix-ctr-forbidden-characters 2023-10-11 17:29:55 -07:00
Derek McGowan
0f8b79b2af
Merge pull request #9221 from thaJeztah/update_golang_1.21.3
update to go1.21.3, go1.20.10
2023-10-11 14:47:09 -07:00
Sebastiaan van Stijn
313f514fdd
update to go1.21.3. gp1.20.10
go1.21.3 (released 2023-10-10) includes a security fix to the net/http package.
See the Go 1.21.3 milestone on our issue tracker for details:

https://github.com/golang/go/issues?q=milestone%3AGo1.21.3+label%3ACherryPickApproved

full diff: https://github.com/golang/go/compare/go1.21.2...go1.21.3

From the security mailing:

[security] Go 1.21.3 and Go 1.20.10 are released

Hello gophers,

We have just released Go versions 1.21.3 and 1.20.10, minor point releases.

These minor releases include 1 security fixes following the security policy:

- net/http: rapid stream resets can cause excessive work

  A malicious HTTP/2 client which rapidly creates requests and
  immediately resets them can cause excessive server resource consumption.
  While the total number of requests is bounded to the
  http2.Server.MaxConcurrentStreams setting, resetting an in-progress
  request allows the attacker to create a new request while the existing
  one is still executing.

  HTTP/2 servers now bound the number of simultaneously executing
  handler goroutines to the stream concurrency limit. New requests
  arriving when at the limit (which can only happen after the client
  has reset an existing, in-flight request) will be queued until a
  handler exits. If the request queue grows too large, the server
  will terminate the connection.

  This issue is also fixed in golang.org/x/net/http2 v0.17.0,
  for users manually configuring HTTP/2.

  The default stream concurrency limit is 250 streams (requests)
  per HTTP/2 connection. This value may be adjusted using the
  golang.org/x/net/http2 package; see the Server.MaxConcurrentStreams
  setting and the ConfigureServer function.

  This is CVE-2023-39325 and Go issue https://go.dev/issue/63417.
  This is also tracked by CVE-2023-44487.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-10-11 20:29:07 +02:00
Sebastiaan van Stijn
6b752b5362
update to go1.21.2, go1.20.9
go1.21.2 (released 2023-10-05) includes one security fixes to the cmd/go package,
as well as bug fixes to the compiler, the go command, the linker, the runtime,
and the runtime/metrics package. See the Go 1.21.2 milestone on our issue
tracker for details:

https://github.com/golang/go/issues?q=milestone%3AGo1.21.2+label%3ACherryPickApproved

full diff: https://github.com/golang/go/compare/go1.21.1...go1.21.2

From the security mailing:

[security] Go 1.21.2 and Go 1.20.9 are released

Hello gophers,

We have just released Go versions 1.21.2 and 1.20.9, minor point releases.

These minor releases include 1 security fixes following the security policy:

- cmd/go: line directives allows arbitrary execution during build

  "//line" directives can be used to bypass the restrictions on "//go:cgo_"
  directives, allowing blocked linker and compiler flags to be passed during
  compliation. This can result in unexpected execution of arbitrary code when
  running "go build". The line directive requires the absolute path of the file in
  which the directive lives, which makes exploting this issue significantly more
  complex.

  This is CVE-2023-39323 and Go issue https://go.dev/issue/63211.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-10-11 20:28:03 +02:00
Fu Wei
8db0d39c68
Merge pull request #9104 from cyyzero/fix-deadlock 2023-10-10 07:36:29 +08:00
rongfu.leng
8f3d1c9d9b add cpu-burst param to ctr command
Signed-off-by: rongfu.leng <rongfu.leng@daocloud.io>
2023-10-09 21:51:24 +08:00
Fu Wei
ecda3b88ce
Merge pull request #9177 from lengrongfu/fix/toml-version-upgrade-bug 2023-10-09 20:19:09 +08:00
rongfu.leng
3ddcd6120d add Duration type to compatible toml v1 version
Signed-off-by: rongfu.leng <rongfu.leng@daocloud.io>
2023-10-09 14:19:23 +08:00
Samuel Karp
b30e0163ac
Merge pull request #8934 from oss-qm/submit/go_build_flags
Makefile: allow overriding GO_BUILD_FLAGS via environment
2023-10-08 00:23:01 -07:00
Samuel Karp
841c693710
Merge pull request #9076 from CFSworks/fix-ipv6-pref
Fix `ip_pref` configuration option
2023-10-06 23:31:45 -07:00
Kazuyoshi Kato
40099ed56b
Merge pull request #9118 from CharityKathure/windows-default-path-overwrite-fix
Fix windows default path overwrite
2023-10-06 16:06:12 -07:00
kaz
535916d1d0 Skip exec.LookPath if a specific gzip implementation is disabled
Both pigz and igzip can be disabled via the environment variables.
If disabled, calling exec.LookPath and logging "not found" message is,
even in the debug level, doesn't make much sense.

Signed-off-by: Kazuyoshi Kato <kaz@fly.io>
2023-10-06 09:26:59 -07:00
Akhil Mohan
4b59d67dd4
add a new flag "skip-reference-check" to skip reference name check
Signed-off-by: Akhil Mohan <makhil@vmware.com>
2023-10-06 17:57:04 +05:30
Kazuyoshi Kato
34378ec9b4 Use Intel ISA-L's igzip if available
Intel ISA-L is Intel's open source (BSD) library that outperforms both
gzip and pigz. This commit checks and uses igzip if available.

Signed-off-by: Kazuyoshi Kato <kaz@fly.io>
2023-10-05 22:16:03 -07:00
Akihiro Suda
66aab638da
Merge pull request #8989 from dmcgowan/add-image-delete-target
Add image delete target
2023-10-05 10:53:57 -07:00
Akihiro Suda
e820a361fe
Merge pull request #9141 from dmcgowan/config-migration
Add support for plugin config migration
2023-10-05 10:51:34 -07:00
Charity Kathure
f73fe52667 Merge branch 'windows-default-path-overwrite-fix' of https://github.com/CharityKathure/containerd into windows-default-path-overwrite-fix 2023-10-05 10:10:14 +03:00
Charity Kathure
7d63690874 Fix windows default path overwrite issue
Windows Containers have a default path already configured at bootup. WithDefaultPathEnv overwrites this with a unix path

Signed-off-by: charitykathure <kathurecharity505@gmail.com>
2023-10-05 10:09:30 +03:00
Charity Kathure
13dcf558e9 Fix windows default path overwrite issue
Windows Containers have a default path already configured at bootup. WithDefaultPathEnv overwrites this with a unix path

Signed-off-by: charitykathure <kathurecharity505@gmail.com>
2023-10-04 23:10:46 +03:00
Phil Estes
3bb46b62c4
Merge pull request #9191 from ktock/compress-v1.17.0
go.mod: Bump up github.com/klauspost/compress v1.16.7 to v1.17.0
2023-10-04 08:52:49 -04:00
Fu Wei
bce8fe60df
Merge pull request #9183 from dcantah/cri-snapshotter-platform 2023-10-04 11:40:33 +08:00
Kohei Tokunaga
39478eeec4
go.mod: Bump up github.com/klauspost/compress v1.16.7 to v1.17.0
- release: https://github.com/klauspost/compress/releases/tag/v1.17.0
- diff: https://github.com/klauspost/compress/compare/v1.16.7...v1.17.0

Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
2023-10-04 10:01:50 +09:00
Derek McGowan
5b097a0817
Merge pull request #9187 from vvoland/remotes-docker-mounted-fix
remotes/docker: Fix MountedFrom prefixed with target repository
2023-10-03 09:33:35 -07:00
Derek McGowan
59134b5b3a
Merge pull request #8924 from polarathene/fix/use-implicit-nofile-limit
fix: Remove `LimitNOFILE` from `containerd.service`
2023-10-03 09:08:32 -07:00
Phil Estes
cffe399e89
Merge pull request #9184 from Kern--/xnet013
Bump x/net to 0.13
2023-10-03 10:41:57 -04:00
Phil Estes
3a154647d3
Merge pull request #9186 from ktock/golangci-lint-v1.54.2
Bump up golangci-lint to v1.54.2
2023-10-03 10:41:41 -04:00
Phil Estes
399c9d8326
Merge pull request #8861 from jedevc/docker-resolver-relevant-error
docker: return most relevant error from docker resolution
2023-10-03 10:40:52 -04:00
Paweł Gronowski
859c2651e5
remotes/docker: Fix MountedFrom prefixed with target repository
`MountedFrom` was prefixed with the whole target repository instead of
just the registry hostname.

Also adjust the test cases to use the registry hostname.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-10-03 16:40:10 +02:00
Derek McGowan
e8770b1716
Merge pull request #9155 from neersighted/image_cleanup_2
Use mediatype helpers in more places
2023-10-03 07:11:12 -07:00
Kohei Tokunaga
c85b1d1e4e
Bump up golangci-lint to v1.54.2
Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
2023-10-03 21:57:07 +09:00
Kohei Tokunaga
6169433b6b
Fix linter issues for golangci-lint 1.54.2
Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
2023-10-03 21:56:47 +09:00
Danny Canter
e3cb7471a6 CRI: Snapshotter per runtime handler adjustments
Pass the passed in context into some nested function calls, wrap
errors instead of %+v, and change some tests to strictly just test
for an error and not an exact error.

Signed-off-by: Danny Canter <danny@dcantah.dev>
2023-10-03 02:05:34 -07:00
Fu Wei
28fa2751f2
Merge pull request #9182 from dmcgowan/localhost-http-fallback
remotes: always try to establish tls connection when tls configured
2023-10-03 16:11:48 +08:00
Kern Walster
42dc8faba8 Bump x/net to 0.13
This silences govulncheck detecting
https://pkg.go.dev/vuln/GO-2023-1988.

containerd does not directly use x/net

Signed-off-by: Kern Walster <walster@amazon.com>
2023-10-03 04:41:35 +00:00
Derek McGowan
79772a0dd4
remotes: always try to establish tls connection when tls configured
When a endpoint is configured for http and has a tls configuration,
always try to the tls connection and fallback to http when the tls
connections fails from receiving an http response. This fixes an issue
with default localhost endpoints which get defaulted to http with
insecure tls also configured but are using tls.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2023-10-02 15:29:11 -07:00
Phil Estes
e1655fe915
Merge pull request #9179 from henry118/test-assertion
Fix some assertions for integ tests
2023-10-02 14:51:12 -04:00