mirror of
https://git.yoctoproject.org/poky
synced 2026-04-04 23:02:22 +02:00
go: fix CVE-2022-41717 Excessive memory use in got server
Upstream-Status: Backport from 618120c165
(From OE-Core rev: f4d179aab7c8f55669ac652a0668644859ec2eb7)
Signed-off-by: Hitendra Prajapati <hprajapati@mvista.com>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
0b4b2c007d
commit
db86e51343
@@ -19,6 +19,7 @@ SRC_URI += "\
|
||||
file://CVE-2022-27664.patch \
|
||||
file://0001-net-http-httputil-avoid-query-parameter-smuggling.patch \
|
||||
file://CVE-2022-41715.patch \
|
||||
file://CVE-2022-41717.patch \
|
||||
"
|
||||
SRC_URI[main.sha256sum] = "a1a48b23afb206f95e7bbaa9b898d965f90826f6f1d1fc0c1d784ada0cd300fd"
|
||||
|
||||
|
||||
89
meta/recipes-devtools/go/go-1.18/CVE-2022-41717.patch
Normal file
89
meta/recipes-devtools/go/go-1.18/CVE-2022-41717.patch
Normal file
@@ -0,0 +1,89 @@
|
||||
From 618120c165669c00a1606505defea6ca755cdc27 Mon Sep 17 00:00:00 2001
|
||||
From: Damien Neil <dneil@google.com>
|
||||
Date: Wed, 30 Nov 2022 16:46:33 -0500
|
||||
Subject: [PATCH] [release-branch.go1.19] net/http: update bundled
|
||||
golang.org/x/net/http2
|
||||
|
||||
Disable cmd/internal/moddeps test, since this update includes PRIVATE
|
||||
track fixes.
|
||||
|
||||
For #56350.
|
||||
For #57009.
|
||||
Fixes CVE-2022-41717.
|
||||
|
||||
Change-Id: I5c6ce546add81f361dcf0d5123fa4eaaf8f0a03b
|
||||
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1663835
|
||||
Reviewed-by: Tatiana Bradley <tatianabradley@google.com>
|
||||
Reviewed-by: Julie Qiu <julieqiu@google.com>
|
||||
Reviewed-on: https://go-review.googlesource.com/c/go/+/455363
|
||||
TryBot-Result: Gopher Robot <gobot@golang.org>
|
||||
Run-TryBot: Jenny Rakoczy <jenny@golang.org>
|
||||
Reviewed-by: Michael Pratt <mpratt@google.com>
|
||||
|
||||
Upstream-Status: Backport [https://github.com/golang/go/commit/618120c165669c00a1606505defea6ca755cdc27]
|
||||
CVE: CVE-2022-41717
|
||||
Signed-off-by: Hitendra Prajapati <hprajapati@mvista.com>
|
||||
---
|
||||
src/cmd/internal/moddeps/moddeps_test.go | 1 +
|
||||
src/net/http/h2_bundle.go | 18 +++++++++++-------
|
||||
2 files changed, 12 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/src/cmd/internal/moddeps/moddeps_test.go b/src/cmd/internal/moddeps/moddeps_test.go
|
||||
index 3306e29..d48d43f 100644
|
||||
--- a/src/cmd/internal/moddeps/moddeps_test.go
|
||||
+++ b/src/cmd/internal/moddeps/moddeps_test.go
|
||||
@@ -34,6 +34,7 @@ import (
|
||||
// See issues 36852, 41409, and 43687.
|
||||
// (Also see golang.org/issue/27348.)
|
||||
func TestAllDependencies(t *testing.T) {
|
||||
+ t.Skip("TODO(#57009): 1.19.4 contains unreleased changes from vendored modules")
|
||||
t.Skip("TODO(#53977): 1.18.5 contains unreleased changes from vendored modules")
|
||||
|
||||
goBin := testenv.GoToolPath(t)
|
||||
diff --git a/src/net/http/h2_bundle.go b/src/net/http/h2_bundle.go
|
||||
index 6e2ef30..9d6abd8 100644
|
||||
--- a/src/net/http/h2_bundle.go
|
||||
+++ b/src/net/http/h2_bundle.go
|
||||
@@ -4189,6 +4189,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
|
||||
@@ -4368,6 +4369,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()
|
||||
@@ -4383,14 +4391,10 @@ func (sc *http2serverConn) canonicalHeader(v string) string {
|
||||
sc.canonHeader = make(map[string]string)
|
||||
}
|
||||
cv = CanonicalHeaderKey(v)
|
||||
- // maxCachedCanonicalHeaders is an arbitrarily-chosen limit on the number of
|
||||
- // entries in the canonHeader cache. This should be larger than the number
|
||||
- // of unique, uncommon header keys likely to be sent by the peer, while not
|
||||
- // so high as to permit unreaasonable memory usage if the peer sends an unbounded
|
||||
- // number of unique header keys.
|
||||
- const maxCachedCanonicalHeaders = 32
|
||||
- if len(sc.canonHeader) < maxCachedCanonicalHeaders {
|
||||
+ 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.25.1
|
||||
|
||||
Reference in New Issue
Block a user