Commit Graph

12660 Commits

Author SHA1 Message Date
Phil Estes
a94918b591
Merge pull request #8803 from kinvolk/rata/userns-sbserver
cri/sbserver: Add support for user namespaces (KEP-127)
2023-07-17 10:57:01 -04:00
Phil Estes
4c538164e6
Merge pull request #8818 from thaJeztah/use_registry.k8s.io
pkg/cri/server: TestImageGetLabels: use registry.k8s.io
2023-07-14 09:45:54 -04:00
Sebastiaan van Stijn
9c673f9673
pkg/cri/server: TestImageGetLabels: use registry.k8s.io
These are not actually being pulled, just removing the deprecated k8s.gcr.io
from the code-base. While at it, also renamed / removed vars that shadowed
with package-level definitions

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-14 11:22:39 +02:00
Mike Brown
3ed1bc108f
Merge pull request #8671 from jsturtevant/fix-windows-edge-cases
[cri] Handle pod transition states gracefully while listing pod stats
2023-07-12 15:43:21 -05:00
James Sturtevant
f914edf4f6
[cri] Handle Windows pod transitions gracefully
When the pods are transitioning there are several
cases where containers might not be in valid state.
There were several cases where the stats where
failing hard but we should just continue on as
they are transient and will be picked up again
when kubelet queries for the stats again.

Signed-off-by: James Sturtevant <jstur@microsoft.com>

Signed-off-by: Mark Rossetti <marosset@microsoft.com>
2023-07-12 09:57:14 -07:00
Phil Estes
0098eacf93
Merge pull request #8804 from dcantah/go-bump-1.20.6
Update Go to 1.20.6,1.19.11
2023-07-12 09:56:53 -04:00
Fu Wei
8f89bd7be3
Merge pull request #8723 from djdongjin/dedup-WithNewSnapshot 2023-07-12 09:36:36 +08:00
Danny Canter
52ef3468bc Update Go to 1.20.6,1.19.11
go1.20.6 (released 2023-07-11) includes a security fix to the net/http
package, as well as bug fixes to the compiler, cgo, the cover tool, the
go command, the runtime, and the crypto/ecdsa, go/build, go/printer,
net/mail, and text/template packages. See the Go 1.20.6 milestone on
our issue tracker for details.

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

Full diff: https://github.com/golang/go/compare/go1.20.5...go1.20.6

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

- net/http: insufficient sanitization of Host header

The HTTP/1 client did not fully validate the contents of the Host header.
A maliciously crafted Host header could inject additional headers or
entire requests. The HTTP/1 client now refuses to send requests containing
an invalid Request.Host or Request.URL.Host value.

Thanks to Bartek Nowotarski for reporting this issue.

Includes security fixes for CVE-2023-29406 and Go issue https://go.dev/issue/60374

