Skip to content

Commit f9c5e56

Browse files
[AutoPR- Security] Patch containerd2 for CVE-2025-64329 [MEDIUM] (microsoft#15041)
1 parent fe89a32 commit f9c5e56

File tree

2 files changed

+78
-1
lines changed

2 files changed

+78
-1
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
From b9beeef78a6fd90ece5801780c45f550caf71b3d Mon Sep 17 00:00:00 2001
2+
From: wheat2018 <[email protected]>
3+
Date: Tue, 13 Aug 2024 15:56:31 +0800
4+
Subject: [PATCH] fix goroutine leak of container Attach
5+
6+
The monitor goroutine (runs (*ContainerIO).Attach.func1) of Attach will
7+
never finish if it attaches to a container without any stdout or stderr
8+
output. Wait for http context cancel and break the pipe actively to
9+
address the issue.
10+
11+
Signed-off-by: wheat2018 <[email protected]>
12+
Signed-off-by: Akihiro Suda <[email protected]>
13+
Signed-off-by: Azure Linux Security Servicing Account <[email protected]>
14+
Upstream-reference: https://github.com/containerd/containerd/commit/083b53cd6f19b5de7717b0ce92c11bdf95e612df.patch
15+
---
16+
internal/cri/io/container_io.go | 14 +++++++++++---
17+
internal/cri/server/container_attach.go | 2 +-
18+
2 files changed, 12 insertions(+), 4 deletions(-)
19+
20+
diff --git a/internal/cri/io/container_io.go b/internal/cri/io/container_io.go
21+
index 9fc5545..194634e 100644
22+
--- a/internal/cri/io/container_io.go
23+
+++ b/internal/cri/io/container_io.go
24+
@@ -17,6 +17,7 @@
25+
package io
26+
27+
import (
28+
+ "context"
29+
"errors"
30+
"fmt"
31+
"io"
32+
@@ -160,7 +161,7 @@ func (c *ContainerIO) Pipe() {
33+
34+
// Attach attaches container stdio.
35+
// TODO(random-liu): Use pools.Copy in docker to reduce memory usage?
36+
-func (c *ContainerIO) Attach(opts AttachOptions) {
37+
+func (c *ContainerIO) Attach(ctx context.Context, opts AttachOptions) {
38+
var wg sync.WaitGroup
39+
key := util.GenerateID()
40+
stdinKey := streamKey(c.id, "attach-"+key, Stdin)
41+
@@ -201,8 +202,15 @@ func (c *ContainerIO) Attach(opts AttachOptions) {
42+
}
43+
44+
attachStream := func(key string, close <-chan struct{}) {
45+
- <-close
46+
- log.L.Infof("Attach stream %q closed", key)
47+
+ select {
48+
+ case <-close:
49+
+ log.L.Infof("Attach stream %q closed", key)
50+
+ case <-ctx.Done():
51+
+ log.L.Infof("Attach client of %q cancelled", key)
52+
+ // Avoid writeGroup heap up
53+
+ c.stdoutGroup.Remove(key)
54+
+ c.stderrGroup.Remove(key)
55+
+ }
56+
// Make sure stdin gets closed.
57+
if stdinStreamRC != nil {
58+
stdinStreamRC.Close()
59+
diff --git a/internal/cri/server/container_attach.go b/internal/cri/server/container_attach.go
60+
index 0147859..f4c3322 100644
61+
--- a/internal/cri/server/container_attach.go
62+
+++ b/internal/cri/server/container_attach.go
63+
@@ -82,6 +82,6 @@ func (c *criService) attachContainer(ctx context.Context, id string, stdin io.Re
64+
},
65+
}
66+
// TODO(random-liu): Figure out whether we need to support historical output.
67+
- cntr.IO.Attach(opts)
68+
+ cntr.IO.Attach(ctx, opts)
69+
return nil
70+
}
71+
--
72+
2.45.4
73+

SPECS/containerd2/containerd2.spec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Summary: Industry-standard container runtime
66
Name: %{upstream_name}2
77
Version: 2.0.0
8-
Release: 14%{?dist}
8+
Release: 15%{?dist}
99
License: ASL 2.0
1010
Group: Tools/Container
1111
URL: https://www.containerd.io
@@ -23,6 +23,7 @@ Patch3: CVE-2025-22872.patch
2323
Patch4: CVE-2025-47291.patch
2424
Patch5: multi-snapshotters-support.patch
2525
Patch6: tardev-support.patch
26+
Patch7: CVE-2025-64329.patch
2627
%{?systemd_requires}
2728

2829
BuildRequires: golang < 1.25
@@ -98,6 +99,9 @@ fi
9899
%dir /opt/containerd/lib
99100

100101
%changelog
102+
* Sat Nov 08 2025 Azure Linux Security Servicing Account <[email protected]> - 2.0.0-15
103+
- Patch for CVE-2025-64329
104+
101105
* Sun Aug 31 2025 Andrew Phelps <[email protected]> - 2.0.0-14
102106
- Set BR for golang to < 1.25
103107

0 commit comments

Comments
 (0)