Skip to content

Commit

Permalink
Merge pull request from GHSA-2qjp-425j-52j9
Browse files Browse the repository at this point in the history
[release/1.6] CRI stream server: Fix goroutine leak in Exec
  • Loading branch information
dmcgowan committed Dec 7, 2022
2 parents 52a4492 + 1899ebc commit a05d175
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
15 changes: 12 additions & 3 deletions pkg/cri/streaming/remotecommand/httpstream.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ limitations under the License.
package remotecommand

import (
gocontext "context"
"encoding/json"
"errors"
"fmt"
Expand Down Expand Up @@ -132,7 +133,7 @@ func createStreams(req *http.Request, w http.ResponseWriter, opts *Options, supp

if ctx.resizeStream != nil {
ctx.resizeChan = make(chan remotecommand.TerminalSize)
go handleResizeEvents(ctx.resizeStream, ctx.resizeChan)
go handleResizeEvents(req.Context(), ctx.resizeStream, ctx.resizeChan)
}

return ctx, true
Expand Down Expand Up @@ -425,7 +426,7 @@ WaitForStreams:
// supportsTerminalResizing returns false because v1ProtocolHandler doesn't support it.
func (*v1ProtocolHandler) supportsTerminalResizing() bool { return false }

func handleResizeEvents(stream io.Reader, channel chan<- remotecommand.TerminalSize) {
func handleResizeEvents(ctx gocontext.Context, stream io.Reader, channel chan<- remotecommand.TerminalSize) {
defer runtime.HandleCrash()
defer close(channel)

Expand All @@ -435,7 +436,15 @@ func handleResizeEvents(stream io.Reader, channel chan<- remotecommand.TerminalS
if err := decoder.Decode(&size); err != nil {
break
}
channel <- size

select {
case channel <- size:
case <-ctx.Done():
// To avoid leaking this routine, exit if the http request finishes. This path
// would generally be hit if starting the process fails and nothing is started to
// ingest these resize events.
return
}
}
}

Expand Down
19 changes: 19 additions & 0 deletions releases/v1.6.12.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# commit to be tagged for new release
commit = "HEAD"

project_name = "containerd"
github_repo = "containerd/containerd"
match_deps = "^github.com/(containerd/[a-zA-Z0-9-]+)$"

# previous release
previous = "v1.6.11"

pre_release = false

preface = """\
The twelfth patch release for containerd 1.6 contains a fix for CVE-2022-23471.
### Notable Updates
* **Fix goroutine leak during Exec in CRI plugin** ([GHSA-2qjp-425j-52j9](https://github.com/containerd/containerd/security/advisories/GHSA-2qjp-425j-52j9))
See the changelog for complete list of changes"""
2 changes: 1 addition & 1 deletion version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var (
Package = "github.com/containerd/containerd"

// Version holds the complete version number. Filled in at linking time.
Version = "1.6.11+unknown"
Version = "1.6.12+unknown"

// Revision is filled with the VCS (e.g. git) revision being used to build
// the program at linking time.
Expand Down

0 comments on commit a05d175

Please sign in to comment.