close channel in write side to avoid panic in docker stats

fix #I5ATMV
This commit is contained in:
zjw 2022-06-29 09:50:20 +08:00
parent 6b4b0f7702
commit 2b2be77fce
5 changed files with 48 additions and 3 deletions

View File

@ -1 +1 @@
18.09.0.302
18.09.0.303

View File

@ -1,6 +1,6 @@
Name: docker-engine
Version: 18.09.0
Release: 302
Release: 303
Summary: The open-source application container engine
Group: Tools/Docker
@ -212,6 +212,12 @@ fi
%endif
%changelog
* Wed Jun 29 2022 zjw<zhongjiawei1@huawei.com> - 18.09.0-303
- Type:bugfix
- CVE:NA
- SUG:NA
- DESC:close channel in write side to avoid panic in docker stats
* Tue Jun 28 2022 zjw<zhongjiawei1@huawei.com> - 18.09.0-302
- Type:bugfix
- CVE:NA

View File

@ -1 +1 @@
9168ea3a0f5f112a9cca9c63f33766cbcb7a58cc
7e7815ae0b96872d235f46c6624cc4b695d04dfa

View File

@ -0,0 +1,38 @@
From 548078b9e76e34c6994830ce35bee1c15e3c091f Mon Sep 17 00:00:00 2001
From: chenjiankun <chenjiankun1@huawei.com>
Date: Mon, 21 Mar 2022 11:05:43 +0800
Subject: [PATCH] docker: close channel in write side to avoid panic in docker
stats
there is a situation when write event to chan c, chan c is close,
and that will cause a panic. Close chan c in write side can avaid
panic.
---
components/cli/cli/command/container/stats.go | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/components/cli/cli/command/container/stats.go b/components/cli/cli/command/container/stats.go
index 8387fc988..daab91627 100644
--- a/components/cli/cli/command/container/stats.go
+++ b/components/cli/cli/command/container/stats.go
@@ -60,6 +60,9 @@ func runStats(dockerCli command.Cli, opts *statsOptions) error {
// monitorContainerEvents watches for container creation and removal (only
// used when calling `docker stats` without arguments).
monitorContainerEvents := func(started chan<- struct{}, c chan events.Message) {
+ // close channel in write side to avoid panic
+ defer close(c)
+
f := filters.NewArgs()
f.Add("type", "container")
options := types.EventsOptions{
@@ -150,7 +153,6 @@ func runStats(dockerCli command.Cli, opts *statsOptions) error {
eventChan := make(chan events.Message)
go eh.Watch(eventChan)
go monitorContainerEvents(started, eventChan)
- defer close(eventChan)
<-started
// Start a short-lived goroutine to retrieve the initial list of
--
2.23.0

View File

@ -222,4 +222,5 @@ patch/0221-docker-fix-Up-292-years-in-status-in-docker-ps-a.patch
patch/0222-docker-Use-original-process-spec-for-execs.patch
patch/0223-docker-fix-CVE-2022-24769.patch
patch/0224-fix-rwlayer-umountd-after-container-restart.patch
patch/0225-docker-close-channel-in-write-side-to-avoid-panic-in.patch
#end