docker: repalce unix.Rmdir with os.RemoveAll when remove mount point dir

fix #I7G1LL
This commit is contained in:
chenjiankun 2023-06-29 16:16:05 +08:00
parent f8a9392395
commit 2e888b9837
5 changed files with 48 additions and 3 deletions

View File

@ -1 +1 @@
18.09.0.325
18.09.0.326

View File

@ -1,6 +1,6 @@
Name: docker-engine
Version: 18.09.0
Release: 325
Release: 326
Epoch: 2
Summary: The open-source application container engine
Group: Tools/Docker
@ -229,6 +229,12 @@ fi
%endif
%changelog
* Thu Jun 29 2023 chenjiankun<chenjiankun1@huawei.com> - 18.09.0-326
- Type:bugfix
- CVE:NA
- SUG:NA
- DESC:repalce unix.Rmdir with os.RemoveAll when remove mount point dir
* Tue Jun 27 2023 chenjiankun<chenjiankun1@huawei.com> - 18.09.0-325
- Type:bugfix
- CVE:NA

View File

@ -1 +1 @@
67cbcd3bf8881fc8434a3e35e778cbe6791e7727
e1a8917f6034ae01a9bc2172799dda8a2f34a882

View File

@ -0,0 +1,38 @@
From 9f1aa90a8c1b3856c4bb6ec422b8f67ac5afc31e Mon Sep 17 00:00:00 2001
From: chenjiankun <chenjiankun1@huawei.com>
Date: Mon, 12 Jun 2023 16:09:06 +0800
Subject: [PATCH] docker: repalce unix.Rmdir with os.RemoveAll when remove
mount point dir
In some cases, there are some files in the mount point dir, so we can't use
unix.Rmdir to remove mount point dir.
---
components/engine/daemon/graphdriver/devmapper/driver.go | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/components/engine/daemon/graphdriver/devmapper/driver.go b/components/engine/daemon/graphdriver/devmapper/driver.go
index 3005b84eb..a1a6e17af 100644
--- a/components/engine/daemon/graphdriver/devmapper/driver.go
+++ b/components/engine/daemon/graphdriver/devmapper/driver.go
@@ -19,7 +19,6 @@ import (
"github.com/docker/go-units"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
- "golang.org/x/sys/unix"
)
func init() {
@@ -196,7 +195,9 @@ func (d *Driver) Remove(id string) error {
// mount point is not important and should not be treated
// as a failure to remove the container.
mp := path.Join(d.home, "mnt", id)
- err := unix.Rmdir(mp)
+ // In some cases, there are some files in the mount point dir, so we can't use
+ // unix.Rmdir to remove mount point dir. os.RemoveAll is more appropriate
+ err := os.RemoveAll(mp)
if err != nil && !os.IsNotExist(err) {
logrus.WithField("storage-driver", "devicemapper").Warnf("unable to remove mount point %q: %s", mp, err)
}
--
2.23.0

View File

@ -257,4 +257,5 @@ patch/0256-docker-libnet-d-overlay-document-some-encryption-code.patch
patch/0257-docker-libnet-d-overlay-add-BPF-powered-VNI-matcher.patch
patch/0258-docker-thinpool-full-because-kill-docker-daemon-when.patch
patch/0259-backport-fix-blockThreshold-full-bug.patch
patch/0260-docker-repalce-unix.Rmdir-with-os.RemoveAll-when-rem.patch
#end