Commit Graph

13325 Commits

Author SHA1 Message Date
Fu Wei
6d8248b6e6
Merge pull request #8581 from thaJeztah/bump_zfs
vendor: github.com/containerd/zfs v1.1.0
2023-07-06 22:12:14 +08:00
Rodrigo Campos
c17d3bdb54 pkg/cri/server: Test net.ipv4.ping_group_range works with userns
Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2023-07-06 14:20:26 +02:00
Rodrigo Campos
9bf5aeca77 pkg/cri/server: Fix net.ipv4.ping_group_range with userns
userns.RunningInUserNS() checks if the code calling that function is
running inside a user namespace. But we need to check if the container
we will create will use a user namespace, in that case we need to
disable the sysctl too (or we would need to take the userns mapping into
account to set the IDs).

This was added in PR:
        https://github.com/containerd/containerd/pull/6170/

And the param documentation says it is not enabled when user namespaces
are in use:
        https://github.com/containerd/containerd/pull/6170/files#diff-91d0a4c61f6d3523b5a19717d1b40b5fffd7e392d8fe22aed7c905fe195b8902R118

I'm not sure if the intention was to disable this if containerd is
running inside a userns (rootless, if that is even supported) or just
when the pod has user namespaces.

Out of an abundance of caution, I'm keeping the userns.RunningInUserNS()
so it is still not used if containerd runs inside a user namespace.

With this patch and "enable_unprivileged_icmp = true" in the config,
running containerd as root on the host, pods with user namespaces start
just fine. Without this patch they fail with:
        ... failed to create containerd task: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: w
 /proc/sys/net/ipv4/ping_group_range: invalid argument: unknown

Thanks a lot to Andy on the k8s slack for reporting the issue. He also
mentions he hits this with k3s on a default installation (the param
is off by default on containerd, but k3s turns that on by default it
seems). He also debugged which part of the stack was setting that
sysctl, found the PR that added this code in containerd and a workaround
(to turn the bool off).

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2023-07-06 14:20:26 +02:00
Sebastiaan van Stijn
05fef52b68
vendor: github.com/containerd/zfs v1.1.0
- update github.com/mistifyio/go-zfs dependency to github.com/mistifyio/go-zfs/v3,
  which contains various bugfixes, and adds go module support (which required a major
  version update): https://github.com/mistifyio/go-zfs/compare/f784269be439...v3.0.1
- remove github.com/pkg/errors dependency
- various minor cleanups/fixes

Full diff: https://github.com/containerd/zfs/compare/v1.0.0...v1.1.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-06 11:56:07 +02:00
Kay Yan
073de93086 Fix the auto restart fail when using LogURI and TTY together
Signed-off-by: Kay Yan <kay.yan@daocloud.io>
2023-07-06 04:58:56 +00:00
Iceber Gu
00e5ae2118 shim: change ttrpcService and ttrpcServerOptioner to exported interfaces
Signed-off-by: Iceber Gu <wei.cai-nat@daocloud.io>
2023-07-06 00:36:43 +08:00
Kazuyoshi Kato
d5ec7286ae
Merge pull request #8714 from thaJeztah/update_go_1.20.5
update go to go1.20.5, go1.19.10
2023-07-05 06:39:54 -07:00
Kazuyoshi Kato
6c041c69f8
Merge pull request #8746 from slonopotamus/fix-example-shim
Fix example shim to actually use its task service
2023-07-05 06:38:59 -07:00
Fu Wei
e7276fe35a
Merge pull request #8744 from cardyok/bugfix_remote_fetch_mediatype 2023-07-04 21:58:35 +08:00
Sebastiaan van Stijn
e9f63f64f5
update go to go1.20.5, go1.19.10
go1.20.5 (released 2023-06-06) includes four security fixes to the cmd/go and
runtime packages, as well as bug fixes to the compiler, the go command, the
runtime, and the crypto/rsa, net, and os packages. See the Go 1.20.5 milestone
on our issue tracker for details:

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

full diff: https://github.com/golang/go/compare/go1.20.4...go1.20.5

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

- cmd/go: cgo code injection
  The go command may generate unexpected code at build time when using cgo. This
  may result in unexpected behavior when running a go program which uses cgo.

  This may occur when running an untrusted module which contains directories with
  newline characters in their names. Modules which are retrieved using the go command,
  i.e. via "go get", are not affected (modules retrieved using GOPATH-mode, i.e.
  GO111MODULE=off, may be affected).

  Thanks to Juho Nurminen of Mattermost for reporting this issue.

  This is CVE-2023-29402 and Go issue https://go.dev/issue/60167.

