diff --git a/0001-Enable-go-plugin-support-for-riscv64.patch b/0001-Enable-go-plugin-support-for-riscv64-based-on-work-b.patch similarity index 55% rename from 0001-Enable-go-plugin-support-for-riscv64.patch rename to 0001-Enable-go-plugin-support-for-riscv64-based-on-work-b.patch index 38912e9ae99feb1240ffca270ebf2b456aab0ef3..46a4c7b24f3c5531dadd06d9af9e368774713541 100644 --- a/0001-Enable-go-plugin-support-for-riscv64.patch +++ b/0001-Enable-go-plugin-support-for-riscv64-based-on-work-b.patch @@ -1,40 +1,40 @@ -From 019ec52ee5e7dec0c3a7937025948a742822a052 Mon Sep 17 00:00:00 2001 -From: misaka00251 -Date: Mon, 27 Mar 2023 10:27:38 +0800 +From 57777dcbc3d05c12ac2b227e7afd5435bf84128c Mon Sep 17 00:00:00 2001 +From: hanchao +Date: Mon, 3 Jul 2023 21:20:32 +0800 Subject: [PATCH] Enable go plugin support for riscv64 (based on work by yangjinghua) --- - src/cmd/internal/sys/supported.go | 2 +- src/cmd/link/internal/ld/config.go | 2 +- + src/internal/platform/supported.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) -diff --git a/src/cmd/internal/sys/supported.go b/src/cmd/internal/sys/supported.go -index 1d74f6b..4fa8ed6 100644 ---- a/src/cmd/internal/sys/supported.go -+++ b/src/cmd/internal/sys/supported.go -@@ -142,7 +142,7 @@ func BuildModeSupported(compiler, buildmode, goos, goarch string) bool { - - case "plugin": - switch platform { -- case "linux/amd64", "linux/arm", "linux/arm64", "linux/386", "linux/s390x", "linux/ppc64le", -+ case "linux/amd64", "linux/arm", "linux/arm64", "linux/riscv64", "linux/386", "linux/s390x", "linux/ppc64le", - "android/amd64", "android/arm", "android/arm64", "android/386", - "darwin/amd64", "darwin/arm64", - "freebsd/amd64": diff --git a/src/cmd/link/internal/ld/config.go b/src/cmd/link/internal/ld/config.go -index 4dd43a1..af5d8c5 100644 +index ba74b6f..836c10d 100644 --- a/src/cmd/link/internal/ld/config.go +++ b/src/cmd/link/internal/ld/config.go -@@ -95,7 +95,7 @@ func (mode *BuildMode) Set(s string) error { +@@ -84,7 +84,7 @@ func (mode *BuildMode) Set(s string) error { switch buildcfg.GOOS { case "linux": switch buildcfg.GOARCH { -- case "386", "amd64", "arm", "arm64", "s390x", "ppc64le": -+ case "386", "amd64", "arm", "arm64", "riscv64", "s390x", "ppc64le": +- case "386", "amd64", "arm", "arm64", "ppc64le", "s390x": ++ case "386", "amd64", "arm", "arm64", "riscv64", "ppc64le", "s390x": default: return badmode() } +diff --git a/src/internal/platform/supported.go b/src/internal/platform/supported.go +index 046352f..644822f 100644 +--- a/src/internal/platform/supported.go ++++ b/src/internal/platform/supported.go +@@ -180,7 +180,7 @@ func BuildModeSupported(compiler, buildmode, goos, goarch string) bool { + + case "plugin": + switch platform { +- case "linux/amd64", "linux/arm", "linux/arm64", "linux/386", "linux/s390x", "linux/ppc64le", ++ case "linux/amd64", "linux/arm", "linux/arm64", "linux/riscv64", "linux/386", "linux/s390x", "linux/ppc64le", + "android/amd64", "android/arm", "android/arm64", "android/386", + "darwin/amd64", "darwin/arm64", + "freebsd/amd64": -- -2.37.1 (Apple Git-137.1) +2.33.0 diff --git a/0002-runtime-support-riscv64-SV57-mode.patch b/0002-runtime-support-riscv64-SV57-mode.patch deleted file mode 100644 index 445761efe7592edb4a006792050d07b233bbfe47..0000000000000000000000000000000000000000 --- a/0002-runtime-support-riscv64-SV57-mode.patch +++ /dev/null @@ -1,61 +0,0 @@ -From 1e3c19f3fee12e5e2b7802a54908a4d4d03960da Mon Sep 17 00:00:00 2001 -From: Dmitry Vyukov -Date: Fri, 27 May 2022 18:55:35 +0200 -Subject: [PATCH] runtime: support riscv64 SV57 mode - -riscv64 has SV57 mode when user-space VA is 56 bits. -Linux kernel recently got support for this mode and Go binaries started crashing as: - -runtime: lfstack.push invalid packing: node=0xffffff5908a940 cnt=0x1 -packed=0xffff5908a9400001 -> node=0xffff5908a940 - -Adjust lfstack code to use only 8 top bits of pointers on riscv64. - -For context see: -https://groups.google.com/g/syzkaller-bugs/c/lU0GQTZoNQQ/m/O_c3vmE3AAAJ - -Update #54104 - -Change-Id: Ib5d3d6a79c0c6eddf11618d73fcc8bc1832a9c25 -Reviewed-on: https://go-review.googlesource.com/c/go/+/409055 -Reviewed-by: Joel Sing -Reviewed-by: Meng Zhuo -Reviewed-by: Michael Knyszek -Reviewed-by: Cherry Mui ---- - -diff --git a/src/runtime/lfstack_64bit.go b/src/runtime/lfstack_64bit.go -index 154130c..88cbd3b 100644 ---- a/src/runtime/lfstack_64bit.go -+++ b/src/runtime/lfstack_64bit.go -@@ -36,12 +36,21 @@ - // We use one bit to distinguish between the two ranges. - aixAddrBits = 57 - aixCntBits = 64 - aixAddrBits + 3 -+ -+ // riscv64 SV57 mode gives 56 bits of userspace VA. -+ // lfstack code supports it, but broader support for SV57 mode is incomplete, -+ // and there may be other issues (see #54104). -+ riscv64AddrBits = 56 -+ riscv64CntBits = 64 - riscv64AddrBits + 3 - ) - - func lfstackPack(node *lfnode, cnt uintptr) uint64 { - if GOARCH == "ppc64" && GOOS == "aix" { - return uint64(uintptr(unsafe.Pointer(node)))<<(64-aixAddrBits) | uint64(cnt&(1<> aixCntBits << 3) | 0xa<<56))) - } -+ if GOARCH == "riscv64" { -+ return (*lfnode)(unsafe.Pointer(uintptr(val >> riscv64CntBits << 3))) -+ } - return (*lfnode)(unsafe.Pointer(uintptr(val >> cntBits << 3))) - } diff --git a/0003-release-branch.go1.19-go-scanner-reject-large-line.patch b/0003-release-branch.go1.19-go-scanner-reject-large-line.patch deleted file mode 100644 index 86875be643fb37b5d4063d0485072c44949fcc9e..0000000000000000000000000000000000000000 --- a/0003-release-branch.go1.19-go-scanner-reject-large-line.patch +++ /dev/null @@ -1,91 +0,0 @@ -From 126a1d02da82f93ede7ce0bd8d3c51ef627f2104 Mon Sep 17 00:00:00 2001 -From: Damien Neil -Date: Wed, 22 Mar 2023 09:33:22 -0700 -Subject: [PATCH] [release-branch.go1.19] go/scanner: reject large line and - column numbers in //line directives - -Setting a large line or column number using a //line directive can cause -integer overflow even in small source files. - -Limit line and column numbers in //line directives to 2^30-1, which -is small enough to avoid int32 overflow on all reasonbly-sized files. - -Fixes CVE-2023-24537 -Fixes #59273 -For #59180 - -Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1802456 -Reviewed-by: Julie Qiu -Reviewed-by: Roland Shoemaker -Run-TryBot: Damien Neil -Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1802611 -Reviewed-by: Damien Neil -Change-Id: Ifdfa192d54f722d781a4d8c5f35b5fb72d122168 -Reviewed-on: https://go-review.googlesource.com/c/go/+/481986 -Reviewed-by: Matthew Dempsky -TryBot-Result: Gopher Robot -Run-TryBot: Michael Knyszek -Auto-Submit: Michael Knyszek ---- - src/go/parser/parser_test.go | 16 ++++++++++++++++ - src/go/scanner/scanner.go | 7 +++++-- - 2 files changed, 21 insertions(+), 2 deletions(-) - -diff --git a/src/go/parser/parser_test.go b/src/go/parser/parser_test.go -index 0c278924c9..15b265ffc3 100644 ---- a/src/go/parser/parser_test.go -+++ b/src/go/parser/parser_test.go -@@ -742,3 +742,19 @@ func TestScopeDepthLimit(t *testing.T) { - } - } - } -+ -+// TestIssue59180 tests that line number overflow doesn't cause an infinite loop. -+func TestIssue59180(t *testing.T) { -+ testcases := []string{ -+ "package p\n//line :9223372036854775806\n\n//", -+ "package p\n//line :1:9223372036854775806\n\n//", -+ "package p\n//line file:9223372036854775806\n\n//", -+ } -+ -+ for _, src := range testcases { -+ _, err := ParseFile(token.NewFileSet(), "", src, ParseComments) -+ if err == nil { -+ t.Errorf("ParseFile(%s) succeeded unexpectedly", src) -+ } -+ } -+} -diff --git a/src/go/scanner/scanner.go b/src/go/scanner/scanner.go -index 07e07581f7..6a7e30bb2f 100644 ---- a/src/go/scanner/scanner.go -+++ b/src/go/scanner/scanner.go -@@ -246,13 +246,16 @@ func (s *Scanner) updateLineInfo(next, offs int, text []byte) { - return - } - -+ // Put a cap on the maximum size of line and column numbers. -+ // 30 bits allows for some additional space before wrapping an int32. -+ const maxLineCol = 1<<30 - 1 - var line, col int - i2, n2, ok2 := trailingDigits(text[:i-1]) - if ok2 { - //line filename:line:col - i, i2 = i2, i - line, col = n2, n -- if col == 0 { -+ if col == 0 || col > maxLineCol { - s.error(offs+i2, "invalid column number: "+string(text[i2:])) - return - } -@@ -262,7 +265,7 @@ func (s *Scanner) updateLineInfo(next, offs int, text []byte) { - line = n - } - -- if line == 0 { -+ if line == 0 || line > maxLineCol { - s.error(offs+i, "invalid line number: "+string(text[i:])) - return - } --- -2.33.0 - diff --git a/0004-release-branch.go1.19-html-template-disallow-actions.patch b/0004-release-branch.go1.19-html-template-disallow-actions.patch deleted file mode 100644 index dc0008a6aab0483c3dde27397ebb4fbd0b3cc9e9..0000000000000000000000000000000000000000 --- a/0004-release-branch.go1.19-html-template-disallow-actions.patch +++ /dev/null @@ -1,369 +0,0 @@ -From b1e3ecfa06b67014429a197ec5e134ce4303ad9b Mon Sep 17 00:00:00 2001 -From: Roland Shoemaker -Date: Mon, 20 Mar 2023 11:01:13 -0700 -Subject: [PATCH] [release-branch.go1.19] html/template: disallow actions in JS - template literals - -ECMAScript 6 introduced template literals[0][1] which are delimited with -backticks. These need to be escaped in a similar fashion to the -delimiters for other string literals. Additionally template literals can -contain special syntax for string interpolation. - -There is no clear way to allow safe insertion of actions within JS -template literals, as handling (JS) string interpolation inside of these -literals is rather complex. As such we've chosen to simply disallow -template actions within these template literals. - -A new error code is added for this parsing failure case, errJsTmplLit, -but it is unexported as it is not backwards compatible with other minor -release versions to introduce an API change in a minor release. We will -export this code in the next major release. - -The previous behavior (with the cavet that backticks are now escaped -properly) can be re-enabled with GODEBUG=jstmpllitinterp=1. - -This change subsumes CL471455. - -Thanks to Sohom Datta, Manipal Institute of Technology, for reporting -this issue. - -Fixes CVE-2023-24538 -For #59234 -Fixes #59271 - -[0] https://tc39.es/ecma262/multipage/ecmascript-language-expressions.html#sec-template-literals -[1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals - -Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1802457 -Reviewed-by: Damien Neil -Run-TryBot: Damien Neil -Reviewed-by: Julie Qiu -Reviewed-by: Roland Shoemaker -Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1802612 -Run-TryBot: Roland Shoemaker -Change-Id: Ic7f10595615f2b2740d9c85ad7ef40dc0e78c04c -Reviewed-on: https://go-review.googlesource.com/c/go/+/481987 -Auto-Submit: Michael Knyszek -TryBot-Result: Gopher Robot -Run-TryBot: Michael Knyszek -Reviewed-by: Matthew Dempsky ---- - src/html/template/context.go | 2 + - src/html/template/error.go | 13 ++++++ - src/html/template/escape.go | 11 ++++++ - src/html/template/escape_test.go | 66 +++++++++++++++++-------------- - src/html/template/js.go | 2 + - src/html/template/js_test.go | 2 +- - src/html/template/jsctx_string.go | 9 +++++ - src/html/template/state_string.go | 37 ++++++++++++++++- - src/html/template/transition.go | 7 +++- - 9 files changed, 116 insertions(+), 33 deletions(-) - -diff --git a/src/html/template/context.go b/src/html/template/context.go -index a97c8be56f..c28fb0c5ea 100644 ---- a/src/html/template/context.go -+++ b/src/html/template/context.go -@@ -120,6 +120,8 @@ const ( - stateJSDqStr - // stateJSSqStr occurs inside a JavaScript single quoted string. - stateJSSqStr -+ // stateJSBqStr occurs inside a JavaScript back quoted string. -+ stateJSBqStr - // stateJSRegexp occurs inside a JavaScript regexp literal. - stateJSRegexp - // stateJSBlockCmt occurs inside a JavaScript /* block comment */. -diff --git a/src/html/template/error.go b/src/html/template/error.go -index 5c51f772cb..d7d6f5b3ab 100644 ---- a/src/html/template/error.go -+++ b/src/html/template/error.go -@@ -214,6 +214,19 @@ const ( - // pipeline occurs in an unquoted attribute value context, "html" is - // disallowed. Avoid using "html" and "urlquery" entirely in new templates. - ErrPredefinedEscaper -+ -+ // errJSTmplLit: "... appears in a JS template literal" -+ // Example: -+ // -+ // Discussion: -+ // Package html/template does not support actions inside of JS template -+ // literals. -+ // -+ // TODO(rolandshoemaker): we cannot add this as an exported error in a minor -+ // release, since it is backwards incompatible with the other minor -+ // releases. As such we need to leave it unexported, and then we'll add it -+ // in the next major release. -+ errJSTmplLit - ) - - func (e *Error) Error() string { -diff --git a/src/html/template/escape.go b/src/html/template/escape.go -index 54fbcdca33..3d4cc19b5d 100644 ---- a/src/html/template/escape.go -+++ b/src/html/template/escape.go -@@ -8,6 +8,7 @@ import ( - "bytes" - "fmt" - "html" -+ "internal/godebug" - "io" - "text/template" - "text/template/parse" -@@ -223,6 +224,16 @@ func (e *escaper) escapeAction(c context, n *parse.ActionNode) context { - c.jsCtx = jsCtxDivOp - case stateJSDqStr, stateJSSqStr: - s = append(s, "_html_template_jsstrescaper") -+ case stateJSBqStr: -+ debugAllowActionJSTmpl := godebug.Get("jstmpllitinterp") -+ if debugAllowActionJSTmpl == "1" { -+ s = append(s, "_html_template_jsstrescaper") -+ } else { -+ return context{ -+ state: stateError, -+ err: errorf(errJSTmplLit, n, n.Line, "%s appears in a JS template literal", n), -+ } -+ } - case stateJSRegexp: - s = append(s, "_html_template_jsregexpescaper") - case stateCSS: -diff --git a/src/html/template/escape_test.go b/src/html/template/escape_test.go -index 58f3f271b7..972b00b921 100644 ---- a/src/html/template/escape_test.go -+++ b/src/html/template/escape_test.go -@@ -681,35 +681,31 @@ func TestEscape(t *testing.T) { - } - - for _, test := range tests { -- tmpl := New(test.name) -- tmpl = Must(tmpl.Parse(test.input)) -- // Check for bug 6459: Tree field was not set in Parse. -- if tmpl.Tree != tmpl.text.Tree { -- t.Errorf("%s: tree not set properly", test.name) -- continue -- } -- b := new(bytes.Buffer) -- if err := tmpl.Execute(b, data); err != nil { -- t.Errorf("%s: template execution failed: %s", test.name, err) -- continue -- } -- if w, g := test.output, b.String(); w != g { -- t.Errorf("%s: escaped output: want\n\t%q\ngot\n\t%q", test.name, w, g) -- continue -- } -- b.Reset() -- if err := tmpl.Execute(b, pdata); err != nil { -- t.Errorf("%s: template execution failed for pointer: %s", test.name, err) -- continue -- } -- if w, g := test.output, b.String(); w != g { -- t.Errorf("%s: escaped output for pointer: want\n\t%q\ngot\n\t%q", test.name, w, g) -- continue -- } -- if tmpl.Tree != tmpl.text.Tree { -- t.Errorf("%s: tree mismatch", test.name) -- continue -- } -+ t.Run(test.name, func(t *testing.T) { -+ tmpl := New(test.name) -+ tmpl = Must(tmpl.Parse(test.input)) -+ // Check for bug 6459: Tree field was not set in Parse. -+ if tmpl.Tree != tmpl.text.Tree { -+ t.Fatalf("%s: tree not set properly", test.name) -+ } -+ b := new(strings.Builder) -+ if err := tmpl.Execute(b, data); err != nil { -+ t.Fatalf("%s: template execution failed: %s", test.name, err) -+ } -+ if w, g := test.output, b.String(); w != g { -+ t.Fatalf("%s: escaped output: want\n\t%q\ngot\n\t%q", test.name, w, g) -+ } -+ b.Reset() -+ if err := tmpl.Execute(b, pdata); err != nil { -+ t.Fatalf("%s: template execution failed for pointer: %s", test.name, err) -+ } -+ if w, g := test.output, b.String(); w != g { -+ t.Fatalf("%s: escaped output for pointer: want\n\t%q\ngot\n\t%q", test.name, w, g) -+ } -+ if tmpl.Tree != tmpl.text.Tree { -+ t.Fatalf("%s: tree mismatch", test.name) -+ } -+ }) - } - } - -@@ -936,6 +932,10 @@ func TestErrors(t *testing.T) { - "{{range .Items}}{{if .X}}{{break}}{{end}}{{end}}", - "", - }, -+ { -+ "`", -+ "", -+ }, - // Error cases. - { - "{{if .Cond}}var tmpl = `asd {{.}}`;", -+ `{{.}} appears in a JS template literal`, -+ }, - } - for _, test := range tests { - buf := new(bytes.Buffer) -@@ -1303,6 +1307,10 @@ func TestEscapeText(t *testing.T) { - `= state(len(_state_index)-1) { -diff --git a/src/html/template/transition.go b/src/html/template/transition.go -index 06df679330..92eb351906 100644 ---- a/src/html/template/transition.go -+++ b/src/html/template/transition.go -@@ -27,6 +27,7 @@ var transitionFunc = [...]func(context, []byte) (context, int){ - stateJS: tJS, - stateJSDqStr: tJSDelimited, - stateJSSqStr: tJSDelimited, -+ stateJSBqStr: tJSDelimited, - stateJSRegexp: tJSDelimited, - stateJSBlockCmt: tBlockCmt, - stateJSLineCmt: tLineCmt, -@@ -262,7 +263,7 @@ func tURL(c context, s []byte) (context, int) { - - // tJS is the context transition function for the JS state. - func tJS(c context, s []byte) (context, int) { -- i := bytes.IndexAny(s, `"'/`) -+ i := bytes.IndexAny(s, "\"`'/") - if i == -1 { - // Entire input is non string, comment, regexp tokens. - c.jsCtx = nextJSCtx(s, c.jsCtx) -@@ -274,6 +275,8 @@ func tJS(c context, s []byte) (context, int) { - c.state, c.jsCtx = stateJSDqStr, jsCtxRegexp - case '\'': - c.state, c.jsCtx = stateJSSqStr, jsCtxRegexp -+ case '`': -+ c.state, c.jsCtx = stateJSBqStr, jsCtxRegexp - case '/': - switch { - case i+1 < len(s) && s[i+1] == '/': -@@ -303,6 +306,8 @@ func tJSDelimited(c context, s []byte) (context, int) { - switch c.state { - case stateJSSqStr: - specials = `\'` -+ case stateJSBqStr: -+ specials = "`\\" - case stateJSRegexp: - specials = `\/[]` - } --- -2.33.0 - diff --git a/0005-release-branch.go1.19-net-textproto-avoid-overpredic.patch b/0005-release-branch.go1.19-net-textproto-avoid-overpredic.patch deleted file mode 100644 index d96308364f52458bd763bc17530c9a4c0fc0b126..0000000000000000000000000000000000000000 --- a/0005-release-branch.go1.19-net-textproto-avoid-overpredic.patch +++ /dev/null @@ -1,188 +0,0 @@ -From d6759e7a059f4208f07aa781402841d7ddaaef96 Mon Sep 17 00:00:00 2001 -From: Damien Neil -Date: Fri, 10 Mar 2023 14:21:05 -0800 -Subject: [PATCH] [release-branch.go1.19] net/textproto: avoid overpredicting - the number of MIME header keys - -A parsed MIME header is a map[string][]string. In the common case, -a header contains many one-element []string slices. To avoid -allocating a separate slice for each key, ReadMIMEHeader looks -ahead in the input to predict the number of keys that will be -parsed, and allocates a single []string of that length. -The individual slices are then allocated out of the larger one. - -The prediction of the number of header keys was done by counting -newlines in the input buffer, which does not take into account -header continuation lines (where a header key/value spans multiple -lines) or the end of the header block and the start of the body. -This could lead to a substantial amount of overallocation, for -example when the body consists of nothing but a large block of -newlines. - -Fix header key count prediction to take into account the end of -the headers (indicated by a blank line) and continuation lines -(starting with whitespace). - -Thanks to Jakob Ackermann (@das7pad) for reporting this issue. - -Fixes CVE-2023-24534 -For #58975 -Fixes #59267 - -Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1802452 -Run-TryBot: Damien Neil -Reviewed-by: Roland Shoemaker -Reviewed-by: Julie Qiu -(cherry picked from commit f739f080a72fd5b06d35c8e244165159645e2ed6) -Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1802393 -Reviewed-by: Damien Neil -Run-TryBot: Roland Shoemaker -Change-Id: I675451438d619a9130360c56daf529559004903f -Reviewed-on: https://go-review.googlesource.com/c/go/+/481982 -Run-TryBot: Michael Knyszek -TryBot-Result: Gopher Robot -Reviewed-by: Matthew Dempsky -Auto-Submit: Michael Knyszek ---- - src/net/textproto/reader.go | 24 ++++++++++--- - src/net/textproto/reader_test.go | 59 ++++++++++++++++++++++++++++++++ - 2 files changed, 79 insertions(+), 4 deletions(-) - -diff --git a/src/net/textproto/reader.go b/src/net/textproto/reader.go -index b37be54d67..9a21777df8 100644 ---- a/src/net/textproto/reader.go -+++ b/src/net/textproto/reader.go -@@ -493,8 +493,11 @@ func readMIMEHeader(r *Reader, lim int64) (MIMEHeader, error) { - // large one ahead of time which we'll cut up into smaller - // slices. If this isn't big enough later, we allocate small ones. - var strs []string -- hint := r.upcomingHeaderNewlines() -+ hint := r.upcomingHeaderKeys() - if hint > 0 { -+ if hint > 1000 { -+ hint = 1000 // set a cap to avoid overallocation -+ } - strs = make([]string, hint) - } - -@@ -577,9 +580,9 @@ func mustHaveFieldNameColon(line []byte) error { - - var nl = []byte("\n") - --// upcomingHeaderNewlines returns an approximation of the number of newlines -+// upcomingHeaderKeys returns an approximation of the number of keys - // that will be in this header. If it gets confused, it returns 0. --func (r *Reader) upcomingHeaderNewlines() (n int) { -+func (r *Reader) upcomingHeaderKeys() (n int) { - // Try to determine the 'hint' size. - r.R.Peek(1) // force a buffer load if empty - s := r.R.Buffered() -@@ -587,7 +590,20 @@ func (r *Reader) upcomingHeaderNewlines() (n int) { - return - } - peek, _ := r.R.Peek(s) -- return bytes.Count(peek, nl) -+ for len(peek) > 0 && n < 1000 { -+ var line []byte -+ line, peek, _ = bytes.Cut(peek, nl) -+ if len(line) == 0 || (len(line) == 1 && line[0] == '\r') { -+ // Blank line separating headers from the body. -+ break -+ } -+ if line[0] == ' ' || line[0] == '\t' { -+ // Folded continuation of the previous line. -+ continue -+ } -+ n++ -+ } -+ return n - } - - // CanonicalMIMEHeaderKey returns the canonical format of the -diff --git a/src/net/textproto/reader_test.go b/src/net/textproto/reader_test.go -index d11d40f1cf..f3c372ce03 100644 ---- a/src/net/textproto/reader_test.go -+++ b/src/net/textproto/reader_test.go -@@ -10,6 +10,7 @@ import ( - "io" - "net" - "reflect" -+ "runtime" - "strings" - "sync" - "testing" -@@ -129,6 +130,42 @@ func TestReadMIMEHeaderSingle(t *testing.T) { - } - } - -+// TestReaderUpcomingHeaderKeys is testing an internal function, but it's very -+// difficult to test well via the external API. -+func TestReaderUpcomingHeaderKeys(t *testing.T) { -+ for _, test := range []struct { -+ input string -+ want int -+ }{{ -+ input: "", -+ want: 0, -+ }, { -+ input: "A: v", -+ want: 1, -+ }, { -+ input: "A: v\r\nB: v\r\n", -+ want: 2, -+ }, { -+ input: "A: v\nB: v\n", -+ want: 2, -+ }, { -+ input: "A: v\r\n continued\r\n still continued\r\nB: v\r\n\r\n", -+ want: 2, -+ }, { -+ input: "A: v\r\n\r\nB: v\r\nC: v\r\n", -+ want: 1, -+ }, { -+ input: "A: v" + strings.Repeat("\n", 1000), -+ want: 1, -+ }} { -+ r := reader(test.input) -+ got := r.upcomingHeaderKeys() -+ if test.want != got { -+ t.Fatalf("upcomingHeaderKeys(%q): %v; want %v", test.input, got, test.want) -+ } -+ } -+} -+ - func TestReadMIMEHeaderNoKey(t *testing.T) { - r := reader(": bar\ntest-1: 1\n\n") - m, err := r.ReadMIMEHeader() -@@ -225,6 +262,28 @@ func TestReadMIMEHeaderTrimContinued(t *testing.T) { - } - } - -+// Test that reading a header doesn't overallocate. Issue 58975. -+func TestReadMIMEHeaderAllocations(t *testing.T) { -+ var totalAlloc uint64 -+ const count = 200 -+ for i := 0; i < count; i++ { -+ r := reader("A: b\r\n\r\n" + strings.Repeat("\n", 4096)) -+ var m1, m2 runtime.MemStats -+ runtime.ReadMemStats(&m1) -+ _, err := r.ReadMIMEHeader() -+ if err != nil { -+ t.Fatalf("ReadMIMEHeader: %v", err) -+ } -+ runtime.ReadMemStats(&m2) -+ totalAlloc += m2.TotalAlloc - m1.TotalAlloc -+ } -+ // 32k is large and we actually allocate substantially less, -+ // but prior to the fix for #58975 we allocated ~400k in this case. -+ if got, want := totalAlloc/count, uint64(32768); got > want { -+ t.Fatalf("ReadMIMEHeader allocated %v bytes, want < %v", got, want) -+ } -+} -+ - type readResponseTest struct { - in string - inCode int --- -2.33.0 - diff --git a/go1.19.4.src.tar.gz b/go1.20.5.src.tar.gz similarity index 71% rename from go1.19.4.src.tar.gz rename to go1.20.5.src.tar.gz index 2a2e59ad1bfbb74899a287646577eabc395ad68f..28a749f42d77029a10726fbb54bf09adea6ff5e8 100644 Binary files a/go1.19.4.src.tar.gz and b/go1.20.5.src.tar.gz differ diff --git a/golang.spec b/golang.spec index 908afb2a359f18fc254e86785fd3fb8825c8345a..fb2290861239ebbe1112e7ceb62e16513b22f36d 100644 --- a/golang.spec +++ b/golang.spec @@ -2,8 +2,8 @@ %global _binaries_in_noarch_packages_terminate_build 0 %global golibdir %{_libdir}/golang %global goroot /usr/lib/%{name} -%global go_api 1.19 -%global go_version 1.19 +%global go_api 1.20 +%global go_version 1.20 %global __spec_install_post /usr/lib/rpm/check-rpaths /usr/lib/rpm/check-buildroot /usr/lib/rpm/brp-compress %global __requires_exclude_from ^(%{_datadir}|/usr/lib)/%{name}/(doc|src)/.*$ %global __strip /bin/true @@ -44,11 +44,9 @@ %global shared 0 -%ifarch x86_64 -%global race 1 -%else +# Pre build std lib with -race enabled +# Disabled due to 1.20 new cache usage, see 1.20 upstream release notes %global race 0 -%endif %ifarch x86_64 %global gohostarch amd64 @@ -61,17 +59,13 @@ %endif Name: golang -Version: 1.19.4 -Release: 5 +Version: 1.20.5 +Release: 1 Summary: The Go Programming Language License: BSD and Public Domain URL: https://golang.org/ -Source0: https://dl.google.com/go/go1.19.4.src.tar.gz -Patch0: 0001-Enable-go-plugin-support-for-riscv64.patch -Patch1: 0002-runtime-support-riscv64-SV57-mode.patch -Patch2: 0003-release-branch.go1.19-go-scanner-reject-large-line.patch -Patch3: 0004-release-branch.go1.19-html-template-disallow-actions.patch -Patch4: 0005-release-branch.go1.19-net-textproto-avoid-overpredic.patch +Source0: https://dl.google.com/go/go1.20.5.src.tar.gz + %if !%{golang_bootstrap} BuildRequires: gcc-go >= 5 %else @@ -152,7 +146,7 @@ Obsoletes: %{name}-vim < 1.4 Obsoletes: emacs-%{name} < 1.4 Requires: %{vendor}-rpm-config -#Patch6001: 0001-release-branch.go1.17-crypto-elliptic-tolerate-zero-.patch +Patch6001: 0001-Enable-go-plugin-support-for-riscv64-based-on-work-b.patch ExclusiveArch: %{golang_arches} @@ -391,18 +385,5 @@ fi %files devel -f go-tests.list -f go-misc.list -f go-src.list %changelog -* Sat May 6 2023 sunchendong - 1.19.4-5 -- fix CVE-2023-24534 - -* Fri Apr 21 2023 sunchendong - 1.19.4-4 -- fix CVE-2023-24538 - -* Thu Apr 20 2023 sunchendong - 1.19.4-3 -- fix CVE-2023-24537 - -* Mon Apr 03 2023 misaka00251 - 1.19.4-2 -- Enable go plugin support for riscv64 (based on work by yangjinghua) -- Backport upstream sv57 enablement for riscv64 - -* Tue Jan 10 2023 hanchao - 1.19.4-1 -- upgrade to 1.19.4 +* Wed Jun 21 2023 hanchao - 1.20.5-1 +- upgrade to 1.20.5