Signed-off-by: Danny Canter <danny@dcantah.dev>
2023-07-11 14:34:23 -07:00
Phil Estes
0789790f07
Merge pull request #8418 from sxllwx/fix/k8s-issue-74551
bugfix(port-forward): Correctly handle known errors
2023-07-11 10:02:56 -04:00
Phil Estes
34b1653e95
Merge pull request #8780 from slonopotamus/uncopypaste-read-spec
Uncopypaste parsing of OCI Bundle spec file
2023-07-11 09:53:00 -04:00
Rodrigo Campos
48cdf1fe2c integration: Enable userns tests for sbserver
Now we ported support to sbserver, let's enable the e2e tests there too.

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2023-07-11 15:15:25 +02:00
Rodrigo Campos
9160386ecc cri/sbserver: Test net.ipv4.ping_group_range works with userns
Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2023-07-11 15:15:25 +02:00
Rodrigo Campos
1c6e268447 cri/sbserver: Fix net.ipv4.ping_group_range with userns
This commit just updates the sbserver with the same fix we did on main:
	9bf5aeca77 ("cri: Fix net.ipv4.ping_group_range with userns ")

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2023-07-11 15:15:25 +02:00
Rodrigo Campos
36a96d7f32 cri/sbserver: Remap snapshots for sbserver too
This is a port of 31a6449734 ("Add capability for snapshotters to
declare support for UID remapping") to sbserver.

This patch remaps the rootfs in the platform-specific if user namespaces
are in use, so the pod can read/write to the rootfs.

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2023-07-11 15:15:22 +02:00
Rodrigo Campos
508e6f6e03 cri/sbserver: Add userns tests to TestLinuxSandboxContainerSpec()
Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2023-07-11 15:14:42 +02:00
Rodrigo Campos
fb9ce5d482 cri/sbserver: Support pods with user namespaces
This patch requests the OCI runtime to create a userns when the CRI
message includes such request.

This is an adaptation of a7adeb6976 ("cri: Support pods with user
namespaces") to sbserver, although the container_create.go parts were
already ported as part of 40be96efa9 ("Have separate spec builder for
each platform"),

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2023-07-11 15:14:42 +02:00
Rodrigo Campos
c99cb95f07 cri/sbserver: Let OCI runtime create netns when userns is used
This commit just ports 36f520dc04 ("Let OCI runtime create netns when
userns is used") to sbserver.

The CNI network setup is done after OCI start, as it didn't seem simple
to get the sandbox PID we need for the netns otherwise.

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2023-07-11 15:14:42 +02:00
Rodrigo Campos
73c75e2c73 cri/sbserver: Copy userns helpers to podsandbox
Currently there is a big c&p of the helpers between these two folders
and a TODO in the platform agnostic file to organize them in the future,
when some other things settle.

So, let's just copy them for now.

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2023-07-11 15:14:12 +02:00
Rodrigo Campos
0b6a0fe773 cri/sbserver: Move runtimeStart to match position with cri/server
Commit c085fac1e5 ("Move sandbox start behind controller") moved the
runtimeStart to only account for time _after_ the netns has been
created.

To match what we currently do in cri/server, let's move it to just after
the get the sandbox runtime.

This come up when porting userns to sbserver, as the CNI network setup
needs to be done at a later stage and runtimeStart was accounting for
the CNI network setup time only when userns is enabled.

To avoid that discrepancy, let's just move it earlier, that also matches
what we do in cri/server.

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2023-07-11 13:58:45 +02:00
Rodrigo Campos
90087ac44f WithRemapperLabels: Update doc to mention overlay supports it
Since we merged support for userns in:
	https://github.com/containerd/containerd/pull/7679

overlay has been doing a chown for the rootfs using WithRemapperLabels.

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2023-07-11 13:58:45 +02:00
Rodrigo Campos
9d9903565a cri: Fix comment typos
Beside the "in future the when" typo, we take the chance to reflect that
user namespaces are already merged.

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2023-07-11 13:58:45 +02:00
Marat Radchenko
9e34b8b441 Uncopypaste parsing of OCI Bundle spec file
Signed-off-by: Marat Radchenko <marat@slonopotamus.org>
2023-07-11 14:41:15 +03:00
wangxiang
232538b768 bugfix(port-forward): Correctly handle known errors
These two errors can occur in the following scenarios:

ECONNRESET: the target process reset connection between CRI and itself.
see: #111825 for detail

EPIPE: the target process did not read the received data, causing the
buffer in the kernel to be full, resulting in the occurrence of Zero Window,
then closing the connection (FIN, RESET)
see: #74551 for detail

In both cases, we should RESET the httpStream.

Signed-off-by: wangxiang <scottwangsxll@gmail.com>
2023-07-11 11:06:13 +08:00
Kazuyoshi Kato
f1d2868785
Merge pull request #8798 from Jenkins-J/blockfile-test-fix-rebase
Modify loopback size
2023-07-10 13:46:38 -07:00
Phil Estes
97f2e3bc03
Merge pull request #8748 from djdongjin/cri-header-race
Resolve docker.NewResolver race condition
2023-07-10 11:12:05 -04:00
James Jenkins
5c480d9c88 Modify loopback size
Modify the loopback size in the blockfile snapshotter test setup.
Set the loopback size to 16MB when the page size is greater than 4096.

Signed-off-by: James Jenkins <James.Jenkins@ibm.com>
2023-07-10 11:06:24 -04:00
Phil Estes
2c73bce378
Merge pull request #8795 from dcantah/retried-typo
Fix mount pkg typo
2023-07-10 09:16:14 -04:00
Danny Canter
7ef133ad47 Fix mount pkg typo
retired -> retried

Signed-off-by: Danny Canter <danny@dcantah.dev>
2023-07-10 01:45:17 -07:00
Fu Wei
9afa2256f1
Merge pull request #8776 from thaJeztah/vagrant_locking
Cirrus CI: configure apt-get to wait for locks
2023-07-09 17:17:56 +08:00
Jin Dong
83ff030e4f Change http.Header copy to builtin Clone
Signed-off-by: Jin Dong <djdongjin95@gmail.com>
2023-07-08 05:25:47 -07:00
Jin Dong
cdb153ec92 Resolve docker.NewResolver race condition
Signed-off-by: Jin Dong <djdongjin95@gmail.com>
2023-07-08 05:25:47 -07:00
Jin Dong
01a6e1c730 Dedup WithNewSnapshotView
Signed-off-by: Jin Dong <djdongjin95@gmail.com>
2023-07-08 05:24:04 -07:00
Sebastiaan van Stijn
6a913ac82e
Cirrus CI: configure apt-get to wait for locks
I saw Cirrus CI / Vagrant BOX:rockylinux/8@5.0.0 failing during setting
up Vagrant, which may be due to other scripts provisioning the machine;

    Reading package lists...
    apt-get install -y libvirt-daemon libvirt-daemon-system vagrant vagrant-libvirt
    E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 2496 (apt-get)
    E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?

Configure dpkg to wait for locks to be released instead of failing. I used
60 second as timeout, which is relatively long, but given that the Vagrant
checks are known to take some time to run, is probably fine.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-07 09:06:03 +02:00
rongfu.leng
38f9bc3e0a fix ci Linux Integration test fail
Signed-off-by: rongfu.leng <rongfu.leng@daocloud.io>
2023-07-07 14:51:04 +08:00
Phil Estes
3c250cb508
Merge pull request #8779 from kinvolk/rata/userns-fixes
Fix net.ipv4.ping_group_range with userns
2023-07-06 15:17:12 -04:00
Maksym Pavlenko
8c857748d9
Merge pull request #8775 from dcantah/sb-change-mount
Sandbox: Change to mount.Mount for CreateOptions
2023-07-06 09:30:06 -07:00
Phil Estes
466d884518
Merge pull request #8777 from yankay/fix-restart-with-tty
Fix the automatically restart issue when using LogURI and Terminal together
2023-07-06 10:51:11 -04:00
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