- runtime: unexpected behavior of setuid/setgid binaries

  The Go runtime didn't act any differently when a binary had the setuid/setgid
  bit set. On Unix platforms, if a setuid/setgid binary was executed with standard
  I/O file descriptors closed, opening any files could result in unexpected
  content being read/written with elevated prilieges. Similarly if a setuid/setgid
  program was terminated, either via panic or signal, it could leak the contents
  of its registers.

  Thanks to Vincent Dehors from Synacktiv for reporting this issue.

  This is CVE-2023-29403 and Go issue https://go.dev/issue/60272.

- cmd/go: improper sanitization of LDFLAGS

  The go command may execute arbitrary code at build time when using cgo. This may
  occur when running "go get" on a malicious module, or when running any other
  command which builds untrusted code. This is can by triggered by linker flags,
  specified via a "#cgo LDFLAGS" directive.

  Thanks to Juho Nurminen of Mattermost for reporting this issue.

  This is CVE-2023-29404 and CVE-2023-29405 and Go issues https://go.dev/issue/60305 and https://go.dev/issue/60306.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-04 11:03:38 +02:00
Fu Wei
fec3191abc
Merge pull request #8755 from dcantah/withbytesbuffers-chg
integration/client: Rework withBytesBuffers
2023-07-04 10:04:10 +08:00
Danny Canter
22a7c63c07 Sandbox: Change to mount.Mount for CreateOptions
We'd wanted to swap to mount.Mount after target was introduced. That
time is now :)

Signed-off-by: Danny Canter <danny@dcantah.dev>
2023-07-03 11:14:19 -07:00
Kazuyoshi Kato
099d2e7c76
Merge pull request #8757 from dcantah/proto-api-conversions
Add From/ToProto helpers
2023-07-03 10:59:08 -07:00
Marat Radchenko
51a1e7f0b2 Fix example shim to actually use its task service
In commit 4b35c3829d, example shim erroneously started to depend on runc, fix that back.

Also, build example shim on all supported platforms to prevent such situations in the future.

Signed-off-by: Marat Radchenko <marat@slonopotamus.org>
2023-07-03 20:40:20 +03:00
Phil Estes
330273d236
Merge pull request #8763 from slonopotamus/GetTopic
Move GetTopic function out of runc shim
2023-07-03 09:39:00 -04:00
Derek McGowan
d89882ae92
Merge pull request #8768 from akhilerm/fix-nightly 2023-07-03 00:19:43 -07:00
Akhil Mohan
a9cb6090e2
ci: remove libseccomp-dev installation for nightly
since libseccomp is required only for building runc and we are only
building containerd binaries in nightly, the libseccomp-dev dependency
is removed. Foreign arch repositories are now removed since
crossbuild-essential-* packages are {arm64, ppc64el,..} cross compiler
packages for amd64 and arch specific repositories are not required.

Signed-off-by: Akhil Mohan <akhilerm@gmail.com>
2023-07-01 09:43:09 +05:30
Marat Radchenko
0607e73263 Move GetTopic function out of runc shim
Every shim implementation needs to select a correct publisher topic when posting events, so move it out of Linux-only runc code to the place where other shims can also use it

Otherwise, shims have to copy-paste this code. For example, see runj: 8158e558a3/containerd/shim.go (L144-L172)

Signed-off-by: Marat Radchenko <marat@slonopotamus.org>
2023-06-30 10:29:21 +03:00
Derek McGowan
5d1ab0129e
Merge pull request #8764 from AkihiroSuda/zero-whiteout-timestamp 2023-06-29 21:51:26 -07:00
Akihiro Suda
5dedb6d0d2
archive: use 1970-01-01 as the whiteout timestamp
The whiteout timestamps are no longer set to the source date epoch.
The source date epoch still applies to non-whiteout files.

Discussion happened in moby/buildkit PR 3560.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2023-06-30 11:30:01 +09:00
Akihiro Suda
a542a57b2e
Merge pull request #8762 from dcantah/upgrade-cgroups-3.0.2
go.mod: Update cgroups to 3.0.2
2023-06-30 09:26:45 +09:00
Danny Canter
d6dbc4040b go.mod: Update cgroups to 3.0.2
This brings in a ton of great improvements, most notably for the containerd
daemon is performance improvements for cgroups1 and 2 for gathering stats,
as well as some fixes for enabling controllers and deleting v1 cgroups.

