golang: fix CVE-2022-27664

Score: 7.5
Reference: https://go-review.googlesource.com/c/go/+/428635/
Conflict: NA
Reason: fix CVE-2022-27664
This commit is contained in:
hanchao 2022-09-15 10:27:36 +08:00
parent eac443ba4a
commit 793f4d493d
2 changed files with 107 additions and 1 deletions

View File

@ -0,0 +1,99 @@
From b2058191785138021b635f609de3d5f651ec02cd Mon Sep 17 00:00:00 2001
From: Damien Neil <dneil@google.com>
Date: Mon, 22 Aug 2022 16:21:02 -0700
Subject: [PATCH] [release-branch.go1.18] net/http: update bundled
golang.org/x/net/http2
Disable cmd/internal/moddeps test, since this update includes PRIVATE
track fixes.
Fixes CVE-2022-27664
Fixes #53977
For #54658.
Change-Id: I84b0b8f61e49e15ef55ef8d738730107a3cf849b
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1554415
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Tatiana Bradley <tatianabradley@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/428635
Reviewed-by: Tatiana Bradley <tatiana@golang.org>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Conflict:NA
Reference:https://go-review.googlesource.com/c/go/+/428635/
---
src/cmd/internal/moddeps/moddeps_test.go | 2 ++
src/net/http/h2_bundle.go | 21 +++++++++++++--------
2 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/src/cmd/internal/moddeps/moddeps_test.go b/src/cmd/internal/moddeps/moddeps_test.go
index 56c3b2585c..3306e29431 100644
--- a/src/cmd/internal/moddeps/moddeps_test.go
+++ b/src/cmd/internal/moddeps/moddeps_test.go
@@ -34,6 +34,8 @@ import (
// See issues 36852, 41409, and 43687.
// (Also see golang.org/issue/27348.)
func TestAllDependencies(t *testing.T) {
+ t.Skip("TODO(#53977): 1.18.5 contains unreleased changes from vendored modules")
+
goBin := testenv.GoToolPath(t)
// Ensure that all packages imported within GOROOT
diff --git a/src/net/http/h2_bundle.go b/src/net/http/h2_bundle.go
index 1b73da7f21..d7e2f764c8 100644
--- a/src/net/http/h2_bundle.go
+++ b/src/net/http/h2_bundle.go
@@ -3339,10 +3339,11 @@ func (s http2SettingID) String() string {
// name (key). See httpguts.ValidHeaderName for the base rules.
//
// Further, http2 says:
-// "Just as in HTTP/1.x, header field names are strings of ASCII
-// characters that are compared in a case-insensitive
-// fashion. However, header field names MUST be converted to
-// lowercase prior to their encoding in HTTP/2. "
+//
+// "Just as in HTTP/1.x, header field names are strings of ASCII
+// characters that are compared in a case-insensitive
+// fashion. However, header field names MUST be converted to
+// lowercase prior to their encoding in HTTP/2. "
func http2validWireHeaderFieldName(v string) bool {
if len(v) == 0 {
return false
@@ -3533,8 +3534,8 @@ func (s *http2sorter) SortStrings(ss []string) {
// validPseudoPath reports whether v is a valid :path pseudo-header
// value. It must be either:
//
-// *) a non-empty string starting with '/'
-// *) the string '*', for OPTIONS requests.
+// *) a non-empty string starting with '/'
+// *) the string '*', for OPTIONS requests.
//
// For now this is only used a quick check for deciding when to clean
// up Opaque URLs before sending requests from the Transport.
@@ -4999,6 +5000,9 @@ func (sc *http2serverConn) startGracefulShutdownInternal() {
func (sc *http2serverConn) goAway(code http2ErrCode) {
sc.serveG.check()
if sc.inGoAway {
+ if sc.goAwayCode == http2ErrCodeNo {
+ sc.goAwayCode = code
+ }
return
}
sc.inGoAway = true
@@ -6211,8 +6215,9 @@ func (rws *http2responseWriterState) writeChunk(p []byte) (n int, err error) {
// prior to the headers being written. If the set of trailers is fixed
// or known before the header is written, the normal Go trailers mechanism
// is preferred:
-// https://golang.org/pkg/net/http/#ResponseWriter
-// https://golang.org/pkg/net/http/#example_ResponseWriter_trailers
+//
+// https://golang.org/pkg/net/http/#ResponseWriter
+// https://golang.org/pkg/net/http/#example_ResponseWriter_trailers
const http2TrailerPrefix = "Trailer:"
// promoteUndeclaredTrailers permits http.Handlers to set trailers
--
2.30.2

View File

@ -62,7 +62,7 @@
Name: golang Name: golang
Version: 1.17.3 Version: 1.17.3
Release: 8 Release: 9
Summary: The Go Programming Language Summary: The Go Programming Language
License: BSD and Public Domain License: BSD and Public Domain
URL: https://golang.org/ URL: https://golang.org/
@ -167,6 +167,7 @@ Patch6015: 0015-release-branch.go1.17-crypto-rand-properly-handle-la.patch
Patch6016: 0016-release-branch.go1.17-math-big-check-buffer-lengths-.patch Patch6016: 0016-release-branch.go1.17-math-big-check-buffer-lengths-.patch
Patch6017: 0017-path-filepath-do-not-remove-prefix-.-when-following-.patch Patch6017: 0017-path-filepath-do-not-remove-prefix-.-when-following-.patch
Patch6018: 0018-release-branch.go1.17-syscall-check-correct-group-in.patch Patch6018: 0018-release-branch.go1.17-syscall-check-correct-group-in.patch
Patch6019: 0019-release-branch.go1.18-net-http-update-bundled-golang.patch
ExclusiveArch: %{golang_arches} ExclusiveArch: %{golang_arches}
@ -405,6 +406,12 @@ fi
%files devel -f go-tests.list -f go-misc.list -f go-src.list %files devel -f go-tests.list -f go-misc.list -f go-src.list
%changelog %changelog
* Thu Sep 15 2022 hanchao <hanchao47@huawei.com> - 1.17.3-9
- Type:CVE
- CVE:CVE-2022-27664
- SUG:NA
- DESC: fix CVE-2022-27664
* Thu Sep 8 2022 hanchao<hanchao47@huawei.com> - 1.17.3-8 * Thu Sep 8 2022 hanchao<hanchao47@huawei.com> - 1.17.3-8
- Type:bugfix - Type:bugfix
- CVE:NA - CVE:NA