From 33315a05485000f7168e80e82fd2d8be502a7c6a Mon Sep 17 00:00:00 2001 From: Evan Phoenix Date: Fri, 24 Jan 2025 11:54:37 -0800 Subject: [PATCH] libcontainer: if close_range fails, fall back to the old way Signed-off-by: Evan Phoenix --- libcontainer/utils/utils_unix.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libcontainer/utils/utils_unix.go b/libcontainer/utils/utils_unix.go index 55933b7d4..25384da80 100644 --- a/libcontainer/utils/utils_unix.go +++ b/libcontainer/utils/utils_unix.go @@ -103,7 +103,13 @@ func CloseExecFrom(minFd int) error { // Use close_range(CLOSE_RANGE_CLOEXEC) if possible. if haveCloseRangeCloexec() { err := unix.CloseRange(uint(minFd), math.MaxInt32, unix.CLOSE_RANGE_CLOEXEC) - return os.NewSyscallError("close_range", err) + if err == nil { + return nil + } + + logrus.Debugf("close_range failed, closing range one at a time (error: %v)", err) + + // If close_range fails, we fall back to the standard loop. } // Otherwise, fall back to the standard loop. return fdRangeFrom(minFd, unix.CloseOnExec)