Signed-off-by: Danny Canter <danny@dcantah.dev>
2023-06-29 12:14:59 -07:00
Danny Canter
f3b7436b61 Platforms: Add From/ToProto helpers for types
Helpers to convert from a slice of platforms to our protobuf representation
and vice-versa appear a couple times. It seems sane to just expose this facility
in the platforms pkg.

Signed-off-by: Danny Canter <danny@dcantah.dev>
2023-06-28 19:54:56 -07:00
Danny Canter
b3ab1f26c4 Snapshots: Add From/ToProto helpers for types
Helpers to convert from snapshot types to their protobuf structures and
vice-versa appear three times. It seems sane to just expose this facility
in the snapshots pkg. From/ToKind weren't used anywhere but doesn't hurt to
round out the types by exposing them.

Signed-off-by: Danny Canter <danny@dcantah.dev>
2023-06-28 12:17:52 -07:00
Danny Canter
0a6b8f0ee0 OCI: Add From/ToProto helpers for Descriptor
Helpers to convert from the OCI image specs [Descriptor] to its protobuf
structure for Descriptor and vice-versa appear three times. It seems sane
to just expose this facility in /oci.

Signed-off-by: Danny Canter <danny@dcantah.dev>
2023-06-28 12:16:20 -07:00
Kazuyoshi Kato
81bc6ce6e9
Merge pull request #8740 from djdongjin/platform-parseall
Add a platform.ParseAll helper
2023-06-28 08:01:12 -07:00
Kazuyoshi Kato
5d4504c196
Merge pull request #8758 from djdongjin/ginkgo
Update ginkgo to match cri-tools' version
2023-06-28 07:58:34 -07:00
Kazuyoshi Kato
a3c9ed7092
Merge pull request #8752 from neersighted/name_to_handle_at
seccomp: always allow name_to_handle_at
2023-06-28 07:58:07 -07:00
Jin Dong
4df27fd774 Update ginkgo to match cri-tools' version
Signed-off-by: Jin Dong <djdongjin95@gmail.com>
2023-06-28 13:14:22 +00:00
Bjorn Neergaard
9a202e342b
seccomp: always allow name_to_handle_at
This syscall is used by systemd to request unique internal names for
paths in the cgroup hierarchy from the kernel, and is overall innocuous.

Due to [previous][1] [mistakes][2] in moby/moby, it ended up attached to
`CAP_SYS_ADMIN`; however, it should not be filtered at all.

An in-depth analysis is available [at moby/moby][3].

  [1]: a01c4dc8f8 (diff-6c0d906dbef148d2060ed71a7461907e5601fea78866e4183835c60e5d2ff01aR1627-R1639)
  [2]: c1ca124682
  [3]: https://github.com/moby/moby/pull/45766#pullrequestreview-1493908145

Co-authored-by: Vitor Anjos <bartier@users.noreply.github.com>
Signed-off-by: Bjorn Neergaard <bjorn.neergaard@docker.com>
2023-06-28 05:50:24 -06:00
Danny Canter
55a8102ec1 mount: Add From/ToProto helpers
Helpers to convert from containerd's [Mount] to its protobuf structure for
[Mount] and vice-versa appear three times. It seems sane to just expose
this facility in /mount.

Signed-off-by: Danny Canter <danny@dcantah.dev>
2023-06-28 04:03:18 -07:00
Danny Canter
e85352183e integration/client: Rework withBytesBuffers
All of the tests using this didn't need stdin/err (one of them not even
stdout), so we can just leave them "empty" and change to a withStdout
naming to make it more obvious.

Signed-off-by: Danny Canter <danny@dcantah.dev>
2023-06-27 23:47:14 -07:00
Jin Dong
54a93c6c52 Make ptypes.Empty a var in contentserver
Signed-off-by: Jin Dong <djdongjin95@gmail.com>
2023-06-27 11:32:59 +00:00
Jin Dong
cdc90c8381 Remove duplicated code in content Copy
Signed-off-by: Jin Dong <djdongjin95@gmail.com>
2023-06-27 11:32:59 +00:00
Cardy.Tang
50376ec9ff remotes: allow FetchByDigest client to pass mediatype as header
accept mediatype header is required for some layers, add additional field for client.

