Skip to content

Commit c5d244f

Browse files
authored
[2.0] Upgrade cri-o to v1.22.3 to resolve regressed CVE-2022-0811 (#9191)
Co-authored-by: Henry Li <lihl@microsoft.com>
1 parent a7e75e1 commit c5d244f

11 files changed

Lines changed: 98 additions & 338 deletions

SPECS/cri-o/CVE-2021-3602.patch

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,3 @@
1-
From 8716daa06e9eb421438b338f18b6b650b082b208 Mon Sep 17 00:00:00 2001
2-
From: Cameron Baird <cameronbaird@microsoft.com>
3-
Date: Tue, 16 Apr 2024 22:33:46 +0000
4-
Subject: [PATCH 4/4] CVE-2021-3602
5-
6-
---
7-
.../github.com/containers/buildah/chroot/run.go | 15 +++++----------
8-
.../podman/v3/pkg/specgen/generate/security.go | 7 +++++--
9-
2 files changed, 10 insertions(+), 12 deletions(-)
10-
11-
diff --git a/vendor/github.com/containers/buildah/chroot/run.go b/vendor/github.com/containers/buildah/chroot/run.go
12-
index a93f97dcd..643f5c91d 100644
13-
--- a/vendor/github.com/containers/buildah/chroot/run.go
14-
+++ b/vendor/github.com/containers/buildah/chroot/run.go
15-
@@ -160,7 +160,7 @@ func RunUsingChroot(spec *specs.Spec, bundlePath, homeDir string, stdin io.Reade
16-
cmd := unshare.Command(runUsingChrootCommand)
17-
cmd.Stdin, cmd.Stdout, cmd.Stderr = stdin, stdout, stderr
18-
cmd.Dir = "/"
19-
- cmd.Env = append([]string{fmt.Sprintf("LOGLEVEL=%d", logrus.GetLevel())}, os.Environ()...)
20-
+ cmd.Env = []string{fmt.Sprintf("LOGLEVEL=%d", logrus.GetLevel())}
21-
22-
logrus.Debugf("Running %#v in %#v", cmd.Cmd, cmd)
23-
confwg.Add(1)
24-
@@ -206,7 +206,7 @@ func runUsingChrootMain() {
25-
os.Exit(1)
26-
}
27-
28-
- if options.Spec == nil {
29-
+ if options.Spec == nil || options.Spec.Process == nil {
30-
fmt.Fprintf(os.Stderr, "invalid options spec in runUsingChrootMain\n")
31-
os.Exit(1)
32-
}
33-
@@ -572,7 +572,7 @@ func runUsingChroot(spec *specs.Spec, bundlePath string, ctty *os.File, stdin io
34-
cmd := unshare.Command(append([]string{runUsingChrootExecCommand}, spec.Process.Args...)...)
35-
cmd.Stdin, cmd.Stdout, cmd.Stderr = stdin, stdout, stderr
36-
cmd.Dir = "/"
37-
- cmd.Env = append([]string{fmt.Sprintf("LOGLEVEL=%d", logrus.GetLevel())}, os.Environ()...)
38-
+ cmd.Env = []string{fmt.Sprintf("LOGLEVEL=%d", logrus.GetLevel())}
39-
cmd.UnshareFlags = syscall.CLONE_NEWUTS | syscall.CLONE_NEWNS
40-
requestedUserNS := false
41-
for _, ns := range spec.Linux.Namespaces {
42-
@@ -662,7 +662,7 @@ func runUsingChrootExecMain() {
43-
// Set the hostname. We're already in a distinct UTS namespace and are admins in the user
44-
// namespace which created it, so we shouldn't get a permissions error, but seccomp policy
45-
// might deny our attempt to call sethostname() anyway, so log a debug message for that.
46-
- if options.Spec == nil {
47-
+ if options.Spec == nil || options.Spec.Process == nil {
48-
fmt.Fprintf(os.Stderr, "invalid options spec passed in\n")
49-
os.Exit(1)
50-
}
51-
@@ -818,7 +818,6 @@ func runUsingChrootExecMain() {
52-
// Output debug messages when that differs from what we're being asked to do.
53-
func logNamespaceDiagnostics(spec *specs.Spec) {
54-
sawMountNS := false
55-
- sawUserNS := false
56-
sawUTSNS := false
57-
for _, ns := range spec.Linux.Namespaces {
58-
switch ns.Type {
59-
@@ -853,9 +852,8 @@ func logNamespaceDiagnostics(spec *specs.Spec) {
60-
}
61-
case specs.UserNamespace:
62-
if ns.Path != "" {
63-
- logrus.Debugf("unable to join user namespace %q, creating a new one", ns.Path)
64-
+ logrus.Debugf("unable to join user namespace, sorry about that")
65-
}
66-
- sawUserNS = true
67-
case specs.UTSNamespace:
68-
if ns.Path != "" {
69-
logrus.Debugf("unable to join UTS namespace %q, creating a new one", ns.Path)
70-
@@ -866,9 +864,6 @@ func logNamespaceDiagnostics(spec *specs.Spec) {
71-
if !sawMountNS {
72-
logrus.Debugf("mount namespace not requested, but creating a new one anyway")
73-
}
74-
- if !sawUserNS {
75-
- logrus.Debugf("user namespace not requested, but creating a new one anyway")
76-
- }
77-
if !sawUTSNS {
78-
logrus.Debugf("UTS namespace not requested, but creating a new one anyway")
79-
}
801
diff --git a/vendor/github.com/containers/podman/v3/pkg/specgen/generate/security.go b/vendor/github.com/containers/podman/v3/pkg/specgen/generate/security.go
812
index e0e4a47a4..3cda89a32 100644
823
--- a/vendor/github.com/containers/podman/v3/pkg/specgen/generate/security.go

SPECS/cri-o/CVE-2021-44716.patch

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
1-
From deb00def7d110f1b4edbe5d03044a9d9f2516151 Mon Sep 17 00:00:00 2001
2-
From: Cameron Baird <cameronbaird@microsoft.com>
3-
Date: Wed, 17 Apr 2024 20:57:05 +0000
4-
Subject: [PATCH 2/2] CVE-2021-44716
5-
6-
---
7-
vendor/golang.org/x/net/http2/server.go | 15 ++++++++++++---
8-
1 file changed, 12 insertions(+), 3 deletions(-)
9-
101
diff --git a/vendor/golang.org/x/net/http2/server.go b/vendor/golang.org/x/net/http2/server.go
11-
index e125bbd2a..5f417b444 100644
2+
index 09bc705..23058b6 100644
123
--- a/vendor/golang.org/x/net/http2/server.go
134
+++ b/vendor/golang.org/x/net/http2/server.go
14-
@@ -720,7 +720,15 @@ func (sc *serverConn) canonicalHeader(v string) string {
5+
@@ -714,7 +714,15 @@ func (sc *serverConn) canonicalHeader(v string) string {
156
sc.canonHeader = make(map[string]string)
167
}
178
cv = http.CanonicalHeaderKey(v)
@@ -28,7 +19,7 @@ index e125bbd2a..5f417b444 100644
2819
return cv
2920
}
3021

31-
@@ -2530,8 +2538,9 @@ func (rws *responseWriterState) writeChunk(p []byte) (n int, err error) {
22+
@@ -2524,8 +2532,9 @@ func (rws *responseWriterState) writeChunk(p []byte) (n int, err error) {
3223
// prior to the headers being written. If the set of trailers is fixed
3324
// or known before the header is written, the normal Go trailers mechanism
3425
// is preferred:
@@ -40,6 +31,3 @@ index e125bbd2a..5f417b444 100644
4031
const TrailerPrefix = "Trailer:"
4132

4233
// promoteUndeclaredTrailers permits http.Handlers to set trailers
43-
--
44-
2.33.8
45-

SPECS/cri-o/CVE-2022-1708.patch

Lines changed: 15 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,5 @@
1-
Modified patch to apply to version 1.21.7.
2-
Modified-by: sumsharma@microsoft.com
3-
4-
commit f032cf649ecc7e0c46718bd9e7814bfb317cb544 (from afab4b78d1d66fb5144ef003b20eba5e53833336)
5-
Merge: afab4b78d 79e404fa5
6-
Author: Peter Hunt <pehunt@redhat.com>
7-
Date: Mon Jun 6 13:54:06 2022 -0400
8-
9-
Merge pull request from GHSA-fcm2-6c3h-pg6j
10-
11-
oci: add support for capping memory and disk usage from exec sync output
12-
---
13-
internal/config/conmonmgr/conmonmgr.go | 32 +++++-
14-
internal/config/conmonmgr/conmonmgr_test.go | 106 +++++++++++++++++-
15-
internal/oci/oci.go | 5 +
16-
internal/oci/runtime_oci.go | 19 +++-
17-
internal/oci/runtime_oci_test.go | 39 +++++++
18-
internal/oci/runtime_vm.go | 5 +-
19-
pkg/config/config.go | 4 +
20-
test/ctr.bats | 8 ++
21-
.../pkg/kubelet/util/ioutils/ioutils.go | 70 ++++++++++++
22-
vendor/modules.txt | 1 +
23-
10 files changed, 282 insertions(+), 7 deletions(-)
24-
create mode 100644 vendor/k8s.io/kubernetes/pkg/kubelet/util/ioutils/ioutils.go
25-
261
diff --git a/internal/config/conmonmgr/conmonmgr.go b/internal/config/conmonmgr/conmonmgr.go
27-
index 9aef7ef..5276039 100644
2+
index 857437c..e95e274 100644
283
--- a/internal/config/conmonmgr/conmonmgr.go
294
+++ b/internal/config/conmonmgr/conmonmgr.go
305
@@ -1,6 +1,7 @@
@@ -212,7 +187,7 @@ index a097312..e804c62 100644
212187
+ })
213188
})
214189
diff --git a/internal/oci/oci.go b/internal/oci/oci.go
215-
index 478726d..d992e90 100644
190+
index 6c4efa9..89ecfb2 100644
216191
--- a/internal/oci/oci.go
217192
+++ b/internal/oci/oci.go
218193
@@ -35,6 +35,11 @@ const (
@@ -228,10 +203,10 @@ index 478726d..d992e90 100644
228203

229204
// Runtime is the generic structure holding both global and specific
230205
diff --git a/internal/oci/runtime_oci.go b/internal/oci/runtime_oci.go
231-
index 4bf66ee..37f62c6 100644
206+
index 6295ff9..1ed9131 100644
232207
--- a/internal/oci/runtime_oci.go
233208
+++ b/internal/oci/runtime_oci.go
234-
@@ -458,6 +458,9 @@ func (r *runtimeOCI) ExecSyncContainer(ctx context.Context, c *Container, comman
209+
@@ -461,6 +461,9 @@ func (r *runtimeOCI) ExecSyncContainer(ctx context.Context, c *Container, comman
235210
if r.config.ConmonSupportsSync() {
236211
args = append(args, "--sync")
237212
}
@@ -241,7 +216,7 @@ index 4bf66ee..37f62c6 100644
241216
if c.terminal {
242217
args = append(args, "-t")
243218
}
244-
@@ -564,7 +567,7 @@ func (r *runtimeOCI) ExecSyncContainer(ctx context.Context, c *Container, comman
219+
@@ -567,7 +570,7 @@ func (r *runtimeOCI) ExecSyncContainer(ctx context.Context, c *Container, comman
245220
// ExecSyncResponse we have to read the logfile.
246221
// XXX: Currently runC dups the same console over both stdout and stderr,
247222
// so we can't differentiate between the two.
@@ -250,7 +225,7 @@ index 4bf66ee..37f62c6 100644
250225
if err != nil {
251226
return nil, &ExecSyncError{
252227
Stdout: stdoutBuf,
253-
@@ -583,6 +586,20 @@ func (r *runtimeOCI) ExecSyncContainer(ctx context.Context, c *Container, comman
228+
@@ -586,6 +589,20 @@ func (r *runtimeOCI) ExecSyncContainer(ctx context.Context, c *Container, comman
254229
}, nil
255230
}
256231

@@ -329,19 +304,19 @@ index 3385e30..90901e8 100644
329304

330305
func waitContainerStopAndFailAfterTimeout(ctx context.Context,
331306
diff --git a/internal/oci/runtime_vm.go b/internal/oci/runtime_vm.go
332-
index 6f10cfc..be8a0fa 100644
307+
index 394b750..51465da 100644
333308
--- a/internal/oci/runtime_vm.go
334309
+++ b/internal/oci/runtime_vm.go
335-
@@ -33,6 +33,7 @@ import (
310+
@@ -36,6 +36,7 @@ import (
336311
"golang.org/x/sys/unix"
337312
"k8s.io/client-go/tools/remotecommand"
338313
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
339314
+ kioutil "k8s.io/kubernetes/pkg/kubelet/util/ioutils"
340315
utilexec "k8s.io/utils/exec"
341316
)
342317

343-
@@ -309,8 +310,8 @@ func (r *runtimeVM) ExecSyncContainer(ctx context.Context, c *Container, command
344-
defer log.Debugf(ctx, "runtimeVM.ExecSyncContainer() end")
318+
@@ -339,8 +340,8 @@ func (r *runtimeVM) ExecSyncContainer(ctx context.Context, c *Container, command
319+
defer log.Debugf(ctx, "RuntimeVM.ExecSyncContainer() end")
345320

346321
var stdoutBuf, stderrBuf bytes.Buffer
347322
- stdout := cioutil.NewNopWriteCloser(&stdoutBuf)
@@ -352,10 +327,10 @@ index 6f10cfc..be8a0fa 100644
352327
exitCode, err := r.execContainerCommon(ctx, c, command, timeout, nil, stdout, stderr, c.terminal, nil)
353328
if err != nil {
354329
diff --git a/pkg/config/config.go b/pkg/config/config.go
355-
index 25c51e2..606c7a9 100644
330+
index 7a75ff8..591623a 100644
356331
--- a/pkg/config/config.go
357332
+++ b/pkg/config/config.go
358-
@@ -1011,6 +1011,10 @@ func (c *RuntimeConfig) ConmonSupportsSync() bool {
333+
@@ -1065,6 +1065,10 @@ func (c *RuntimeConfig) ConmonSupportsSync() bool {
359334
return c.conmonManager.SupportsSync()
360335
}
361336

@@ -367,7 +342,7 @@ index 25c51e2..606c7a9 100644
367342
var err error
368343
c.PinnsPath, err = validateExecutablePath(executable, c.PinnsPath)
369344
diff --git a/test/ctr.bats b/test/ctr.bats
370-
index 31cf6c7..a9f9393 100644
345+
index 3e7577d..ea7b635 100644
371346
--- a/test/ctr.bats
372347
+++ b/test/ctr.bats
373348
@@ -487,6 +487,14 @@ function check_oci_annotation() {
@@ -385,93 +360,15 @@ index 31cf6c7..a9f9393 100644
385360
@test "ctr device add" {
386361
# In an user namespace we can only bind mount devices from the host, not mknod
387362
# https://github.com/opencontainers/runc/blob/master/libcontainer/rootfs_linux.go#L480-L481
388-
diff --git a/vendor/k8s.io/kubernetes/pkg/kubelet/util/ioutils/ioutils.go b/vendor/k8s.io/kubernetes/pkg/kubelet/util/ioutils/ioutils.go
389-
new file mode 100644
390-
index 0000000..1b2b5a6
391-
--- /dev/null
392-
+++ b/vendor/k8s.io/kubernetes/pkg/kubelet/util/ioutils/ioutils.go
393-
@@ -0,0 +1,70 @@
394-
+/*
395-
+Copyright 2016 The Kubernetes Authors.
396-
+
397-
+Licensed under the Apache License, Version 2.0 (the "License");
398-
+you may not use this file except in compliance with the License.
399-
+You may obtain a copy of the License at
400-
+
401-
+ http://www.apache.org/licenses/LICENSE-2.0
402-
+
403-
+Unless required by applicable law or agreed to in writing, software
404-
+distributed under the License is distributed on an "AS IS" BASIS,
405-
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
406-
+See the License for the specific language governing permissions and
407-
+limitations under the License.
408-
+*/
409-
+
410-
+package ioutils
411-
+
412-
+import "io"
413-
+
414-
+// writeCloserWrapper represents a WriteCloser whose closer operation is noop.
415-
+type writeCloserWrapper struct {
416-
+ Writer io.Writer
417-
+}
418-
+
419-
+func (w *writeCloserWrapper) Write(buf []byte) (int, error) {
420-
+ return w.Writer.Write(buf)
421-
+}
422-
+
423-
+func (w *writeCloserWrapper) Close() error {
424-
+ return nil
425-
+}
426-
+
427-
+// WriteCloserWrapper returns a writeCloserWrapper.
428-
+func WriteCloserWrapper(w io.Writer) io.WriteCloser {
429-
+ return &writeCloserWrapper{w}
430-
+}
431-
+
432-
+// LimitWriter is a copy of the standard library ioutils.LimitReader,
433-
+// applied to the writer interface.
434-
+// LimitWriter returns a Writer that writes to w
435-
+// but stops with EOF after n bytes.
436-
+// The underlying implementation is a *LimitedWriter.
437-
+func LimitWriter(w io.Writer, n int64) io.Writer { return &LimitedWriter{w, n} }
438-
+
439-
+// A LimitedWriter writes to W but limits the amount of
440-
+// data returned to just N bytes. Each call to Write
441-
+// updates N to reflect the new amount remaining.
442-
+// Write returns EOF when N <= 0 or when the underlying W returns EOF.
443-
+type LimitedWriter struct {
444-
+ W io.Writer // underlying writer
445-
+ N int64 // max bytes remaining
446-
+}
447-
+
448-
+func (l *LimitedWriter) Write(p []byte) (n int, err error) {
449-
+ if l.N <= 0 {
450-
+ return 0, io.ErrShortWrite
451-
+ }
452-
+ truncated := false
453-
+ if int64(len(p)) > l.N {
454-
+ p = p[0:l.N]
455-
+ truncated = true
456-
+ }
457-
+ n, err = l.W.Write(p)
458-
+ l.N -= int64(n)
459-
+ if err == nil && truncated {
460-
+ err = io.ErrShortWrite
461-
+ }
462-
+ return
463-
+}
464363
diff --git a/vendor/modules.txt b/vendor/modules.txt
465-
index 030e1d1..d911968 100644
364+
index 6f8a08b..1899c90 100644
466365
--- a/vendor/modules.txt
467366
+++ b/vendor/modules.txt
468-
@@ -1373,6 +1373,7 @@ k8s.io/kubernetes/pkg/kubelet/cri/streaming
367+
@@ -1517,6 +1517,7 @@ k8s.io/kubernetes/pkg/kubelet/cri/streaming
469368
k8s.io/kubernetes/pkg/kubelet/cri/streaming/portforward
470369
k8s.io/kubernetes/pkg/kubelet/cri/streaming/remotecommand
471370
k8s.io/kubernetes/pkg/kubelet/types
472371
+k8s.io/kubernetes/pkg/kubelet/util/ioutils
473372
k8s.io/kubernetes/pkg/proxy
474373
k8s.io/kubernetes/pkg/proxy/config
475374
k8s.io/kubernetes/pkg/proxy/healthcheck
476-
--
477-
2.25.1

SPECS/cri-o/CVE-2022-27651.patch

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,8 @@
1-
From a3b181b667b8bd408c036e94f2b2f61295610ed6 Mon Sep 17 00:00:00 2001
2-
From: Cameron Baird <cameronbaird@microsoft.com>
3-
Date: Tue, 16 Apr 2024 22:27:00 +0000
4-
Subject: [PATCH 3/4] CVE-2022-27651
5-
6-
---
7-
vendor/github.com/containers/buildah/chroot/run.go | 2 +-
8-
vendor/github.com/containers/buildah/run_linux.go | 6 ------
9-
2 files changed, 1 insertion(+), 7 deletions(-)
10-
111
diff --git a/vendor/github.com/containers/buildah/chroot/run.go b/vendor/github.com/containers/buildah/chroot/run.go
12-
index 39ad88b2b..a93f97dcd 100644
2+
index 5910035..e533e2f 100644
133
--- a/vendor/github.com/containers/buildah/chroot/run.go
144
+++ b/vendor/github.com/containers/buildah/chroot/run.go
15-
@@ -898,7 +898,7 @@ func setCapabilities(spec *specs.Spec, keepCaps ...string) error {
5+
@@ -894,7 +894,7 @@ func setCapabilities(spec *specs.Spec, keepCaps ...string) error {
166
capMap := map[capability.CapType][]string{
177
capability.BOUNDING: spec.Process.Capabilities.Bounding,
188
capability.EFFECTIVE: spec.Process.Capabilities.Effective,
@@ -22,10 +12,10 @@ index 39ad88b2b..a93f97dcd 100644
2212
capability.AMBIENT: spec.Process.Capabilities.Ambient,
2313
}
2414
diff --git a/vendor/github.com/containers/buildah/run_linux.go b/vendor/github.com/containers/buildah/run_linux.go
25-
index ffbb36b7b..1d0646612 100644
15+
index 81af8ee..f82c52f 100644
2616
--- a/vendor/github.com/containers/buildah/run_linux.go
2717
+++ b/vendor/github.com/containers/buildah/run_linux.go
28-
@@ -1850,9 +1850,6 @@ func setupCapAdd(g *generate.Generator, caps ...string) error {
18+
@@ -1898,9 +1898,6 @@ func setupCapAdd(g *generate.Generator, caps ...string) error {
2919
if err := g.AddProcessCapabilityEffective(cap); err != nil {
3020
return errors.Wrapf(err, "error adding %q to the effective capability set", cap)
3121
}
@@ -35,7 +25,7 @@ index ffbb36b7b..1d0646612 100644
3525
if err := g.AddProcessCapabilityPermitted(cap); err != nil {
3626
return errors.Wrapf(err, "error adding %q to the permitted capability set", cap)
3727
}
38-
@@ -1871,9 +1868,6 @@ func setupCapDrop(g *generate.Generator, caps ...string) error {
28+
@@ -1919,9 +1916,6 @@ func setupCapDrop(g *generate.Generator, caps ...string) error {
3929
if err := g.DropProcessCapabilityEffective(cap); err != nil {
4030
return errors.Wrapf(err, "error removing %q from the effective capability set", cap)
4131
}
@@ -45,6 +35,3 @@ index ffbb36b7b..1d0646612 100644
4535
if err := g.DropProcessCapabilityPermitted(cap); err != nil {
4636
return errors.Wrapf(err, "error removing %q from the permitted capability set", cap)
4737
}
48-
--
49-
2.33.8
50-

0 commit comments

Comments
 (0)