From 6bfec9646c4088c587ebe768d3b6d6e4f170486a Mon Sep 17 00:00:00 2001 From: Damien Neil Date: Wed, 30 Nov 2022 16:37:07 -0500 Subject: [PATCH] [go1.15.15-eks] net/http: update bundled golang.org/x/net/http2 # AWS EKS Backported To: go-1.15.15-eks Backported On: Thu, 15 Dec 2022 Backported By: rcrozean@amazon.com Backported From: release-branch.go1.18 Source Commit: https://github.com/golang/go/commit/76cad4edc29d28432a7a0aa27e87385d3d7db7a1 EKS Patch Source Commit: # Original Information Disable cmd/internal/moddeps test, since this update includes PRIVATE track fixes. For #56350 For #57008 Fixes CVE-2022-41717 Change-Id: I31ebd2b9ae190ef6f7646187103ea1c8a713ff2e Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1663833 Reviewed-by: Tatiana Bradley Reviewed-by: Julie Qiu Reviewed-on: https://go-review.googlesource.com/c/go/+/455361 Run-TryBot: Jenny Rakoczy Reviewed-by: Michael Pratt TryBot-Result: Gopher Robot --- src/cmd/internal/moddeps/moddeps_test.go | 2 ++ src/net/http/h2_bundle.go | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/cmd/internal/moddeps/moddeps_test.go b/src/cmd/internal/moddeps/moddeps_test.go index 2e6167322e..8d9f8a6d87 100644 --- a/src/cmd/internal/moddeps/moddeps_test.go +++ b/src/cmd/internal/moddeps/moddeps_test.go @@ -103,6 +103,8 @@ var goroot struct { // or explicitly invoke version control to check for changes. // (See golang.org/issue/36852 and golang.org/issue/27348.) func TestAllDependenciesVendored(t *testing.T) { + t.Skip("TODO(#57008): 1.18.9 contains unreleased changes from vendored modules") + goBin := testenv.GoToolPath(t) for _, m := range findGorootModules(t) { diff --git a/src/net/http/h2_bundle.go b/src/net/http/h2_bundle.go index 0fc00e89cb..6d3ce0f64f 100644 --- a/src/net/http/h2_bundle.go +++ b/src/net/http/h2_bundle.go @@ -4096,6 +4096,7 @@ type http2serverConn struct { headerTableSize uint32 peerMaxHeaderListSize uint32 // zero means unknown (default) canonHeader map[string]string // http2-lower-case -> Go-Canonical-Case + canonHeaderKeysSize int // canonHeader keys size in bytes writingFrame bool // started writing a frame (on serve goroutine or separate) writingFrameAsync bool // started a frame on its own goroutine but haven't heard back on wroteFrameCh needsFrameFlush bool // last frame write wasn't a flush @@ -4275,6 +4276,13 @@ func (sc *http2serverConn) condlogf(err error, format string, args ...interface{ } } +// maxCachedCanonicalHeadersKeysSize is an arbitrarily-chosen limit on the size +// of the entries in the canonHeader cache. +// This should be larger than the size of unique, uncommon header keys likely to +// be sent by the peer, while not so high as to permit unreasonable memory usage +// if the peer sends an unbounded number of unique header keys. +const http2maxCachedCanonicalHeadersKeysSize = 2048 + func (sc *http2serverConn) canonicalHeader(v string) string { sc.serveG.check() http2buildCommonHeaderMapsOnce() @@ -4290,7 +4298,11 @@ func (sc *http2serverConn) canonicalHeader(v string) string { sc.canonHeader = make(map[string]string) } cv = CanonicalHeaderKey(v) - sc.canonHeader[v] = cv + size := 100 + len(v)*2 // 100 bytes of map overhead + key + value + if sc.canonHeaderKeysSize+size <= http2maxCachedCanonicalHeadersKeysSize { + sc.canonHeader[v] = cv + sc.canonHeaderKeysSize += size + } return cv } -- 2.38.1