Signed-off-by: Cardy.Tang <zuniorone@gmail.com>
2023-06-27 16:36:01 +08:00
Jin Dong
0a92661e69 Add a platform.ParseAll helper
Signed-off-by: Jin Dong <djdongjin95@gmail.com>
2023-06-26 20:34:37 +00:00
Kazuyoshi Kato
9b4ed8acc2
Merge pull request #8696 from fuweid/deflaky-blockfile
chore: deflake the blockfile testsuite
2023-06-26 09:54:33 -07:00
Fu Wei
b6abda73b8
Merge pull request #8728 from dcantah/rm-hcsshim-todo
Makefile: Remove hcsshim related TODO
2023-06-25 15:18:36 +08:00
Fu Wei
43ae9c26b8
Merge pull request #8729 from dcantah/integration-empty-windows
Integration: Align empty IO func on Windows
2023-06-25 15:17:23 +08:00
Fu Wei
e350c8ca94
Merge pull request #8711 from djdongjin/sb-metadata
Minor changes to sandbox metadata
2023-06-25 15:16:43 +08:00
Fu Wei
ef61125871
Merge pull request #8719 from alexcb/log-expired-leases
log when a lease expires
2023-06-25 14:09:04 +08:00
Phil Estes
1a5eaa9ad0
Merge pull request #8732 from thaJeztah/epoch_export_parse
pkg/epoch: extract parsing SOURCE_DATE_EPOCH to a function
2023-06-23 17:06:21 -04:00
Phil Estes
753e6d2f8e
Merge pull request #8731 from dcantah/rm-windows-file-todo
Reword Windows file related TODO
2023-06-23 16:59:27 -04:00
helen
e89d7204eb MergeStringSlices use sets
Signed-off-by: helen <haitao.zhang@daocloud.io>
2023-06-24 03:04:24 +08:00
Sebastiaan van Stijn
8760b87174
pkg/epoch: extract parsing SOURCE_DATE_EPOCH to a function
This introduces a ParseSourceDateEpoch function, which can be used
to parse "SOURCE_DATE_EPOCH" values for situations where those
values are not passed through an env-var (or the env-var has been
read through other means).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-06-23 17:32:02 +02:00
Sebastiaan van Stijn
9924e56f42
pkg/epoch: fix tests on macOS
These tests were failing on my macOS; could be the precision issue (like on
Windows), or just because they're "too fast".

    === RUN   TestSourceDateEpoch/WithoutSourceDateEpoch
        epoch_test.go:51:
                Error Trace:	/Users/thajeztah/go/src/github.com/containerd/containerd/pkg/epoch/epoch_test.go:51
                Error:      	Should be true
                Test:       	TestSourceDateEpoch/WithoutSourceDateEpoch
                Messages:   	now: 2023-06-23 11:47:09.93118 +0000 UTC, v: 2023-06-23 11:47:09.93118 +0000 UTC

This patch:

- updates the rightAfter utility to allow the timestamps to be "equal"
- updates the asserts to provide some details about the timestamps
- uses UTC for the value we're comparing to, to match the timestamps
  that are generated.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-06-23 17:29:55 +02:00
Danny Canter
dfd7ad8b37 Reword Windows file related TODO
https://github.com/golang/go/issues/32088 was never accepted or implemented
in 1.14.

Signed-off-by: Danny Canter <danny@dcantah.dev>
2023-06-23 05:42:44 -07:00
Sebastiaan van Stijn
44e2b26a87
pkg/epoch: replace some fmt.Sprintfs with strconv
Teeny-tiny optimizations:

    BenchmarkSprintf-10       37735996    32.31  ns/op  0 B/op  0 allocs/op
    BenchmarkItoa-10         591945836     2.031 ns/op  0 B/op  0 allocs/op
    BenchmarkFormatUint-10   593701444     2.014 ns/op  0 B/op  0 allocs/op

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-06-23 13:10:58 +02:00
Danny Canter
f82d9b7991 Integration: Align empty IO func on Windows
I think NullIO is fine on Windows now. We have it as an option in ctr
and it's used for the pod sandbox container in CRI. Lets see if CI agrees..

Signed-off-by: Danny Canter <danny@dcantah.dev>
2023-06-22 20:05:34 -07:00
Phil Estes
13498a3258
Merge pull request #8726 from djdongjin/write-content
Remove duplicated `writeIndex` func
2023-06-22 21:33:22 -04:00