diff --git a/0001-drop-hard-code-cert.patch b/0001-drop-hard-code-cert.patch deleted file mode 100644 index 1af1acc73a346d0e546ae1f4be3c0f0bd6c55841..0000000000000000000000000000000000000000 --- a/0001-drop-hard-code-cert.patch +++ /dev/null @@ -1,135 +0,0 @@ -From 2720067ebfb7568792bb0c8fe3fbf095c89b77a9 Mon Sep 17 00:00:00 2001 -From: jingrui -Date: Tue, 17 Mar 2020 17:43:33 +0800 -Subject: [PATCH] drop hard-code cert - -Signed-off-by: jingrui ---- - src/crypto/x509/test-file.crt | 32 --------------------------- - src/crypto/x509/testdata/test-dir.crt | 31 -------------------------- - src/net/http/internal/testcert.go | 31 ++------------------------ - 3 files changed, 2 insertions(+), 92 deletions(-) - delete mode 100644 src/crypto/x509/test-file.crt - delete mode 100644 src/crypto/x509/testdata/test-dir.crt - -diff --git a/src/crypto/x509/test-file.crt b/src/crypto/x509/test-file.crt -deleted file mode 100644 -index caa83b9..0000000 ---- a/src/crypto/x509/test-file.crt -+++ /dev/null -@@ -1,32 +0,0 @@ -------BEGIN CERTIFICATE----- --MIIFbTCCA1WgAwIBAgIJAN338vEmMtLsMA0GCSqGSIb3DQEBCwUAME0xCzAJBgNV --BAYTAlVLMRMwEQYDVQQIDApUZXN0LVN0YXRlMRUwEwYDVQQKDAxHb2xhbmcgVGVz --dHMxEjAQBgNVBAMMCXRlc3QtZmlsZTAeFw0xNzAyMDEyMzUyMDhaFw0yNzAxMzAy --MzUyMDhaME0xCzAJBgNVBAYTAlVLMRMwEQYDVQQIDApUZXN0LVN0YXRlMRUwEwYD --VQQKDAxHb2xhbmcgVGVzdHMxEjAQBgNVBAMMCXRlc3QtZmlsZTCCAiIwDQYJKoZI --hvcNAQEBBQADggIPADCCAgoCggIBAPMGiLjdiffQo3Xc8oUe7wsDhSaAJFOhO6Qs --i0xYrYl7jmCuz9rGD2fdgk5cLqGazKuQ6fIFzHXFU2BKs4CWXt9KO0KFEhfvZeuW --jG5d7C1ZUiuKOrPqjKVu8SZtFPc7y7Ke7msXzY+Z2LLyiJJ93LCMq4+cTSGNXVlI --KqUxhxeoD5/QkUPyQy/ilu3GMYfx/YORhDP6Edcuskfj8wRh1UxBejP8YPMvI6St --cE2GkxoEGqDWnQ/61F18te6WI3MD29tnKXOkXVhnSC+yvRLljotW2/tAhHKBG4tj --iQWT5Ri4Wrw2tXxPKRLsVWc7e1/hdxhnuvYpXkWNhKsm002jzkFXlzfEwPd8nZdw --5aT6gPUBN2AAzdoqZI7E200i0orEF7WaSoMfjU1tbHvExp3vyAPOfJ5PS2MQ6W03 --Zsy5dTVH+OBH++rkRzQCFcnIv/OIhya5XZ9KX9nFPgBEP7Xq2A+IjH7B6VN/S/bv --8lhp2V+SQvlew9GttKC4hKuPsl5o7+CMbcqcNUdxm9gGkN8epGEKCuix97bpNlxN --fHZxHE5+8GMzPXMkCD56y5TNKR6ut7JGHMPtGl5lPCLqzG/HzYyFgxsDfDUu2B0A --GKj0lGpnLfGqwhs2/s3jpY7+pcvVQxEpvVTId5byDxu1ujP4HjO/VTQ2P72rE8Ft --C6J2Av0tAgMBAAGjUDBOMB0GA1UdDgQWBBTLT/RbyfBB/Pa07oBnaM+QSJPO9TAf --BgNVHSMEGDAWgBTLT/RbyfBB/Pa07oBnaM+QSJPO9TAMBgNVHRMEBTADAQH/MA0G --CSqGSIb3DQEBCwUAA4ICAQB3sCntCcQwhMgRPPyvOCMyTcQ/Iv+cpfxz2Ck14nlx --AkEAH2CH0ov5GWTt07/ur3aa5x+SAKi0J3wTD1cdiw4U/6Uin6jWGKKxvoo4IaeK --SbM8w/6eKx6UbmHx7PA/eRABY9tTlpdPCVgw7/o3WDr03QM+IAtatzvaCPPczake --pbdLwmBZB/v8V+6jUajy6jOgdSH0PyffGnt7MWgDETmNC6p/Xigp5eh+C8Fb4NGT --xgHES5PBC+sruWp4u22bJGDKTvYNdZHsnw/CaKQWNsQqwisxa3/8N5v+PCff/pxl --r05pE3PdHn9JrCl4iWdVlgtiI9BoPtQyDfa/OEFaScE8KYR8LxaAgdgp3zYncWls --BpwQ6Y/A2wIkhlD9eEp5Ib2hz7isXOs9UwjdriKqrBXqcIAE5M+YIk3+KAQKxAtd --4YsK3CSJ010uphr12YKqlScj4vuKFjuOtd5RyyMIxUG3lrrhAu2AzCeKCLdVgA8+ --75FrYMApUdvcjp4uzbBoED4XRQlx9kdFHVbYgmE/+yddBYJM8u4YlgAL0hW2/D8p --z9JWIfxVmjJnBnXaKGBuiUyZ864A3PJndP6EMMo7TzS2CDnfCYuJjvI0KvDjFNmc --rQA04+qfMSEz3nmKhbbZu4eYLzlADhfH8tT4GMtXf71WLA5AUHGf2Y4+HIHTsmHG --vQ== -------END CERTIFICATE----- -diff --git a/src/crypto/x509/testdata/test-dir.crt b/src/crypto/x509/testdata/test-dir.crt -deleted file mode 100644 -index b7fc9c5..0000000 ---- a/src/crypto/x509/testdata/test-dir.crt -+++ /dev/null -@@ -1,31 +0,0 @@ -------BEGIN CERTIFICATE----- --MIIFazCCA1OgAwIBAgIJAL8a/lsnspOqMA0GCSqGSIb3DQEBCwUAMEwxCzAJBgNV --BAYTAlVLMRMwEQYDVQQIDApUZXN0LVN0YXRlMRUwEwYDVQQKDAxHb2xhbmcgVGVz --dHMxETAPBgNVBAMMCHRlc3QtZGlyMB4XDTE3MDIwMTIzNTAyN1oXDTI3MDEzMDIz --NTAyN1owTDELMAkGA1UEBhMCVUsxEzARBgNVBAgMClRlc3QtU3RhdGUxFTATBgNV --BAoMDEdvbGFuZyBUZXN0czERMA8GA1UEAwwIdGVzdC1kaXIwggIiMA0GCSqGSIb3 --DQEBAQUAA4ICDwAwggIKAoICAQDzBoi43Yn30KN13PKFHu8LA4UmgCRToTukLItM --WK2Je45grs/axg9n3YJOXC6hmsyrkOnyBcx1xVNgSrOAll7fSjtChRIX72Xrloxu --XewtWVIrijqz6oylbvEmbRT3O8uynu5rF82Pmdiy8oiSfdywjKuPnE0hjV1ZSCql --MYcXqA+f0JFD8kMv4pbtxjGH8f2DkYQz+hHXLrJH4/MEYdVMQXoz/GDzLyOkrXBN --hpMaBBqg1p0P+tRdfLXuliNzA9vbZylzpF1YZ0gvsr0S5Y6LVtv7QIRygRuLY4kF --k+UYuFq8NrV8TykS7FVnO3tf4XcYZ7r2KV5FjYSrJtNNo85BV5c3xMD3fJ2XcOWk --+oD1ATdgAM3aKmSOxNtNItKKxBe1mkqDH41NbWx7xMad78gDznyeT0tjEOltN2bM --uXU1R/jgR/vq5Ec0AhXJyL/ziIcmuV2fSl/ZxT4ARD+16tgPiIx+welTf0v27/JY --adlfkkL5XsPRrbSguISrj7JeaO/gjG3KnDVHcZvYBpDfHqRhCgrosfe26TZcTXx2 --cRxOfvBjMz1zJAg+esuUzSkerreyRhzD7RpeZTwi6sxvx82MhYMbA3w1LtgdABio --9JRqZy3xqsIbNv7N46WO/qXL1UMRKb1UyHeW8g8btboz+B4zv1U0Nj+9qxPBbQui --dgL9LQIDAQABo1AwTjAdBgNVHQ4EFgQUy0/0W8nwQfz2tO6AZ2jPkEiTzvUwHwYD --VR0jBBgwFoAUy0/0W8nwQfz2tO6AZ2jPkEiTzvUwDAYDVR0TBAUwAwEB/zANBgkq --hkiG9w0BAQsFAAOCAgEAvEVnUYsIOt87rggmLPqEueynkuQ+562M8EDHSQl82zbe --xDCxeg3DvPgKb+RvaUdt1362z/szK10SoeMgx6+EQLoV9LiVqXwNqeYfixrhrdw3 --ppAhYYhymdkbUQCEMHypmXP1vPhAz4o8Bs+eES1M+zO6ErBiD7SqkmBElT+GixJC --6epC9ZQFs+dw3lPlbiZSsGE85sqc3VAs0/JgpL/pb1/Eg4s0FUhZD2C2uWdSyZGc --g0/v3aXJCp4j/9VoNhI1WXz3M45nysZIL5OQgXymLqJElQa1pZ3Wa4i/nidvT4AT --Xlxc/qijM8set/nOqp7hVd5J0uG6qdwLRILUddZ6OpXd7ZNi1EXg+Bpc7ehzGsDt --3UFGzYXDjxYnK2frQfjLS8stOQIqSrGthW6x0fdkVx0y8BByvd5J6+JmZl4UZfzA --m99VxXSt4B9x6BvnY7ktzcFDOjtuLc4B/7yg9fv1eQuStA4cHGGAttsCg1X/Kx8W --PvkkeH0UWDZ9vhH9K36703z89da6MWF+bz92B0+4HoOmlVaXRkvblsNaynJnL0LC --Ayry7QBxuh5cMnDdRwJB3AVJIiJ1GVpb7aGvBOnx+s2lwRv9HWtghb+cbwwktx1M --JHyBf3GZNSWTpKY7cD8V+NnBv3UuioOVVo+XAU4LF/bYUjdRpxWADJizNtZrtFo= -------END CERTIFICATE----- -diff --git a/src/net/http/internal/testcert.go b/src/net/http/internal/testcert.go -index 2284a83..a33d06b 100644 ---- a/src/net/http/internal/testcert.go -+++ b/src/net/http/internal/testcert.go -@@ -10,36 +10,9 @@ import "strings" - // "127.0.0.1" and "[::1]", expiring at Jan 29 16:00:00 2084 GMT. - // generated from src/crypto/tls: - // go run generate_cert.go --rsa-bits 1024 --host 127.0.0.1,::1,example.com --ca --start-date "Jan 1 00:00:00 1970" --duration=1000000h --var LocalhostCert = []byte(`-----BEGIN CERTIFICATE----- --MIICEzCCAXygAwIBAgIQMIMChMLGrR+QvmQvpwAU6zANBgkqhkiG9w0BAQsFADAS --MRAwDgYDVQQKEwdBY21lIENvMCAXDTcwMDEwMTAwMDAwMFoYDzIwODQwMTI5MTYw --MDAwWjASMRAwDgYDVQQKEwdBY21lIENvMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCB --iQKBgQDuLnQAI3mDgey3VBzWnB2L39JUU4txjeVE6myuDqkM/uGlfjb9SjY1bIw4 --iA5sBBZzHi3z0h1YV8QPuxEbi4nW91IJm2gsvvZhIrCHS3l6afab4pZBl2+XsDul --rKBxKKtD1rGxlG4LjncdabFn9gvLZad2bSysqz/qTAUStTvqJQIDAQABo2gwZjAO --BgNVHQ8BAf8EBAMCAqQwEwYDVR0lBAwwCgYIKwYBBQUHAwEwDwYDVR0TAQH/BAUw --AwEB/zAuBgNVHREEJzAlggtleGFtcGxlLmNvbYcEfwAAAYcQAAAAAAAAAAAAAAAA --AAAAATANBgkqhkiG9w0BAQsFAAOBgQCEcetwO59EWk7WiJsG4x8SY+UIAA+flUI9 --tyC4lNhbcF2Idq9greZwbYCqTTTr2XiRNSMLCOjKyI7ukPoPjo16ocHj+P3vZGfs --h1fIw3cSS2OolhloGw/XM6RWPWtPAlGykKLciQrBru5NAPvCMsb/I1DAceTiotQM --fblo6RBxUQ== -------END CERTIFICATE-----`) -+var LocalhostCert = []byte(``) - - // LocalhostKey is the private key for localhostCert. --var LocalhostKey = []byte(testingKey(`-----BEGIN RSA TESTING KEY----- --MIICXgIBAAKBgQDuLnQAI3mDgey3VBzWnB2L39JUU4txjeVE6myuDqkM/uGlfjb9 --SjY1bIw4iA5sBBZzHi3z0h1YV8QPuxEbi4nW91IJm2gsvvZhIrCHS3l6afab4pZB --l2+XsDulrKBxKKtD1rGxlG4LjncdabFn9gvLZad2bSysqz/qTAUStTvqJQIDAQAB --AoGAGRzwwir7XvBOAy5tM/uV6e+Zf6anZzus1s1Y1ClbjbE6HXbnWWF/wbZGOpet --3Zm4vD6MXc7jpTLryzTQIvVdfQbRc6+MUVeLKwZatTXtdZrhu+Jk7hx0nTPy8Jcb --uJqFk541aEw+mMogY/xEcfbWd6IOkp+4xqjlFLBEDytgbIECQQDvH/E6nk+hgN4H --qzzVtxxr397vWrjrIgPbJpQvBsafG7b0dA4AFjwVbFLmQcj2PprIMmPcQrooz8vp --jy4SHEg1AkEA/v13/5M47K9vCxmb8QeD/asydfsgS5TeuNi8DoUBEmiSJwma7FXY --fFUtxuvL7XvjwjN5B30pNEbc6Iuyt7y4MQJBAIt21su4b3sjXNueLKH85Q+phy2U --fQtuUE9txblTu14q3N7gHRZB4ZMhFYyDy8CKrN2cPg/Fvyt0Xlp/DoCzjA0CQQDU --y2ptGsuSmgUtWj3NM9xuwYPm+Z/F84K6+ARYiZ6PYj013sovGKUFfYAqVXVlxtIX --qyUBnu3X9ps8ZfjLZO7BAkEAlT4R5Yl6cGhaJQYZHOde3JEMhNRcVFMO8dJDaFeo --f9Oeos0UUothgiDktdQHxdNEwLjQf7lJJBzV+5OtwswCWA== -------END RSA TESTING KEY-----`)) -+var LocalhostKey = []byte(testingKey(``)) - - func testingKey(s string) string { return strings.ReplaceAll(s, "TESTING KEY", "PRIVATE KEY") } --- -2.17.1 - diff --git a/0001-release-branch.go1.15-doc-go1.15-mention-1.15.3-cgo-.patch b/0001-release-branch.go1.15-doc-go1.15-mention-1.15.3-cgo-.patch deleted file mode 100644 index dfe3597f83f78b4854a3674ee54364d0033ed1c2..0000000000000000000000000000000000000000 --- a/0001-release-branch.go1.15-doc-go1.15-mention-1.15.3-cgo-.patch +++ /dev/null @@ -1,52 +0,0 @@ -From 069f9d96d179becc61231d566c9a75f1ec26e991 Mon Sep 17 00:00:00 2001 -From: Ian Lance Taylor -Date: Fri, 11 Dec 2020 19:10:00 -0800 -Subject: [PATCH 01/44] [release-branch.go1.15] doc/go1.15: mention 1.15.3 cgo - restriction on empty structs - -For #40954 - -Change-Id: I6a30aed31a16e820817f4ca5c7f591222e922946 -Reviewed-on: https://go-review.googlesource.com/c/go/+/277432 -Trust: Ian Lance Taylor -Reviewed-by: Keith Randall -(cherry picked from commit 129bb1917b4914f0743ec9b4ef0dfb74df39c07d) -Reviewed-on: https://go-review.googlesource.com/c/go/+/278573 -Run-TryBot: Ian Lance Taylor -TryBot-Result: Go Bot -Reviewed-by: Dmitri Shuralyov - -Conflict:NA -Reference:https://github.com/golang/go/commit/069f9d96d179becc61231d566c9a75f1ec26e991 - ---- - doc/go1.15.html | 13 +++++++++++++ - 1 file changed, 13 insertions(+) - -diff --git a/doc/go1.15.html b/doc/go1.15.html -index c691bf3bd5..c9997c0ca3 100644 ---- a/doc/go1.15.html -+++ b/doc/go1.15.html -@@ -397,6 +397,19 @@ Do not send CLs removing the interior tags from such phrases. - documentation for more information. -

- -+

-+ In Go 1.15.3 and later, cgo will not permit Go code to allocate an -+ undefined struct type (a C struct defined as just struct -+ S; or similar) on the stack or heap. -+ Go code will only be permitted to use pointers to those types. -+ Allocating an instance of such a struct and passing a pointer, or a -+ full struct value, to C code was always unsafe and unlikely to work -+ correctly; it is now forbidden. -+ The fix is to either rewrite the Go code to use only pointers, or to -+ ensure that the Go code sees the full definition of the struct by -+ including the appropriate C header file. -+

-+ -

X.509 CommonName deprecation

- -

--- -2.27.0 - diff --git a/0061-release-branch.go1.17-crypto-elliptic-tolerate-zero-.patch b/0001-release-branch.go1.17-crypto-elliptic-tolerate-zero-.patch similarity index 60% rename from 0061-release-branch.go1.17-crypto-elliptic-tolerate-zero-.patch rename to 0001-release-branch.go1.17-crypto-elliptic-tolerate-zero-.patch index d0da46e29856dad78dc0f30056104cd289a5c5c1..6f993e03193c56d30da7f26fdb8cbdc9c9e95ebd 100644 --- a/0061-release-branch.go1.17-crypto-elliptic-tolerate-zero-.patch +++ b/0001-release-branch.go1.17-crypto-elliptic-tolerate-zero-.patch @@ -1,7 +1,7 @@ -From 0a42f7750216ff7ca3aa1c0fb3fcf6a1f431cca0 Mon Sep 17 00:00:00 2001 +From ad33fdc8f4bce612842d922ca701c3062fe4d4c6 Mon Sep 17 00:00:00 2001 From: Filippo Valsorda Date: Thu, 31 Mar 2022 12:31:58 -0400 -Subject: [Backport] [release-branch.go1.17] crypto/elliptic: tolerate +Subject: [Backport 1/2] [release-branch.go1.17] crypto/elliptic: tolerate zero-padded scalars in generic P-256 Updates #52075 @@ -13,19 +13,32 @@ Reviewed-on: https://go-review.googlesource.com/c/go/+/397136 Trust: Filippo Valsorda Reviewed-by: Julie Qiu -Conflict: NA -Reference: https://go-review.googlesource.com/c/go/+/397136 +Conflict:NA +Reference:https://go-review.googlesource.com/c/go/+/399816,https://go-review.googlesource.com/c/go/+/397136 --- - src/crypto/elliptic/elliptic_test.go | 14 ++++++++++++++ - src/crypto/elliptic/p256.go | 2 +- + src/crypto/elliptic/p256.go | 2 +- + src/crypto/elliptic/p256_test.go | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) -diff --git a/src/crypto/elliptic/elliptic_test.go b/src/crypto/elliptic/elliptic_test.go -index bb16b0d163..498f617198 100644 ---- a/src/crypto/elliptic/elliptic_test.go -+++ b/src/crypto/elliptic/elliptic_test.go -@@ -802,3 +802,17 @@ func testInvalidCoordinates(t *testing.T, curve Curve) { - checkIsOnCurveFalse("P, y", p, yy) +diff --git a/src/crypto/elliptic/p256.go b/src/crypto/elliptic/p256.go +index b2b12c8f13..da5283735c 100644 +--- a/src/crypto/elliptic/p256.go ++++ b/src/crypto/elliptic/p256.go +@@ -52,7 +52,7 @@ func p256GetScalar(out *[32]byte, in []byte) { + n := new(big.Int).SetBytes(in) + var scalarBytes []byte + +- if n.Cmp(p256Params.N) >= 0 { ++ if n.Cmp(p256Params.N) >= 0 || len(in) > len(out) { + n.Mod(n, p256Params.N) + scalarBytes = n.Bytes() + } else { +diff --git a/src/crypto/elliptic/p256_test.go b/src/crypto/elliptic/p256_test.go +index 1435f5e1a5..694186df81 100644 +--- a/src/crypto/elliptic/p256_test.go ++++ b/src/crypto/elliptic/p256_test.go +@@ -153,3 +153,17 @@ func TestP256CombinedMult(t *testing.T) { + t.Errorf("1×G + (-1)×G = (%d, %d), should be ∞", x, y) } } + @@ -42,19 +55,6 @@ index bb16b0d163..498f617198 100644 + t.Errorf("unexpected output (%v,%v)", x, y) + } +} -diff --git a/src/crypto/elliptic/p256.go b/src/crypto/elliptic/p256.go -index c23e414156..787e3e7444 100644 ---- a/src/crypto/elliptic/p256.go -+++ b/src/crypto/elliptic/p256.go -@@ -51,7 +51,7 @@ func p256GetScalar(out *[32]byte, in []byte) { - n := new(big.Int).SetBytes(in) - var scalarBytes []byte - -- if n.Cmp(p256Params.N) >= 0 { -+ if n.Cmp(p256Params.N) >= 0 || len(in) > len(out) { - n.Mod(n, p256Params.N) - scalarBytes = n.Bytes() - } else { -- 2.30.0 diff --git a/0002-fix-patch-cmd-go-internal-modfetch-do-not-sho.patch b/0002-fix-patch-cmd-go-internal-modfetch-do-not-sho.patch deleted file mode 100644 index beb1de472e356debda18f1b42492530b1765dacc..0000000000000000000000000000000000000000 --- a/0002-fix-patch-cmd-go-internal-modfetch-do-not-sho.patch +++ /dev/null @@ -1,77 +0,0 @@ -From d57e23e7bd6a8f80ace3f1d668a387cf1bc989f7 Mon Sep 17 00:00:00 2001 -From: hanchao -Date: Wed, 23 Mar 2022 20:51:31 +0800 -Subject: [PATCH 2/2] fix patch - cmd-go-internal-modfetch-do-not-short-circuit-canoni.patch - -reason:the above patch is to fix CVE-2022-23773, but it does not work with golang1.15, -so this patch is used to fix the above issue. - -Conflict:NA -Reference:https://go-review.googlesource.com/c/go/+/378400/ - -Signed-off-by: hanchao ---- - src/cmd/go/internal/modfetch/coderepo.go | 24 +++++------------------- - 1 file changed, 5 insertions(+), 19 deletions(-) - -diff --git a/src/cmd/go/internal/modfetch/coderepo.go b/src/cmd/go/internal/modfetch/coderepo.go -index c654b36..def62d7 100644 ---- a/src/cmd/go/internal/modfetch/coderepo.go -+++ b/src/cmd/go/internal/modfetch/coderepo.go -@@ -456,11 +456,6 @@ func (r *codeRepo) convert(info *codehost.RevInfo, statVers string) (*RevInfo, e - tagPrefix = r.codeDir + "/" - } - -- isRetracted, err := r.retractedVersions() -- if err != nil { -- isRetracted = func(string) bool { return false } -- } -- - // tagToVersion returns the version obtained by trimming tagPrefix from tag. - // If the tag is invalid, retracted, or a pseudo-version, tagToVersion returns - // an empty version. -@@ -523,7 +518,7 @@ func (r *codeRepo) convert(info *codehost.RevInfo, statVers string) (*RevInfo, e - } - // Save the highest non-retracted canonical tag for the revision. - // If we don't find a better match, we'll use it as the canonical version. -- if tagIsCanonical && semver.Compare(highestCanonical, v) < 0 && !isRetracted(v) { -+ if tagIsCanonical && semver.Compare(highestCanonical, v) < 0 { - if module.MatchPathMajor(v, r.pathMajor) || canUseIncompatible(v) { - highestCanonical = v - } -@@ -536,27 +531,18 @@ func (r *codeRepo) convert(info *codehost.RevInfo, statVers string) (*RevInfo, e - return checkCanonical(highestCanonical) - } - -- // Find the highest tagged version in the revision's history, subject to -- // major version and +incompatible constraints. Use that version as the -- // pseudo-version base so that the pseudo-version sorts higher. Ignore -- // retracted versions. -- allowedMajor := func(major string) func(v string) bool { -- return func(v string) bool { -- return ((major == "" && canUseIncompatible(v)) || semver.Major(v) == major) && !isRetracted(v) -- } -- } - if pseudoBase == "" { - var tag string - if r.pseudoMajor != "" || canUseIncompatible("") { -- tag, _ = r.code.RecentTag(info.Name, tagPrefix, allowedMajor(r.pseudoMajor)) -+ tag, _ = r.code.RecentTag(info.Name, tagPrefix, r.pseudoMajor) - } else { - // Allow either v1 or v0, but not incompatible higher versions. -- tag, _ = r.code.RecentTag(info.Name, tagPrefix, allowedMajor("v1")) -+ tag, _ = r.code.RecentTag(info.Name, tagPrefix, "v1") - if tag == "" { -- tag, _ = r.code.RecentTag(info.Name, tagPrefix, allowedMajor("v0")) -+ tag, _ = r.code.RecentTag(info.Name, tagPrefix, "v0") - } - } -- pseudoBase, _ = tagToVersion(tag) -+ pseudoBase, _ = tagToVersion(tag) // empty if the tag is invalid - } - - return checkCanonical(PseudoVersion(r.pseudoMajor, pseudoBase, info.Time, info.Short)) --- -2.30.0 - diff --git a/0002-release-branch.go1.15-cmd-go-fix-mod_get_fallback-te.patch b/0002-release-branch.go1.15-cmd-go-fix-mod_get_fallback-te.patch deleted file mode 100644 index 6b855bac47d78308a130c7c236da89f566d2ac85..0000000000000000000000000000000000000000 --- a/0002-release-branch.go1.15-cmd-go-fix-mod_get_fallback-te.patch +++ /dev/null @@ -1,38 +0,0 @@ -From aaef93bba34740d793e987d95355feb312f01cfd Mon Sep 17 00:00:00 2001 -From: Jay Conrod -Date: Wed, 20 Jan 2021 09:45:03 -0500 -Subject: [PATCH 02/44] [release-branch.go1.15] cmd/go: fix mod_get_fallback - test - -Fixes #43797 - -Change-Id: I3d791d0ac9ce0b523c78c649aaf5e339a7f63b76 -Reviewed-on: https://go-review.googlesource.com/c/go/+/284797 -Trust: Jay Conrod -Run-TryBot: Jay Conrod -Reviewed-by: Bryan C. Mills -TryBot-Result: Go Bot -(cherry picked from commit be28e5abc5ddca0d6b2d8c91b7bb9c05717154e7) -Reviewed-on: https://go-review.googlesource.com/c/go/+/284799 - -Conflict:NA -Reference:https://github.com/golang/go/commit/aaef93bba34740d793e987d95355feb312f01cfd - ---- - src/cmd/go/testdata/script/mod_get_fallback.txt | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/cmd/go/testdata/script/mod_get_fallback.txt b/src/cmd/go/testdata/script/mod_get_fallback.txt -index a9834a324e..9733fa366b 100644 ---- a/src/cmd/go/testdata/script/mod_get_fallback.txt -+++ b/src/cmd/go/testdata/script/mod_get_fallback.txt -@@ -6,5 +6,5 @@ env GOPROXY=https://proxy.golang.org,direct - env GOSUMDB=off - - go get -x -v -d golang.org/x/tools/cmd/goimports --stderr '# get https://proxy.golang.org/golang.org/x/tools/@latest' -+stderr '# get https://proxy.golang.org/golang.org/x/tools/@v/list' - ! stderr '# get https://golang.org' --- -2.27.0 - diff --git a/0062-release-branch.go1.17-encoding-pem-fix-stack-overflo.patch b/0002-release-branch.go1.17-encoding-pem-fix-stack-overflo.patch similarity index 98% rename from 0062-release-branch.go1.17-encoding-pem-fix-stack-overflo.patch rename to 0002-release-branch.go1.17-encoding-pem-fix-stack-overflo.patch index 25fc23002c6e543bf9554a53bc191df0ef8c7039..243596c90ead364fc953a1fd4144479adb812e12 100644 --- a/0062-release-branch.go1.17-encoding-pem-fix-stack-overflo.patch +++ b/0002-release-branch.go1.17-encoding-pem-fix-stack-overflo.patch @@ -1,4 +1,4 @@ -From bef7ed470e9a784e1b736c5847aabef2d9ac8094 Mon Sep 17 00:00:00 2001 +From baaaf3ce29bf98efc00c2f06c531f2b0186b027b Mon Sep 17 00:00:00 2001 From: Julie Qiu Date: Tue, 1 Mar 2022 10:19:38 -0600 Subject: [Backport 2/2] [release-branch.go1.17] encoding/pem: fix stack @@ -234,7 +234,7 @@ index a7272da5ad..1bee1c12d2 100644 const pemLineLength = 64 diff --git a/src/encoding/pem/pem_test.go b/src/encoding/pem/pem_test.go -index 8515b46498..44855812b0 100644 +index b2b6b15e73..c94b5ca53b 100644 --- a/src/encoding/pem/pem_test.go +++ b/src/encoding/pem/pem_test.go @@ -107,6 +107,12 @@ const pemMissingEndingSpace = ` diff --git a/0003-release-branch.go1.15-internal-execabs-only-run-test.patch b/0003-release-branch.go1.15-internal-execabs-only-run-test.patch deleted file mode 100644 index bfa22efdc077af7a510c18fe03661b64be14a9e4..0000000000000000000000000000000000000000 --- a/0003-release-branch.go1.15-internal-execabs-only-run-test.patch +++ /dev/null @@ -1,54 +0,0 @@ -From e540758b604dd46b682593e284cf77a61ce3fde6 Mon Sep 17 00:00:00 2001 -From: Roland Shoemaker -Date: Wed, 20 Jan 2021 09:06:12 -0800 -Subject: [PATCH 03/44] [release-branch.go1.15] internal/execabs: only run - tests on platforms that support them - -Fixes #43793 - -Change-Id: I3bf022a28b194f0089ea96d93e56bbd9fb7e0aa8 -Reviewed-on: https://go-review.googlesource.com/c/go/+/285056 -Trust: Roland Shoemaker -Run-TryBot: Roland Shoemaker -Reviewed-by: Dmitri Shuralyov - -Conflict:NA -Reference:https://github.com/golang/go/commit/e540758b604dd46b682593e284cf77a61ce3fde6 - ---- - src/internal/execabs/execabs_test.go | 5 +++++ - 1 file changed, 5 insertions(+) - -diff --git a/src/internal/execabs/execabs_test.go b/src/internal/execabs/execabs_test.go -index a0b88dd2a0..1a197b8701 100644 ---- a/src/internal/execabs/execabs_test.go -+++ b/src/internal/execabs/execabs_test.go -@@ -7,6 +7,7 @@ package execabs - import ( - "context" - "fmt" -+ "internal/testenv" - "io/ioutil" - "os" - "os/exec" -@@ -30,6 +31,8 @@ func TestFixCmd(t *testing.T) { - } - - func TestCommand(t *testing.T) { -+ testenv.MustHaveExec(t) -+ - for _, cmd := range []func(string) *Cmd{ - func(s string) *Cmd { return Command(s) }, - func(s string) *Cmd { return CommandContext(context.Background(), s) }, -@@ -71,6 +74,8 @@ func TestCommand(t *testing.T) { - } - - func TestLookPath(t *testing.T) { -+ testenv.MustHaveExec(t) -+ - tmpDir, err := ioutil.TempDir("", "execabs-test") - if err != nil { - t.Fatalf("ioutil.TempDir failed: %s", err) --- -2.27.0 - diff --git a/0063-release-branch.go1.16-syscall-fix-ForkLock-spurious-.patch b/0003-release-branch.go1.17-syscall-fix-ForkLock-spurious-.patch similarity index 79% rename from 0063-release-branch.go1.16-syscall-fix-ForkLock-spurious-.patch rename to 0003-release-branch.go1.17-syscall-fix-ForkLock-spurious-.patch index efa0922eda83232e26ef59c3be0733e8b03bec7d..64aee693f6998b6f9dd75f404673a048b9e74a24 100644 --- a/0063-release-branch.go1.16-syscall-fix-ForkLock-spurious-.patch +++ b/0003-release-branch.go1.17-syscall-fix-ForkLock-spurious-.patch @@ -1,7 +1,7 @@ -From 98e370069ffceeeeecb94c0b8e6c60c33994071a Mon Sep 17 00:00:00 2001 +From e7aab832069d06d77e04a585803dfdb04453253a Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 8 Dec 2021 18:05:11 -0500 -Subject: [PATCH] [release-branch.go1.16] syscall: fix ForkLock spurious +Subject: [PATCH] [release-branch.go1.17] syscall: fix ForkLock spurious close(0) on pipe failure Pipe (and therefore forkLockPipe) does not make any guarantees @@ -15,23 +15,20 @@ Fixes CVE-2021-44717 Change-Id: Iff8e19a6efbba0c73cc8b13ecfae381c87600bb4 Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1291270 Reviewed-by: Ian Lance Taylor -Reviewed-on: https://go-review.googlesource.com/c/go/+/370514 +Reviewed-on: https://go-review.googlesource.com/c/go/+/370534 Trust: Filippo Valsorda Run-TryBot: Filippo Valsorda TryBot-Result: Gopher Robot Reviewed-by: Alex Rakoczy - -Conflict: NA -Conference: https://go-review.googlesource.com/c/go/+/370514 --- src/syscall/exec_unix.go | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/syscall/exec_unix.go b/src/syscall/exec_unix.go -index cb08b7084c..3a8ef0925e 100644 +index 54b18dccd7..c9c9d1abf3 100644 --- a/src/syscall/exec_unix.go +++ b/src/syscall/exec_unix.go -@@ -152,9 +152,6 @@ func forkExec(argv0 string, argv []string, attr *ProcAttr) (pid int, err error) +@@ -153,9 +153,6 @@ func forkExec(argv0 string, argv []string, attr *ProcAttr) (pid int, err error) sys = &zeroSysProcAttr } @@ -41,7 +38,7 @@ index cb08b7084c..3a8ef0925e 100644 // Convert args to C form. argv0p, err := BytePtrFromString(argv0) if err != nil { -@@ -204,14 +201,17 @@ func forkExec(argv0 string, argv []string, attr *ProcAttr) (pid int, err error) +@@ -205,14 +202,17 @@ func forkExec(argv0 string, argv []string, attr *ProcAttr) (pid int, err error) // Allocate child status pipe close on exec. if err = forkExecPipe(p[:]); err != nil { @@ -62,7 +59,7 @@ index cb08b7084c..3a8ef0925e 100644 } ForkLock.Unlock() -@@ -243,14 +243,6 @@ func forkExec(argv0 string, argv []string, attr *ProcAttr) (pid int, err error) +@@ -244,14 +244,6 @@ func forkExec(argv0 string, argv []string, attr *ProcAttr) (pid int, err error) // Read got EOF, so pipe closed on exec, so exec succeeded. return pid, nil diff --git a/0004-backport-cmd-link-mark-unexported-methods-for-plugins.patch b/0004-backport-cmd-link-mark-unexported-methods-for-plugins.patch new file mode 100644 index 0000000000000000000000000000000000000000..6b9dd4b07c525c5e2263c1abb1c7c8fa199f8c92 --- /dev/null +++ b/0004-backport-cmd-link-mark-unexported-methods-for-plugins.patch @@ -0,0 +1,39 @@ +From c872b0594f716a2a0799b07d7226a45f02c005f1 Mon Sep 17 00:00:00 2001 +From: Cherry Mui +Date: Wed, 16 Mar 2022 13:07:57 -0400 +Subject: [PATCH] cmd/link: mark unexported methods for plugins + +When plugin is used, we already mark all exported methods +reachable. However, when the plugin and the host program share +a common package, an unexported method could also be reachable +from both the plugin and the host via interfaces. We need to mark +them as well. + +Fixes #51621. + +Change-Id: I1a70d3f96b66b803f2d0ab14d00ed0df276ea500 +Reviewed-on: https://go-review.googlesource.com/c/go/+/393365 +Trust: Cherry Mui +Run-TryBot: Cherry Mui +TryBot-Result: Gopher Robot +Reviewed-by: Than McIntosh +--- + src/cmd/link/internal/ld/deadcode.go | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/cmd/link/internal/ld/deadcode.go b/src/cmd/link/internal/ld/deadcode.go +index e4fa75f..21a9703 100644 +--- a/src/cmd/link/internal/ld/deadcode.go ++++ b/src/cmd/link/internal/ld/deadcode.go +@@ -350,7 +350,7 @@ func deadcode(ctxt *Link) { + // in the last pass. + rem := d.markableMethods[:0] + for _, m := range d.markableMethods { +- if (d.reflectSeen && m.isExported()) || d.ifaceMethod[m.m] { ++ if (d.reflectSeen && (m.isExported() || d.dynlink)) || d.ifaceMethod[m.m] { + d.markMethod(m) + } else { + rem = append(rem, m) +-- +1.8.3.1 + diff --git a/0004-release-branch.go1.15-cmd-compile-don-t-short-circui.patch b/0004-release-branch.go1.15-cmd-compile-don-t-short-circui.patch deleted file mode 100644 index c2211d5fee1929812876453170798551a7a69bd4..0000000000000000000000000000000000000000 --- a/0004-release-branch.go1.15-cmd-compile-don-t-short-circui.patch +++ /dev/null @@ -1,154 +0,0 @@ -From 27d5fccd2119099c70ab6a4418626beac7a97b4b Mon Sep 17 00:00:00 2001 -From: Keith Randall -Date: Thu, 7 Jan 2021 14:57:53 -0800 -Subject: [PATCH 04/44] [release-branch.go1.15] cmd/compile: don't - short-circuit copies whose source is volatile - -Current optimization: When we copy a->b and then b->c, we might as well -copy a->c instead of b->c (then b might be dead and go away). - -*Except* if a is a volatile location (might be clobbered by a call). -In that case, we really do want to copy a immediately, because there -might be a call before we can do the a->c copy. - -User calls can't happen in between, because the rule matches up the -memory states. But calls inserted for memory barriers, particularly -runtime.typedmemmove, can. - -(I guess we could introduce a register-calling-convention version -of runtime.typedmemmove, but that seems a bigger change than this one.) - -Fixes #43575 - -Change-Id: Ifa518bb1a6f3a8dd46c352d4fd54ea9713b3eb1a -Reviewed-on: https://go-review.googlesource.com/c/go/+/282492 -Trust: Keith Randall -Trust: Josh Bleecher Snyder -Run-TryBot: Keith Randall -TryBot-Result: Go Bot -Reviewed-by: Josh Bleecher Snyder -(cherry picked from commit 304f769ffc68e64244266b3aadbf91e6738c0064) -Reviewed-on: https://go-review.googlesource.com/c/go/+/282558 -Trust: Dmitri Shuralyov - -Conflict:NA -Reference:https://github.com/golang/go/commit/27d5fccd2119099c70ab6a4418626beac7a97b4b - ---- - .../compile/internal/ssa/gen/generic.rules | 4 +- - .../compile/internal/ssa/rewritegeneric.go | 8 ++-- - test/fixedbugs/issue43570.go | 40 +++++++++++++++++++ - 3 files changed, 46 insertions(+), 6 deletions(-) - create mode 100644 test/fixedbugs/issue43570.go - -diff --git a/src/cmd/compile/internal/ssa/gen/generic.rules b/src/cmd/compile/internal/ssa/gen/generic.rules -index ed5bfc81fd..8bbe913380 100644 ---- a/src/cmd/compile/internal/ssa/gen/generic.rules -+++ b/src/cmd/compile/internal/ssa/gen/generic.rules -@@ -2404,7 +2404,7 @@ - (Move {t1} [s] dst tmp1 midmem:(Move {t2} [s] tmp2 src _)) - && t1.Compare(t2) == types.CMPeq - && isSamePtr(tmp1, tmp2) -- && isStackPtr(src) -+ && isStackPtr(src) && !isVolatile(src) - && disjoint(src, s, tmp2, s) - && (disjoint(src, s, dst, s) || isInlinableMemmove(dst, src, s, config)) - => (Move {t1} [s] dst src midmem) -@@ -2413,7 +2413,7 @@ - (Move {t1} [s] dst tmp1 midmem:(VarDef (Move {t2} [s] tmp2 src _))) - && t1.Compare(t2) == types.CMPeq - && isSamePtr(tmp1, tmp2) -- && isStackPtr(src) -+ && isStackPtr(src) && !isVolatile(src) - && disjoint(src, s, tmp2, s) - && (disjoint(src, s, dst, s) || isInlinableMemmove(dst, src, s, config)) - => (Move {t1} [s] dst src midmem) -diff --git a/src/cmd/compile/internal/ssa/rewritegeneric.go b/src/cmd/compile/internal/ssa/rewritegeneric.go -index 9f4e1b95bd..6a09616aad 100644 ---- a/src/cmd/compile/internal/ssa/rewritegeneric.go -+++ b/src/cmd/compile/internal/ssa/rewritegeneric.go -@@ -13666,7 +13666,7 @@ func rewriteValuegeneric_OpMove(v *Value) bool { - return true - } - // match: (Move {t1} [s] dst tmp1 midmem:(Move {t2} [s] tmp2 src _)) -- // cond: t1.Compare(t2) == types.CMPeq && isSamePtr(tmp1, tmp2) && isStackPtr(src) && disjoint(src, s, tmp2, s) && (disjoint(src, s, dst, s) || isInlinableMemmove(dst, src, s, config)) -+ // cond: t1.Compare(t2) == types.CMPeq && isSamePtr(tmp1, tmp2) && isStackPtr(src) && !isVolatile(src) && disjoint(src, s, tmp2, s) && (disjoint(src, s, dst, s) || isInlinableMemmove(dst, src, s, config)) - // result: (Move {t1} [s] dst src midmem) - for { - s := auxIntToInt64(v.AuxInt) -@@ -13680,7 +13680,7 @@ func rewriteValuegeneric_OpMove(v *Value) bool { - t2 := auxToType(midmem.Aux) - src := midmem.Args[1] - tmp2 := midmem.Args[0] -- if !(t1.Compare(t2) == types.CMPeq && isSamePtr(tmp1, tmp2) && isStackPtr(src) && disjoint(src, s, tmp2, s) && (disjoint(src, s, dst, s) || isInlinableMemmove(dst, src, s, config))) { -+ if !(t1.Compare(t2) == types.CMPeq && isSamePtr(tmp1, tmp2) && isStackPtr(src) && !isVolatile(src) && disjoint(src, s, tmp2, s) && (disjoint(src, s, dst, s) || isInlinableMemmove(dst, src, s, config))) { - break - } - v.reset(OpMove) -@@ -13690,7 +13690,7 @@ func rewriteValuegeneric_OpMove(v *Value) bool { - return true - } - // match: (Move {t1} [s] dst tmp1 midmem:(VarDef (Move {t2} [s] tmp2 src _))) -- // cond: t1.Compare(t2) == types.CMPeq && isSamePtr(tmp1, tmp2) && isStackPtr(src) && disjoint(src, s, tmp2, s) && (disjoint(src, s, dst, s) || isInlinableMemmove(dst, src, s, config)) -+ // cond: t1.Compare(t2) == types.CMPeq && isSamePtr(tmp1, tmp2) && isStackPtr(src) && !isVolatile(src) && disjoint(src, s, tmp2, s) && (disjoint(src, s, dst, s) || isInlinableMemmove(dst, src, s, config)) - // result: (Move {t1} [s] dst src midmem) - for { - s := auxIntToInt64(v.AuxInt) -@@ -13708,7 +13708,7 @@ func rewriteValuegeneric_OpMove(v *Value) bool { - t2 := auxToType(midmem_0.Aux) - src := midmem_0.Args[1] - tmp2 := midmem_0.Args[0] -- if !(t1.Compare(t2) == types.CMPeq && isSamePtr(tmp1, tmp2) && isStackPtr(src) && disjoint(src, s, tmp2, s) && (disjoint(src, s, dst, s) || isInlinableMemmove(dst, src, s, config))) { -+ if !(t1.Compare(t2) == types.CMPeq && isSamePtr(tmp1, tmp2) && isStackPtr(src) && !isVolatile(src) && disjoint(src, s, tmp2, s) && (disjoint(src, s, dst, s) || isInlinableMemmove(dst, src, s, config))) { - break - } - v.reset(OpMove) -diff --git a/test/fixedbugs/issue43570.go b/test/fixedbugs/issue43570.go -new file mode 100644 -index 0000000000..d073fde5f6 ---- /dev/null -+++ b/test/fixedbugs/issue43570.go -@@ -0,0 +1,40 @@ -+// run -+ -+// Copyright 2021 The Go Authors. All rights reserved. -+// Use of this source code is governed by a BSD-style -+// license that can be found in the LICENSE file. -+ -+package main -+ -+import "fmt" -+ -+type T [8]*int -+ -+//go:noinline -+func f(x int) T { -+ return T{} -+} -+ -+//go:noinline -+func g(x int, t T) { -+ if t != (T{}) { -+ panic(fmt.Sprintf("bad: %v", t)) -+ } -+} -+ -+func main() { -+ const N = 10000 -+ var q T -+ func() { -+ for i := 0; i < N; i++ { -+ q = f(0) -+ g(0, q) -+ sink = make([]byte, 1024) -+ } -+ }() -+ // Note that the closure is a trick to get the write to q to be a -+ // write to a pointer that is known to be non-nil and requires -+ // a write barrier. -+} -+ -+var sink []byte --- -2.27.0 - diff --git a/0005-release-branch.go1.15-cmd-go-fix-get_update_unknown_.patch b/0005-release-branch.go1.15-cmd-go-fix-get_update_unknown_.patch deleted file mode 100644 index 7c01a1940ca6c925b6c52ad36cf96a473f93676d..0000000000000000000000000000000000000000 --- a/0005-release-branch.go1.15-cmd-go-fix-get_update_unknown_.patch +++ /dev/null @@ -1,47 +0,0 @@ -From 9bb97ea047890e900dae04202a231685492c4b18 Mon Sep 17 00:00:00 2001 -From: Jay Conrod -Date: Fri, 22 Jan 2021 16:59:16 -0500 -Subject: [PATCH 05/44] [release-branch.go1.15] cmd/go: fix - get_update_unknown_protocol test - -This test needs to run in GOPATH mode. It broke when a go.mod file was -added to github.com/golang/example. This change sets GO111MODULE=off, -which matches master since CL 255051. - -Fixes #43861 - -Change-Id: I9ea109a99509fac3185756a0f0d852a84c677bf5 -Reviewed-on: https://go-review.googlesource.com/c/go/+/285956 -Trust: Jay Conrod -Run-TryBot: Jay Conrod -TryBot-Result: Go Bot -Reviewed-by: Bryan C. Mills - -Conflict:NA -Reference:https://github.com/golang/go/commit/9bb97ea047890e900dae04202a231685492c4b18 - ---- - src/cmd/go/testdata/script/get_update_unknown_protocol.txt | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/src/cmd/go/testdata/script/get_update_unknown_protocol.txt b/src/cmd/go/testdata/script/get_update_unknown_protocol.txt -index 85c2e24bc8..b00adea70b 100644 ---- a/src/cmd/go/testdata/script/get_update_unknown_protocol.txt -+++ b/src/cmd/go/testdata/script/get_update_unknown_protocol.txt -@@ -1,5 +1,6 @@ - [!net] skip - [!exec:git] skip -+env GO111MODULE=off - - # Clone the repo via HTTPS manually. - exec git clone -q https://github.com/golang/example github.com/golang/example -@@ -10,4 +11,4 @@ cd github.com/golang/example - exec git remote set-url origin xyz://github.com/golang/example - exec git config --local url.https://github.com/.insteadOf xyz://github.com/ - --go get -d -u -f github.com/golang/example/hello -\ No newline at end of file -+go get -d -u -f github.com/golang/example/hello --- -2.27.0 - diff --git a/0064-release-branch.go1.17-net-http-preserve-nil-values-i.patch b/0005-release-branch.go1.17-net-http-preserve-nil-values-i.patch similarity index 90% rename from 0064-release-branch.go1.17-net-http-preserve-nil-values-i.patch rename to 0005-release-branch.go1.17-net-http-preserve-nil-values-i.patch index 3782251ce605851c47182dca720dc73a59206466..98972340a918d866c0322d17b1c10068f2f57910 100644 --- a/0064-release-branch.go1.17-net-http-preserve-nil-values-i.patch +++ b/0005-release-branch.go1.17-net-http-preserve-nil-values-i.patch @@ -1,7 +1,7 @@ -From a6115663a62fb5559d023e32058f2219dd466095 Mon Sep 17 00:00:00 2001 +From 67bff2eb995a098f838fa4b799c0b8261292e6e7 Mon Sep 17 00:00:00 2001 From: Damien Neil Date: Fri, 17 Jun 2022 10:09:45 -0700 -Subject: [PATCH 01/10] [release-branch.go1.17] net/http: preserve nil values +Subject: [PATCH 01/11] [release-branch.go1.17] net/http: preserve nil values in Header.Clone ReverseProxy makes a distinction between nil and zero-length header values. @@ -33,10 +33,10 @@ Reference: https://go-review.googlesource.com/c/go/+/415221 2 files changed, 11 insertions(+) diff --git a/src/net/http/header.go b/src/net/http/header.go -index b9b53911f38..221f613f642 100644 +index 4c72dcb2c88..ef4ee7ffa81 100644 --- a/src/net/http/header.go +++ b/src/net/http/header.go -@@ -100,6 +100,12 @@ func (h Header) Clone() Header { +@@ -101,6 +101,12 @@ func (h Header) Clone() Header { sv := make([]string, nv) // shared backing array for headers' values h2 := make(Header, len(h)) for k, vv := range h { diff --git a/0006-release-branch.go1.15-net-http-update-bundled-x-net-.patch b/0006-release-branch.go1.15-net-http-update-bundled-x-net-.patch deleted file mode 100644 index 35e6235d3086f30c94a948dca5d669f35e9d36f2..0000000000000000000000000000000000000000 --- a/0006-release-branch.go1.15-net-http-update-bundled-x-net-.patch +++ /dev/null @@ -1,106 +0,0 @@ -From a01db0df00fed281f6a9673eb93fe6acae6197cf Mon Sep 17 00:00:00 2001 -From: Damien Neil -Date: Fri, 29 Jan 2021 11:01:37 -0800 -Subject: [PATCH 06/44] [release-branch.go1.15] net/http: update bundled - x/net/http2 - -Updates bundled http2 to x/net git rev 16c2bbf55 for: - - http2: send a nil error if we cancel a delayed body write - https://golang.org/cl/288013 - - http2: wait until the request body has been written - https://golang.org/cl/288012 - -Created by: - -go mod edit -replace=golang.org/x/net=golang.org/x/net@release-branch.go1.15-bundle -GOFLAGS='-mod=mod' go generate -run=bundle std -go mod edit -dropreplace=golang.org/x/net -go get -d golang.org/x/net@release-branch.go1.15 -go mod tidy -go mod vendor - -Fixes golang/go#42539 - -Change-Id: I299c6d4a67ebc036e45c978e4d03cba73717b363 -Reviewed-on: https://go-review.googlesource.com/c/go/+/288112 -Trust: Damien Neil -Run-TryBot: Damien Neil -Reviewed-by: Dmitri Shuralyov - -Conflict:NA -Reference:https://github.com/golang/go/commit/a01db0df00fed281f6a9673eb93fe6acae6197cf - ---- - src/net/http/h2_bundle.go | 12 ++++++++++-- - 1 file changed, 10 insertions(+), 2 deletions(-) - -diff --git a/src/net/http/h2_bundle.go b/src/net/http/h2_bundle.go -index b03b84d2f3..678c6eb9d4 100644 ---- a/src/net/http/h2_bundle.go -+++ b/src/net/http/h2_bundle.go -@@ -7592,6 +7592,9 @@ func (cc *http2ClientConn) roundTrip(req *Request) (res *Response, gotErrAfterRe - // we can keep it. - bodyWriter.cancel() - cs.abortRequestBodyWrite(http2errStopReqBodyWrite) -+ if hasBody && !bodyWritten { -+ <-bodyWriter.resc -+ } - } - if re.err != nil { - cc.forgetStreamID(cs.ID) -@@ -7612,6 +7615,7 @@ func (cc *http2ClientConn) roundTrip(req *Request) (res *Response, gotErrAfterRe - } else { - bodyWriter.cancel() - cs.abortRequestBodyWrite(http2errStopReqBodyWriteAndCancel) -+ <-bodyWriter.resc - } - cc.forgetStreamID(cs.ID) - return nil, cs.getStartedWrite(), http2errTimeout -@@ -7621,6 +7625,7 @@ func (cc *http2ClientConn) roundTrip(req *Request) (res *Response, gotErrAfterRe - } else { - bodyWriter.cancel() - cs.abortRequestBodyWrite(http2errStopReqBodyWriteAndCancel) -+ <-bodyWriter.resc - } - cc.forgetStreamID(cs.ID) - return nil, cs.getStartedWrite(), ctx.Err() -@@ -7630,6 +7635,7 @@ func (cc *http2ClientConn) roundTrip(req *Request) (res *Response, gotErrAfterRe - } else { - bodyWriter.cancel() - cs.abortRequestBodyWrite(http2errStopReqBodyWriteAndCancel) -+ <-bodyWriter.resc - } - cc.forgetStreamID(cs.ID) - return nil, cs.getStartedWrite(), http2errRequestCanceled -@@ -7639,6 +7645,7 @@ func (cc *http2ClientConn) roundTrip(req *Request) (res *Response, gotErrAfterRe - // forgetStreamID. - return nil, cs.getStartedWrite(), cs.resetErr - case err := <-bodyWriter.resc: -+ bodyWritten = true - // Prefer the read loop's response, if available. Issue 16102. - select { - case re := <-readLoopResCh: -@@ -7649,7 +7656,6 @@ func (cc *http2ClientConn) roundTrip(req *Request) (res *Response, gotErrAfterRe - cc.forgetStreamID(cs.ID) - return nil, cs.getStartedWrite(), err - } -- bodyWritten = true - if d := cc.responseHeaderTimeout(); d != 0 { - timer := time.NewTimer(d) - defer timer.Stop() -@@ -9060,7 +9066,9 @@ func (t *http2Transport) getBodyWriterState(cs *http2clientStream, body io.Reade - - func (s http2bodyWriterState) cancel() { - if s.timer != nil { -- s.timer.Stop() -+ if s.timer.Stop() { -+ s.resc <- nil -+ } - } - } - --- -2.27.0 - diff --git a/0065-release-branch.go1.17-go-parser-limit-recursion-dept.patch b/0006-release-branch.go1.17-go-parser-limit-recursion-dept.patch similarity index 78% rename from 0065-release-branch.go1.17-go-parser-limit-recursion-dept.patch rename to 0006-release-branch.go1.17-go-parser-limit-recursion-dept.patch index 18ff8b9b5a23b8b295eb99419c309ce99646f049..23a903a9e5c421b420127404315fbf9983f6fde8 100644 --- a/0065-release-branch.go1.17-go-parser-limit-recursion-dept.patch +++ b/0006-release-branch.go1.17-go-parser-limit-recursion-dept.patch @@ -1,7 +1,8 @@ -From ef7049cb34d5e2d3b4afbd37d3964cd8baf07282 Mon Sep 17 00:00:00 2001 +From b78e521644334294019da243a5ff57436f70cd72 Mon Sep 17 00:00:00 2001 From: Roland Shoemaker Date: Wed, 15 Jun 2022 10:43:05 -0700 -Subject: [PATCH] go/parser: limit recursion depth +Subject: [PATCH 02/11] [release-branch.go1.17] go/parser: limit recursion + depth Limit nested parsing to 100,000, which prevents stack exhaustion when parsing deeply nested statements, types, and expressions. Also limit @@ -23,41 +24,20 @@ Reviewed-by: Heschi Kreinick TryBot-Result: Gopher Robot Run-TryBot: Michael Knyszek -Conflict: src/go/parser/parser.go +Conflict: NA Reference: https://go-review.googlesource.com/c/go/+/417070 --- - src/go/parser/interface.go | 25 +++-- - src/go/parser/parser.go | 64 ++++++++++--- - src/go/parser/parser_test.go | 171 +++++++++++++++++++++++++++++++++++ - 3 files changed, 240 insertions(+), 20 deletions(-) + src/go/parser/interface.go | 10 ++- + src/go/parser/parser.go | 54 ++++++++++- + src/go/parser/parser_test.go | 169 +++++++++++++++++++++++++++++++++++ + src/go/parser/resolver.go | 9 ++ + 4 files changed, 236 insertions(+), 6 deletions(-) diff --git a/src/go/parser/interface.go b/src/go/parser/interface.go -index 54f9d7b..9fc9f7a 100644 +index 85486d2f4b4..eae429e6ef3 100644 --- a/src/go/parser/interface.go +++ b/src/go/parser/interface.go -@@ -49,13 +49,14 @@ func readSource(filename string, src interface{}) ([]byte, error) { - type Mode uint - - const ( -- PackageClauseOnly Mode = 1 << iota // stop parsing after package clause -- ImportsOnly // stop parsing after import declarations -- ParseComments // parse comments and add them to AST -- Trace // print a trace of parsed productions -- DeclarationErrors // report declaration errors -- SpuriousErrors // same as AllErrors, for backward-compatibility -- AllErrors = SpuriousErrors // report all errors (not just the first 10 on different lines) -+ PackageClauseOnly Mode = 1 << iota // stop parsing after package clause -+ ImportsOnly // stop parsing after import declarations -+ ParseComments // parse comments and add them to AST -+ Trace // print a trace of parsed productions -+ DeclarationErrors // report declaration errors -+ SpuriousErrors // same as AllErrors, for backward-compatibility -+ SkipObjectResolution // don't resolve identifiers to objects - see ParseFile -+ AllErrors = SpuriousErrors // report all errors (not just the first 10 on different lines) - ) - - // ParseFile parses the source code of a single Go source file and returns -@@ -92,8 +93,11 @@ func ParseFile(fset *token.FileSet, filename string, src interface{}, mode Mode) +@@ -97,8 +97,11 @@ func ParseFile(fset *token.FileSet, filename string, src interface{}, mode Mode) defer func() { if e := recover(); e != nil { // resume same panic if it's not a bailout @@ -70,7 +50,7 @@ index 54f9d7b..9fc9f7a 100644 } } -@@ -188,8 +192,11 @@ func ParseExprFrom(fset *token.FileSet, filename string, src interface{}, mode M +@@ -203,8 +206,11 @@ func ParseExprFrom(fset *token.FileSet, filename string, src interface{}, mode M defer func() { if e := recover(); e != nil { // resume same panic if it's not a bailout @@ -84,13 +64,13 @@ index 54f9d7b..9fc9f7a 100644 } p.errors.Sort() diff --git a/src/go/parser/parser.go b/src/go/parser/parser.go -index 31a7398..29bf774 100644 +index f10c8650afd..2c42b9f8cc2 100644 --- a/src/go/parser/parser.go +++ b/src/go/parser/parser.go -@@ -68,6 +68,10 @@ type parser struct { - // (maintained by open/close LabelScope) - labelScope *ast.Scope // label scope for current function - targetStack [][]*ast.Ident // stack of unresolved labels +@@ -60,6 +60,10 @@ type parser struct { + inRhs bool // if set, the parser is parsing a rhs expression + + imports []*ast.ImportSpec // list of imports + + // nestLev is used to track and limit the recursion depth + // during parsing. @@ -98,7 +78,7 @@ index 31a7398..29bf774 100644 } func (p *parser) init(fset *token.FileSet, filename string, src []byte, mode Mode) { -@@ -236,6 +240,24 @@ func un(p *parser) { +@@ -110,6 +114,24 @@ func un(p *parser) { p.printTrace(")") } @@ -123,7 +103,7 @@ index 31a7398..29bf774 100644 // Advance to the next token. func (p *parser) next0() { // Because of one-token look-ahead, print the previous token -@@ -348,8 +370,12 @@ func (p *parser) next() { +@@ -222,8 +244,12 @@ func (p *parser) next() { } } @@ -137,30 +117,21 @@ index 31a7398..29bf774 100644 +} func (p *parser) error(pos token.Pos, msg string) { - epos := p.file.Position(pos) -@@ -1030,6 +1056,8 @@ func (p *parser) parseChanType() *ast.ChanType { + if p.trace { +@@ -1119,6 +1145,8 @@ func (p *parser) parseTypeInstance(typ ast.Expr) ast.Expr { + } - // If the result is an identifier, it is not resolved. func (p *parser) tryIdentOrType() ast.Expr { + defer decNestLev(incNestLev(p)) + switch p.tok { case token.IDENT: - return p.parseTypeName() -@@ -1470,14 +1498,19 @@ func (p *parser) checkExprOrType(x ast.Expr) ast.Expr { - } - - // If lhs is set and the result is an identifier, it is not resolved. --func (p *parser) parsePrimaryExpr(lhs bool) ast.Expr { -+func (p *parser) parsePrimaryExpr(lhs bool) (x ast.Expr) { - if p.trace { - defer un(trace(p, "PrimaryExpr")) + typ := p.parseTypeName(nil) +@@ -1531,7 +1559,13 @@ func (p *parser) parsePrimaryExpr() (x ast.Expr) { } -- x := p.parseOperand(lhs) --L: + x = p.parseOperand() - for { -+ x = p.parseOperand(lhs) + // We track the nesting here rather than at the entry for the function, + // since it can iteratively produce a nested output, and we want to + // limit how deep a structure we generate. @@ -171,33 +142,19 @@ index 31a7398..29bf774 100644 switch p.tok { case token.PERIOD: p.next() -@@ -1513,19 +1546,18 @@ L: - } - x = p.parseLiteralValue(x) - } else { -- break L -+ return - } - default: -- break L -+ return - } - lhs = false // no need to try to resolve again - } -- -- return x +@@ -1591,6 +1625,8 @@ func (p *parser) parsePrimaryExpr() (x ast.Expr) { } - // If lhs is set and the result is an identifier, it is not resolved. - func (p *parser) parseUnaryExpr(lhs bool) ast.Expr { + func (p *parser) parseUnaryExpr() ast.Expr { + defer decNestLev(incNestLev(p)) ++ if p.trace { defer un(trace(p, "UnaryExpr")) } -@@ -1609,7 +1641,13 @@ func (p *parser) parseBinaryExpr(lhs bool, prec1 int) ast.Expr { +@@ -1673,7 +1709,13 @@ func (p *parser) parseBinaryExpr(prec1 int) ast.Expr { } - x := p.parseUnaryExpr(lhs) + x := p.parseUnaryExpr() - for { + // We track the nesting here rather than at the entry for the function, + // since it can iteratively produce a nested output, and we want to @@ -209,7 +166,7 @@ index 31a7398..29bf774 100644 op, oprec := p.tokPrec() if oprec < prec1 { return x -@@ -1899,6 +1937,8 @@ func (p *parser) parseIfHeader() (init ast.Stmt, cond ast.Expr) { +@@ -1962,6 +2004,8 @@ func (p *parser) parseIfHeader() (init ast.Stmt, cond ast.Expr) { } func (p *parser) parseIfStmt() *ast.IfStmt { @@ -218,7 +175,7 @@ index 31a7398..29bf774 100644 if p.trace { defer un(trace(p, "IfStmt")) } -@@ -2214,6 +2254,8 @@ func (p *parser) parseForStmt() ast.Stmt { +@@ -2265,6 +2309,8 @@ func (p *parser) parseForStmt() ast.Stmt { } func (p *parser) parseStmt() (s ast.Stmt) { @@ -228,18 +185,18 @@ index 31a7398..29bf774 100644 defer un(trace(p, "Statement")) } diff --git a/src/go/parser/parser_test.go b/src/go/parser/parser_test.go -index 25a374e..344597d 100644 +index a4f882d3688..1a46c878663 100644 --- a/src/go/parser/parser_test.go +++ b/src/go/parser/parser_test.go @@ -10,6 +10,7 @@ import ( "go/ast" "go/token" - "os" + "io/fs" + "runtime" "strings" "testing" ) -@@ -569,3 +570,173 @@ type x int // comment +@@ -577,3 +578,171 @@ type x int // comment t.Errorf("got %q, want %q", comment, "// comment") } } @@ -363,8 +320,6 @@ index 25a374e..344597d 100644 + } +} + -+const maxScopeDepth int = 1e3 -+ +func TestScopeDepthLimit(t *testing.T) { + if runtime.GOARCH == "wasm" { + t.Skip("causes call stack exhaustion on js/wasm") @@ -413,6 +368,54 @@ index 25a374e..344597d 100644 + } + } +} +diff --git a/src/go/parser/resolver.go b/src/go/parser/resolver.go +index cf92c7e4f57..f55bdb7f177 100644 +--- a/src/go/parser/resolver.go ++++ b/src/go/parser/resolver.go +@@ -25,6 +25,7 @@ func resolveFile(file *ast.File, handle *token.File, declErr func(token.Pos, str + declErr: declErr, + topScope: pkgScope, + pkgScope: pkgScope, ++ depth: 1, + } + + for _, decl := range file.Decls { +@@ -53,6 +54,8 @@ func resolveFile(file *ast.File, handle *token.File, declErr func(token.Pos, str + file.Unresolved = r.unresolved[0:i] + } + ++const maxScopeDepth int = 1e3 ++ + type resolver struct { + handle *token.File + declErr func(token.Pos, string) +@@ -61,6 +64,7 @@ type resolver struct { + pkgScope *ast.Scope // pkgScope.Outer == nil + topScope *ast.Scope // top-most scope; may be pkgScope + unresolved []*ast.Ident // unresolved identifiers ++ depth int // scope depth + + // Label scopes + // (maintained by open/close LabelScope) +@@ -83,6 +87,10 @@ func (r *resolver) sprintf(format string, args ...interface{}) string { + } + + func (r *resolver) openScope(pos token.Pos) { ++ r.depth++ ++ if r.depth > maxScopeDepth { ++ panic(bailout{pos: pos, msg: "exceeded max scope depth during object resolution"}) ++ } + if debugResolve { + r.dump("opening scope @%v", pos) + } +@@ -90,6 +98,7 @@ func (r *resolver) openScope(pos token.Pos) { + } + + func (r *resolver) closeScope() { ++ r.depth-- + if debugResolve { + r.dump("closing scope") + } -- 2.30.2 diff --git a/0007-release-branch.go1.15-cmd-go-don-t-lookup-the-path-f.patch b/0007-release-branch.go1.15-cmd-go-don-t-lookup-the-path-f.patch deleted file mode 100644 index 69747bbd84412a562953978f29d8d7d1502809a6..0000000000000000000000000000000000000000 --- a/0007-release-branch.go1.15-cmd-go-don-t-lookup-the-path-f.patch +++ /dev/null @@ -1,208 +0,0 @@ -From 4a48a7d7bda25a844a7e597e96041b55c9f32d4d Mon Sep 17 00:00:00 2001 -From: Jay Conrod -Date: Fri, 22 Jan 2021 14:27:24 -0500 -Subject: [PATCH 07/44] [release-branch.go1.15] cmd/go: don't lookup the path - for CC when invoking cgo - -Previously, if CC was a path without separators (like gcc or clang), -we'd look it up in PATH in cmd/go using internal/execabs.LookPath, -then pass the resolved path to cgo in CC. - -This caused a regression: if the directory in PATH containing CC has a -space, cgo splits it and interprets it as multiple arguments. - -With this change, cmd/go no longer resolves CC before invoking -cgo. cgo does the path lookup on each invocation. This reverts the -security fix CL 284780, but that was redundant with the addition of -internal/execabs (CL 955304), which still protects us. - -NOTE: This CL includes a related test fix from CL 286292. - -Fixes #43860 - -Change-Id: I65d91a1e303856df8653881eb6e2e75a3bf95c49 -Reviewed-on: https://go-review.googlesource.com/c/go/+/285873 -Trust: Jay Conrod -Run-TryBot: Jay Conrod -TryBot-Result: Go Bot -Reviewed-by: Bryan C. Mills -(cherry picked from commit a2cef9b544708ecae983ed8836ee2425a28aab68) -Reviewed-on: https://go-review.googlesource.com/c/go/+/285954 -Run-TryBot: Dmitri Shuralyov - -Conflict:NA -Reference:https://github.com/golang/go/commit/4a48a7d7bda25a844a7e597e96041b55c9f32d4d - ---- - src/cmd/go/internal/work/action.go | 3 - - src/cmd/go/internal/work/exec.go | 27 ++------- - src/cmd/go/testdata/script/cgo_path.txt | 12 +++- - src/cmd/go/testdata/script/cgo_path_space.txt | 56 +++++++++++++++++++ - 4 files changed, 72 insertions(+), 26 deletions(-) - create mode 100644 src/cmd/go/testdata/script/cgo_path_space.txt - -diff --git a/src/cmd/go/internal/work/action.go b/src/cmd/go/internal/work/action.go -index 03ca301bdd..6b5f9e4807 100644 ---- a/src/cmd/go/internal/work/action.go -+++ b/src/cmd/go/internal/work/action.go -@@ -56,9 +56,6 @@ type Builder struct { - id sync.Mutex - toolIDCache map[string]string // tool name -> tool ID - buildIDCache map[string]string // file name -> build ID -- -- cgoEnvOnce sync.Once -- cgoEnvCache []string - } - - // NOTE: Much of Action would not need to be exported if not for test. -diff --git a/src/cmd/go/internal/work/exec.go b/src/cmd/go/internal/work/exec.go -index f5f9951afa..eb1efd9f82 100644 ---- a/src/cmd/go/internal/work/exec.go -+++ b/src/cmd/go/internal/work/exec.go -@@ -1081,7 +1081,10 @@ func (b *Builder) vet(a *Action) error { - } - - // TODO(rsc): Why do we pass $GCCGO to go vet? -- env := b.cgoEnv() -+ env := b.cCompilerEnv() -+ if cfg.BuildToolchainName == "gccgo" { -+ env = append(env, "GCCGO="+BuildToolchain.compiler()) -+ } - - p := a.Package - tool := VetTool -@@ -2015,24 +2018,6 @@ func (b *Builder) cCompilerEnv() []string { - return []string{"TERM=dumb"} - } - --// cgoEnv returns environment variables to set when running cgo. --// Some of these pass through to cgo running the C compiler, --// so it includes cCompilerEnv. --func (b *Builder) cgoEnv() []string { -- b.cgoEnvOnce.Do(func() { -- cc, err := exec.LookPath(b.ccExe()[0]) -- if err != nil || filepath.Base(cc) == cc { // reject relative path -- cc = "/missing-cc" -- } -- gccgo := GccgoBin -- if filepath.Base(gccgo) == gccgo { // reject relative path -- gccgo = "/missing-gccgo" -- } -- b.cgoEnvCache = append(b.cCompilerEnv(), "CC="+cc, "GCCGO="+gccgo) -- }) -- return b.cgoEnvCache --} -- - // mkdir makes the named directory. - func (b *Builder) Mkdir(dir string) error { - // Make Mkdir(a.Objdir) a no-op instead of an error when a.Objdir == "". -@@ -2622,7 +2607,7 @@ func (b *Builder) cgo(a *Action, cgoExe, objdir string, pcCFLAGS, pcLDFLAGS, cgo - // along to the host linker. At this point in the code, cgoLDFLAGS - // consists of the original $CGO_LDFLAGS (unchecked) and all the - // flags put together from source code (checked). -- cgoenv := b.cgoEnv() -+ cgoenv := b.cCompilerEnv() - if len(cgoLDFLAGS) > 0 { - flags := make([]string, len(cgoLDFLAGS)) - for i, f := range cgoLDFLAGS { -@@ -2843,7 +2828,7 @@ func (b *Builder) dynimport(a *Action, p *load.Package, objdir, importGo, cgoExe - if p.Standard && p.ImportPath == "runtime/cgo" { - cgoflags = []string{"-dynlinker"} // record path to dynamic linker - } -- return b.run(a, p.Dir, p.ImportPath, b.cgoEnv(), cfg.BuildToolexec, cgoExe, "-dynpackage", p.Name, "-dynimport", dynobj, "-dynout", importGo, cgoflags) -+ return b.run(a, p.Dir, p.ImportPath, b.cCompilerEnv(), cfg.BuildToolexec, cgoExe, "-dynpackage", p.Name, "-dynimport", dynobj, "-dynout", importGo, cgoflags) - } - - // Run SWIG on all SWIG input files. -diff --git a/src/cmd/go/testdata/script/cgo_path.txt b/src/cmd/go/testdata/script/cgo_path.txt -index 0d15998426..3eba71bc15 100644 ---- a/src/cmd/go/testdata/script/cgo_path.txt -+++ b/src/cmd/go/testdata/script/cgo_path.txt -@@ -1,12 +1,20 @@ - [!cgo] skip - -+# Set CC explicitly to something that requires a PATH lookup. -+# Normally, the default is gcc or clang, but if CC was set during make.bash, -+# that becomes the default. -+[exec:clang] env CC=clang -+[exec:gcc] env CC=gcc -+[!exec:clang] [!exec:gcc] skip 'Unknown C compiler' -+ - env GOCACHE=$WORK/gocache # Looking for compile flags, so need a clean cache. - [!windows] env PATH=.:$PATH --[!windows] chmod 0777 p/gcc p/clang -+[!windows] chmod 0755 p/gcc p/clang - [!windows] exists -exec p/gcc p/clang - [windows] exists -exec p/gcc.bat p/clang.bat - ! exists p/bug.txt --go build -x -+! go build -x -+stderr '^cgo: exec (clang|gcc): (clang|gcc) resolves to executable in current directory \(.[/\\](clang|gcc)(.bat)?\)$' - ! exists p/bug.txt - - -- go.mod -- -diff --git a/src/cmd/go/testdata/script/cgo_path_space.txt b/src/cmd/go/testdata/script/cgo_path_space.txt -new file mode 100644 -index 0000000000..654295dc69 ---- /dev/null -+++ b/src/cmd/go/testdata/script/cgo_path_space.txt -@@ -0,0 +1,56 @@ -+# Check that if the PATH directory containing the C compiler has a space, -+# we can still use that compiler with cgo. -+# Verifies #43808. -+[!cgo] skip -+ -+# Set CC explicitly to something that requires a PATH lookup. -+# Normally, the default is gcc or clang, but if CC was set during make.bash, -+# that becomes the default. -+[exec:clang] env CC=clang -+[exec:gcc] env CC=gcc -+[!exec:clang] [!exec:gcc] skip 'Unknown C compiler' -+ -+[!windows] chmod 0755 $WORK/'program files'/clang -+[!windows] chmod 0755 $WORK/'program files'/gcc -+[!windows] exists -exec $WORK/'program files'/clang -+[!windows] exists -exec $WORK/'program files'/gcc -+[!windows] env PATH=$WORK/'program files':$PATH -+[windows] exists -exec $WORK/'program files'/gcc.bat -+[windows] exists -exec $WORK/'program files'/clang.bat -+[windows] env PATH=$WORK\'program files';%PATH% -+ -+! exists $WORK/log.txt -+? go build -x -+exists $WORK/log.txt -+rm $WORK/log.txt -+ -+# TODO(#41400, #43078): when CC is set explicitly, it should be allowed to -+# contain spaces separating arguments, and it should be possible to quote -+# arguments with spaces (including the path), as in CGO_CFLAGS and other -+# variables. For now, this doesn't work. -+[!windows] env CC=$WORK/'program files'/gcc -+[windows] env CC=$WORK\'program files'\gcc.bat -+! go build -x -+! exists $WORK/log.txt -+ -+-- go.mod -- -+module m -+ -+-- m.go -- -+package m -+ -+// #define X 1 -+import "C" -+ -+-- $WORK/program files/gcc -- -+#!/bin/sh -+ -+echo ok >$WORK/log.txt -+-- $WORK/program files/clang -- -+#!/bin/sh -+ -+echo ok >$WORK/log.txt -+-- $WORK/program files/gcc.bat -- -+echo ok >%WORK%\log.txt -+-- $WORK/program files/clang.bat -- -+echo ok >%WORK%\log.txt --- -2.27.0 - diff --git a/0066-release-branch.go1.17-net-http-don-t-strip-whitespac.patch b/0007-release-branch.go1.17-net-http-don-t-strip-whitespac.patch similarity index 77% rename from 0066-release-branch.go1.17-net-http-don-t-strip-whitespac.patch rename to 0007-release-branch.go1.17-net-http-don-t-strip-whitespac.patch index 3cd89eaf49ea1715cd3b99ed5c91508fc7a9000a..7fdcd6f86e68031ece6523d3aed9973202e91630 100644 --- a/0066-release-branch.go1.17-net-http-don-t-strip-whitespac.patch +++ b/0007-release-branch.go1.17-net-http-don-t-strip-whitespac.patch @@ -1,7 +1,7 @@ -From f1da2608e141b54e7c1791220c3493a36863c651 Mon Sep 17 00:00:00 2001 +From 4ad62aecaf57ca3adc11a04bd2113bdbee6249c3 Mon Sep 17 00:00:00 2001 From: Damien Neil Date: Wed, 1 Jun 2022 11:17:07 -0700 -Subject: [PATCH 03/10] [release-branch.go1.17] net/http: don't strip +Subject: [PATCH 03/11] [release-branch.go1.17] net/http: don't strip whitespace from Transfer-Encoding headers Do not accept "Transfer-Encoding: \rchunked" as a valid TE header @@ -25,7 +25,7 @@ Run-TryBot: Dmitri Shuralyov Reviewed-by: Dmitri Shuralyov TryBot-Result: Gopher Robot -Conflict: src/net/http/transfer.go +Conflict: NA Reference: https://go-review.googlesource.com/c/go/+/415217 --- src/net/http/serve_test.go | 1 + @@ -33,10 +33,10 @@ Reference: https://go-review.googlesource.com/c/go/+/415217 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/net/http/serve_test.go b/src/net/http/serve_test.go -index 5f569327782..c3f33a5e403 100644 +index 6394da3bb7c..bfac783e3a9 100644 --- a/src/net/http/serve_test.go +++ b/src/net/http/serve_test.go -@@ -6151,6 +6151,7 @@ func TestUnsupportedTransferEncodingsReturn501(t *testing.T) { +@@ -6189,6 +6189,7 @@ func TestUnsupportedTransferEncodingsReturn501(t *testing.T) { "fugazi", "foo-bar", "unknown", @@ -45,15 +45,15 @@ index 5f569327782..c3f33a5e403 100644 for _, badTE := range unsupportedTEs { diff --git a/src/net/http/transfer.go b/src/net/http/transfer.go -index 50d434b1fb0..75ca7eda294 100644 +index 85c2e5a360d..3894007d306 100644 --- a/src/net/http/transfer.go +++ b/src/net/http/transfer.go -@@ -629,7 +629,7 @@ func (t *transferReader) parseTransferEncoding() error { +@@ -639,7 +639,7 @@ func (t *transferReader) parseTransferEncoding() error { if len(raw) != 1 { return &unsupportedTEError{fmt.Sprintf("too many transfer encodings: %q", raw)} } -- if strings.ToLower(textproto.TrimString(raw[0])) != "chunked" { -+ if strings.ToLower(raw[0]) != "chunked" { +- if !ascii.EqualFold(textproto.TrimString(raw[0]), "chunked") { ++ if !ascii.EqualFold(raw[0], "chunked") { return &unsupportedTEError{fmt.Sprintf("unsupported transfer encoding: %q", raw[0])} } diff --git a/0008-release-branch.go1.15-cmd-link-internal-ld-pe-fix-se.patch b/0008-release-branch.go1.15-cmd-link-internal-ld-pe-fix-se.patch deleted file mode 100644 index b19737a024cc0b71366c321169b3f5c4982f6d22..0000000000000000000000000000000000000000 --- a/0008-release-branch.go1.15-cmd-link-internal-ld-pe-fix-se.patch +++ /dev/null @@ -1,58 +0,0 @@ -From aa9b48cd1837644a1555fd7a370800924cef627a Mon Sep 17 00:00:00 2001 -From: Derek Parker -Date: Wed, 25 Nov 2020 16:31:57 +0000 -Subject: [PATCH 08/44] [release-branch.go1.15] cmd/link/internal/ld/pe: fix - segfault adding resource section - -The resource symbol may have been copied to the mmap'd -output buffer. If so, certain conditions can cause that -mmap'd output buffer to be munmap'd before we get a chance -to use it. To avoid any issues we copy the data to the heap -when the resource symbol exists. - -Fixes #42384 - -Change-Id: I32ef5420802d7313a3d965b8badfbcfb9f0fba4a -GitHub-Last-Rev: 7b0f43011d06083ee3e871e48a87847636f738f9 -GitHub-Pull-Request: golang/go#42427 -Reviewed-on: https://go-review.googlesource.com/c/go/+/268018 -Run-TryBot: Carlos Amedee -TryBot-Result: Go Bot -Reviewed-by: Russ Cox -Reviewed-by: Cherry Zhang -Reviewed-by: Than McIntosh -Trust: Carlos Amedee - -Conflict:NA -Reference:https://github.com/golang/go/commit/aa9b48cd1837644a1555fd7a370800924cef627a - ---- - src/cmd/link/internal/ld/pe.go | 12 ++++++++++++ - 1 file changed, 12 insertions(+) - -diff --git a/src/cmd/link/internal/ld/pe.go b/src/cmd/link/internal/ld/pe.go -index c9cb25dbe5..5d68ca7d9c 100644 ---- a/src/cmd/link/internal/ld/pe.go -+++ b/src/cmd/link/internal/ld/pe.go -@@ -1515,6 +1515,18 @@ func Asmbpe(ctxt *Link) { - case sys.AMD64, sys.I386, sys.ARM: - } - -+ if rsrcsym != 0 { -+ // The resource symbol may have been copied to the mmap'd -+ // output buffer. If so, certain conditions can cause that -+ // mmap'd output buffer to be munmap'd before we get a chance -+ // to use it. To avoid any issues we copy the data to the heap -+ // when the resource symbol exists. -+ rsrc := ctxt.loader.Syms[rsrcsym] -+ data := make([]byte, len(rsrc.P)) -+ copy(data, rsrc.P) -+ rsrc.P = data -+ } -+ - t := pefile.addSection(".text", int(Segtext.Length), int(Segtext.Length)) - t.characteristics = IMAGE_SCN_CNT_CODE | IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_EXECUTE | IMAGE_SCN_MEM_READ - if ctxt.LinkMode == LinkExternal { --- -2.27.0 - diff --git a/0067-release-branch.go1.17-encoding-xml-limit-depth-of-ne.patch b/0008-release-branch.go1.17-encoding-xml-limit-depth-of-ne.patch similarity index 97% rename from 0067-release-branch.go1.17-encoding-xml-limit-depth-of-ne.patch rename to 0008-release-branch.go1.17-encoding-xml-limit-depth-of-ne.patch index a1f3c123fd1ac9204d6b1025ba95fb0226294650..077af1523521e89770af7211afd05a3cf1422ca7 100644 --- a/0067-release-branch.go1.17-encoding-xml-limit-depth-of-ne.patch +++ b/0008-release-branch.go1.17-encoding-xml-limit-depth-of-ne.patch @@ -1,7 +1,7 @@ -From ae32eafe7dad2b437e38cf65b60abf4971342569 Mon Sep 17 00:00:00 2001 +From 106c859f68c3137cfa05c433a9b90494db386fda Mon Sep 17 00:00:00 2001 From: Roland Shoemaker Date: Tue, 29 Mar 2022 15:52:09 -0700 -Subject: [PATCH 04/10] [release-branch.go1.17] encoding/xml: limit depth of +Subject: [PATCH 04/11] [release-branch.go1.17] encoding/xml: limit depth of nesting in unmarshal Prevent exhausting the stack limit when unmarshalling extremely deeply diff --git a/0009-release-branch.go1.15-cmd-internal-goobj2-fix-buglet.patch b/0009-release-branch.go1.15-cmd-internal-goobj2-fix-buglet.patch deleted file mode 100644 index 97fea5b30aa0c3b07fe7bb2c871521bcb7a352c2..0000000000000000000000000000000000000000 --- a/0009-release-branch.go1.15-cmd-internal-goobj2-fix-buglet.patch +++ /dev/null @@ -1,73 +0,0 @@ -From 58dc4452620ebefa75742661c538b8406b213b4a Mon Sep 17 00:00:00 2001 -From: Than McIntosh -Date: Tue, 15 Dec 2020 15:54:25 -0500 -Subject: [PATCH 09/44] [release-branch.go1.15] cmd/internal/goobj2: fix buglet - in object file reader - -The code in the Go object file reader was casting a pointer to mmaped -memory into a large array prior to performing a read of the -relocations section: - - return (*[1<<20]Reloc)(unsafe.Pointer(&r.b[off]))[:n:n] - -For very large object files, this artificial array isn't large enough -(that is, there are more than 1048576 relocs to read), so update the -code to use a larger artifical array size. - -Fixes #43214. -Updates #41621. - -Change-Id: Ic047c8aef4f8a3839f2e7e3594bce652ebd6bd5b -Reviewed-on: https://go-review.googlesource.com/c/go/+/278492 -Run-TryBot: Than McIntosh -TryBot-Result: Go Bot -Reviewed-by: Cherry Zhang -Reviewed-by: Jeremy Faller -Trust: Than McIntosh -(cherry picked from commit f4e7a6b905ce60448e506a3f6578d01b60602cdd) -Reviewed-on: https://go-review.googlesource.com/c/go/+/278673 - -Conflict:NA -Reference:https://github.com/golang/go/commit/58dc4452620ebefa75742661c538b8406b213b4a - ---- - src/cmd/internal/goobj2/objfile.go | 9 +++++++-- - 1 file changed, 7 insertions(+), 2 deletions(-) - -diff --git a/src/cmd/internal/goobj2/objfile.go b/src/cmd/internal/goobj2/objfile.go -index 7f728e4f76..aba9b9856e 100644 ---- a/src/cmd/internal/goobj2/objfile.go -+++ b/src/cmd/internal/goobj2/objfile.go -@@ -379,6 +379,11 @@ func (a *Aux) Write(w *Writer) { w.Bytes(a[:]) } - // for testing - func (a *Aux) fromBytes(b []byte) { copy(a[:], b) } - -+// Used to construct an artifically large array type when reading an -+// item from the object file relocs section or aux sym section (needs -+// to work on 32-bit as well as 64-bit). See issue 41621. -+const huge = (1<<31 - 1) / RelocSize -+ - // Referenced symbol name. - // - // Serialized format: -@@ -652,7 +657,7 @@ func (r *Reader) Reloc(i int, j int) *Reloc { - func (r *Reader) Relocs(i int) []Reloc { - off := r.RelocOff(i, 0) - n := r.NReloc(i) -- return (*[1 << 20]Reloc)(unsafe.Pointer(&r.b[off]))[:n:n] -+ return (*[huge]Reloc)(unsafe.Pointer(&r.b[off]))[:n:n] - } - - // NAux returns the number of aux symbols of the i-th symbol. -@@ -678,7 +683,7 @@ func (r *Reader) Aux(i int, j int) *Aux { - func (r *Reader) Auxs(i int) []Aux { - off := r.AuxOff(i, 0) - n := r.NAux(i) -- return (*[1 << 20]Aux)(unsafe.Pointer(&r.b[off]))[:n:n] -+ return (*[huge]Aux)(unsafe.Pointer(&r.b[off]))[:n:n] - } - - // DataOff returns the offset of the i-th symbol's data. --- -2.27.0 - diff --git a/0068-release-branch.go1.17-encoding-gob-add-a-depth-limit.patch b/0009-release-branch.go1.17-encoding-gob-add-a-depth-limit.patch similarity index 97% rename from 0068-release-branch.go1.17-encoding-gob-add-a-depth-limit.patch rename to 0009-release-branch.go1.17-encoding-gob-add-a-depth-limit.patch index dbbe26e87e89ac21e1e6b263a0973bd2b830e0d0..13f56a5ce339c494603c9e8c1a7c47bcf8a318f4 100644 --- a/0068-release-branch.go1.17-encoding-gob-add-a-depth-limit.patch +++ b/0009-release-branch.go1.17-encoding-gob-add-a-depth-limit.patch @@ -1,7 +1,7 @@ -From 30b474a6578f25ce4e065362bea06f61abe8b7df Mon Sep 17 00:00:00 2001 +From 8747af9a1098e8fa497441be4c4a79a23de31a98 Mon Sep 17 00:00:00 2001 From: Roland Shoemaker Date: Tue, 7 Jun 2022 13:00:43 -0700 -Subject: [PATCH 05/10] [release-branch.go1.17] encoding/gob: add a depth limit +Subject: [PATCH 05/11] [release-branch.go1.17] encoding/gob: add a depth limit for ignored fields Enforce a nesting limit of 10,000 for ignored fields during decoding diff --git a/0010-release-branch.go1.15-runtime-don-t-adjust-timer-pp-.patch b/0010-release-branch.go1.15-runtime-don-t-adjust-timer-pp-.patch deleted file mode 100644 index 8484da4f7e0875fd2453c63e9d406cda2203231e..0000000000000000000000000000000000000000 --- a/0010-release-branch.go1.15-runtime-don-t-adjust-timer-pp-.patch +++ /dev/null @@ -1,72 +0,0 @@ -From 3171f483775c7eb8d38b68f53d8fd5078db7f967 Mon Sep 17 00:00:00 2001 -From: Ian Lance Taylor -Date: Tue, 19 Jan 2021 21:30:36 -0800 -Subject: [PATCH 10/44] [release-branch.go1.15] runtime: don't adjust timer pp - field in timerWaiting status - -Before this CL, the following sequence was possible: - -* GC scavenger starts and sets up scavenge.timer -* GC calls readyForScavenger, but sysmon is sleeping -* program calls runtime.GOMAXPROCS to shrink number of processors -* procresize destroys a P, the one that scavenge.timer is on -* (*pp).destroy calls moveTimers, which gets to the scavenger timer -* scavenger timer is timerWaiting, and moveTimers clears t.pp -* sysmon wakes up and calls wakeScavenger -* wakeScavengers calls stopTimer on scavenger.timer, still timerWaiting -* stopTimer calls deltimer which loads t.pp, which is still nil -* stopTimer tries to increment deletedTimers on nil t.pp, and crashes - -The point of vulnerability is the time that t.pp is set to nil by -moveTimers and the time that t.pp is set to non-nil by moveTimers, -which is a few instructions at most. So it's not likely and in -particular is quite unlikely on x86. But with a more relaxed memory -model the area of vulnerability can be somewhat larger. This appears -to tbe the cause of two builder failures in a few months on linux-mips. - -This CL fixes the problem by making moveTimers change the status from -timerWaiting to timerMoving while t.pp is clear. That will cause -deltimer to wait until the status is back to timerWaiting, at which -point t.pp has been set again. - -For #43712 -Fixes #43833 - -Change-Id: I66838319ecfbf15be66c1fac88d9bd40e2295852 -Reviewed-on: https://go-review.googlesource.com/c/go/+/284775 -Trust: Ian Lance Taylor -Reviewed-by: Michael Knyszek -Reviewed-by: Michael Pratt -(cherry picked from commit d2d155d1ae8c704a37f42fd3ebb1f3846f78e4d4) -Reviewed-on: https://go-review.googlesource.com/c/go/+/287092 -Run-TryBot: Carlos Amedee - -Conflict:NA -Reference:https://github.com/golang/go/commit/3171f483775c7eb8d38b68f53d8fd5078db7f967 - ---- - src/runtime/time.go | 6 ++++++ - 1 file changed, 6 insertions(+) - -diff --git a/src/runtime/time.go b/src/runtime/time.go -index fdb5066b24..ec3eae9cca 100644 ---- a/src/runtime/time.go -+++ b/src/runtime/time.go -@@ -594,8 +594,14 @@ func moveTimers(pp *p, timers []*timer) { - for { - switch s := atomic.Load(&t.status); s { - case timerWaiting: -+ if !atomic.Cas(&t.status, s, timerMoving) { -+ continue -+ } - t.pp = 0 - doaddtimer(pp, t) -+ if !atomic.Cas(&t.status, timerMoving, timerWaiting) { -+ badTimer() -+ } - break loop - case timerModifiedEarlier, timerModifiedLater: - if !atomic.Cas(&t.status, s, timerMoving) { --- -2.27.0 - diff --git a/0010-release-branch.go1.17-io-fs-fix-stack-exhaustion-in-.patch b/0010-release-branch.go1.17-io-fs-fix-stack-exhaustion-in-.patch new file mode 100644 index 0000000000000000000000000000000000000000..c1943787ed4deeb3a6687cd4fd560c68b9dbac4c --- /dev/null +++ b/0010-release-branch.go1.17-io-fs-fix-stack-exhaustion-in-.patch @@ -0,0 +1,96 @@ +From a8d44d0477f2182563e279da115cbc164d639f33 Mon Sep 17 00:00:00 2001 +From: Julie Qiu +Date: Thu, 23 Jun 2022 23:17:53 +0000 +Subject: [PATCH 06/11] [release-branch.go1.17] io/fs: fix stack exhaustion in + Glob + +A limit is added to the number of path separators allowed by an input to +Glob, to prevent stack exhaustion issues. + +Thanks to Juho Nurminen of Mattermost who reported a similar issue in +path/filepath. + +Fixes #53719 +Updates #53415 +Fixes CVE-2022-30630 + +Change-Id: I5a9d02591fed90cd3d52627f5945f1301e53465d +Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1497588 +Reviewed-by: Roland Shoemaker +(cherry picked from commit fdccc5d7bd0f276d0a8de3a818ca844f0bed5d97) +Reviewed-on: https://go-review.googlesource.com/c/go/+/417072 +Reviewed-by: Heschi Kreinick +TryBot-Result: Gopher Robot +Run-TryBot: Michael Knyszek + +Conflict: NA +Reference: https://go-review.googlesource.com/c/go/+/417072 +--- + src/io/fs/glob.go | 14 ++++++++++++-- + src/io/fs/glob_test.go | 10 ++++++++++ + 2 files changed, 22 insertions(+), 2 deletions(-) + +diff --git a/src/io/fs/glob.go b/src/io/fs/glob.go +index 45d9cb61b96..0e529cd05d1 100644 +--- a/src/io/fs/glob.go ++++ b/src/io/fs/glob.go +@@ -31,6 +31,16 @@ type GlobFS interface { + // Otherwise, Glob uses ReadDir to traverse the directory tree + // and look for matches for the pattern. + func Glob(fsys FS, pattern string) (matches []string, err error) { ++ return globWithLimit(fsys, pattern, 0) ++} ++ ++func globWithLimit(fsys FS, pattern string, depth int) (matches []string, err error) { ++ // This limit is added to prevent stack exhaustion issues. See ++ // CVE-2022-30630. ++ const pathSeparatorsLimit = 10000 ++ if depth > pathSeparatorsLimit { ++ return nil, path.ErrBadPattern ++ } + if fsys, ok := fsys.(GlobFS); ok { + return fsys.Glob(pattern) + } +@@ -59,9 +69,9 @@ func Glob(fsys FS, pattern string) (matches []string, err error) { + } + + var m []string +- m, err = Glob(fsys, dir) ++ m, err = globWithLimit(fsys, dir, depth+1) + if err != nil { +- return ++ return nil, err + } + for _, d := range m { + matches, err = glob(fsys, d, file, matches) +diff --git a/src/io/fs/glob_test.go b/src/io/fs/glob_test.go +index f19bebed77f..d052eab3713 100644 +--- a/src/io/fs/glob_test.go ++++ b/src/io/fs/glob_test.go +@@ -8,6 +8,7 @@ import ( + . "io/fs" + "os" + "path" ++ "strings" + "testing" + ) + +@@ -55,6 +56,15 @@ func TestGlobError(t *testing.T) { + } + } + ++func TestCVE202230630(t *testing.T) { ++ // Prior to CVE-2022-30630, a stack exhaustion would occur given a large ++ // number of separators. There is now a limit of 10,000. ++ _, err := Glob(os.DirFS("."), "/*"+strings.Repeat("/", 10001)) ++ if err != path.ErrBadPattern { ++ t.Fatalf("Glob returned err=%v, want %v", err, path.ErrBadPattern) ++ } ++} ++ + // contains reports whether vector contains the string s. + func contains(vector []string, s string) bool { + for _, elem := range vector { +-- +2.30.2 + diff --git a/0011-release-branch.go1.15-runtime-cgo-fix-Android-build-.patch b/0011-release-branch.go1.15-runtime-cgo-fix-Android-build-.patch deleted file mode 100644 index 9fe1721db43fdd9818b170faee336b9524f35b83..0000000000000000000000000000000000000000 --- a/0011-release-branch.go1.15-runtime-cgo-fix-Android-build-.patch +++ /dev/null @@ -1,82 +0,0 @@ -From c3e1c3800bfb56bf1b0c3d696f59f42b16bd4fc2 Mon Sep 17 00:00:00 2001 -From: Elias Naur -Date: Fri, 25 Dec 2020 11:14:11 +0100 -Subject: [PATCH 11/44] [release-branch.go1.15] runtime/cgo: fix Android build - with NDK 22 - -Fixes #43406 - -Change-Id: I7d2b70098a4ba4dcb325fb0be076043789b86135 -Reviewed-on: https://go-review.googlesource.com/c/go/+/280312 -Run-TryBot: Elias Naur -TryBot-Result: Go Bot -Reviewed-by: Ian Lance Taylor -Trust: Elias Naur -(cherry picked from commit 1d78139128d6d839d7da0aeb10b3e51b6c7c0749) -Reviewed-on: https://go-review.googlesource.com/c/go/+/289149 - -Conflict:NA -Reference:https://github.com/golang/go/commit/c3e1c3800bfb56bf1b0c3d696f59f42b16bd4fc2 - ---- - src/runtime/cgo/gcc_linux_386.c | 2 +- - src/runtime/cgo/gcc_linux_amd64.c | 2 +- - src/runtime/cgo/gcc_linux_arm.c | 2 +- - src/runtime/cgo/gcc_linux_arm64.c | 2 +- - 4 files changed, 4 insertions(+), 4 deletions(-) - -diff --git a/src/runtime/cgo/gcc_linux_386.c b/src/runtime/cgo/gcc_linux_386.c -index ece9f933c5..70c942aeb8 100644 ---- a/src/runtime/cgo/gcc_linux_386.c -+++ b/src/runtime/cgo/gcc_linux_386.c -@@ -12,7 +12,7 @@ static void *threadentry(void*); - static void (*setg_gcc)(void*); - - // This will be set in gcc_android.c for android-specific customization. --void (*x_cgo_inittls)(void **tlsg, void **tlsbase); -+void (*x_cgo_inittls)(void **tlsg, void **tlsbase) __attribute__((common)); - - void - x_cgo_init(G *g, void (*setg)(void*), void **tlsg, void **tlsbase) -diff --git a/src/runtime/cgo/gcc_linux_amd64.c b/src/runtime/cgo/gcc_linux_amd64.c -index 9134e0df92..f2bf6482cb 100644 ---- a/src/runtime/cgo/gcc_linux_amd64.c -+++ b/src/runtime/cgo/gcc_linux_amd64.c -@@ -14,7 +14,7 @@ static void* threadentry(void*); - static void (*setg_gcc)(void*); - - // This will be set in gcc_android.c for android-specific customization. --void (*x_cgo_inittls)(void **tlsg, void **tlsbase); -+void (*x_cgo_inittls)(void **tlsg, void **tlsbase) __attribute__((common)); - - void - x_cgo_init(G *g, void (*setg)(void*), void **tlsg, void **tlsbase) -diff --git a/src/runtime/cgo/gcc_linux_arm.c b/src/runtime/cgo/gcc_linux_arm.c -index 61855b96b2..5bc0fee90d 100644 ---- a/src/runtime/cgo/gcc_linux_arm.c -+++ b/src/runtime/cgo/gcc_linux_arm.c -@@ -10,7 +10,7 @@ - - static void *threadentry(void*); - --void (*x_cgo_inittls)(void **tlsg, void **tlsbase); -+void (*x_cgo_inittls)(void **tlsg, void **tlsbase) __attribute__((common)); - static void (*setg_gcc)(void*); - - void -diff --git a/src/runtime/cgo/gcc_linux_arm64.c b/src/runtime/cgo/gcc_linux_arm64.c -index 261c884ac9..17ff274fbb 100644 ---- a/src/runtime/cgo/gcc_linux_arm64.c -+++ b/src/runtime/cgo/gcc_linux_arm64.c -@@ -12,7 +12,7 @@ - - static void *threadentry(void*); - --void (*x_cgo_inittls)(void **tlsg, void **tlsbase); -+void (*x_cgo_inittls)(void **tlsg, void **tlsbase) __attribute__((common)); - static void (*setg_gcc)(void*); - - void --- -2.27.0 - diff --git a/0069-release-branch.go1.17-path-filepath-fix-stack-exhaus.patch b/0011-release-branch.go1.17-path-filepath-fix-stack-exhaus.patch similarity index 75% rename from 0069-release-branch.go1.17-path-filepath-fix-stack-exhaus.patch rename to 0011-release-branch.go1.17-path-filepath-fix-stack-exhaus.patch index 23a4b6f65dcf0287de7ab65749429febf449abff..661634ac3dabe484b61c160c12218f3fb5a04700 100644 --- a/0069-release-branch.go1.17-path-filepath-fix-stack-exhaus.patch +++ b/0011-release-branch.go1.17-path-filepath-fix-stack-exhaus.patch @@ -1,7 +1,7 @@ -From 472c7e454d5d2a6afbc5494d55e0955c4f2a6990 Mon Sep 17 00:00:00 2001 +From 7b98bf3a8711126c532033ca89647f3b743b58ec Mon Sep 17 00:00:00 2001 From: Julie Qiu Date: Thu, 23 Jun 2022 23:18:56 +0000 -Subject: [PATCH 06/10] [release-branch.go1.17] path/filepath: fix stack +Subject: [PATCH 07/11] [release-branch.go1.17] path/filepath: fix stack exhaustion in Glob A limit is added to the number of path separators allowed by an input to @@ -25,15 +25,15 @@ Run-TryBot: Michael Knyszek Conflict: NA Reference: https://go-review.googlesource.com/c/go/+/417073 --- - src/path/filepath/match.go | 16 +++++++++++++++- + src/path/filepath/match.go | 12 +++++++++++- src/path/filepath/match_test.go | 10 ++++++++++ - 2 files changed, 25 insertions(+), 1 deletion(-) + 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/path/filepath/match.go b/src/path/filepath/match.go -index 20a334805ba..b6a3b450fe8 100644 +index c77a26952a6..55ed1d75ae1 100644 --- a/src/path/filepath/match.go +++ b/src/path/filepath/match.go -@@ -232,6 +232,20 @@ func getEsc(chunk string) (r rune, nchunk string, err error) { +@@ -241,6 +241,16 @@ func getEsc(chunk string) (r rune, nchunk string, err error) { // The only possible returned error is ErrBadPattern, when pattern // is malformed. func Glob(pattern string) (matches []string, err error) { @@ -47,14 +47,10 @@ index 20a334805ba..b6a3b450fe8 100644 + return nil, ErrBadPattern + } + -+ // Check pattern is well-formed. -+ if _, err := Match(pattern, ""); err != nil { -+ return nil, err -+ } - if !hasMeta(pattern) { - if _, err = os.Lstat(pattern); err != nil { - return nil, nil -@@ -257,7 +271,7 @@ func Glob(pattern string) (matches []string, err error) { + // Check pattern is well-formed. + if _, err := Match(pattern, ""); err != nil { + return nil, err +@@ -270,7 +280,7 @@ func Glob(pattern string) (matches []string, err error) { } var m []string @@ -64,10 +60,10 @@ index 20a334805ba..b6a3b450fe8 100644 return } diff --git a/src/path/filepath/match_test.go b/src/path/filepath/match_test.go -index b8657626bc7..c37c812181f 100644 +index 375c41a7e9d..d6282596fed 100644 --- a/src/path/filepath/match_test.go +++ b/src/path/filepath/match_test.go -@@ -154,6 +154,16 @@ func TestGlob(t *testing.T) { +@@ -155,6 +155,16 @@ func TestGlob(t *testing.T) { } } @@ -82,8 +78,8 @@ index b8657626bc7..c37c812181f 100644 +} + func TestGlobError(t *testing.T) { - _, err := Glob("[]") - if err == nil { + bad := []string{`[]`, `nonexist/[]`} + for _, pattern := range bad { -- 2.30.2 diff --git a/0070-release-branch.go1.17-encoding-xml-use-iterative-Ski.patch b/0012-release-branch.go1.17-encoding-xml-use-iterative-Ski.patch similarity index 93% rename from 0070-release-branch.go1.17-encoding-xml-use-iterative-Ski.patch rename to 0012-release-branch.go1.17-encoding-xml-use-iterative-Ski.patch index 622c336bd323ab7f2c8390f38593d9b842820366..9be1eea8260baee823f1d033a0493f36a0efb8e1 100644 --- a/0070-release-branch.go1.17-encoding-xml-use-iterative-Ski.patch +++ b/0012-release-branch.go1.17-encoding-xml-use-iterative-Ski.patch @@ -1,7 +1,7 @@ -From a63efc45c908bfd46c60e95956cce499a2c92e44 Mon Sep 17 00:00:00 2001 +From cedbe8f7a1f0d174636e70de68d85499d8025000 Mon Sep 17 00:00:00 2001 From: Roland Shoemaker Date: Mon, 28 Mar 2022 18:41:26 -0700 -Subject: [PATCH 07/10] [release-branch.go1.17] encoding/xml: use iterative +Subject: [PATCH 08/11] [release-branch.go1.17] encoding/xml: use iterative Skip, rather than recursive Prevents exhausting the stack limit in _incredibly_ deeply nested diff --git a/0013-release-branch.go1.15-internal-poll-if-copy_file_ran.patch b/0013-release-branch.go1.15-internal-poll-if-copy_file_ran.patch deleted file mode 100644 index 6aee0f5a52935d641b9226afb7887b5e31cac7d1..0000000000000000000000000000000000000000 --- a/0013-release-branch.go1.15-internal-poll-if-copy_file_ran.patch +++ /dev/null @@ -1,102 +0,0 @@ -From 023c46676db26e75d244b1d38ccc4a4b8bfe3eef Mon Sep 17 00:00:00 2001 -From: Ian Lance Taylor -Date: Sun, 14 Feb 2021 17:14:41 -0800 -Subject: [PATCH 13/44] [release-branch.go1.15] internal/poll: if - copy_file_range returns 0, assume it failed - -On current Linux kernels copy_file_range does not correctly handle -files in certain special file systems, such as /proc. For those file -systems it fails to copy any data and returns zero. This breaks Go's -io.Copy for those files. - -Fix the problem by assuming that if copy_file_range returns 0 the -first time it is called on a file, that that file is not supported. -In that case fall back to just using read. This will force an extra -system call when using io.Copy to copy a zero-sized normal file, -but at least it will work correctly. - -For #36817 -For #44272 -Fixes #44273 - -Change-Id: I02e81872cb70fda0ce5485e2ea712f219132e614 -Reviewed-on: https://go-review.googlesource.com/c/go/+/291989 -Trust: Ian Lance Taylor -Run-TryBot: Ian Lance Taylor -TryBot-Result: Go Bot -Reviewed-by: Russ Cox -(cherry picked from commit 30641e36aa5b547eee48565caa3078b0a2e7c185) -Reviewed-on: https://go-review.googlesource.com/c/go/+/292289 - -Conflict:NA -Reference:https://github.com/golang/go/commit/023c46676db26e75d244b1d38ccc4a4b8bfe3eef - ---- - src/internal/poll/copy_file_range_linux.go | 10 ++++++- - src/os/readfrom_linux_test.go | 32 ++++++++++++++++++++++ - 2 files changed, 41 insertions(+), 1 deletion(-) - -diff --git a/src/internal/poll/copy_file_range_linux.go b/src/internal/poll/copy_file_range_linux.go -index fc34aef4cb..01b242a4ea 100644 ---- a/src/internal/poll/copy_file_range_linux.go -+++ b/src/internal/poll/copy_file_range_linux.go -@@ -112,7 +112,15 @@ func CopyFileRange(dst, src *FD, remain int64) (written int64, handled bool, err - return 0, false, nil - case nil: - if n == 0 { -- // src is at EOF, which means we are done. -+ // If we did not read any bytes at all, -+ // then this file may be in a file system -+ // where copy_file_range silently fails. -+ // https://lore.kernel.org/linux-fsdevel/20210126233840.GG4626@dread.disaster.area/T/#m05753578c7f7882f6e9ffe01f981bc223edef2b0 -+ if written == 0 { -+ return 0, false, nil -+ } -+ // Otherwise src is at EOF, which means -+ // we are done. - return written, true, nil - } - remain -= n -diff --git a/src/os/readfrom_linux_test.go b/src/os/readfrom_linux_test.go -index 00faf39fe5..aa3f050667 100644 ---- a/src/os/readfrom_linux_test.go -+++ b/src/os/readfrom_linux_test.go -@@ -361,3 +361,35 @@ func (h *copyFileRangeHook) install() { - func (h *copyFileRangeHook) uninstall() { - *PollCopyFileRangeP = h.original - } -+ -+// On some kernels copy_file_range fails on files in /proc. -+func TestProcCopy(t *testing.T) { -+ const cmdlineFile = "/proc/self/cmdline" -+ cmdline, err := ioutil.ReadFile(cmdlineFile) -+ if err != nil { -+ t.Skipf("can't read /proc file: %v", err) -+ } -+ in, err := Open(cmdlineFile) -+ if err != nil { -+ t.Fatal(err) -+ } -+ defer in.Close() -+ outFile := filepath.Join(t.TempDir(), "cmdline") -+ out, err := Create(outFile) -+ if err != nil { -+ t.Fatal(err) -+ } -+ if _, err := io.Copy(out, in); err != nil { -+ t.Fatal(err) -+ } -+ if err := out.Close(); err != nil { -+ t.Fatal(err) -+ } -+ copy, err := ioutil.ReadFile(outFile) -+ if err != nil { -+ t.Fatal(err) -+ } -+ if !bytes.Equal(cmdline, copy) { -+ t.Errorf("copy of %q got %q want %q\n", cmdlineFile, copy, cmdline) -+ } -+} --- -2.27.0 - diff --git a/0071-release-branch.go1.17-compress-gzip-fix-stack-exhaus.patch b/0013-release-branch.go1.17-compress-gzip-fix-stack-exhaus.patch similarity index 94% rename from 0071-release-branch.go1.17-compress-gzip-fix-stack-exhaus.patch rename to 0013-release-branch.go1.17-compress-gzip-fix-stack-exhaus.patch index a201e00e7b34122ba351408292abd096aacb0a37..7a54a71ea1789a38b6e07405b4c2d47766b75f08 100644 --- a/0071-release-branch.go1.17-compress-gzip-fix-stack-exhaus.patch +++ b/0013-release-branch.go1.17-compress-gzip-fix-stack-exhaus.patch @@ -1,7 +1,7 @@ -From 10531e040d8ed73f51032a7d75c708ca07b638ff Mon Sep 17 00:00:00 2001 +From 8a445abc7f7e2ed41112f176a169b97859c8d425 Mon Sep 17 00:00:00 2001 From: Tatiana Bradley Date: Fri, 6 May 2022 11:25:06 -0400 -Subject: [PATCH 08/10] [release-branch.go1.17] compress/gzip: fix stack +Subject: [PATCH 09/11] [release-branch.go1.17] compress/gzip: fix stack exhaustion bug in Reader.Read Replace recursion with iteration in Reader.Read to avoid stack @@ -105,10 +105,10 @@ index 924bce10b7c..237b2b928bf 100644 // Close closes the Reader. It does not close the underlying io.Reader. diff --git a/src/compress/gzip/gunzip_test.go b/src/compress/gzip/gunzip_test.go -index 1b014041692..95220ae82d9 100644 +index 17c23e8a9be..6fe8ddcf558 100644 --- a/src/compress/gzip/gunzip_test.go +++ b/src/compress/gzip/gunzip_test.go -@@ -516,3 +516,19 @@ func TestTruncatedStreams(t *testing.T) { +@@ -515,3 +515,19 @@ func TestTruncatedStreams(t *testing.T) { } } } diff --git a/0014-release-branch.go1.15-internal-poll-netpollcheckerr-.patch b/0014-release-branch.go1.15-internal-poll-netpollcheckerr-.patch deleted file mode 100644 index 4a9859a80400caf8876cd90f1feb10bd391ac4f1..0000000000000000000000000000000000000000 --- a/0014-release-branch.go1.15-internal-poll-netpollcheckerr-.patch +++ /dev/null @@ -1,166 +0,0 @@ -From 30357d6ef6513b18fade686a629ab8d49987260f Mon Sep 17 00:00:00 2001 -From: Wei Fu -Date: Sun, 24 Jan 2021 18:21:06 +0800 -Subject: [PATCH 14/44] [release-branch.go1.15] internal/poll: netpollcheckerr - before sendfile - -In net/http package, the ServeContent/ServeFile doesn't check the I/O -timeout error from chunkWriter or *net.TCPConn, which means that both -HTTP status and headers might be missing when WriteTimeout happens. If -the poll.SendFile() doesn't check the *poll.FD state before sending -data, the client will only receive the response body with status and -report "malformed http response/status code". - -This patch is to enable netpollcheckerr before sendfile, which should -align with normal *poll.FD.Write() and Splice(). - -For #43822 -Fixes #44294 - -Change-Id: I32517e3f261bab883a58b577b813ef189214b954 -Reviewed-on: https://go-review.googlesource.com/c/go/+/285914 -Reviewed-by: Emmanuel Odeke -Trust: Emmanuel Odeke -Trust: Bryan C. Mills -Run-TryBot: Emmanuel Odeke -(cherry picked from commit f0d23c9dbb2142b975fa8fb13a57213d0c15bdd1) -Reviewed-on: https://go-review.googlesource.com/c/go/+/296530 -Trust: Ian Lance Taylor -Run-TryBot: Ian Lance Taylor -TryBot-Result: Go Bot - -Conflict:NA -Reference:https://github.com/golang/go/commit/30357d6ef6513b18fade686a629ab8d49987260f - ---- - src/internal/poll/sendfile_bsd.go | 4 ++ - src/internal/poll/sendfile_linux.go | 3 ++ - src/internal/poll/sendfile_solaris.go | 3 ++ - src/net/sendfile_test.go | 64 +++++++++++++++++++++++++++ - 4 files changed, 74 insertions(+) - -diff --git a/src/internal/poll/sendfile_bsd.go b/src/internal/poll/sendfile_bsd.go -index a24e41dcaa..66005a9f5c 100644 ---- a/src/internal/poll/sendfile_bsd.go -+++ b/src/internal/poll/sendfile_bsd.go -@@ -18,6 +18,10 @@ func SendFile(dstFD *FD, src int, pos, remain int64) (int64, error) { - return 0, err - } - defer dstFD.writeUnlock() -+ if err := dstFD.pd.prepareWrite(dstFD.isFile); err != nil { -+ return 0, err -+ } -+ - dst := int(dstFD.Sysfd) - var written int64 - var err error -diff --git a/src/internal/poll/sendfile_linux.go b/src/internal/poll/sendfile_linux.go -index d64283007d..d6442e8666 100644 ---- a/src/internal/poll/sendfile_linux.go -+++ b/src/internal/poll/sendfile_linux.go -@@ -16,6 +16,9 @@ func SendFile(dstFD *FD, src int, remain int64) (int64, error) { - return 0, err - } - defer dstFD.writeUnlock() -+ if err := dstFD.pd.prepareWrite(dstFD.isFile); err != nil { -+ return 0, err -+ } - - dst := int(dstFD.Sysfd) - var written int64 -diff --git a/src/internal/poll/sendfile_solaris.go b/src/internal/poll/sendfile_solaris.go -index 762992e9eb..748c85131e 100644 ---- a/src/internal/poll/sendfile_solaris.go -+++ b/src/internal/poll/sendfile_solaris.go -@@ -20,6 +20,9 @@ func SendFile(dstFD *FD, src int, pos, remain int64) (int64, error) { - return 0, err - } - defer dstFD.writeUnlock() -+ if err := dstFD.pd.prepareWrite(dstFD.isFile); err != nil { -+ return 0, err -+ } - - dst := int(dstFD.Sysfd) - var written int64 -diff --git a/src/net/sendfile_test.go b/src/net/sendfile_test.go -index 13842a1261..0e344b3649 100644 ---- a/src/net/sendfile_test.go -+++ b/src/net/sendfile_test.go -@@ -10,6 +10,7 @@ import ( - "bytes" - "crypto/sha256" - "encoding/hex" -+ "errors" - "fmt" - "io" - "io/ioutil" -@@ -314,3 +315,66 @@ func TestSendfilePipe(t *testing.T) { - - wg.Wait() - } -+ -+// Issue 43822: tests that returns EOF when conn write timeout. -+func TestSendfileOnWriteTimeoutExceeded(t *testing.T) { -+ ln, err := newLocalListener("tcp") -+ if err != nil { -+ t.Fatal(err) -+ } -+ defer ln.Close() -+ -+ errc := make(chan error, 1) -+ go func(ln Listener) (retErr error) { -+ defer func() { -+ errc <- retErr -+ close(errc) -+ }() -+ -+ conn, err := ln.Accept() -+ if err != nil { -+ return err -+ } -+ defer conn.Close() -+ -+ // Set the write deadline in the past(1h ago). It makes -+ // sure that it is always write timeout. -+ if err := conn.SetWriteDeadline(time.Now().Add(-1 * time.Hour)); err != nil { -+ return err -+ } -+ -+ f, err := os.Open(newton) -+ if err != nil { -+ return err -+ } -+ defer f.Close() -+ -+ _, err = io.Copy(conn, f) -+ if errors.Is(err, os.ErrDeadlineExceeded) { -+ return nil -+ } -+ -+ if err == nil { -+ err = fmt.Errorf("expected ErrDeadlineExceeded, but got nil") -+ } -+ return err -+ }(ln) -+ -+ conn, err := Dial("tcp", ln.Addr().String()) -+ if err != nil { -+ t.Fatal(err) -+ } -+ defer conn.Close() -+ -+ n, err := io.Copy(ioutil.Discard, conn) -+ if err != nil { -+ t.Fatalf("expected nil error, but got %v", err) -+ } -+ if n != 0 { -+ t.Fatalf("expected receive zero, but got %d byte(s)", n) -+ } -+ -+ if err := <-errc; err != nil { -+ t.Fatal(err) -+ } -+} --- -2.27.0 - diff --git a/0072-release-branch.go1.17-crypto-tls-randomly-generate-t.patch b/0014-release-branch.go1.17-crypto-tls-randomly-generate-t.patch similarity index 89% rename from 0072-release-branch.go1.17-crypto-tls-randomly-generate-t.patch rename to 0014-release-branch.go1.17-crypto-tls-randomly-generate-t.patch index 244642451f25bd128d45a025de04d0a08eb3f825..f8f418a62b7f0a81fcd8bd8ae61ed498bf433228 100644 --- a/0072-release-branch.go1.17-crypto-tls-randomly-generate-t.patch +++ b/0014-release-branch.go1.17-crypto-tls-randomly-generate-t.patch @@ -1,7 +1,7 @@ -From 251fa2dcc814ef51816245336fd1884239dd002a Mon Sep 17 00:00:00 2001 +From b2815a72bef3f829c5ac7735feddb034f5501cc0 Mon Sep 17 00:00:00 2001 From: Tatiana Bradley Date: Thu, 12 May 2022 14:58:29 -0400 -Subject: [PATCH 09/10] [release-branch.go1.17] crypto/tls: randomly generate +Subject: [PATCH 10/11] [release-branch.go1.17] crypto/tls: randomly generate ticket_age_add As required by RFC 8446, section 4.6.1, ticket_age_add now holds a @@ -33,10 +33,10 @@ Reference: https://go-review.googlesource.com/c/go/+/408574 1 file changed, 14 insertions(+) diff --git a/src/crypto/tls/handshake_server_tls13.go b/src/crypto/tls/handshake_server_tls13.go -index 92d55e0293a..fcea739b9a9 100644 +index 08251b84def..6aa52698a3a 100644 --- a/src/crypto/tls/handshake_server_tls13.go +++ b/src/crypto/tls/handshake_server_tls13.go -@@ -9,6 +9,7 @@ import ( +@@ -10,6 +10,7 @@ import ( "crypto" "crypto/hmac" "crypto/rsa" @@ -44,7 +44,7 @@ index 92d55e0293a..fcea739b9a9 100644 "errors" "hash" "io" -@@ -742,6 +743,19 @@ func (hs *serverHandshakeStateTLS13) sendSessionTickets() error { +@@ -741,6 +742,19 @@ func (hs *serverHandshakeStateTLS13) sendSessionTickets() error { } m.lifetime = uint32(maxSessionTicketLifetime / time.Second) diff --git a/0015-release-branch.go1.15-cmd-compile-do-not-assume-TST-.patch b/0015-release-branch.go1.15-cmd-compile-do-not-assume-TST-.patch deleted file mode 100644 index ab3e6dac0cc88ace5fcf0929ec6569a1b8e06cdb..0000000000000000000000000000000000000000 --- a/0015-release-branch.go1.15-cmd-compile-do-not-assume-TST-.patch +++ /dev/null @@ -1,1281 +0,0 @@ -From d9b4ef591c2b058004545eccf10a538aa7597adb Mon Sep 17 00:00:00 2001 -From: "Jason A. Donenfeld" -Date: Mon, 30 Nov 2020 10:41:46 +0100 -Subject: [PATCH 15/44] [release-branch.go1.15] cmd/compile: do not assume TST - and TEQ set V on arm - -These replacement rules assume that TST and TEQ set V. But TST and -TEQ do not set V. This is a problem because instructions like LT are -actually checking for N!=V. But with TST and TEQ not setting V, LT -doesn't do anything meaningful. It's possible to construct trivial -miscompilations from this, such as: - - package main - - var x = [4]int32{-0x7fffffff, 0x7fffffff, 2, 4} - - func main() { - if x[0] > x[1] { - panic("fail 1") - } - if x[2]&x[3] < 0 { - panic("fail 2") // Fails here - } - } - -That first comparison sets V, via the CMP that subtracts the values -causing the overflow. Then the second comparison operation thinks that -it uses the result of TST, when it actually uses the V from CMP. - -Before this fix: - - TST R0, R1 - BLT loc_6C164 - -After this fix: - - TST R0, R1 - BMI loc_6C164 - -The BMI instruction checks the N flag, which TST sets. This commit -fixes the issue by using [LG][TE]noov instead of vanilla [LG][TE], and -also adds a test case for the direct issue. - -Updates #42876. -Fixes #42930. - -Change-Id: I13c62c88d18574247ad002b671b38d2d0b0fc6fa -Reviewed-on: https://go-review.googlesource.com/c/go/+/282432 -Trust: Jason A. Donenfeld -Run-TryBot: Jason A. Donenfeld -TryBot-Result: Go Bot -Reviewed-by: Cherry Zhang - -Conflict:NA -Reference:https://github.com/golang/go/commit/d9b4ef591c2b058004545eccf10a538aa7597adb - ---- - src/cmd/compile/internal/ssa/gen/ARM.rules | 128 ++++----- - src/cmd/compile/internal/ssa/rewriteARM.go | 306 ++++++++++----------- - test/fixedbugs/issue42876.go | 18 ++ - 3 files changed, 235 insertions(+), 217 deletions(-) - create mode 100644 test/fixedbugs/issue42876.go - -diff --git a/src/cmd/compile/internal/ssa/gen/ARM.rules b/src/cmd/compile/internal/ssa/gen/ARM.rules -index ab8bd0e81e..c69084a701 100644 ---- a/src/cmd/compile/internal/ssa/gen/ARM.rules -+++ b/src/cmd/compile/internal/ssa/gen/ARM.rules -@@ -1369,38 +1369,38 @@ - (LE (CMPconst [0] l:(ADDshiftLLreg x y z)) yes no) && l.Uses==1 -> (LEnoov (CMNshiftLLreg x y z) yes no) - (LE (CMPconst [0] l:(ADDshiftRLreg x y z)) yes no) && l.Uses==1 -> (LEnoov (CMNshiftRLreg x y z) yes no) - (LE (CMPconst [0] l:(ADDshiftRAreg x y z)) yes no) && l.Uses==1 -> (LEnoov (CMNshiftRAreg x y z) yes no) --(LT (CMPconst [0] l:(AND x y)) yes no) && l.Uses==1 -> (LT (TST x y) yes no) --(LT (CMPconst [0] l:(ANDconst [c] x)) yes no) && l.Uses==1 -> (LT (TSTconst [c] x) yes no) --(LT (CMPconst [0] l:(ANDshiftLL x y [c])) yes no) && l.Uses==1 -> (LT (TSTshiftLL x y [c]) yes no) --(LT (CMPconst [0] l:(ANDshiftRL x y [c])) yes no) && l.Uses==1 -> (LT (TSTshiftRL x y [c]) yes no) --(LT (CMPconst [0] l:(ANDshiftRA x y [c])) yes no) && l.Uses==1 -> (LT (TSTshiftRA x y [c]) yes no) --(LT (CMPconst [0] l:(ANDshiftLLreg x y z)) yes no) && l.Uses==1 -> (LT (TSTshiftLLreg x y z) yes no) --(LT (CMPconst [0] l:(ANDshiftRLreg x y z)) yes no) && l.Uses==1 -> (LT (TSTshiftRLreg x y z) yes no) --(LT (CMPconst [0] l:(ANDshiftRAreg x y z)) yes no) && l.Uses==1 -> (LT (TSTshiftRAreg x y z) yes no) --(LE (CMPconst [0] l:(AND x y)) yes no) && l.Uses==1 -> (LE (TST x y) yes no) --(LE (CMPconst [0] l:(ANDconst [c] x)) yes no) && l.Uses==1 -> (LE (TSTconst [c] x) yes no) --(LE (CMPconst [0] l:(ANDshiftLL x y [c])) yes no) && l.Uses==1 -> (LE (TSTshiftLL x y [c]) yes no) --(LE (CMPconst [0] l:(ANDshiftRL x y [c])) yes no) && l.Uses==1 -> (LE (TSTshiftRL x y [c]) yes no) --(LE (CMPconst [0] l:(ANDshiftRA x y [c])) yes no) && l.Uses==1 -> (LE (TSTshiftRA x y [c]) yes no) --(LE (CMPconst [0] l:(ANDshiftLLreg x y z)) yes no) && l.Uses==1 -> (LE (TSTshiftLLreg x y z) yes no) --(LE (CMPconst [0] l:(ANDshiftRLreg x y z)) yes no) && l.Uses==1 -> (LE (TSTshiftRLreg x y z) yes no) --(LE (CMPconst [0] l:(ANDshiftRAreg x y z)) yes no) && l.Uses==1 -> (LE (TSTshiftRAreg x y z) yes no) --(LT (CMPconst [0] l:(XOR x y)) yes no) && l.Uses==1 -> (LT (TEQ x y) yes no) --(LT (CMPconst [0] l:(XORconst [c] x)) yes no) && l.Uses==1 -> (LT (TEQconst [c] x) yes no) --(LT (CMPconst [0] l:(XORshiftLL x y [c])) yes no) && l.Uses==1 -> (LT (TEQshiftLL x y [c]) yes no) --(LT (CMPconst [0] l:(XORshiftRL x y [c])) yes no) && l.Uses==1 -> (LT (TEQshiftRL x y [c]) yes no) --(LT (CMPconst [0] l:(XORshiftRA x y [c])) yes no) && l.Uses==1 -> (LT (TEQshiftRA x y [c]) yes no) --(LT (CMPconst [0] l:(XORshiftLLreg x y z)) yes no) && l.Uses==1 -> (LT (TEQshiftLLreg x y z) yes no) --(LT (CMPconst [0] l:(XORshiftRLreg x y z)) yes no) && l.Uses==1 -> (LT (TEQshiftRLreg x y z) yes no) --(LT (CMPconst [0] l:(XORshiftRAreg x y z)) yes no) && l.Uses==1 -> (LT (TEQshiftRAreg x y z) yes no) --(LE (CMPconst [0] l:(XOR x y)) yes no) && l.Uses==1 -> (LE (TEQ x y) yes no) --(LE (CMPconst [0] l:(XORconst [c] x)) yes no) && l.Uses==1 -> (LE (TEQconst [c] x) yes no) --(LE (CMPconst [0] l:(XORshiftLL x y [c])) yes no) && l.Uses==1 -> (LE (TEQshiftLL x y [c]) yes no) --(LE (CMPconst [0] l:(XORshiftRL x y [c])) yes no) && l.Uses==1 -> (LE (TEQshiftRL x y [c]) yes no) --(LE (CMPconst [0] l:(XORshiftRA x y [c])) yes no) && l.Uses==1 -> (LE (TEQshiftRA x y [c]) yes no) --(LE (CMPconst [0] l:(XORshiftLLreg x y z)) yes no) && l.Uses==1 -> (LE (TEQshiftLLreg x y z) yes no) --(LE (CMPconst [0] l:(XORshiftRLreg x y z)) yes no) && l.Uses==1 -> (LE (TEQshiftRLreg x y z) yes no) --(LE (CMPconst [0] l:(XORshiftRAreg x y z)) yes no) && l.Uses==1 -> (LE (TEQshiftRAreg x y z) yes no) -+(LT (CMPconst [0] l:(AND x y)) yes no) && l.Uses==1 -> (LTnoov (TST x y) yes no) -+(LT (CMPconst [0] l:(ANDconst [c] x)) yes no) && l.Uses==1 -> (LTnoov (TSTconst [c] x) yes no) -+(LT (CMPconst [0] l:(ANDshiftLL x y [c])) yes no) && l.Uses==1 -> (LTnoov (TSTshiftLL x y [c]) yes no) -+(LT (CMPconst [0] l:(ANDshiftRL x y [c])) yes no) && l.Uses==1 -> (LTnoov (TSTshiftRL x y [c]) yes no) -+(LT (CMPconst [0] l:(ANDshiftRA x y [c])) yes no) && l.Uses==1 -> (LTnoov (TSTshiftRA x y [c]) yes no) -+(LT (CMPconst [0] l:(ANDshiftLLreg x y z)) yes no) && l.Uses==1 -> (LTnoov (TSTshiftLLreg x y z) yes no) -+(LT (CMPconst [0] l:(ANDshiftRLreg x y z)) yes no) && l.Uses==1 -> (LTnoov (TSTshiftRLreg x y z) yes no) -+(LT (CMPconst [0] l:(ANDshiftRAreg x y z)) yes no) && l.Uses==1 -> (LTnoov (TSTshiftRAreg x y z) yes no) -+(LE (CMPconst [0] l:(AND x y)) yes no) && l.Uses==1 -> (LEnoov (TST x y) yes no) -+(LE (CMPconst [0] l:(ANDconst [c] x)) yes no) && l.Uses==1 -> (LEnoov (TSTconst [c] x) yes no) -+(LE (CMPconst [0] l:(ANDshiftLL x y [c])) yes no) && l.Uses==1 -> (LEnoov (TSTshiftLL x y [c]) yes no) -+(LE (CMPconst [0] l:(ANDshiftRL x y [c])) yes no) && l.Uses==1 -> (LEnoov (TSTshiftRL x y [c]) yes no) -+(LE (CMPconst [0] l:(ANDshiftRA x y [c])) yes no) && l.Uses==1 -> (LEnoov (TSTshiftRA x y [c]) yes no) -+(LE (CMPconst [0] l:(ANDshiftLLreg x y z)) yes no) && l.Uses==1 -> (LEnoov (TSTshiftLLreg x y z) yes no) -+(LE (CMPconst [0] l:(ANDshiftRLreg x y z)) yes no) && l.Uses==1 -> (LEnoov (TSTshiftRLreg x y z) yes no) -+(LE (CMPconst [0] l:(ANDshiftRAreg x y z)) yes no) && l.Uses==1 -> (LEnoov (TSTshiftRAreg x y z) yes no) -+(LT (CMPconst [0] l:(XOR x y)) yes no) && l.Uses==1 -> (LTnoov (TEQ x y) yes no) -+(LT (CMPconst [0] l:(XORconst [c] x)) yes no) && l.Uses==1 -> (LTnoov (TEQconst [c] x) yes no) -+(LT (CMPconst [0] l:(XORshiftLL x y [c])) yes no) && l.Uses==1 -> (LTnoov (TEQshiftLL x y [c]) yes no) -+(LT (CMPconst [0] l:(XORshiftRL x y [c])) yes no) && l.Uses==1 -> (LTnoov (TEQshiftRL x y [c]) yes no) -+(LT (CMPconst [0] l:(XORshiftRA x y [c])) yes no) && l.Uses==1 -> (LTnoov (TEQshiftRA x y [c]) yes no) -+(LT (CMPconst [0] l:(XORshiftLLreg x y z)) yes no) && l.Uses==1 -> (LTnoov (TEQshiftLLreg x y z) yes no) -+(LT (CMPconst [0] l:(XORshiftRLreg x y z)) yes no) && l.Uses==1 -> (LTnoov (TEQshiftRLreg x y z) yes no) -+(LT (CMPconst [0] l:(XORshiftRAreg x y z)) yes no) && l.Uses==1 -> (LTnoov (TEQshiftRAreg x y z) yes no) -+(LE (CMPconst [0] l:(XOR x y)) yes no) && l.Uses==1 -> (LEnoov (TEQ x y) yes no) -+(LE (CMPconst [0] l:(XORconst [c] x)) yes no) && l.Uses==1 -> (LEnoov (TEQconst [c] x) yes no) -+(LE (CMPconst [0] l:(XORshiftLL x y [c])) yes no) && l.Uses==1 -> (LEnoov (TEQshiftLL x y [c]) yes no) -+(LE (CMPconst [0] l:(XORshiftRL x y [c])) yes no) && l.Uses==1 -> (LEnoov (TEQshiftRL x y [c]) yes no) -+(LE (CMPconst [0] l:(XORshiftRA x y [c])) yes no) && l.Uses==1 -> (LEnoov (TEQshiftRA x y [c]) yes no) -+(LE (CMPconst [0] l:(XORshiftLLreg x y z)) yes no) && l.Uses==1 -> (LEnoov (TEQshiftLLreg x y z) yes no) -+(LE (CMPconst [0] l:(XORshiftRLreg x y z)) yes no) && l.Uses==1 -> (LEnoov (TEQshiftRLreg x y z) yes no) -+(LE (CMPconst [0] l:(XORshiftRAreg x y z)) yes no) && l.Uses==1 -> (LEnoov (TEQshiftRAreg x y z) yes no) - (GT (CMPconst [0] l:(SUB x y)) yes no) && l.Uses==1 -> (GTnoov (CMP x y) yes no) - (GT (CMPconst [0] l:(MULS x y a)) yes no) && l.Uses==1 -> (GTnoov (CMP a (MUL x y)) yes no) - (GT (CMPconst [0] l:(SUBconst [c] x)) yes no) && l.Uses==1 -> (GTnoov (CMPconst [c] x) yes no) -@@ -1436,39 +1436,39 @@ - (GE (CMPconst [0] l:(ADDshiftLLreg x y z)) yes no) && l.Uses==1 -> (GEnoov (CMNshiftLLreg x y z) yes no) - (GE (CMPconst [0] l:(ADDshiftRLreg x y z)) yes no) && l.Uses==1 -> (GEnoov (CMNshiftRLreg x y z) yes no) - (GE (CMPconst [0] l:(ADDshiftRAreg x y z)) yes no) && l.Uses==1 -> (GEnoov (CMNshiftRAreg x y z) yes no) --(GT (CMPconst [0] l:(AND x y)) yes no) && l.Uses==1 -> (GT (TST x y) yes no) - (GT (CMPconst [0] l:(MULA x y a)) yes no) && l.Uses==1 -> (GTnoov (CMN a (MUL x y)) yes no) --(GT (CMPconst [0] l:(ANDconst [c] x)) yes no) && l.Uses==1 -> (GT (TSTconst [c] x) yes no) --(GT (CMPconst [0] l:(ANDshiftLL x y [c])) yes no) && l.Uses==1 -> (GT (TSTshiftLL x y [c]) yes no) --(GT (CMPconst [0] l:(ANDshiftRL x y [c])) yes no) && l.Uses==1 -> (GT (TSTshiftRL x y [c]) yes no) --(GT (CMPconst [0] l:(ANDshiftRA x y [c])) yes no) && l.Uses==1 -> (GT (TSTshiftRA x y [c]) yes no) --(GT (CMPconst [0] l:(ANDshiftLLreg x y z)) yes no) && l.Uses==1 -> (GT (TSTshiftLLreg x y z) yes no) --(GT (CMPconst [0] l:(ANDshiftRLreg x y z)) yes no) && l.Uses==1 -> (GT (TSTshiftRLreg x y z) yes no) --(GT (CMPconst [0] l:(ANDshiftRAreg x y z)) yes no) && l.Uses==1 -> (GT (TSTshiftRAreg x y z) yes no) --(GE (CMPconst [0] l:(AND x y)) yes no) && l.Uses==1 -> (GE (TST x y) yes no) --(GE (CMPconst [0] l:(ANDconst [c] x)) yes no) && l.Uses==1 -> (GE (TSTconst [c] x) yes no) --(GE (CMPconst [0] l:(ANDshiftLL x y [c])) yes no) && l.Uses==1 -> (GE (TSTshiftLL x y [c]) yes no) --(GE (CMPconst [0] l:(ANDshiftRL x y [c])) yes no) && l.Uses==1 -> (GE (TSTshiftRL x y [c]) yes no) --(GE (CMPconst [0] l:(ANDshiftRA x y [c])) yes no) && l.Uses==1 -> (GE (TSTshiftRA x y [c]) yes no) --(GE (CMPconst [0] l:(ANDshiftLLreg x y z)) yes no) && l.Uses==1 -> (GE (TSTshiftLLreg x y z) yes no) --(GE (CMPconst [0] l:(ANDshiftRLreg x y z)) yes no) && l.Uses==1 -> (GE (TSTshiftRLreg x y z) yes no) --(GE (CMPconst [0] l:(ANDshiftRAreg x y z)) yes no) && l.Uses==1 -> (GE (TSTshiftRAreg x y z) yes no) --(GT (CMPconst [0] l:(XOR x y)) yes no) && l.Uses==1 -> (GT (TEQ x y) yes no) --(GT (CMPconst [0] l:(XORconst [c] x)) yes no) && l.Uses==1 -> (GT (TEQconst [c] x) yes no) --(GT (CMPconst [0] l:(XORshiftLL x y [c])) yes no) && l.Uses==1 -> (GT (TEQshiftLL x y [c]) yes no) --(GT (CMPconst [0] l:(XORshiftRL x y [c])) yes no) && l.Uses==1 -> (GT (TEQshiftRL x y [c]) yes no) --(GT (CMPconst [0] l:(XORshiftRA x y [c])) yes no) && l.Uses==1 -> (GT (TEQshiftRA x y [c]) yes no) --(GT (CMPconst [0] l:(XORshiftLLreg x y z)) yes no) && l.Uses==1 -> (GT (TEQshiftLLreg x y z) yes no) --(GT (CMPconst [0] l:(XORshiftRLreg x y z)) yes no) && l.Uses==1 -> (GT (TEQshiftRLreg x y z) yes no) --(GT (CMPconst [0] l:(XORshiftRAreg x y z)) yes no) && l.Uses==1 -> (GT (TEQshiftRAreg x y z) yes no) --(GE (CMPconst [0] l:(XOR x y)) yes no) && l.Uses==1 -> (GE (TEQ x y) yes no) --(GE (CMPconst [0] l:(XORconst [c] x)) yes no) && l.Uses==1 -> (GE (TEQconst [c] x) yes no) --(GE (CMPconst [0] l:(XORshiftLL x y [c])) yes no) && l.Uses==1 -> (GE (TEQshiftLL x y [c]) yes no) --(GE (CMPconst [0] l:(XORshiftRL x y [c])) yes no) && l.Uses==1 -> (GE (TEQshiftRL x y [c]) yes no) --(GE (CMPconst [0] l:(XORshiftRA x y [c])) yes no) && l.Uses==1 -> (GE (TEQshiftRA x y [c]) yes no) --(GE (CMPconst [0] l:(XORshiftLLreg x y z)) yes no) && l.Uses==1 -> (GE (TEQshiftLLreg x y z) yes no) --(GE (CMPconst [0] l:(XORshiftRLreg x y z)) yes no) && l.Uses==1 -> (GE (TEQshiftRLreg x y z) yes no) --(GE (CMPconst [0] l:(XORshiftRAreg x y z)) yes no) && l.Uses==1 -> (GE (TEQshiftRAreg x y z) yes no) -+(GT (CMPconst [0] l:(AND x y)) yes no) && l.Uses==1 -> (GTnoov (TST x y) yes no) -+(GT (CMPconst [0] l:(ANDconst [c] x)) yes no) && l.Uses==1 -> (GTnoov (TSTconst [c] x) yes no) -+(GT (CMPconst [0] l:(ANDshiftLL x y [c])) yes no) && l.Uses==1 -> (GTnoov (TSTshiftLL x y [c]) yes no) -+(GT (CMPconst [0] l:(ANDshiftRL x y [c])) yes no) && l.Uses==1 -> (GTnoov (TSTshiftRL x y [c]) yes no) -+(GT (CMPconst [0] l:(ANDshiftRA x y [c])) yes no) && l.Uses==1 -> (GTnoov (TSTshiftRA x y [c]) yes no) -+(GT (CMPconst [0] l:(ANDshiftLLreg x y z)) yes no) && l.Uses==1 -> (GTnoov (TSTshiftLLreg x y z) yes no) -+(GT (CMPconst [0] l:(ANDshiftRLreg x y z)) yes no) && l.Uses==1 -> (GTnoov (TSTshiftRLreg x y z) yes no) -+(GT (CMPconst [0] l:(ANDshiftRAreg x y z)) yes no) && l.Uses==1 -> (GTnoov (TSTshiftRAreg x y z) yes no) -+(GE (CMPconst [0] l:(AND x y)) yes no) && l.Uses==1 -> (GEnoov (TST x y) yes no) -+(GE (CMPconst [0] l:(ANDconst [c] x)) yes no) && l.Uses==1 -> (GEnoov (TSTconst [c] x) yes no) -+(GE (CMPconst [0] l:(ANDshiftLL x y [c])) yes no) && l.Uses==1 -> (GEnoov (TSTshiftLL x y [c]) yes no) -+(GE (CMPconst [0] l:(ANDshiftRL x y [c])) yes no) && l.Uses==1 -> (GEnoov (TSTshiftRL x y [c]) yes no) -+(GE (CMPconst [0] l:(ANDshiftRA x y [c])) yes no) && l.Uses==1 -> (GEnoov (TSTshiftRA x y [c]) yes no) -+(GE (CMPconst [0] l:(ANDshiftLLreg x y z)) yes no) && l.Uses==1 -> (GEnoov (TSTshiftLLreg x y z) yes no) -+(GE (CMPconst [0] l:(ANDshiftRLreg x y z)) yes no) && l.Uses==1 -> (GEnoov (TSTshiftRLreg x y z) yes no) -+(GE (CMPconst [0] l:(ANDshiftRAreg x y z)) yes no) && l.Uses==1 -> (GEnoov (TSTshiftRAreg x y z) yes no) -+(GT (CMPconst [0] l:(XOR x y)) yes no) && l.Uses==1 -> (GTnoov (TEQ x y) yes no) -+(GT (CMPconst [0] l:(XORconst [c] x)) yes no) && l.Uses==1 -> (GTnoov (TEQconst [c] x) yes no) -+(GT (CMPconst [0] l:(XORshiftLL x y [c])) yes no) && l.Uses==1 -> (GTnoov (TEQshiftLL x y [c]) yes no) -+(GT (CMPconst [0] l:(XORshiftRL x y [c])) yes no) && l.Uses==1 -> (GTnoov (TEQshiftRL x y [c]) yes no) -+(GT (CMPconst [0] l:(XORshiftRA x y [c])) yes no) && l.Uses==1 -> (GTnoov (TEQshiftRA x y [c]) yes no) -+(GT (CMPconst [0] l:(XORshiftLLreg x y z)) yes no) && l.Uses==1 -> (GTnoov (TEQshiftLLreg x y z) yes no) -+(GT (CMPconst [0] l:(XORshiftRLreg x y z)) yes no) && l.Uses==1 -> (GTnoov (TEQshiftRLreg x y z) yes no) -+(GT (CMPconst [0] l:(XORshiftRAreg x y z)) yes no) && l.Uses==1 -> (GTnoov (TEQshiftRAreg x y z) yes no) -+(GE (CMPconst [0] l:(XOR x y)) yes no) && l.Uses==1 -> (GEnoov (TEQ x y) yes no) -+(GE (CMPconst [0] l:(XORconst [c] x)) yes no) && l.Uses==1 -> (GEnoov (TEQconst [c] x) yes no) -+(GE (CMPconst [0] l:(XORshiftLL x y [c])) yes no) && l.Uses==1 -> (GEnoov (TEQshiftLL x y [c]) yes no) -+(GE (CMPconst [0] l:(XORshiftRL x y [c])) yes no) && l.Uses==1 -> (GEnoov (TEQshiftRL x y [c]) yes no) -+(GE (CMPconst [0] l:(XORshiftRA x y [c])) yes no) && l.Uses==1 -> (GEnoov (TEQshiftRA x y [c]) yes no) -+(GE (CMPconst [0] l:(XORshiftLLreg x y z)) yes no) && l.Uses==1 -> (GEnoov (TEQshiftLLreg x y z) yes no) -+(GE (CMPconst [0] l:(XORshiftRLreg x y z)) yes no) && l.Uses==1 -> (GEnoov (TEQshiftRLreg x y z) yes no) -+(GE (CMPconst [0] l:(XORshiftRAreg x y z)) yes no) && l.Uses==1 -> (GEnoov (TEQshiftRAreg x y z) yes no) - - (MOVBUload [off] {sym} (SB) _) && symIsRO(sym) -> (MOVWconst [int64(read8(sym, off))]) - (MOVHUload [off] {sym} (SB) _) && symIsRO(sym) -> (MOVWconst [int64(read16(sym, off, config.ctxt.Arch.ByteOrder))]) -diff --git a/src/cmd/compile/internal/ssa/rewriteARM.go b/src/cmd/compile/internal/ssa/rewriteARM.go -index f55e542505..07653b78f8 100644 ---- a/src/cmd/compile/internal/ssa/rewriteARM.go -+++ b/src/cmd/compile/internal/ssa/rewriteARM.go -@@ -17278,7 +17278,7 @@ func rewriteBlockARM(b *Block) bool { - } - // match: (GE (CMPconst [0] l:(AND x y)) yes no) - // cond: l.Uses==1 -- // result: (GE (TST x y) yes no) -+ // result: (GEnoov (TST x y) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -17299,14 +17299,14 @@ func rewriteBlockARM(b *Block) bool { - } - v0 := b.NewValue0(v_0.Pos, OpARMTST, types.TypeFlags) - v0.AddArg2(x, y) -- b.resetWithControl(BlockARMGE, v0) -+ b.resetWithControl(BlockARMGEnoov, v0) - return true - } - break - } - // match: (GE (CMPconst [0] l:(ANDconst [c] x)) yes no) - // cond: l.Uses==1 -- // result: (GE (TSTconst [c] x) yes no) -+ // result: (GEnoov (TSTconst [c] x) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -17324,12 +17324,12 @@ func rewriteBlockARM(b *Block) bool { - v0 := b.NewValue0(v_0.Pos, OpARMTSTconst, types.TypeFlags) - v0.AuxInt = c - v0.AddArg(x) -- b.resetWithControl(BlockARMGE, v0) -+ b.resetWithControl(BlockARMGEnoov, v0) - return true - } - // match: (GE (CMPconst [0] l:(ANDshiftLL x y [c])) yes no) - // cond: l.Uses==1 -- // result: (GE (TSTshiftLL x y [c]) yes no) -+ // result: (GEnoov (TSTshiftLL x y [c]) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -17348,12 +17348,12 @@ func rewriteBlockARM(b *Block) bool { - v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftLL, types.TypeFlags) - v0.AuxInt = c - v0.AddArg2(x, y) -- b.resetWithControl(BlockARMGE, v0) -+ b.resetWithControl(BlockARMGEnoov, v0) - return true - } - // match: (GE (CMPconst [0] l:(ANDshiftRL x y [c])) yes no) - // cond: l.Uses==1 -- // result: (GE (TSTshiftRL x y [c]) yes no) -+ // result: (GEnoov (TSTshiftRL x y [c]) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -17372,12 +17372,12 @@ func rewriteBlockARM(b *Block) bool { - v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRL, types.TypeFlags) - v0.AuxInt = c - v0.AddArg2(x, y) -- b.resetWithControl(BlockARMGE, v0) -+ b.resetWithControl(BlockARMGEnoov, v0) - return true - } - // match: (GE (CMPconst [0] l:(ANDshiftRA x y [c])) yes no) - // cond: l.Uses==1 -- // result: (GE (TSTshiftRA x y [c]) yes no) -+ // result: (GEnoov (TSTshiftRA x y [c]) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -17396,12 +17396,12 @@ func rewriteBlockARM(b *Block) bool { - v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRA, types.TypeFlags) - v0.AuxInt = c - v0.AddArg2(x, y) -- b.resetWithControl(BlockARMGE, v0) -+ b.resetWithControl(BlockARMGEnoov, v0) - return true - } - // match: (GE (CMPconst [0] l:(ANDshiftLLreg x y z)) yes no) - // cond: l.Uses==1 -- // result: (GE (TSTshiftLLreg x y z) yes no) -+ // result: (GEnoov (TSTshiftLLreg x y z) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -17419,12 +17419,12 @@ func rewriteBlockARM(b *Block) bool { - } - v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftLLreg, types.TypeFlags) - v0.AddArg3(x, y, z) -- b.resetWithControl(BlockARMGE, v0) -+ b.resetWithControl(BlockARMGEnoov, v0) - return true - } - // match: (GE (CMPconst [0] l:(ANDshiftRLreg x y z)) yes no) - // cond: l.Uses==1 -- // result: (GE (TSTshiftRLreg x y z) yes no) -+ // result: (GEnoov (TSTshiftRLreg x y z) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -17442,12 +17442,12 @@ func rewriteBlockARM(b *Block) bool { - } - v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRLreg, types.TypeFlags) - v0.AddArg3(x, y, z) -- b.resetWithControl(BlockARMGE, v0) -+ b.resetWithControl(BlockARMGEnoov, v0) - return true - } - // match: (GE (CMPconst [0] l:(ANDshiftRAreg x y z)) yes no) - // cond: l.Uses==1 -- // result: (GE (TSTshiftRAreg x y z) yes no) -+ // result: (GEnoov (TSTshiftRAreg x y z) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -17465,12 +17465,12 @@ func rewriteBlockARM(b *Block) bool { - } - v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRAreg, types.TypeFlags) - v0.AddArg3(x, y, z) -- b.resetWithControl(BlockARMGE, v0) -+ b.resetWithControl(BlockARMGEnoov, v0) - return true - } - // match: (GE (CMPconst [0] l:(XOR x y)) yes no) - // cond: l.Uses==1 -- // result: (GE (TEQ x y) yes no) -+ // result: (GEnoov (TEQ x y) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -17491,14 +17491,14 @@ func rewriteBlockARM(b *Block) bool { - } - v0 := b.NewValue0(v_0.Pos, OpARMTEQ, types.TypeFlags) - v0.AddArg2(x, y) -- b.resetWithControl(BlockARMGE, v0) -+ b.resetWithControl(BlockARMGEnoov, v0) - return true - } - break - } - // match: (GE (CMPconst [0] l:(XORconst [c] x)) yes no) - // cond: l.Uses==1 -- // result: (GE (TEQconst [c] x) yes no) -+ // result: (GEnoov (TEQconst [c] x) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -17516,12 +17516,12 @@ func rewriteBlockARM(b *Block) bool { - v0 := b.NewValue0(v_0.Pos, OpARMTEQconst, types.TypeFlags) - v0.AuxInt = c - v0.AddArg(x) -- b.resetWithControl(BlockARMGE, v0) -+ b.resetWithControl(BlockARMGEnoov, v0) - return true - } - // match: (GE (CMPconst [0] l:(XORshiftLL x y [c])) yes no) - // cond: l.Uses==1 -- // result: (GE (TEQshiftLL x y [c]) yes no) -+ // result: (GEnoov (TEQshiftLL x y [c]) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -17540,12 +17540,12 @@ func rewriteBlockARM(b *Block) bool { - v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftLL, types.TypeFlags) - v0.AuxInt = c - v0.AddArg2(x, y) -- b.resetWithControl(BlockARMGE, v0) -+ b.resetWithControl(BlockARMGEnoov, v0) - return true - } - // match: (GE (CMPconst [0] l:(XORshiftRL x y [c])) yes no) - // cond: l.Uses==1 -- // result: (GE (TEQshiftRL x y [c]) yes no) -+ // result: (GEnoov (TEQshiftRL x y [c]) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -17564,12 +17564,12 @@ func rewriteBlockARM(b *Block) bool { - v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRL, types.TypeFlags) - v0.AuxInt = c - v0.AddArg2(x, y) -- b.resetWithControl(BlockARMGE, v0) -+ b.resetWithControl(BlockARMGEnoov, v0) - return true - } - // match: (GE (CMPconst [0] l:(XORshiftRA x y [c])) yes no) - // cond: l.Uses==1 -- // result: (GE (TEQshiftRA x y [c]) yes no) -+ // result: (GEnoov (TEQshiftRA x y [c]) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -17588,12 +17588,12 @@ func rewriteBlockARM(b *Block) bool { - v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRA, types.TypeFlags) - v0.AuxInt = c - v0.AddArg2(x, y) -- b.resetWithControl(BlockARMGE, v0) -+ b.resetWithControl(BlockARMGEnoov, v0) - return true - } - // match: (GE (CMPconst [0] l:(XORshiftLLreg x y z)) yes no) - // cond: l.Uses==1 -- // result: (GE (TEQshiftLLreg x y z) yes no) -+ // result: (GEnoov (TEQshiftLLreg x y z) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -17611,12 +17611,12 @@ func rewriteBlockARM(b *Block) bool { - } - v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftLLreg, types.TypeFlags) - v0.AddArg3(x, y, z) -- b.resetWithControl(BlockARMGE, v0) -+ b.resetWithControl(BlockARMGEnoov, v0) - return true - } - // match: (GE (CMPconst [0] l:(XORshiftRLreg x y z)) yes no) - // cond: l.Uses==1 -- // result: (GE (TEQshiftRLreg x y z) yes no) -+ // result: (GEnoov (TEQshiftRLreg x y z) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -17634,12 +17634,12 @@ func rewriteBlockARM(b *Block) bool { - } - v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRLreg, types.TypeFlags) - v0.AddArg3(x, y, z) -- b.resetWithControl(BlockARMGE, v0) -+ b.resetWithControl(BlockARMGEnoov, v0) - return true - } - // match: (GE (CMPconst [0] l:(XORshiftRAreg x y z)) yes no) - // cond: l.Uses==1 -- // result: (GE (TEQshiftRAreg x y z) yes no) -+ // result: (GEnoov (TEQshiftRAreg x y z) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -17657,7 +17657,7 @@ func rewriteBlockARM(b *Block) bool { - } - v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRAreg, types.TypeFlags) - v0.AddArg3(x, y, z) -- b.resetWithControl(BlockARMGE, v0) -+ b.resetWithControl(BlockARMGEnoov, v0) - return true - } - case BlockARMGEnoov: -@@ -18131,9 +18131,34 @@ func rewriteBlockARM(b *Block) bool { - b.resetWithControl(BlockARMGTnoov, v0) - return true - } -+ // match: (GT (CMPconst [0] l:(MULA x y a)) yes no) -+ // cond: l.Uses==1 -+ // result: (GTnoov (CMN a (MUL x y)) yes no) -+ for b.Controls[0].Op == OpARMCMPconst { -+ v_0 := b.Controls[0] -+ if v_0.AuxInt != 0 { -+ break -+ } -+ l := v_0.Args[0] -+ if l.Op != OpARMMULA { -+ break -+ } -+ a := l.Args[2] -+ x := l.Args[0] -+ y := l.Args[1] -+ if !(l.Uses == 1) { -+ break -+ } -+ v0 := b.NewValue0(v_0.Pos, OpARMCMN, types.TypeFlags) -+ v1 := b.NewValue0(v_0.Pos, OpARMMUL, x.Type) -+ v1.AddArg2(x, y) -+ v0.AddArg2(a, v1) -+ b.resetWithControl(BlockARMGTnoov, v0) -+ return true -+ } - // match: (GT (CMPconst [0] l:(AND x y)) yes no) - // cond: l.Uses==1 -- // result: (GT (TST x y) yes no) -+ // result: (GTnoov (TST x y) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -18154,39 +18179,14 @@ func rewriteBlockARM(b *Block) bool { - } - v0 := b.NewValue0(v_0.Pos, OpARMTST, types.TypeFlags) - v0.AddArg2(x, y) -- b.resetWithControl(BlockARMGT, v0) -+ b.resetWithControl(BlockARMGTnoov, v0) - return true - } - break - } -- // match: (GT (CMPconst [0] l:(MULA x y a)) yes no) -- // cond: l.Uses==1 -- // result: (GTnoov (CMN a (MUL x y)) yes no) -- for b.Controls[0].Op == OpARMCMPconst { -- v_0 := b.Controls[0] -- if v_0.AuxInt != 0 { -- break -- } -- l := v_0.Args[0] -- if l.Op != OpARMMULA { -- break -- } -- a := l.Args[2] -- x := l.Args[0] -- y := l.Args[1] -- if !(l.Uses == 1) { -- break -- } -- v0 := b.NewValue0(v_0.Pos, OpARMCMN, types.TypeFlags) -- v1 := b.NewValue0(v_0.Pos, OpARMMUL, x.Type) -- v1.AddArg2(x, y) -- v0.AddArg2(a, v1) -- b.resetWithControl(BlockARMGTnoov, v0) -- return true -- } - // match: (GT (CMPconst [0] l:(ANDconst [c] x)) yes no) - // cond: l.Uses==1 -- // result: (GT (TSTconst [c] x) yes no) -+ // result: (GTnoov (TSTconst [c] x) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -18204,12 +18204,12 @@ func rewriteBlockARM(b *Block) bool { - v0 := b.NewValue0(v_0.Pos, OpARMTSTconst, types.TypeFlags) - v0.AuxInt = c - v0.AddArg(x) -- b.resetWithControl(BlockARMGT, v0) -+ b.resetWithControl(BlockARMGTnoov, v0) - return true - } - // match: (GT (CMPconst [0] l:(ANDshiftLL x y [c])) yes no) - // cond: l.Uses==1 -- // result: (GT (TSTshiftLL x y [c]) yes no) -+ // result: (GTnoov (TSTshiftLL x y [c]) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -18228,12 +18228,12 @@ func rewriteBlockARM(b *Block) bool { - v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftLL, types.TypeFlags) - v0.AuxInt = c - v0.AddArg2(x, y) -- b.resetWithControl(BlockARMGT, v0) -+ b.resetWithControl(BlockARMGTnoov, v0) - return true - } - // match: (GT (CMPconst [0] l:(ANDshiftRL x y [c])) yes no) - // cond: l.Uses==1 -- // result: (GT (TSTshiftRL x y [c]) yes no) -+ // result: (GTnoov (TSTshiftRL x y [c]) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -18252,12 +18252,12 @@ func rewriteBlockARM(b *Block) bool { - v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRL, types.TypeFlags) - v0.AuxInt = c - v0.AddArg2(x, y) -- b.resetWithControl(BlockARMGT, v0) -+ b.resetWithControl(BlockARMGTnoov, v0) - return true - } - // match: (GT (CMPconst [0] l:(ANDshiftRA x y [c])) yes no) - // cond: l.Uses==1 -- // result: (GT (TSTshiftRA x y [c]) yes no) -+ // result: (GTnoov (TSTshiftRA x y [c]) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -18276,12 +18276,12 @@ func rewriteBlockARM(b *Block) bool { - v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRA, types.TypeFlags) - v0.AuxInt = c - v0.AddArg2(x, y) -- b.resetWithControl(BlockARMGT, v0) -+ b.resetWithControl(BlockARMGTnoov, v0) - return true - } - // match: (GT (CMPconst [0] l:(ANDshiftLLreg x y z)) yes no) - // cond: l.Uses==1 -- // result: (GT (TSTshiftLLreg x y z) yes no) -+ // result: (GTnoov (TSTshiftLLreg x y z) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -18299,12 +18299,12 @@ func rewriteBlockARM(b *Block) bool { - } - v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftLLreg, types.TypeFlags) - v0.AddArg3(x, y, z) -- b.resetWithControl(BlockARMGT, v0) -+ b.resetWithControl(BlockARMGTnoov, v0) - return true - } - // match: (GT (CMPconst [0] l:(ANDshiftRLreg x y z)) yes no) - // cond: l.Uses==1 -- // result: (GT (TSTshiftRLreg x y z) yes no) -+ // result: (GTnoov (TSTshiftRLreg x y z) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -18322,12 +18322,12 @@ func rewriteBlockARM(b *Block) bool { - } - v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRLreg, types.TypeFlags) - v0.AddArg3(x, y, z) -- b.resetWithControl(BlockARMGT, v0) -+ b.resetWithControl(BlockARMGTnoov, v0) - return true - } - // match: (GT (CMPconst [0] l:(ANDshiftRAreg x y z)) yes no) - // cond: l.Uses==1 -- // result: (GT (TSTshiftRAreg x y z) yes no) -+ // result: (GTnoov (TSTshiftRAreg x y z) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -18345,12 +18345,12 @@ func rewriteBlockARM(b *Block) bool { - } - v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRAreg, types.TypeFlags) - v0.AddArg3(x, y, z) -- b.resetWithControl(BlockARMGT, v0) -+ b.resetWithControl(BlockARMGTnoov, v0) - return true - } - // match: (GT (CMPconst [0] l:(XOR x y)) yes no) - // cond: l.Uses==1 -- // result: (GT (TEQ x y) yes no) -+ // result: (GTnoov (TEQ x y) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -18371,14 +18371,14 @@ func rewriteBlockARM(b *Block) bool { - } - v0 := b.NewValue0(v_0.Pos, OpARMTEQ, types.TypeFlags) - v0.AddArg2(x, y) -- b.resetWithControl(BlockARMGT, v0) -+ b.resetWithControl(BlockARMGTnoov, v0) - return true - } - break - } - // match: (GT (CMPconst [0] l:(XORconst [c] x)) yes no) - // cond: l.Uses==1 -- // result: (GT (TEQconst [c] x) yes no) -+ // result: (GTnoov (TEQconst [c] x) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -18396,12 +18396,12 @@ func rewriteBlockARM(b *Block) bool { - v0 := b.NewValue0(v_0.Pos, OpARMTEQconst, types.TypeFlags) - v0.AuxInt = c - v0.AddArg(x) -- b.resetWithControl(BlockARMGT, v0) -+ b.resetWithControl(BlockARMGTnoov, v0) - return true - } - // match: (GT (CMPconst [0] l:(XORshiftLL x y [c])) yes no) - // cond: l.Uses==1 -- // result: (GT (TEQshiftLL x y [c]) yes no) -+ // result: (GTnoov (TEQshiftLL x y [c]) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -18420,12 +18420,12 @@ func rewriteBlockARM(b *Block) bool { - v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftLL, types.TypeFlags) - v0.AuxInt = c - v0.AddArg2(x, y) -- b.resetWithControl(BlockARMGT, v0) -+ b.resetWithControl(BlockARMGTnoov, v0) - return true - } - // match: (GT (CMPconst [0] l:(XORshiftRL x y [c])) yes no) - // cond: l.Uses==1 -- // result: (GT (TEQshiftRL x y [c]) yes no) -+ // result: (GTnoov (TEQshiftRL x y [c]) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -18444,12 +18444,12 @@ func rewriteBlockARM(b *Block) bool { - v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRL, types.TypeFlags) - v0.AuxInt = c - v0.AddArg2(x, y) -- b.resetWithControl(BlockARMGT, v0) -+ b.resetWithControl(BlockARMGTnoov, v0) - return true - } - // match: (GT (CMPconst [0] l:(XORshiftRA x y [c])) yes no) - // cond: l.Uses==1 -- // result: (GT (TEQshiftRA x y [c]) yes no) -+ // result: (GTnoov (TEQshiftRA x y [c]) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -18468,12 +18468,12 @@ func rewriteBlockARM(b *Block) bool { - v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRA, types.TypeFlags) - v0.AuxInt = c - v0.AddArg2(x, y) -- b.resetWithControl(BlockARMGT, v0) -+ b.resetWithControl(BlockARMGTnoov, v0) - return true - } - // match: (GT (CMPconst [0] l:(XORshiftLLreg x y z)) yes no) - // cond: l.Uses==1 -- // result: (GT (TEQshiftLLreg x y z) yes no) -+ // result: (GTnoov (TEQshiftLLreg x y z) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -18491,12 +18491,12 @@ func rewriteBlockARM(b *Block) bool { - } - v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftLLreg, types.TypeFlags) - v0.AddArg3(x, y, z) -- b.resetWithControl(BlockARMGT, v0) -+ b.resetWithControl(BlockARMGTnoov, v0) - return true - } - // match: (GT (CMPconst [0] l:(XORshiftRLreg x y z)) yes no) - // cond: l.Uses==1 -- // result: (GT (TEQshiftRLreg x y z) yes no) -+ // result: (GTnoov (TEQshiftRLreg x y z) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -18514,12 +18514,12 @@ func rewriteBlockARM(b *Block) bool { - } - v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRLreg, types.TypeFlags) - v0.AddArg3(x, y, z) -- b.resetWithControl(BlockARMGT, v0) -+ b.resetWithControl(BlockARMGTnoov, v0) - return true - } - // match: (GT (CMPconst [0] l:(XORshiftRAreg x y z)) yes no) - // cond: l.Uses==1 -- // result: (GT (TEQshiftRAreg x y z) yes no) -+ // result: (GTnoov (TEQshiftRAreg x y z) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -18537,7 +18537,7 @@ func rewriteBlockARM(b *Block) bool { - } - v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRAreg, types.TypeFlags) - v0.AddArg3(x, y, z) -- b.resetWithControl(BlockARMGT, v0) -+ b.resetWithControl(BlockARMGTnoov, v0) - return true - } - case BlockARMGTnoov: -@@ -19129,7 +19129,7 @@ func rewriteBlockARM(b *Block) bool { - } - // match: (LE (CMPconst [0] l:(AND x y)) yes no) - // cond: l.Uses==1 -- // result: (LE (TST x y) yes no) -+ // result: (LEnoov (TST x y) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -19150,14 +19150,14 @@ func rewriteBlockARM(b *Block) bool { - } - v0 := b.NewValue0(v_0.Pos, OpARMTST, types.TypeFlags) - v0.AddArg2(x, y) -- b.resetWithControl(BlockARMLE, v0) -+ b.resetWithControl(BlockARMLEnoov, v0) - return true - } - break - } - // match: (LE (CMPconst [0] l:(ANDconst [c] x)) yes no) - // cond: l.Uses==1 -- // result: (LE (TSTconst [c] x) yes no) -+ // result: (LEnoov (TSTconst [c] x) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -19175,12 +19175,12 @@ func rewriteBlockARM(b *Block) bool { - v0 := b.NewValue0(v_0.Pos, OpARMTSTconst, types.TypeFlags) - v0.AuxInt = c - v0.AddArg(x) -- b.resetWithControl(BlockARMLE, v0) -+ b.resetWithControl(BlockARMLEnoov, v0) - return true - } - // match: (LE (CMPconst [0] l:(ANDshiftLL x y [c])) yes no) - // cond: l.Uses==1 -- // result: (LE (TSTshiftLL x y [c]) yes no) -+ // result: (LEnoov (TSTshiftLL x y [c]) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -19199,12 +19199,12 @@ func rewriteBlockARM(b *Block) bool { - v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftLL, types.TypeFlags) - v0.AuxInt = c - v0.AddArg2(x, y) -- b.resetWithControl(BlockARMLE, v0) -+ b.resetWithControl(BlockARMLEnoov, v0) - return true - } - // match: (LE (CMPconst [0] l:(ANDshiftRL x y [c])) yes no) - // cond: l.Uses==1 -- // result: (LE (TSTshiftRL x y [c]) yes no) -+ // result: (LEnoov (TSTshiftRL x y [c]) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -19223,12 +19223,12 @@ func rewriteBlockARM(b *Block) bool { - v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRL, types.TypeFlags) - v0.AuxInt = c - v0.AddArg2(x, y) -- b.resetWithControl(BlockARMLE, v0) -+ b.resetWithControl(BlockARMLEnoov, v0) - return true - } - // match: (LE (CMPconst [0] l:(ANDshiftRA x y [c])) yes no) - // cond: l.Uses==1 -- // result: (LE (TSTshiftRA x y [c]) yes no) -+ // result: (LEnoov (TSTshiftRA x y [c]) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -19247,12 +19247,12 @@ func rewriteBlockARM(b *Block) bool { - v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRA, types.TypeFlags) - v0.AuxInt = c - v0.AddArg2(x, y) -- b.resetWithControl(BlockARMLE, v0) -+ b.resetWithControl(BlockARMLEnoov, v0) - return true - } - // match: (LE (CMPconst [0] l:(ANDshiftLLreg x y z)) yes no) - // cond: l.Uses==1 -- // result: (LE (TSTshiftLLreg x y z) yes no) -+ // result: (LEnoov (TSTshiftLLreg x y z) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -19270,12 +19270,12 @@ func rewriteBlockARM(b *Block) bool { - } - v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftLLreg, types.TypeFlags) - v0.AddArg3(x, y, z) -- b.resetWithControl(BlockARMLE, v0) -+ b.resetWithControl(BlockARMLEnoov, v0) - return true - } - // match: (LE (CMPconst [0] l:(ANDshiftRLreg x y z)) yes no) - // cond: l.Uses==1 -- // result: (LE (TSTshiftRLreg x y z) yes no) -+ // result: (LEnoov (TSTshiftRLreg x y z) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -19293,12 +19293,12 @@ func rewriteBlockARM(b *Block) bool { - } - v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRLreg, types.TypeFlags) - v0.AddArg3(x, y, z) -- b.resetWithControl(BlockARMLE, v0) -+ b.resetWithControl(BlockARMLEnoov, v0) - return true - } - // match: (LE (CMPconst [0] l:(ANDshiftRAreg x y z)) yes no) - // cond: l.Uses==1 -- // result: (LE (TSTshiftRAreg x y z) yes no) -+ // result: (LEnoov (TSTshiftRAreg x y z) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -19316,12 +19316,12 @@ func rewriteBlockARM(b *Block) bool { - } - v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRAreg, types.TypeFlags) - v0.AddArg3(x, y, z) -- b.resetWithControl(BlockARMLE, v0) -+ b.resetWithControl(BlockARMLEnoov, v0) - return true - } - // match: (LE (CMPconst [0] l:(XOR x y)) yes no) - // cond: l.Uses==1 -- // result: (LE (TEQ x y) yes no) -+ // result: (LEnoov (TEQ x y) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -19342,14 +19342,14 @@ func rewriteBlockARM(b *Block) bool { - } - v0 := b.NewValue0(v_0.Pos, OpARMTEQ, types.TypeFlags) - v0.AddArg2(x, y) -- b.resetWithControl(BlockARMLE, v0) -+ b.resetWithControl(BlockARMLEnoov, v0) - return true - } - break - } - // match: (LE (CMPconst [0] l:(XORconst [c] x)) yes no) - // cond: l.Uses==1 -- // result: (LE (TEQconst [c] x) yes no) -+ // result: (LEnoov (TEQconst [c] x) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -19367,12 +19367,12 @@ func rewriteBlockARM(b *Block) bool { - v0 := b.NewValue0(v_0.Pos, OpARMTEQconst, types.TypeFlags) - v0.AuxInt = c - v0.AddArg(x) -- b.resetWithControl(BlockARMLE, v0) -+ b.resetWithControl(BlockARMLEnoov, v0) - return true - } - // match: (LE (CMPconst [0] l:(XORshiftLL x y [c])) yes no) - // cond: l.Uses==1 -- // result: (LE (TEQshiftLL x y [c]) yes no) -+ // result: (LEnoov (TEQshiftLL x y [c]) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -19391,12 +19391,12 @@ func rewriteBlockARM(b *Block) bool { - v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftLL, types.TypeFlags) - v0.AuxInt = c - v0.AddArg2(x, y) -- b.resetWithControl(BlockARMLE, v0) -+ b.resetWithControl(BlockARMLEnoov, v0) - return true - } - // match: (LE (CMPconst [0] l:(XORshiftRL x y [c])) yes no) - // cond: l.Uses==1 -- // result: (LE (TEQshiftRL x y [c]) yes no) -+ // result: (LEnoov (TEQshiftRL x y [c]) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -19415,12 +19415,12 @@ func rewriteBlockARM(b *Block) bool { - v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRL, types.TypeFlags) - v0.AuxInt = c - v0.AddArg2(x, y) -- b.resetWithControl(BlockARMLE, v0) -+ b.resetWithControl(BlockARMLEnoov, v0) - return true - } - // match: (LE (CMPconst [0] l:(XORshiftRA x y [c])) yes no) - // cond: l.Uses==1 -- // result: (LE (TEQshiftRA x y [c]) yes no) -+ // result: (LEnoov (TEQshiftRA x y [c]) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -19439,12 +19439,12 @@ func rewriteBlockARM(b *Block) bool { - v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRA, types.TypeFlags) - v0.AuxInt = c - v0.AddArg2(x, y) -- b.resetWithControl(BlockARMLE, v0) -+ b.resetWithControl(BlockARMLEnoov, v0) - return true - } - // match: (LE (CMPconst [0] l:(XORshiftLLreg x y z)) yes no) - // cond: l.Uses==1 -- // result: (LE (TEQshiftLLreg x y z) yes no) -+ // result: (LEnoov (TEQshiftLLreg x y z) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -19462,12 +19462,12 @@ func rewriteBlockARM(b *Block) bool { - } - v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftLLreg, types.TypeFlags) - v0.AddArg3(x, y, z) -- b.resetWithControl(BlockARMLE, v0) -+ b.resetWithControl(BlockARMLEnoov, v0) - return true - } - // match: (LE (CMPconst [0] l:(XORshiftRLreg x y z)) yes no) - // cond: l.Uses==1 -- // result: (LE (TEQshiftRLreg x y z) yes no) -+ // result: (LEnoov (TEQshiftRLreg x y z) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -19485,12 +19485,12 @@ func rewriteBlockARM(b *Block) bool { - } - v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRLreg, types.TypeFlags) - v0.AddArg3(x, y, z) -- b.resetWithControl(BlockARMLE, v0) -+ b.resetWithControl(BlockARMLEnoov, v0) - return true - } - // match: (LE (CMPconst [0] l:(XORshiftRAreg x y z)) yes no) - // cond: l.Uses==1 -- // result: (LE (TEQshiftRAreg x y z) yes no) -+ // result: (LEnoov (TEQshiftRAreg x y z) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -19508,7 +19508,7 @@ func rewriteBlockARM(b *Block) bool { - } - v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRAreg, types.TypeFlags) - v0.AddArg3(x, y, z) -- b.resetWithControl(BlockARMLE, v0) -+ b.resetWithControl(BlockARMLEnoov, v0) - return true - } - case BlockARMLEnoov: -@@ -20009,7 +20009,7 @@ func rewriteBlockARM(b *Block) bool { - } - // match: (LT (CMPconst [0] l:(AND x y)) yes no) - // cond: l.Uses==1 -- // result: (LT (TST x y) yes no) -+ // result: (LTnoov (TST x y) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -20030,14 +20030,14 @@ func rewriteBlockARM(b *Block) bool { - } - v0 := b.NewValue0(v_0.Pos, OpARMTST, types.TypeFlags) - v0.AddArg2(x, y) -- b.resetWithControl(BlockARMLT, v0) -+ b.resetWithControl(BlockARMLTnoov, v0) - return true - } - break - } - // match: (LT (CMPconst [0] l:(ANDconst [c] x)) yes no) - // cond: l.Uses==1 -- // result: (LT (TSTconst [c] x) yes no) -+ // result: (LTnoov (TSTconst [c] x) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -20055,12 +20055,12 @@ func rewriteBlockARM(b *Block) bool { - v0 := b.NewValue0(v_0.Pos, OpARMTSTconst, types.TypeFlags) - v0.AuxInt = c - v0.AddArg(x) -- b.resetWithControl(BlockARMLT, v0) -+ b.resetWithControl(BlockARMLTnoov, v0) - return true - } - // match: (LT (CMPconst [0] l:(ANDshiftLL x y [c])) yes no) - // cond: l.Uses==1 -- // result: (LT (TSTshiftLL x y [c]) yes no) -+ // result: (LTnoov (TSTshiftLL x y [c]) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -20079,12 +20079,12 @@ func rewriteBlockARM(b *Block) bool { - v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftLL, types.TypeFlags) - v0.AuxInt = c - v0.AddArg2(x, y) -- b.resetWithControl(BlockARMLT, v0) -+ b.resetWithControl(BlockARMLTnoov, v0) - return true - } - // match: (LT (CMPconst [0] l:(ANDshiftRL x y [c])) yes no) - // cond: l.Uses==1 -- // result: (LT (TSTshiftRL x y [c]) yes no) -+ // result: (LTnoov (TSTshiftRL x y [c]) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -20103,12 +20103,12 @@ func rewriteBlockARM(b *Block) bool { - v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRL, types.TypeFlags) - v0.AuxInt = c - v0.AddArg2(x, y) -- b.resetWithControl(BlockARMLT, v0) -+ b.resetWithControl(BlockARMLTnoov, v0) - return true - } - // match: (LT (CMPconst [0] l:(ANDshiftRA x y [c])) yes no) - // cond: l.Uses==1 -- // result: (LT (TSTshiftRA x y [c]) yes no) -+ // result: (LTnoov (TSTshiftRA x y [c]) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -20127,12 +20127,12 @@ func rewriteBlockARM(b *Block) bool { - v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRA, types.TypeFlags) - v0.AuxInt = c - v0.AddArg2(x, y) -- b.resetWithControl(BlockARMLT, v0) -+ b.resetWithControl(BlockARMLTnoov, v0) - return true - } - // match: (LT (CMPconst [0] l:(ANDshiftLLreg x y z)) yes no) - // cond: l.Uses==1 -- // result: (LT (TSTshiftLLreg x y z) yes no) -+ // result: (LTnoov (TSTshiftLLreg x y z) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -20150,12 +20150,12 @@ func rewriteBlockARM(b *Block) bool { - } - v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftLLreg, types.TypeFlags) - v0.AddArg3(x, y, z) -- b.resetWithControl(BlockARMLT, v0) -+ b.resetWithControl(BlockARMLTnoov, v0) - return true - } - // match: (LT (CMPconst [0] l:(ANDshiftRLreg x y z)) yes no) - // cond: l.Uses==1 -- // result: (LT (TSTshiftRLreg x y z) yes no) -+ // result: (LTnoov (TSTshiftRLreg x y z) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -20173,12 +20173,12 @@ func rewriteBlockARM(b *Block) bool { - } - v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRLreg, types.TypeFlags) - v0.AddArg3(x, y, z) -- b.resetWithControl(BlockARMLT, v0) -+ b.resetWithControl(BlockARMLTnoov, v0) - return true - } - // match: (LT (CMPconst [0] l:(ANDshiftRAreg x y z)) yes no) - // cond: l.Uses==1 -- // result: (LT (TSTshiftRAreg x y z) yes no) -+ // result: (LTnoov (TSTshiftRAreg x y z) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -20196,12 +20196,12 @@ func rewriteBlockARM(b *Block) bool { - } - v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRAreg, types.TypeFlags) - v0.AddArg3(x, y, z) -- b.resetWithControl(BlockARMLT, v0) -+ b.resetWithControl(BlockARMLTnoov, v0) - return true - } - // match: (LT (CMPconst [0] l:(XOR x y)) yes no) - // cond: l.Uses==1 -- // result: (LT (TEQ x y) yes no) -+ // result: (LTnoov (TEQ x y) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -20222,14 +20222,14 @@ func rewriteBlockARM(b *Block) bool { - } - v0 := b.NewValue0(v_0.Pos, OpARMTEQ, types.TypeFlags) - v0.AddArg2(x, y) -- b.resetWithControl(BlockARMLT, v0) -+ b.resetWithControl(BlockARMLTnoov, v0) - return true - } - break - } - // match: (LT (CMPconst [0] l:(XORconst [c] x)) yes no) - // cond: l.Uses==1 -- // result: (LT (TEQconst [c] x) yes no) -+ // result: (LTnoov (TEQconst [c] x) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -20247,12 +20247,12 @@ func rewriteBlockARM(b *Block) bool { - v0 := b.NewValue0(v_0.Pos, OpARMTEQconst, types.TypeFlags) - v0.AuxInt = c - v0.AddArg(x) -- b.resetWithControl(BlockARMLT, v0) -+ b.resetWithControl(BlockARMLTnoov, v0) - return true - } - // match: (LT (CMPconst [0] l:(XORshiftLL x y [c])) yes no) - // cond: l.Uses==1 -- // result: (LT (TEQshiftLL x y [c]) yes no) -+ // result: (LTnoov (TEQshiftLL x y [c]) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -20271,12 +20271,12 @@ func rewriteBlockARM(b *Block) bool { - v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftLL, types.TypeFlags) - v0.AuxInt = c - v0.AddArg2(x, y) -- b.resetWithControl(BlockARMLT, v0) -+ b.resetWithControl(BlockARMLTnoov, v0) - return true - } - // match: (LT (CMPconst [0] l:(XORshiftRL x y [c])) yes no) - // cond: l.Uses==1 -- // result: (LT (TEQshiftRL x y [c]) yes no) -+ // result: (LTnoov (TEQshiftRL x y [c]) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -20295,12 +20295,12 @@ func rewriteBlockARM(b *Block) bool { - v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRL, types.TypeFlags) - v0.AuxInt = c - v0.AddArg2(x, y) -- b.resetWithControl(BlockARMLT, v0) -+ b.resetWithControl(BlockARMLTnoov, v0) - return true - } - // match: (LT (CMPconst [0] l:(XORshiftRA x y [c])) yes no) - // cond: l.Uses==1 -- // result: (LT (TEQshiftRA x y [c]) yes no) -+ // result: (LTnoov (TEQshiftRA x y [c]) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -20319,12 +20319,12 @@ func rewriteBlockARM(b *Block) bool { - v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRA, types.TypeFlags) - v0.AuxInt = c - v0.AddArg2(x, y) -- b.resetWithControl(BlockARMLT, v0) -+ b.resetWithControl(BlockARMLTnoov, v0) - return true - } - // match: (LT (CMPconst [0] l:(XORshiftLLreg x y z)) yes no) - // cond: l.Uses==1 -- // result: (LT (TEQshiftLLreg x y z) yes no) -+ // result: (LTnoov (TEQshiftLLreg x y z) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -20342,12 +20342,12 @@ func rewriteBlockARM(b *Block) bool { - } - v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftLLreg, types.TypeFlags) - v0.AddArg3(x, y, z) -- b.resetWithControl(BlockARMLT, v0) -+ b.resetWithControl(BlockARMLTnoov, v0) - return true - } - // match: (LT (CMPconst [0] l:(XORshiftRLreg x y z)) yes no) - // cond: l.Uses==1 -- // result: (LT (TEQshiftRLreg x y z) yes no) -+ // result: (LTnoov (TEQshiftRLreg x y z) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -20365,12 +20365,12 @@ func rewriteBlockARM(b *Block) bool { - } - v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRLreg, types.TypeFlags) - v0.AddArg3(x, y, z) -- b.resetWithControl(BlockARMLT, v0) -+ b.resetWithControl(BlockARMLTnoov, v0) - return true - } - // match: (LT (CMPconst [0] l:(XORshiftRAreg x y z)) yes no) - // cond: l.Uses==1 -- // result: (LT (TEQshiftRAreg x y z) yes no) -+ // result: (LTnoov (TEQshiftRAreg x y z) yes no) - for b.Controls[0].Op == OpARMCMPconst { - v_0 := b.Controls[0] - if v_0.AuxInt != 0 { -@@ -20388,7 +20388,7 @@ func rewriteBlockARM(b *Block) bool { - } - v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRAreg, types.TypeFlags) - v0.AddArg3(x, y, z) -- b.resetWithControl(BlockARMLT, v0) -+ b.resetWithControl(BlockARMLTnoov, v0) - return true - } - case BlockARMLTnoov: -diff --git a/test/fixedbugs/issue42876.go b/test/fixedbugs/issue42876.go -new file mode 100644 -index 0000000000..67cf4919ac ---- /dev/null -+++ b/test/fixedbugs/issue42876.go -@@ -0,0 +1,18 @@ -+// run -+ -+// Copyright 2020 The Go Authors. All rights reserved. -+// Use of this source code is governed by a BSD-style -+// license that can be found in the LICENSE file. -+ -+package main -+ -+var x = [4]int32{-0x7fffffff, 0x7fffffff, 2, 4} -+ -+func main() { -+ if x[0] > x[1] { -+ panic("fail 1") -+ } -+ if x[2]&x[3] < 0 { -+ panic("fail 2") // Fails here -+ } -+} --- -2.27.0 - diff --git a/0073-release-branch.go1.17-crypto-rand-properly-handle-la.patch b/0015-release-branch.go1.17-crypto-rand-properly-handle-la.patch similarity index 72% rename from 0073-release-branch.go1.17-crypto-rand-properly-handle-la.patch rename to 0015-release-branch.go1.17-crypto-rand-properly-handle-la.patch index cb1d4509dd5fec1367b60bd997f671a9a4ebf329..092814022de625d9ed3205ff3821ec33ae0f0350 100644 --- a/0073-release-branch.go1.17-crypto-rand-properly-handle-la.patch +++ b/0015-release-branch.go1.17-crypto-rand-properly-handle-la.patch @@ -1,7 +1,7 @@ -From 4dfd37e5c41d531b9e5eb9618a0683d67ef3e594 Mon Sep 17 00:00:00 2001 +From 07a30769186210c1b1e25943824743355c4e50f5 Mon Sep 17 00:00:00 2001 From: Roland Shoemaker Date: Mon, 25 Apr 2022 19:02:35 -0700 -Subject: [PATCH 10/10] [release-branch.go1.17] crypto/rand: properly handle +Subject: [PATCH 11/11] [release-branch.go1.17] crypto/rand: properly handle large Read on windows Use the batched reader to chunk large Read calls on windows to a max of @@ -25,23 +25,24 @@ TryBot-Result: Gopher Robot Reviewed-on: https://go-review.googlesource.com/c/go/+/406635 Reviewed-by: Damien Neil -Conflict: src/crypto/rand/rand.go, src/crypto/rand/rand_windows.go +Conflict: NA Reference: https://go-review.googlesource.com/c/go/+/406635 --- - src/crypto/rand/rand.go | 18 +++++++++++++++ - src/crypto/rand/rand_batched.go | 22 +++++-------------- - src/crypto/rand/rand_batched_test.go | 21 +++++++++--------- + src/crypto/rand/rand.go | 18 ++++++++++++++++++ + src/crypto/rand/rand_batched.go | 22 ++++++---------------- + src/crypto/rand/rand_batched_test.go | 21 +++++++++++---------- + src/crypto/rand/rand_getentropy.go | 6 +++--- src/crypto/rand/rand_unix.go | 4 ++-- - src/crypto/rand/rand_windows.go | 33 +++++----------------------- - 5 files changed, 43 insertions(+), 55 deletions(-) + src/crypto/rand/rand_windows.go | 18 ++++++------------ + 6 files changed, 46 insertions(+), 43 deletions(-) diff --git a/src/crypto/rand/rand.go b/src/crypto/rand/rand.go -index a5ccd19de32..5606f248f02 100644 +index fddd1147e6e..f2c276008d7 100644 --- a/src/crypto/rand/rand.go +++ b/src/crypto/rand/rand.go -@@ -27,3 +27,21 @@ func Read(b []byte) (n int, err error) { - func warnBlocked() { - println("crypto/rand: blocked for 60 seconds waiting to read random data from the kernel") +@@ -23,3 +23,21 @@ var Reader io.Reader + func Read(b []byte) (n int, err error) { + return io.ReadFull(Reader, b) } + +// batched returns a function that calls f to populate a []byte by chunking it @@ -62,10 +63,10 @@ index a5ccd19de32..5606f248f02 100644 + } +} diff --git a/src/crypto/rand/rand_batched.go b/src/crypto/rand/rand_batched.go -index 60267fd4bc2..cad958d79c0 100644 +index d7c5bf3562d..8df715fdd14 100644 --- a/src/crypto/rand/rand_batched.go +++ b/src/crypto/rand/rand_batched.go -@@ -7,6 +7,7 @@ +@@ -8,6 +8,7 @@ package rand import ( @@ -73,7 +74,7 @@ index 60267fd4bc2..cad958d79c0 100644 "internal/syscall/unix" ) -@@ -15,20 +16,6 @@ func init() { +@@ -16,20 +17,6 @@ func init() { altGetRandom = batched(getRandomBatch, maxGetRandomRead) } @@ -94,7 +95,7 @@ index 60267fd4bc2..cad958d79c0 100644 // If the kernel is too old to support the getrandom syscall(), // unix.GetRandom will immediately return ENOSYS and we will then fall back to // reading from /dev/urandom in rand_unix.go. unix.GetRandom caches the ENOSYS -@@ -36,7 +23,10 @@ func batched(f func([]byte) bool, readMax int) func([]byte) bool { +@@ -37,7 +24,10 @@ func batched(f func([]byte) bool, readMax int) func([]byte) bool { // If the kernel supports the getrandom() syscall, unix.GetRandom will block // until the kernel has sufficient randomness (as we don't use GRND_NONBLOCK). // In this case, unix.GetRandom will not return an error. @@ -108,10 +109,10 @@ index 60267fd4bc2..cad958d79c0 100644 + return err } diff --git a/src/crypto/rand/rand_batched_test.go b/src/crypto/rand/rand_batched_test.go -index 837db83f770..8122bceba4b 100644 +index 2d20922c825..b56345e50f1 100644 --- a/src/crypto/rand/rand_batched_test.go +++ b/src/crypto/rand/rand_batched_test.go -@@ -8,20 +8,21 @@ package rand +@@ -9,20 +9,21 @@ package rand import ( "bytes" @@ -137,7 +138,7 @@ index 837db83f770..8122bceba4b 100644 } expected := []byte{0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2} if !bytes.Equal(expected, p) { -@@ -30,15 +31,15 @@ func TestBatched(t *testing.T) { +@@ -31,15 +32,15 @@ func TestBatched(t *testing.T) { } func TestBatchedError(t *testing.T) { @@ -159,20 +160,44 @@ index 837db83f770..8122bceba4b 100644 + t.Fatalf("empty slice should always return nil: %s", err) } } +diff --git a/src/crypto/rand/rand_getentropy.go b/src/crypto/rand/rand_getentropy.go +index dd725372ad9..b1c19f3d0da 100644 +--- a/src/crypto/rand/rand_getentropy.go ++++ b/src/crypto/rand/rand_getentropy.go +@@ -15,7 +15,7 @@ func init() { + altGetRandom = getEntropy + } + +-func getEntropy(p []byte) (ok bool) { ++func getEntropy(p []byte) error { + // getentropy(2) returns a maximum of 256 bytes per call + for i := 0; i < len(p); i += 256 { + end := i + 256 +@@ -24,8 +24,8 @@ func getEntropy(p []byte) (ok bool) { + } + err := unix.GetEntropy(p[i:end]) + if err != nil { +- return false ++ return err + } + } +- return true ++ return nil + } diff --git a/src/crypto/rand/rand_unix.go b/src/crypto/rand/rand_unix.go -index 0610f691b0d..5ddc76be266 100644 +index 81277eb6a5d..3d11159a340 100644 --- a/src/crypto/rand/rand_unix.go +++ b/src/crypto/rand/rand_unix.go -@@ -45,7 +45,7 @@ type devReader struct { +@@ -46,7 +46,7 @@ type devReader struct { // altGetRandom if non-nil specifies an OS-specific function to get // urandom-style randomness. -var altGetRandom func([]byte) (ok bool) +var altGetRandom func([]byte) (err error) - func (r *devReader) Read(b []byte) (n int, err error) { - if atomic.CompareAndSwapInt32(&r.used, 0, 1) { -@@ -54,7 +54,7 @@ func (r *devReader) Read(b []byte) (n int, err error) { + func warnBlocked() { + println("crypto/rand: blocked for 60 seconds waiting to read random data from the kernel") +@@ -59,7 +59,7 @@ func (r *devReader) Read(b []byte) (n int, err error) { t := time.AfterFunc(60*time.Second, warnBlocked) defer t.Stop() } @@ -182,57 +207,39 @@ index 0610f691b0d..5ddc76be266 100644 } r.mu.Lock() diff --git a/src/crypto/rand/rand_windows.go b/src/crypto/rand/rand_windows.go -index 78a4ed6d67b..b5036ba9713 100644 +index 7379f1489ad..6c0655c72b6 100644 --- a/src/crypto/rand/rand_windows.go +++ b/src/crypto/rand/rand_windows.go -@@ -8,11 +8,9 @@ - package rand +@@ -9,7 +9,6 @@ package rand import ( + "internal/syscall/windows" - "os" -+ "internal/syscall/windows" - "sync" -- "sync/atomic" - "syscall" -- "time" ) - // Implemented by using Windows CryptoAPI 2.0. -@@ -27,30 +25,11 @@ type rngReader struct { - } + func init() { Reader = &rngReader{} } +@@ -17,16 +16,11 @@ func init() { Reader = &rngReader{} } + type rngReader struct{} func (r *rngReader) Read(b []byte) (n int, err error) { -- if atomic.CompareAndSwapInt32(&r.used, 0, 1) { -- // First use of randomness. Start timer to warn about -- // being blocked on entropy not being available. -- t := time.AfterFunc(60*time.Second, warnBlocked) -- defer t.Stop() -- } -- r.mu.Lock() -- if r.prov == 0 { -- const provType = syscall.PROV_RSA_FULL -- const flags = syscall.CRYPT_VERIFYCONTEXT | syscall.CRYPT_SILENT -- err := syscall.CryptAcquireContext(&r.prov, nil, nil, provType, flags) -- if err != nil { -- r.mu.Unlock() -- return 0, os.NewSyscallError("CryptAcquireContext", err) -- } -- } -- r.mu.Unlock() +- // RtlGenRandom only accepts 2**32-1 bytes at a time, so truncate. +- inputLen := uint32(len(b)) - -- if len(b) == 0 { +- if inputLen == 0 { - return 0, nil - } -- err = syscall.CryptGenRandom(r.prov, uint32(len(b)), &b[0]) +- +- err = windows.RtlGenRandom(b) - if err != nil { -- return 0, os.NewSyscallError("CryptGenRandom", err) +- return 0, os.NewSyscallError("RtlGenRandom", err) + // RtlGenRandom only returns 1<<32-1 bytes at a time. We only read at + // most 1<<31-1 bytes at a time so that this works the same on 32-bit + // and 64-bit systems. + if err := batched(windows.RtlGenRandom, 1<<31-1)(b); err != nil { + return 0, err } - return len(b), nil +- return int(inputLen), nil ++ return len(b), nil } -- 2.30.2 diff --git a/0016-release-branch.go1.15-syscall-do-not-overflow-key-me.patch b/0016-release-branch.go1.15-syscall-do-not-overflow-key-me.patch deleted file mode 100644 index 08f29f32a988eea5b3a81fb28ab12b584fd86ff6..0000000000000000000000000000000000000000 --- a/0016-release-branch.go1.15-syscall-do-not-overflow-key-me.patch +++ /dev/null @@ -1,115 +0,0 @@ -From 4fda89d4201fc9f0c1e192bbcc95dd8d660e9122 Mon Sep 17 00:00:00 2001 -From: "Jason A. Donenfeld" -Date: Tue, 23 Feb 2021 13:29:40 +0100 -Subject: [PATCH 16/44] [release-branch.go1.15] syscall: do not overflow key - memory in GetQueuedCompletionStatus - -The third argument to GetQueuedCompletionStatus is a pointer to a -uintptr, not a uint32. Users of this functions have therefore been -corrupting their memory every time they used it. Either that memory -corruption was silent (dangerous), or their programs didn't work so they -chose a different API to use. - -This fixes the problem by passing through an intermediate buffer. - -Updates #44538. -Fixes #44592. - -Change-Id: Icacd71f705b36e41e52bd8c4d74898559a27522f -Reviewed-on: https://go-review.googlesource.com/c/go/+/296151 -Trust: Jason A. Donenfeld -Run-TryBot: Jason A. Donenfeld -TryBot-Result: Go Bot -Reviewed-by: Bryan C. Mills - -Conflict:NA -Reference:https://github.com/golang/go/commit/4fda89d4201fc9f0c1e192bbcc95dd8d660e9122 - ---- - src/syscall/syscall_windows.go | 34 ++++++++++++++++++++++++++++++--- - src/syscall/zsyscall_windows.go | 6 +++--- - 2 files changed, 34 insertions(+), 6 deletions(-) - -diff --git a/src/syscall/syscall_windows.go b/src/syscall/syscall_windows.go -index f62c00d72f..fbb11a89ca 100644 ---- a/src/syscall/syscall_windows.go -+++ b/src/syscall/syscall_windows.go -@@ -213,9 +213,9 @@ func NewCallbackCDecl(fn interface{}) uintptr { - //sys SetEndOfFile(handle Handle) (err error) - //sys GetSystemTimeAsFileTime(time *Filetime) - //sys GetTimeZoneInformation(tzi *Timezoneinformation) (rc uint32, err error) [failretval==0xffffffff] --//sys CreateIoCompletionPort(filehandle Handle, cphandle Handle, key uint32, threadcnt uint32) (handle Handle, err error) --//sys GetQueuedCompletionStatus(cphandle Handle, qty *uint32, key *uint32, overlapped **Overlapped, timeout uint32) (err error) --//sys PostQueuedCompletionStatus(cphandle Handle, qty uint32, key uint32, overlapped *Overlapped) (err error) -+//sys createIoCompletionPort(filehandle Handle, cphandle Handle, key uintptr, threadcnt uint32) (handle Handle, err error) = CreateIoCompletionPort -+//sys getQueuedCompletionStatus(cphandle Handle, qty *uint32, key *uintptr, overlapped **Overlapped, timeout uint32) (err error) = GetQueuedCompletionStatus -+//sys postQueuedCompletionStatus(cphandle Handle, qty uint32, key uintptr, overlapped *Overlapped) (err error) = PostQueuedCompletionStatus - //sys CancelIo(s Handle) (err error) - //sys CancelIoEx(s Handle, o *Overlapped) (err error) - //sys CreateProcess(appName *uint16, commandLine *uint16, procSecurity *SecurityAttributes, threadSecurity *SecurityAttributes, inheritHandles bool, creationFlags uint32, env *uint16, currentDir *uint16, startupInfo *StartupInfo, outProcInfo *ProcessInformation) (err error) = CreateProcessW -@@ -1209,3 +1209,31 @@ func Readlink(path string, buf []byte) (n int, err error) { - - return n, nil - } -+ -+// Deprecated: CreateIoCompletionPort has the wrong function signature. Use x/sys/windows.CreateIoCompletionPort. -+func CreateIoCompletionPort(filehandle Handle, cphandle Handle, key uint32, threadcnt uint32) (Handle, error) { -+ return createIoCompletionPort(filehandle, cphandle, uintptr(key), threadcnt) -+} -+ -+// Deprecated: GetQueuedCompletionStatus has the wrong function signature. Use x/sys/windows.GetQueuedCompletionStatus. -+func GetQueuedCompletionStatus(cphandle Handle, qty *uint32, key *uint32, overlapped **Overlapped, timeout uint32) error { -+ var ukey uintptr -+ var pukey *uintptr -+ if key != nil { -+ ukey = uintptr(*key) -+ pukey = &ukey -+ } -+ err := getQueuedCompletionStatus(cphandle, qty, pukey, overlapped, timeout) -+ if key != nil { -+ *key = uint32(ukey) -+ if uintptr(*key) != ukey && err == nil { -+ err = errorspkg.New("GetQueuedCompletionStatus returned key overflow") -+ } -+ } -+ return err -+} -+ -+// Deprecated: PostQueuedCompletionStatus has the wrong function signature. Use x/sys/windows.PostQueuedCompletionStatus. -+func PostQueuedCompletionStatus(cphandle Handle, qty uint32, key uint32, overlapped *Overlapped) error { -+ return postQueuedCompletionStatus(cphandle, qty, uintptr(key), overlapped) -+} -diff --git a/src/syscall/zsyscall_windows.go b/src/syscall/zsyscall_windows.go -index 2348f6534f..2762fb3b74 100644 ---- a/src/syscall/zsyscall_windows.go -+++ b/src/syscall/zsyscall_windows.go -@@ -539,7 +539,7 @@ func GetTimeZoneInformation(tzi *Timezoneinformation) (rc uint32, err error) { - return - } - --func CreateIoCompletionPort(filehandle Handle, cphandle Handle, key uint32, threadcnt uint32) (handle Handle, err error) { -+func createIoCompletionPort(filehandle Handle, cphandle Handle, key uintptr, threadcnt uint32) (handle Handle, err error) { - r0, _, e1 := Syscall6(procCreateIoCompletionPort.Addr(), 4, uintptr(filehandle), uintptr(cphandle), uintptr(key), uintptr(threadcnt), 0, 0) - handle = Handle(r0) - if handle == 0 { -@@ -552,7 +552,7 @@ func CreateIoCompletionPort(filehandle Handle, cphandle Handle, key uint32, thre - return - } - --func GetQueuedCompletionStatus(cphandle Handle, qty *uint32, key *uint32, overlapped **Overlapped, timeout uint32) (err error) { -+func getQueuedCompletionStatus(cphandle Handle, qty *uint32, key *uintptr, overlapped **Overlapped, timeout uint32) (err error) { - r1, _, e1 := Syscall6(procGetQueuedCompletionStatus.Addr(), 5, uintptr(cphandle), uintptr(unsafe.Pointer(qty)), uintptr(unsafe.Pointer(key)), uintptr(unsafe.Pointer(overlapped)), uintptr(timeout), 0) - if r1 == 0 { - if e1 != 0 { -@@ -564,7 +564,7 @@ func GetQueuedCompletionStatus(cphandle Handle, qty *uint32, key *uint32, overla - return - } - --func PostQueuedCompletionStatus(cphandle Handle, qty uint32, key uint32, overlapped *Overlapped) (err error) { -+func postQueuedCompletionStatus(cphandle Handle, qty uint32, key uintptr, overlapped *Overlapped) (err error) { - r1, _, e1 := Syscall6(procPostQueuedCompletionStatus.Addr(), 4, uintptr(cphandle), uintptr(qty), uintptr(key), uintptr(unsafe.Pointer(overlapped)), 0, 0) - if r1 == 0 { - if e1 != 0 { --- -2.27.0 - diff --git a/0074-release-branch.go1.17-math-big-check-buffer-lengths-.patch b/0016-release-branch.go1.17-math-big-check-buffer-lengths-.patch similarity index 96% rename from 0074-release-branch.go1.17-math-big-check-buffer-lengths-.patch rename to 0016-release-branch.go1.17-math-big-check-buffer-lengths-.patch index abaa9a1784bbe314aa2f42da4c2ebc97d43be212..78f8090c522ff73f635f567a3ce02cd46d419180 100644 --- a/0074-release-branch.go1.17-math-big-check-buffer-lengths-.patch +++ b/0016-release-branch.go1.17-math-big-check-buffer-lengths-.patch @@ -1,4 +1,4 @@ -From 490df635ab990bcc5796cf5765c74675503d9964 Mon Sep 17 00:00:00 2001 +From dc903a8196a831d23e9b6504239e09a9e6bcd98a Mon Sep 17 00:00:00 2001 From: Roland Shoemaker Date: Fri, 15 Jul 2022 10:43:44 -0700 Subject: [PATCH] [release-branch.go1.17] math/big: check buffer lengths in @@ -18,10 +18,6 @@ Run-TryBot: Roland Shoemaker (cherry picked from commit 055113ef364337607e3e72ed7d48df67fde6fc66) Reviewed-on: https://go-review.googlesource.com/c/go/+/419814 Reviewed-by: Julie Qiu - -Conflict:NA -Reference:https://go-review.googlesource.com/c/go/+/419814 - --- src/math/big/floatmarsh.go | 7 +++++++ src/math/big/floatmarsh_test.go | 12 ++++++++++++ diff --git a/0075-path-filepath-do-not-remove-prefix-.-when-following-.patch b/0017-path-filepath-do-not-remove-prefix-.-when-following-.patch similarity index 88% rename from 0075-path-filepath-do-not-remove-prefix-.-when-following-.patch rename to 0017-path-filepath-do-not-remove-prefix-.-when-following-.patch index 96de818716967e414b446b76db640b06bae413e0..0f44f3850d75025e402eebca56b103c2e0751d04 100644 --- a/0075-path-filepath-do-not-remove-prefix-.-when-following-.patch +++ b/0017-path-filepath-do-not-remove-prefix-.-when-following-.patch @@ -1,4 +1,4 @@ -From 0de49f05ec2b03819ae698c97e9445a6ab928d4c Mon Sep 17 00:00:00 2001 +From e903e474f9632a151fff2df3dd3e891395f1a8f1 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Fri, 22 Apr 2022 10:07:51 +0900 Subject: [PATCH 1/2] path/filepath: do not remove prefix "." when following @@ -15,9 +15,8 @@ Reviewed-by: Ian Lance Taylor Reviewed-by: Damien Neil TryBot-Result: Gopher Robot -Conflict: NA -Reference: https://go-review.googlesource.com/c/go/+/401595/ - +Reference:https://go-review.googlesource.com/c/go/+/401595/ +Conflict:NA --- src/path/filepath/path.go | 14 +++++++++++++- src/path/filepath/path_test.go | 3 +++ @@ -25,10 +24,10 @@ Reference: https://go-review.googlesource.com/c/go/+/401595/ 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/path/filepath/path.go b/src/path/filepath/path.go -index 26f1833189..92dc090eea 100644 +index b56534dead..8300a32cb1 100644 --- a/src/path/filepath/path.go +++ b/src/path/filepath/path.go -@@ -116,9 +116,21 @@ func Clean(path string) string { +@@ -117,9 +117,21 @@ func Clean(path string) string { case os.IsPathSeparator(path[r]): // empty path element r++ @@ -52,7 +51,7 @@ index 26f1833189..92dc090eea 100644 // .. element: remove to last separator r += 2 diff --git a/src/path/filepath/path_test.go b/src/path/filepath/path_test.go -index d6f680556c..531a66333b 100644 +index bc5509b49c..ed17a8854d 100644 --- a/src/path/filepath/path_test.go +++ b/src/path/filepath/path_test.go @@ -93,6 +93,9 @@ var wincleantests = []PathTest{ @@ -66,10 +65,10 @@ index d6f680556c..531a66333b 100644 func TestClean(t *testing.T) { diff --git a/src/path/filepath/path_windows_test.go b/src/path/filepath/path_windows_test.go -index f7c454bf65..e3979fe1e7 100644 +index 76a459ac96..3edafb5a85 100644 --- a/src/path/filepath/path_windows_test.go +++ b/src/path/filepath/path_windows_test.go -@@ -581,3 +581,29 @@ func TestNTNamespaceSymlink(t *testing.T) { +@@ -530,3 +530,29 @@ func TestNTNamespaceSymlink(t *testing.T) { t.Errorf(`EvalSymlinks(%q): got %q, want %q`, filelink, got, want) } } diff --git a/0017-release-branch.go1.15-time-correct-unusual-extension.patch b/0017-release-branch.go1.15-time-correct-unusual-extension.patch deleted file mode 100644 index 9c58dc79a18b3edb587511e2e49335aa607f4c8e..0000000000000000000000000000000000000000 --- a/0017-release-branch.go1.15-time-correct-unusual-extension.patch +++ /dev/null @@ -1,150 +0,0 @@ -From 6bb96000b3215a84d0a5193e387cf809d2fa2800 Mon Sep 17 00:00:00 2001 -From: Ian Lance Taylor -Date: Thu, 25 Feb 2021 10:01:56 -0800 -Subject: [PATCH 17/44] [release-branch.go1.15] time: correct unusual extension - string cases - -This fixes two uncommon cases. - -First, the tzdata code permits timezone offsets up to 24 * 7, although -the POSIX TZ parsing does not. The tzdata code uses this to specify a -day of week in some cases. - -Second, we incorrectly rejected a negative time offset for when a time -zone change comes into effect. - -For #44385 -Fixes #44617 - -Change-Id: I5f2efc1d385e9bfa974a0de3fa81e7a94b827602 -Reviewed-on: https://go-review.googlesource.com/c/go/+/296392 -Trust: Ian Lance Taylor -Run-TryBot: Ian Lance Taylor -TryBot-Result: Go Bot -Reviewed-by: Tobias Klauser -(cherry picked from commit d9fd38e68ba00a51c2c7363150688d0e7687ef84) -Reviewed-on: https://go-review.googlesource.com/c/go/+/297229 - -Conflict:NA -Reference:https://github.com/golang/go/commit/6bb96000b3215a84d0a5193e387cf809d2fa2800 - ---- - src/time/zoneinfo.go | 6 ++-- - src/time/zoneinfo_test.go | 60 +++++++++++++++++++++++++++++---------- - 2 files changed, 49 insertions(+), 17 deletions(-) - -diff --git a/src/time/zoneinfo.go b/src/time/zoneinfo.go -index c3662297c7..6db9443474 100644 ---- a/src/time/zoneinfo.go -+++ b/src/time/zoneinfo.go -@@ -377,8 +377,10 @@ func tzsetOffset(s string) (offset int, rest string, ok bool) { - neg = true - } - -+ // The tzdata code permits values up to 24 * 7 here, -+ // although POSIX does not. - var hours int -- hours, s, ok = tzsetNum(s, 0, 24) -+ hours, s, ok = tzsetNum(s, 0, 24*7) - if !ok { - return 0, "", false - } -@@ -487,7 +489,7 @@ func tzsetRule(s string) (rule, string, bool) { - } - - offset, s, ok := tzsetOffset(s[1:]) -- if !ok || offset < 0 { -+ if !ok { - return rule{}, "", false - } - r.time = offset -diff --git a/src/time/zoneinfo_test.go b/src/time/zoneinfo_test.go -index 277b68f798..d043e1e9f1 100644 ---- a/src/time/zoneinfo_test.go -+++ b/src/time/zoneinfo_test.go -@@ -183,22 +183,50 @@ func TestMalformedTZData(t *testing.T) { - } - } - --func TestLoadLocationFromTZDataSlim(t *testing.T) { -- // A 2020b slim tzdata for Europe/Berlin -- tzData := "TZif2\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00TZif2\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00<\x00\x00\x00\x04\x00\x00\x00\x12\xff\xff\xff\xffo\xa2a\xf8\xff\xff\xff\xff\x9b\f\x17`\xff\xff\xff\xff\x9b\xd5\xda\xf0\xff\xff\xff\xff\x9cٮ\x90\xff\xff\xff\xff\x9d\xa4\xb5\x90\xff\xff\xff\xff\x9e\xb9\x90\x90\xff\xff\xff\xff\x9f\x84\x97\x90\xff\xff\xff\xff\xc8\tq\x90\xff\xff\xff\xff\xcc\xe7K\x10\xff\xff\xff\xffͩ\x17\x90\xff\xff\xff\xff\u03a2C\x10\xff\xff\xff\xffϒ4\x10\xff\xff\xff\xffЂ%\x10\xff\xff\xff\xff\xd1r\x16\x10\xff\xff\xff\xffѶ\x96\x00\xff\xff\xff\xff\xd2X\xbe\x80\xff\xff\xff\xffҡO\x10\xff\xff\xff\xff\xd3c\x1b\x90\xff\xff\xff\xff\xd4K#\x90\xff\xff\xff\xff\xd59\xd1 \xff\xff\xff\xff\xd5g\xe7\x90\xff\xff\xff\xffըs\x00\xff\xff\xff\xff\xd6)\xb4\x10\xff\xff\xff\xff\xd7,\x1a\x10\xff\xff\xff\xff\xd8\t\x96\x10\xff\xff\xff\xff\xd9\x02\xc1\x90\xff\xff\xff\xff\xd9\xe9x\x10\x00\x00\x00\x00\x13MD\x10\x00\x00\x00\x00\x143\xfa\x90\x00\x00\x00\x00\x15#\xeb\x90\x00\x00\x00\x00\x16\x13ܐ\x00\x00\x00\x00\x17\x03͐\x00\x00\x00\x00\x17\xf3\xbe\x90\x00\x00\x00\x00\x18㯐\x00\x00\x00\x00\x19Ӡ\x90\x00\x00\x00\x00\x1aÑ\x90\x00\x00\x00\x00\x1b\xbc\xbd\x10\x00\x00\x00\x00\x1c\xac\xae\x10\x00\x00\x00\x00\x1d\x9c\x9f\x10\x00\x00\x00\x00\x1e\x8c\x90\x10\x00\x00\x00\x00\x1f|\x81\x10\x00\x00\x00\x00 lr\x10\x00\x00\x00\x00!\\c\x10\x00\x00\x00\x00\"LT\x10\x00\x00\x00\x00#3<-02>,M3.5.0/-2,M10.5.0/-1\n", -+ wantName: "-03", -+ wantOffset: -10800, -+ }, -+ { -+ // 2021a slim tzdata for Asia/Gaza. -+ zoneName: "Asia/Gaza", -+ tzData: "TZif3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00TZif3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00s\x00\x00\x00\x05\x00\x00\x00\x15\xff\xff\xff\xff}\xbdJ\xb0\xff\xff\xff\xff\xc8Y\xcf\x00\xff\xff\xff\xff\xc8\xfa\xa6\x00\xff\xff\xff\xff\xc98\x9c\x80\xff\xff\xff\xff\xcc\xe5\xeb\x80\xff\xff\xff\xffͬ\xfe\x00\xff\xff\xff\xff\xce\xc7\x1f\x00\xff\xff\xff\xffϏ\x83\x00\xff\xff\xff\xffЩ\xa4\x00\xff\xff\xff\xffф}\x00\xff\xff\xff\xffҊ׀\xff\xff\xff\xff\xd3e\xb0\x80\xff\xff\xff\xff\xd4l\v\x00\xff\xff\xff\xff\xe86c`\xff\xff\xff\xff\xe8\xf4-P\xff\xff\xff\xff\xea\v\xb9`\xff\xff\xff\xff\xea\xd5`\xd0\xff\xff\xff\xff\xeb\xec\xfa\xf0\xff\xff\xff\xff\xec\xb5m\x00\xff\xff\xff\xff\xed\xcf\u007f\xf0\xff\xff\xff\xff\xee\x97\xf2\x00\xff\xff\xff\xffﰳp\xff\xff\xff\xff\xf0y%\x80\xff\xff\xff\xff\xf1\x91\xe6\xf0\xff\xff\xff\xff\xf2ZY\x00\xff\xff\xff\xff\xf3s\x1ap\xff\xff\xff\xff\xf4;\x8c\x80\xff\xff\xff\xff\xf5U\x9fp\xff\xff\xff\xff\xf6\x1e\x11\x80\xff\xff\xff\xff\xf76\xd2\xf0\xff\xff\xff\xff\xf7\xffE\x00\xff\xff\xff\xff\xf9\x18\x06p\xff\xff\xff\xff\xf9\xe1\xca\x00\xff\xff\xff\xff\xfa\xf99\xf0\xff\xff\xff\xff\xfb'BP\x00\x00\x00\x00\b|\x8b\xe0\x00\x00\x00\x00\b\xfd\xb0\xd0\x00\x00\x00\x00\t\xf6\xea`\x00\x00\x00\x00\n\xa63\xd0\x00\x00\x00\x00\x13\xe9\xfc`\x00\x00\x00\x00\x14![`\x00\x00\x00\x00\x1a\xfa\xc6`\x00\x00\x00\x00\x1b\x8en`\x00\x00\x00\x00\x1c\xbe\xf8\xe0\x00\x00\x00\x00\x1dw|\xd0\x00\x00\x00\x00\x1e\xcc\xff`\x00\x00\x00\x00\x1f`\x99P\x00\x00\x00\x00 \x82\xb1`\x00\x00\x00\x00!I\xb5\xd0\x00\x00\x00\x00\"^\x9e\xe0\x00\x00\x00\x00# ]P\x00\x00\x00\x00$Z0`\x00\x00\x00\x00%\x00?P\x00\x00\x00\x00&\v\xed\xe0\x00\x00\x00\x00&\xd6\xe6\xd0\x00\x00\x00\x00'\xeb\xcf\xe0\x00\x00\x00\x00(\xc0\x03P\x00\x00\x00\x00)\xd4\xec`\x00\x00\x00\x00*\xa9\x1f\xd0\x00\x00\x00\x00+\xbbe\xe0\x00\x00\x00\x00,\x89\x01\xd0\x00\x00\x00\x00-\x9bG\xe0\x00\x00\x00\x00._\xa9P\x00\x00\x00\x00/{)\xe0\x00\x00\x00\x000H\xc5\xd0\x00\x00\x00\x000\xe7\a\xe0\x00\x00\x00\x001dF`\x00\x00\x00\x002A\xc2`\x00\x00\x00\x003D(`\x00\x00\x00\x004!\xa4`\x00\x00\x00\x005$\n`\x00\x00\x00\x006\x01\x86`\x00\x00\x00\x007\x16a`\x00\x00\x00\x008\x06DP\x00\x00\x00\x008\xff}\xe0\x00\x00\x00\x009\xef`\xd0\x00\x00\x00\x00:\xdf_\xe0\x00\x00\x00\x00;\xcfB\xd0\x00\x00\x00\x00<\xbfA\xe0\x00\x00\x00\x00=\xaf$\xd0\x00\x00\x00\x00>\x9f#\xe0\x00\x00\x00\x00?\x8f\x06\xd0\x00\x00\x00\x00@\u007f\x05\xe0\x00\x00\x00\x00A\\\x81\xe0\x00\x00\x00\x00B^\xe7\xe0\x00\x00\x00\x00CA\xb7\xf0\x00\x00\x00\x00D-\xa6`\x00\x00\x00\x00E\x12\xfdP\x00\x00\x00\x00F\x0e\xd9\xe0\x00\x00\x00\x00F\xe8op\x00\x00\x00\x00G\xec\x18\xe0\x00\x00\x00\x00H\xb7\x11\xd0\x00\x00\x00\x00I\xcb\xfa\xe0\x00\x00\x00\x00J\xa0<`\x00\x00\x00\x00K\xad.\x9c\x00\x00\x00\x00La\xbd\xd0\x00\x00\x00\x00M\x94\xf9\x9c\x00\x00\x00\x00N5\xc2P\x00\x00\x00\x00Ot\xdb`\x00\x00\x00\x00P[\x91\xe0\x00\x00\x00\x00QT\xbd`\x00\x00\x00\x00RD\xa0P\x00\x00\x00\x00S4\x9f`\x00\x00\x00\x00TIlP\x00\x00\x00\x00U\x15\xd2\xe0\x00\x00\x00\x00V)\\`\x00\x00\x00\x00V\xf5\xc2\xf0\x00\x00\x00\x00X\x13\xca`\x00\x00\x00\x00Xդ\xf0\x00\x00\x00\x00Y\xf3\xac`\x00\x00\x00\x00Z\xb5\x86\xf0\x00\x00\x00\x00[ӎ`\x00\x00\x00\x00\\\x9dC\xe0\x00\x00\x00\x00]\xb3bP\x00\x00\x00\x00^~w`\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x00\x00 P\x00\x00\x00\x00*0\x01\x04\x00\x00\x1c \x00\t\x00\x00*0\x01\r\x00\x00\x1c \x00\x11LMT\x00EEST\x00EET\x00IDT\x00IST\x00\nEET-2EEST,M3.4.4/48,M10.4.4/49\n", -+ wantName: "EET", -+ wantOffset: 7200, -+ }, -+} - -- reference, err := time.LoadLocationFromTZData("Europe/Berlin", []byte(tzData)) -- if err != nil { -- t.Fatal(err) -- } -+func TestLoadLocationFromTZDataSlim(t *testing.T) { -+ for _, test := range slimTests { -+ reference, err := time.LoadLocationFromTZData(test.zoneName, []byte(test.tzData)) -+ if err != nil { -+ t.Fatal(err) -+ } - -- d := time.Date(2020, time.October, 29, 15, 30, 0, 0, reference) -- tzName, tzOffset := d.Zone() -- if want := "CET"; tzName != want { -- t.Errorf("Zone name == %s, want %s", tzName, want) -- } -- if want := 3600; tzOffset != want { -- t.Errorf("Zone offset == %d, want %d", tzOffset, want) -+ d := time.Date(2020, time.October, 29, 15, 30, 0, 0, reference) -+ tzName, tzOffset := d.Zone() -+ if tzName != test.wantName { -+ t.Errorf("Zone name == %s, want %s", tzName, test.wantName) -+ } -+ if tzOffset != test.wantOffset { -+ t.Errorf("Zone offset == %d, want %d", tzOffset, test.wantOffset) -+ } - } - } - -@@ -263,7 +291,8 @@ func TestTzsetOffset(t *testing.T) { - {"+08", 8 * 60 * 60, "", true}, - {"-01:02:03", -1*60*60 - 2*60 - 3, "", true}, - {"01", 1 * 60 * 60, "", true}, -- {"100", 0, "", false}, -+ {"100", 100 * 60 * 60, "", true}, -+ {"1000", 0, "", false}, - {"8PDT", 8 * 60 * 60, "PDT", true}, - } { - off, out, ok := time.TzsetOffset(test.in) -@@ -288,6 +317,7 @@ func TestTzsetRule(t *testing.T) { - {"30/03:00:00", time.Rule{Kind: time.RuleDOY, Day: 30, Time: 3 * 60 * 60}, "", true}, - {"M4.5.6/03:00:00", time.Rule{Kind: time.RuleMonthWeekDay, Mon: 4, Week: 5, Day: 6, Time: 3 * 60 * 60}, "", true}, - {"M4.5.7/03:00:00", time.Rule{}, "", false}, -+ {"M4.5.6/-04", time.Rule{Kind: time.RuleMonthWeekDay, Mon: 4, Week: 5, Day: 6, Time: -4 * 60 * 60}, "", true}, - } { - r, out, ok := time.TzsetRule(test.in) - if r != test.r || out != test.out || ok != test.ok { --- -2.27.0 - diff --git a/0018-release-branch.go1.15-cmd-compile-fix-escape-analysi.patch b/0018-release-branch.go1.15-cmd-compile-fix-escape-analysi.patch deleted file mode 100644 index e13076f4d3921c04fb65f93955890b66b4eb2455..0000000000000000000000000000000000000000 --- a/0018-release-branch.go1.15-cmd-compile-fix-escape-analysi.patch +++ /dev/null @@ -1,87 +0,0 @@ -From f75ab2d5a61f1a5aabaffe7752110e2dcd581236 Mon Sep 17 00:00:00 2001 -From: Matthew Dempsky -Date: Sat, 27 Feb 2021 09:41:19 -0800 -Subject: [PATCH 18/44] [release-branch.go1.15] cmd/compile: fix escape - analysis of heap-allocated results - -One of escape analysis's responsibilities is to summarize whether/how -each function parameter flows to the heap so we can correctly -incorporate those flows into callers' escape analysis data flow -graphs. - -As an optimization, we separately record when parameters flow to -result parameters, so that we can more precisely analyze parameter -flows based on how the results are used at the call site. However, if -a named result parameter itself needs to be heap allocated, this -optimization isn't safe and the parameter needs to be recorded as -flowing to heap rather than flowing to result. - -Escape analysis used to get this correct because it conservatively -rewalked the data-flow graph multiple times. So even though it would -incorrectly record the result parameter flow, it would separately find -a flow to the heap. However, CL 196811 (specifically, case 3) -optimized the walking logic to reduce unnecessary rewalks causing us -to stop finding the extra heap flow. - -This CL fixes the issue by correcting location.leakTo to be sensitive -to sink.escapes and not record result-flows when the result parameter -escapes to the heap. - -Fixes #44658. - -Change-Id: I48742ed35a6cab591094e2d23a439e205bd65c50 -Reviewed-on: https://go-review.googlesource.com/c/go/+/297289 -Trust: Matthew Dempsky -Run-TryBot: Matthew Dempsky -TryBot-Result: Go Bot -Reviewed-by: Keith Randall -Reviewed-on: https://go-review.googlesource.com/c/go/+/297291 - -Conflict:NA -Reference:https://github.com/golang/go/commit/f75ab2d5a61f1a5aabaffe7752110e2dcd581236 - ---- - src/cmd/compile/internal/gc/escape.go | 7 ++++--- - test/escape5.go | 11 +++++++++++ - 2 files changed, 15 insertions(+), 3 deletions(-) - -diff --git a/src/cmd/compile/internal/gc/escape.go b/src/cmd/compile/internal/gc/escape.go -index 08000dd374..2c55163100 100644 ---- a/src/cmd/compile/internal/gc/escape.go -+++ b/src/cmd/compile/internal/gc/escape.go -@@ -1379,9 +1379,10 @@ func containsClosure(f, c *Node) bool { - - // leak records that parameter l leaks to sink. - func (l *EscLocation) leakTo(sink *EscLocation, derefs int) { -- // If sink is a result parameter and we can fit return bits -- // into the escape analysis tag, then record a return leak. -- if sink.isName(PPARAMOUT) && sink.curfn == l.curfn { -+ // If sink is a result parameter that doesn't escape (#44614) -+ // and we can fit return bits into the escape analysis tag, -+ // then record as a result leak. -+ if !sink.escapes && sink.isName(PPARAMOUT) && sink.curfn == l.curfn { - // TODO(mdempsky): Eliminate dependency on Vargen here. - ri := int(sink.n.Name.Vargen) - 1 - if ri < numEscResults { -diff --git a/test/escape5.go b/test/escape5.go -index 061e57a069..145c5dd900 100644 ---- a/test/escape5.go -+++ b/test/escape5.go -@@ -262,3 +262,14 @@ func f28369(n int) int { - - return 1 + f28369(n-1) - } -+ -+// Issue 44614: parameters that flow to a heap-allocated result -+// parameter must be recorded as a heap-flow rather than a -+// result-flow. -+ -+// N.B., must match "leaking param: p", -+// but *not* "leaking param: p to result r level=0". -+func f(p *int) (r *int) { // ERROR "leaking param: p$" "moved to heap: r" -+ sink4 = &r -+ return p -+} --- -2.27.0 - diff --git a/0076-release-branch.go1.17-syscall-check-correct-group-in.patch b/0018-release-branch.go1.17-syscall-check-correct-group-in.patch similarity index 88% rename from 0076-release-branch.go1.17-syscall-check-correct-group-in.patch rename to 0018-release-branch.go1.17-syscall-check-correct-group-in.patch index c6ec4dd0d2a21f70a947ed0723759eaaf79f1b6c..23872111deb09ff6cf9b92db33cd86301899934d 100644 --- a/0076-release-branch.go1.17-syscall-check-correct-group-in.patch +++ b/0018-release-branch.go1.17-syscall-check-correct-group-in.patch @@ -1,4 +1,4 @@ -From 77f1f0c3293857f1010dd1899d5a6dafbc21a378 Mon Sep 17 00:00:00 2001 +From 66cff0cda766c1533373fabf3bc26fc3397e55d5 Mon Sep 17 00:00:00 2001 From: Damien Neil Date: Tue, 12 Apr 2022 13:38:17 -0700 Subject: [PATCH 2/2] [release-branch.go1.17] syscall: check correct group in @@ -29,17 +29,17 @@ Run-TryBot: Damien Neil Auto-Submit: Damien Neil Reviewed-by: Tatiana Bradley -Conflict: NA -Reference: https://go-review.googlesource.com/c/go/+/401078/ +Reference:https://go-review.googlesource.com/c/go/+/401078/ +Conflict:NA --- src/syscall/syscall_linux.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/syscall/syscall_linux.go b/src/syscall/syscall_linux.go -index 07fe6a6c2b..dbf16d9af2 100644 +index dfce3d0a4b..3387f3bdc2 100644 --- a/src/syscall/syscall_linux.go +++ b/src/syscall/syscall_linux.go -@@ -106,7 +106,7 @@ func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) { +@@ -109,7 +109,7 @@ func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) { gid = Getgid() } diff --git a/0019-release-branch.go1.15-net-http-ignore-connection-clo.patch b/0019-release-branch.go1.15-net-http-ignore-connection-clo.patch deleted file mode 100644 index 38b1bc7c774101e7df5a165f2fed7e01a7689985..0000000000000000000000000000000000000000 --- a/0019-release-branch.go1.15-net-http-ignore-connection-clo.patch +++ /dev/null @@ -1,124 +0,0 @@ -From 5de8d3bfcb060bbc61b9b9c945055fd3fb5b9607 Mon Sep 17 00:00:00 2001 -From: Michael Fraenkel -Date: Sat, 26 Sep 2020 09:20:16 -0600 -Subject: [PATCH 19/44] [release-branch.go1.15] net/http: ignore connection - closes once done with the connection - -Once the connection is put back into the idle pool, the request should -not take any action if the connection is closed. - -For #42935. -Updates #41600. - -Change-Id: I5e4ddcdc03cd44f5197ecfbe324638604961de84 -Reviewed-on: https://go-review.googlesource.com/c/go/+/257818 -Reviewed-by: Brad Fitzpatrick -Trust: Damien Neil -(cherry picked from commit 212d385a2f723a8dd5e7d2e83efb478ddd139349) -Reviewed-on: https://go-review.googlesource.com/c/go/+/297909 -Trust: Dmitri Shuralyov -Run-TryBot: Dmitri Shuralyov -Reviewed-by: Damien Neil - -Conflict:NA -Reference:https://github.com/golang/go/commit/5de8d3bfcb060bbc61b9b9c945055fd3fb5b9607 - ---- - src/net/http/transport.go | 13 ++++++--- - src/net/http/transport_test.go | 51 ++++++++++++++++++++++++++++++++++ - 2 files changed, 60 insertions(+), 4 deletions(-) - -diff --git a/src/net/http/transport.go b/src/net/http/transport.go -index d37b52b13d..6fb2ea5663 100644 ---- a/src/net/http/transport.go -+++ b/src/net/http/transport.go -@@ -2560,6 +2560,7 @@ func (pc *persistConn) roundTrip(req *transportRequest) (resp *Response, err err - var respHeaderTimer <-chan time.Time - cancelChan := req.Request.Cancel - ctxDoneChan := req.Context().Done() -+ pcClosed := pc.closech - for { - testHookWaitResLoop() - select { -@@ -2579,11 +2580,15 @@ func (pc *persistConn) roundTrip(req *transportRequest) (resp *Response, err err - defer timer.Stop() // prevent leaks - respHeaderTimer = timer.C - } -- case <-pc.closech: -- if debugRoundTrip { -- req.logf("closech recv: %T %#v", pc.closed, pc.closed) -+ case <-pcClosed: -+ pcClosed = nil -+ // check if we are still using the connection -+ if pc.t.replaceReqCanceler(req.cancelKey, nil) { -+ if debugRoundTrip { -+ req.logf("closech recv: %T %#v", pc.closed, pc.closed) -+ } -+ return nil, pc.mapRoundTripError(req, startBytesWritten, pc.closed) - } -- return nil, pc.mapRoundTripError(req, startBytesWritten, pc.closed) - case <-respHeaderTimer: - if debugRoundTrip { - req.logf("timeout waiting for response headers.") -diff --git a/src/net/http/transport_test.go b/src/net/http/transport_test.go -index 0a47687d9a..3c7b9eb4de 100644 ---- a/src/net/http/transport_test.go -+++ b/src/net/http/transport_test.go -@@ -6289,3 +6289,54 @@ func TestTransportRejectsSignInContentLength(t *testing.T) { - t.Fatalf("Error mismatch\nGot: %q\nWanted substring: %q", got, want) - } - } -+ -+// Issue 41600 -+// Test that a new request which uses the connection of an active request -+// cannot cause it to be canceled as well. -+func TestCancelRequestWhenSharingConnection(t *testing.T) { -+ if testing.Short() { -+ t.Skip("skipping in short mode") -+ } -+ ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, req *Request) { -+ w.Header().Add("Content-Length", "0") -+ })) -+ defer ts.Close() -+ -+ client := ts.Client() -+ transport := client.Transport.(*Transport) -+ transport.MaxIdleConns = 1 -+ transport.MaxConnsPerHost = 1 -+ -+ var wg sync.WaitGroup -+ -+ ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) -+ -+ for i := 0; i < 10; i++ { -+ wg.Add(1) -+ go func() { -+ defer wg.Done() -+ for ctx.Err() == nil { -+ reqctx, reqcancel := context.WithCancel(ctx) -+ go reqcancel() -+ req, _ := NewRequestWithContext(reqctx, "GET", ts.URL, nil) -+ res, err := client.Do(req) -+ if err == nil { -+ res.Body.Close() -+ } -+ } -+ }() -+ } -+ -+ for ctx.Err() == nil { -+ req, _ := NewRequest("GET", ts.URL, nil) -+ if res, err := client.Do(req); err != nil { -+ t.Errorf("unexpected: %p %v", req, err) -+ break -+ } else { -+ res.Body.Close() -+ } -+ } -+ -+ cancel() -+ wg.Wait() -+} --- -2.27.0 - diff --git a/0078-release-branch.go1.18-net-http-update-bundled-golang.patch b/0019-release-branch.go1.18-net-http-update-bundled-golang.patch similarity index 71% rename from 0078-release-branch.go1.18-net-http-update-bundled-golang.patch rename to 0019-release-branch.go1.18-net-http-update-bundled-golang.patch index 0236818b28da8f3626f0995e87c59a4dc8c6084a..bb88ffd8f25334b9b38efb3a899543927ce056ad 100644 --- a/0078-release-branch.go1.18-net-http-update-bundled-golang.patch +++ b/0019-release-branch.go1.18-net-http-update-bundled-golang.patch @@ -1,4 +1,4 @@ -From 2afe499bc3ce4d9706e91b43522b6eca9ff4f43a Mon Sep 17 00:00:00 2001 +From b2058191785138021b635f609de3d5f651ec02cd Mon Sep 17 00:00:00 2001 From: Damien Neil Date: Mon, 22 Aug 2022 16:21:02 -0700 Subject: [PATCH] [release-branch.go1.18] net/http: update bundled @@ -21,17 +21,31 @@ Run-TryBot: Michael Knyszek TryBot-Result: Gopher Robot Reviewed-by: Carlos Amedee -Conflict: NA -Reference: https://go-review.googlesource.com/c/go/+/428635/ +Conflict:NA +Reference:https://go-review.googlesource.com/c/go/+/428635/ --- - src/net/http/h2_bundle.go | 21 +++++++++++++-------- - 1 file changed, 13 insertions(+), 8 deletions(-) + 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 06f8808dc6..dc30e077ae 100644 +index 1b73da7f21..d7e2f764c8 100644 --- a/src/net/http/h2_bundle.go +++ b/src/net/http/h2_bundle.go -@@ -3247,10 +3247,11 @@ func (s http2SettingID) String() string { +@@ -3339,10 +3339,11 @@ func (s http2SettingID) String() string { // name (key). See httpguts.ValidHeaderName for the base rules. // // Further, http2 says: @@ -47,7 +61,7 @@ index 06f8808dc6..dc30e077ae 100644 func http2validWireHeaderFieldName(v string) bool { if len(v) == 0 { return false -@@ -3441,8 +3442,8 @@ func (s *http2sorter) SortStrings(ss []string) { +@@ -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: // @@ -58,7 +72,7 @@ index 06f8808dc6..dc30e077ae 100644 // // For now this is only used a quick check for deciding when to clean // up Opaque URLs before sending requests from the Transport. -@@ -4895,6 +4896,9 @@ func (sc *http2serverConn) startGracefulShutdownInternal() { +@@ -4999,6 +5000,9 @@ func (sc *http2serverConn) startGracefulShutdownInternal() { func (sc *http2serverConn) goAway(code http2ErrCode) { sc.serveG.check() if sc.inGoAway { @@ -68,7 +82,7 @@ index 06f8808dc6..dc30e077ae 100644 return } sc.inGoAway = true -@@ -6090,8 +6094,9 @@ func (rws *http2responseWriterState) writeChunk(p []byte) (n int, err error) { +@@ -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: diff --git a/0020-release-branch.go1.15-net-http-add-connections-back-.patch b/0020-release-branch.go1.15-net-http-add-connections-back-.patch deleted file mode 100644 index f3b0198bc2a528fa9a23436fd422092107db2197..0000000000000000000000000000000000000000 --- a/0020-release-branch.go1.15-net-http-add-connections-back-.patch +++ /dev/null @@ -1,129 +0,0 @@ -From 1c60e0d928764b1b755c494d4a760eb51b99bc90 Mon Sep 17 00:00:00 2001 -From: Michael Fraenkel -Date: Wed, 2 Dec 2020 17:07:27 -0700 -Subject: [PATCH 20/44] [release-branch.go1.15] net/http: add connections back - that haven't been canceled - -Issue #41600 fixed the issue when a second request canceled a connection -while the first request was still in roundTrip. -This uncovered a second issue where a request was being canceled (in -roundtrip) but the connection was put back into the idle pool for a -subsequent request. -The fix is the similar except its now in readLoop instead of roundTrip. -A persistent connection is only added back if it successfully removed -the cancel function; otherwise we know the roundTrip has started -cancelRequest. - -Fixes #42935. -Updates #42942. - -Change-Id: Ia56add20880ccd0c1ab812d380d8628e45f6f44c -Reviewed-on: https://go-review.googlesource.com/c/go/+/274973 -Trust: Dmitri Shuralyov -Trust: Damien Neil -Reviewed-by: Damien Neil -(cherry picked from commit 854a2f8e01a554d8052445563863775406a04b71) -Reviewed-on: https://go-review.googlesource.com/c/go/+/297910 -Run-TryBot: Dmitri Shuralyov -TryBot-Result: Go Bot - -Conflict:NA -Reference:https://github.com/golang/go/commit/1c60e0d928764b1b755c494d4a760eb51b99bc90 - ---- - src/net/http/transport.go | 22 ++++++++++++---------- - 1 file changed, 12 insertions(+), 10 deletions(-) - -diff --git a/src/net/http/transport.go b/src/net/http/transport.go -index 6fb2ea5663..6e430b9885 100644 ---- a/src/net/http/transport.go -+++ b/src/net/http/transport.go -@@ -766,7 +766,8 @@ func (t *Transport) CancelRequest(req *Request) { - } - - // Cancel an in-flight request, recording the error value. --func (t *Transport) cancelRequest(key cancelKey, err error) { -+// Returns whether the request was canceled. -+func (t *Transport) cancelRequest(key cancelKey, err error) bool { - t.reqMu.Lock() - cancel := t.reqCanceler[key] - delete(t.reqCanceler, key) -@@ -774,6 +775,8 @@ func (t *Transport) cancelRequest(key cancelKey, err error) { - if cancel != nil { - cancel(err) - } -+ -+ return cancel != nil - } - - // -@@ -2087,18 +2090,17 @@ func (pc *persistConn) readLoop() { - } - - if !hasBody || bodyWritable { -- pc.t.setReqCanceler(rc.cancelKey, nil) -+ replaced := pc.t.replaceReqCanceler(rc.cancelKey, nil) - - // Put the idle conn back into the pool before we send the response - // so if they process it quickly and make another request, they'll - // get this same conn. But we use the unbuffered channel 'rc' - // to guarantee that persistConn.roundTrip got out of its select - // potentially waiting for this persistConn to close. -- // but after - alive = alive && - !pc.sawEOF && - pc.wroteRequest() && -- tryPutIdleConn(trace) -+ replaced && tryPutIdleConn(trace) - - if bodyWritable { - closeErr = errCallerOwnsConn -@@ -2160,12 +2162,12 @@ func (pc *persistConn) readLoop() { - // reading the response body. (or for cancellation or death) - select { - case bodyEOF := <-waitForBodyRead: -- pc.t.setReqCanceler(rc.cancelKey, nil) // before pc might return to idle pool -+ replaced := pc.t.replaceReqCanceler(rc.cancelKey, nil) // before pc might return to idle pool - alive = alive && - bodyEOF && - !pc.sawEOF && - pc.wroteRequest() && -- tryPutIdleConn(trace) -+ replaced && tryPutIdleConn(trace) - if bodyEOF { - eofc <- struct{}{} - } -@@ -2561,6 +2563,7 @@ func (pc *persistConn) roundTrip(req *transportRequest) (resp *Response, err err - cancelChan := req.Request.Cancel - ctxDoneChan := req.Context().Done() - pcClosed := pc.closech -+ canceled := false - for { - testHookWaitResLoop() - select { -@@ -2582,8 +2585,7 @@ func (pc *persistConn) roundTrip(req *transportRequest) (resp *Response, err err - } - case <-pcClosed: - pcClosed = nil -- // check if we are still using the connection -- if pc.t.replaceReqCanceler(req.cancelKey, nil) { -+ if canceled || pc.t.replaceReqCanceler(req.cancelKey, nil) { - if debugRoundTrip { - req.logf("closech recv: %T %#v", pc.closed, pc.closed) - } -@@ -2607,10 +2609,10 @@ func (pc *persistConn) roundTrip(req *transportRequest) (resp *Response, err err - } - return re.res, nil - case <-cancelChan: -- pc.t.cancelRequest(req.cancelKey, errRequestCanceled) -+ canceled = pc.t.cancelRequest(req.cancelKey, errRequestCanceled) - cancelChan = nil - case <-ctxDoneChan: -- pc.t.cancelRequest(req.cancelKey, req.Context().Err()) -+ canceled = pc.t.cancelRequest(req.cancelKey, req.Context().Err()) - cancelChan = nil - ctxDoneChan = nil - } --- -2.27.0 - diff --git a/0079-release-branch.go1.18-regexp-limit-size-of-parsed-re.patch b/0020-release-branch.go1.18-regexp-limit-size-of-parsed-re.patch similarity index 72% rename from 0079-release-branch.go1.18-regexp-limit-size-of-parsed-re.patch rename to 0020-release-branch.go1.18-regexp-limit-size-of-parsed-re.patch index 8696633fd3e726271a0aac9411b20f4df28a7c3c..436d179e6bff17d7fa124142248dc997ba68947d 100644 --- a/0079-release-branch.go1.18-regexp-limit-size-of-parsed-re.patch +++ b/0020-release-branch.go1.18-regexp-limit-size-of-parsed-re.patch @@ -1,4 +1,4 @@ -From 6a6f6943355ecca5fc6ca4538484edd492274b9a Mon Sep 17 00:00:00 2001 +From 8b3a5d153b7b255bafd1a82d61505088356d0458 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 28 Sep 2022 11:18:51 -0400 Subject: [PATCH] regexp: limit size of parsed regexps @@ -28,12 +28,12 @@ Reviewed-by: Dmitri Shuralyov TryBot-Result: Gopher Robot Reviewed-by: Dmitri Shuralyov --- - src/regexp/syntax/parse.go | 164 +++++++++++++++++++++++++++++--- - src/regexp/syntax/parse_test.go | 13 ++- - 2 files changed, 161 insertions(+), 16 deletions(-) + src/regexp/syntax/parse.go | 222 +++++++++++++++++++++++++++++++- + src/regexp/syntax/parse_test.go | 11 +- + 2 files changed, 224 insertions(+), 9 deletions(-) diff --git a/src/regexp/syntax/parse.go b/src/regexp/syntax/parse.go -index d7cf2af..67254d6 100644 +index 7b40309..67254d6 100644 --- a/src/regexp/syntax/parse.go +++ b/src/regexp/syntax/parse.go @@ -43,6 +43,7 @@ const ( @@ -44,10 +44,24 @@ index d7cf2af..67254d6 100644 ) func (e ErrorCode) String() string { -@@ -90,15 +91,49 @@ const ( - // until we've allocated at least maxHeight Regexp structures. - const maxHeight = 1000 +@@ -76,13 +77,63 @@ const ( + opVerticalBar + ) ++// maxHeight is the maximum height of a regexp parse tree. ++// It is somewhat arbitrarily chosen, but the idea is to be large enough ++// that no one will actually hit in real use but at the same time small enough ++// that recursion on the Regexp tree will not hit the 1GB Go stack limit. ++// The maximum amount of stack for a single recursive frame is probably ++// closer to 1kB, so this could potentially be raised, but it seems unlikely ++// that people have regexps nested even this deeply. ++// We ran a test on Google's C++ code base and turned up only ++// a single use case with depth > 100; it had depth 128. ++// Using depth 1000 should be plenty of margin. ++// As an optimization, we don't even bother calculating heights ++// until we've allocated at least maxHeight Regexp structures. ++const maxHeight = 1000 ++ +// maxSize is the maximum size of a compiled regexp in Insts. +// It too is somewhat arbitrarily chosen, but the idea is to be large enough +// to allow significant regexps while at the same time small enough that @@ -85,9 +99,7 @@ index d7cf2af..67254d6 100644 free *Regexp numCap int // number of capturing groups seen wholeRegexp string -- tmpClass []rune // temporary char class work space -- numRegexp int // number of regexps allocated -- height map[*Regexp]int // regexp height for height limit check +- tmpClass []rune // temporary char class work space + tmpClass []rune // temporary char class work space + numRegexp int // number of regexps allocated + numRunes int // number of runes in char classes @@ -97,7 +109,21 @@ index d7cf2af..67254d6 100644 } func (p *parser) newRegexp(op Op) *Regexp { -@@ -122,6 +157,104 @@ func (p *parser) reuse(re *Regexp) { +@@ -92,20 +143,155 @@ func (p *parser) newRegexp(op Op) *Regexp { + *re = Regexp{} + } else { + re = new(Regexp) ++ p.numRegexp++ + } + re.Op = op + return re + } + + func (p *parser) reuse(re *Regexp) { ++ if p.height != nil { ++ delete(p.height, re) ++ } + re.Sub0[0] = p.free p.free = re } @@ -199,19 +225,39 @@ index d7cf2af..67254d6 100644 + return size +} + - func (p *parser) checkHeight(re *Regexp) { - if p.numRegexp < maxHeight { - return -@@ -133,7 +266,7 @@ func (p *parser) checkHeight(re *Regexp) { - } - } - if p.calcHeight(re, true) > maxHeight { -- panic(ErrInternalError) ++func (p *parser) checkHeight(re *Regexp) { ++ if p.numRegexp < maxHeight { ++ return ++ } ++ if p.height == nil { ++ p.height = make(map[*Regexp]int) ++ for _, re := range p.stack { ++ p.checkHeight(re) ++ } ++ } ++ if p.calcHeight(re, true) > maxHeight { + panic(ErrNestingDepth) - } - } - -@@ -158,6 +291,7 @@ func (p *parser) calcHeight(re *Regexp, force bool) int { ++ } ++} ++ ++func (p *parser) calcHeight(re *Regexp, force bool) int { ++ if !force { ++ if h, ok := p.height[re]; ok { ++ return h ++ } ++ } ++ h := 1 ++ for _, sub := range re.Sub { ++ hsub := p.calcHeight(sub, false) ++ if h < 1+hsub { ++ h = 1 + hsub ++ } ++ } ++ p.height[re] = h ++ return h ++} ++ + // Parse stack manipulation. // push pushes the regexp re onto the parse stack and returns the regexp. func (p *parser) push(re *Regexp) *Regexp { @@ -219,25 +265,23 @@ index d7cf2af..67254d6 100644 if re.Op == OpCharClass && len(re.Rune) == 2 && re.Rune[0] == re.Rune[1] { // Single rune. if p.maybeConcat(re.Rune[0], p.flags&^FoldCase) { -@@ -189,7 +323,7 @@ func (p *parser) push(re *Regexp) *Regexp { +@@ -137,6 +323,7 @@ func (p *parser) push(re *Regexp) *Regexp { } p.stack = append(p.stack, re) -- p.checkHeight(re) + p.checkLimits(re) return re } -@@ -299,7 +433,7 @@ func (p *parser) repeat(op Op, min, max int, before, after, lastRepeat string) ( +@@ -246,6 +433,7 @@ func (p *parser) repeat(op Op, min, max int, before, after, lastRepeat string) ( re.Sub = re.Sub0[:1] re.Sub[0] = sub p.stack[n-1] = re -- p.checkHeight(re) + p.checkLimits(re) if op == OpRepeat && (min >= 2 || max >= 2) && !repeatIsValid(re, 1000) { return "", &Error{ErrInvalidRepeatSize, before[:len(before)-len(after)]} -@@ -444,12 +578,16 @@ func (p *parser) collapse(subs []*Regexp, op Op) *Regexp { +@@ -390,12 +578,16 @@ func (p *parser) collapse(subs []*Regexp, op Op) *Regexp { // frees (passes to p.reuse) any removed *Regexps. // // For example, @@ -257,7 +301,7 @@ index d7cf2af..67254d6 100644 func (p *parser) factor(sub []*Regexp) []*Regexp { if len(sub) < 2 { return sub -@@ -503,6 +641,7 @@ func (p *parser) factor(sub []*Regexp) []*Regexp { +@@ -449,6 +641,7 @@ func (p *parser) factor(sub []*Regexp) []*Regexp { for j := start; j < i; j++ { sub[j] = p.removeLeadingString(sub[j], len(str)) @@ -265,7 +309,7 @@ index d7cf2af..67254d6 100644 } suffix := p.collapse(sub[start:i], OpAlternate) // recurse -@@ -560,6 +699,7 @@ func (p *parser) factor(sub []*Regexp) []*Regexp { +@@ -506,6 +699,7 @@ func (p *parser) factor(sub []*Regexp) []*Regexp { for j := start; j < i; j++ { reuse := j != start // prefix came from sub[start] sub[j] = p.removeLeadingRegexp(sub[j], reuse) @@ -273,19 +317,39 @@ index d7cf2af..67254d6 100644 } suffix := p.collapse(sub[start:i], OpAlternate) // recurse -@@ -757,8 +897,10 @@ func parse(s string, flags Flags) (_ *Regexp, err error) { - panic(r) - case nil: - // ok -- case ErrInternalError: +@@ -693,6 +887,23 @@ func literalRegexp(s string, flags Flags) *Regexp { + // Flags, and returns a regular expression parse tree. The syntax is + // described in the top-level comment. + func Parse(s string, flags Flags) (*Regexp, error) { ++ return parse(s, flags) ++} ++ ++func parse(s string, flags Flags) (_ *Regexp, err error) { ++ defer func() { ++ switch r := recover(); r { ++ default: ++ panic(r) ++ case nil: ++ // ok + case ErrInternalError: // too big - err = &Error{Code: ErrInternalError, Expr: s} ++ err = &Error{Code: ErrInternalError, Expr: s} + case ErrNestingDepth: + err = &Error{Code: ErrNestingDepth, Expr: s} - } - }() - -@@ -1801,7 +1943,7 @@ func appendClass(r []rune, x []rune) []rune { ++ } ++ }() ++ + if flags&Literal != 0 { + // Trivial parser for literal string. + if err := checkUTF8(s); err != nil { +@@ -704,7 +915,6 @@ func Parse(s string, flags Flags) (*Regexp, error) { + // Otherwise, must do real work. + var ( + p parser +- err error + c rune + op Op + lastRepeat string +@@ -1733,7 +1943,7 @@ func appendClass(r []rune, x []rune) []rune { return r } @@ -295,18 +359,16 @@ index d7cf2af..67254d6 100644 for i := 0; i < len(x); i += 2 { r = appendFoldedRange(r, x[i], x[i+1]) diff --git a/src/regexp/syntax/parse_test.go b/src/regexp/syntax/parse_test.go -index 1ef6d8a..67e3c56 100644 +index 5581ba1..6044da6 100644 --- a/src/regexp/syntax/parse_test.go +++ b/src/regexp/syntax/parse_test.go -@@ -484,12 +484,15 @@ var invalidRegexps = []string{ +@@ -479,10 +479,15 @@ var invalidRegexps = []string{ `(?P<>a)`, `[a-Z]`, `(?i)[a-Z]`, - `a{100000}`, - `a{100000,}`, - "((((((((((x{2}){2}){2}){2}){2}){2}){2}){2}){2}){2})", -- strings.Repeat("(", 1000) + strings.Repeat(")", 1000), -- strings.Repeat("(?:", 1000) + strings.Repeat(")*", 1000), `\Q\E*`, + `a{100000}`, // too much repetition + `a{100000,}`, // too much repetition @@ -315,7 +377,7 @@ index 1ef6d8a..67e3c56 100644 + strings.Repeat("(?:", 1000) + strings.Repeat(")*", 1000), // too deep + "(" + strings.Repeat("(xx?)", 1000) + "){1000}", // too long + strings.Repeat("(xx?){1000}", 1000), // too long -+ strings.Repeat(`\pL`, 270000), // too many runes ++ strings.Repeat(`\pL`, 27000), // too many runes } var onlyPerl = []string{ diff --git a/0021-release-branch.go1.15-security-encoding-xml-prevent-.patch b/0021-release-branch.go1.15-security-encoding-xml-prevent-.patch deleted file mode 100644 index 294539e68dc268a9e50c930cd9b4eb83898d44a6..0000000000000000000000000000000000000000 --- a/0021-release-branch.go1.15-security-encoding-xml-prevent-.patch +++ /dev/null @@ -1,189 +0,0 @@ -From 91062c2e4cbbf78a108919f6ed3ded1173937cf3 Mon Sep 17 00:00:00 2001 -From: Katie Hockman -Date: Mon, 1 Mar 2021 09:54:00 -0500 -Subject: [PATCH 21/44] [release-branch.go1.15-security] encoding/xml: prevent - infinite loop while decoding - -This change properly handles a TokenReader which -returns an EOF in the middle of an open XML -element. - -Thanks to Sam Whited for reporting this. - -Fixes CVE-2021-27918 - -Change-Id: Id02a3f3def4a1b415fa2d9a8e3b373eb6cb0f433 -Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1004594 -Reviewed-by: Russ Cox -Reviewed-by: Roland Shoemaker -Reviewed-by: Filippo Valsorda -(cherry picked from commit e7ce1f6746223ec7b4caa3b1ece25d9be3864710) -Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1014236 - -Conflict:NA -Reference:https://github.com/golang/go/commit/91062c2e4cbbf78a108919f6ed3ded1173937cf3 - ---- - src/encoding/xml/xml.go | 19 ++++--- - src/encoding/xml/xml_test.go | 104 +++++++++++++++++++++++++++-------- - 2 files changed, 92 insertions(+), 31 deletions(-) - -diff --git a/src/encoding/xml/xml.go b/src/encoding/xml/xml.go -index adaf4daf19..6f9594d7ba 100644 ---- a/src/encoding/xml/xml.go -+++ b/src/encoding/xml/xml.go -@@ -271,7 +271,7 @@ func NewTokenDecoder(t TokenReader) *Decoder { - // it will return an error. - // - // Token implements XML name spaces as described by --// https://www.w3.org/TR/REC-xml-names/. Each of the -+// https://www.w3.org/TR/REC-xml-names/. Each of the - // Name structures contained in the Token has the Space - // set to the URL identifying its name space when known. - // If Token encounters an unrecognized name space prefix, -@@ -285,16 +285,17 @@ func (d *Decoder) Token() (Token, error) { - if d.nextToken != nil { - t = d.nextToken - d.nextToken = nil -- } else if t, err = d.rawToken(); err != nil { -- switch { -- case err == io.EOF && d.t != nil: -- err = nil -- case err == io.EOF && d.stk != nil && d.stk.kind != stkEOF: -- err = d.syntaxError("unexpected EOF") -+ } else { -+ if t, err = d.rawToken(); t == nil && err != nil { -+ if err == io.EOF && d.stk != nil && d.stk.kind != stkEOF { -+ err = d.syntaxError("unexpected EOF") -+ } -+ return nil, err - } -- return t, err -+ // We still have a token to process, so clear any -+ // errors (e.g. EOF) and proceed. -+ err = nil - } -- - if !d.Strict { - if t1, ok := d.autoClose(t); ok { - d.nextToken = t -diff --git a/src/encoding/xml/xml_test.go b/src/encoding/xml/xml_test.go -index efddca43e9..5672ebb375 100644 ---- a/src/encoding/xml/xml_test.go -+++ b/src/encoding/xml/xml_test.go -@@ -33,30 +33,90 @@ func (t *toks) Token() (Token, error) { - - func TestDecodeEOF(t *testing.T) { - start := StartElement{Name: Name{Local: "test"}} -- t.Run("EarlyEOF", func(t *testing.T) { -- d := NewTokenDecoder(&toks{earlyEOF: true, t: []Token{ -- start, -- start.End(), -- }}) -- err := d.Decode(&struct { -- XMLName Name `xml:"test"` -- }{}) -- if err != nil { -- t.Error(err) -+ tests := []struct { -+ name string -+ tokens []Token -+ ok bool -+ }{ -+ { -+ name: "OK", -+ tokens: []Token{ -+ start, -+ start.End(), -+ }, -+ ok: true, -+ }, -+ { -+ name: "Malformed", -+ tokens: []Token{ -+ start, -+ StartElement{Name: Name{Local: "bad"}}, -+ start.End(), -+ }, -+ ok: false, -+ }, -+ } -+ for _, tc := range tests { -+ for _, eof := range []bool{true, false} { -+ name := fmt.Sprintf("%s/earlyEOF=%v", tc.name, eof) -+ t.Run(name, func(t *testing.T) { -+ d := NewTokenDecoder(&toks{ -+ earlyEOF: eof, -+ t: tc.tokens, -+ }) -+ err := d.Decode(&struct { -+ XMLName Name `xml:"test"` -+ }{}) -+ if tc.ok && err != nil { -+ t.Fatalf("d.Decode: expected nil error, got %v", err) -+ } -+ if _, ok := err.(*SyntaxError); !tc.ok && !ok { -+ t.Errorf("d.Decode: expected syntax error, got %v", err) -+ } -+ }) - } -- }) -- t.Run("LateEOF", func(t *testing.T) { -- d := NewTokenDecoder(&toks{t: []Token{ -- start, -- start.End(), -- }}) -- err := d.Decode(&struct { -- XMLName Name `xml:"test"` -- }{}) -- if err != nil { -- t.Error(err) -+ } -+} -+ -+type toksNil struct { -+ returnEOF bool -+ t []Token -+} -+ -+func (t *toksNil) Token() (Token, error) { -+ if len(t.t) == 0 { -+ if !t.returnEOF { -+ // Return nil, nil before returning an EOF. It's legal, but -+ // discouraged. -+ t.returnEOF = true -+ return nil, nil - } -- }) -+ return nil, io.EOF -+ } -+ var tok Token -+ tok, t.t = t.t[0], t.t[1:] -+ return tok, nil -+} -+ -+func TestDecodeNilToken(t *testing.T) { -+ for _, strict := range []bool{true, false} { -+ name := fmt.Sprintf("Strict=%v", strict) -+ t.Run(name, func(t *testing.T) { -+ start := StartElement{Name: Name{Local: "test"}} -+ bad := StartElement{Name: Name{Local: "bad"}} -+ d := NewTokenDecoder(&toksNil{ -+ // Malformed -+ t: []Token{start, bad, start.End()}, -+ }) -+ d.Strict = strict -+ err := d.Decode(&struct { -+ XMLName Name `xml:"test"` -+ }{}) -+ if _, ok := err.(*SyntaxError); !ok { -+ t.Errorf("d.Decode: expected syntax error, got %v", err) -+ } -+ }) -+ } - } - - const testInput = ` --- -2.27.0 - diff --git a/0080-release-branch.go1.18-net-http-httputil-avoid-query-.patch b/0021-release-branch.go1.18-net-http-httputil-avoid-query-.patch similarity index 92% rename from 0080-release-branch.go1.18-net-http-httputil-avoid-query-.patch rename to 0021-release-branch.go1.18-net-http-httputil-avoid-query-.patch index df193bc2524caffff991b554132411c9cadeca98..b07cf56be34db31d457fe07f457477c33be3122b 100644 --- a/0080-release-branch.go1.18-net-http-httputil-avoid-query-.patch +++ b/0021-release-branch.go1.18-net-http-httputil-avoid-query-.patch @@ -1,7 +1,7 @@ -From 61cdfc54fe4d7dd2179d3d6ae1d3ebb5709daad7 Mon Sep 17 00:00:00 2001 +From 51a477dc4f1130d53e66cd2003de0bac40e5e2be Mon Sep 17 00:00:00 2001 From: Damien Neil Date: Thu, 22 Sep 2022 13:32:00 -0700 -Subject: [PATCH] [release-branch.go1.18] net/http/httputil: avoid query +Subject: [PATCH 2/3] [release-branch.go1.18] net/http/httputil: avoid query parameter smuggling Query parameter smuggling occurs when a proxy's interpretation @@ -37,10 +37,10 @@ Reviewed-by: Dmitri Shuralyov 2 files changed, 110 insertions(+) diff --git a/src/net/http/httputil/reverseproxy.go b/src/net/http/httputil/reverseproxy.go -index 68754cb088..5b42b76f37 100644 +index 8b63368386..c76eec6987 100644 --- a/src/net/http/httputil/reverseproxy.go +++ b/src/net/http/httputil/reverseproxy.go -@@ -248,6 +248,9 @@ func (p *ReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) { +@@ -249,6 +249,9 @@ func (p *ReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) { } p.Director(outreq) @@ -50,7 +50,7 @@ index 68754cb088..5b42b76f37 100644 outreq.Close = false reqUpType := upgradeType(outreq.Header) -@@ -614,3 +617,36 @@ func (c switchProtocolCopier) copyToBackend(errc chan<- error) { +@@ -628,3 +631,36 @@ func (c switchProtocolCopier) copyToBackend(errc chan<- error) { _, err := io.Copy(c.backend, c.user) errc <- err } @@ -88,10 +88,10 @@ index 68754cb088..5b42b76f37 100644 + return false +} diff --git a/src/net/http/httputil/reverseproxy_test.go b/src/net/http/httputil/reverseproxy_test.go -index 1f2dfb9867..3dfd24df35 100644 +index 4b6ad77a29..8c0a4f136b 100644 --- a/src/net/http/httputil/reverseproxy_test.go +++ b/src/net/http/httputil/reverseproxy_test.go -@@ -1460,3 +1460,77 @@ func TestJoinURLPath(t *testing.T) { +@@ -1517,3 +1517,77 @@ func TestJoinURLPath(t *testing.T) { } } } diff --git a/0081-release-branch.go1.18-archive-tar-limit-size-of-head.patch b/0022-release-branch.go1.18-archive-tar-limit-size-of-head.patch similarity index 62% rename from 0081-release-branch.go1.18-archive-tar-limit-size-of-head.patch rename to 0022-release-branch.go1.18-archive-tar-limit-size-of-head.patch index 93d520273692cf5f85964578af549ff69fb12dbb..550877a2761d619b88ba92186052542583d1ad5c 100644 --- a/0081-release-branch.go1.18-archive-tar-limit-size-of-head.patch +++ b/0022-release-branch.go1.18-archive-tar-limit-size-of-head.patch @@ -1,4 +1,4 @@ -From 61088cf9ed18b7b03dad384f2691a17f85fc24c5 Mon Sep 17 00:00:00 2001 +From 7dd44b287830fbb2256aceac4a36756b955c0279 Mon Sep 17 00:00:00 2001 From: Damien Neil Date: Fri, 2 Sep 2022 20:45:18 -0700 Subject: [PATCH] archive/tar: limit size of headers @@ -30,13 +30,12 @@ Reviewed-by: Dmitri Shuralyov Run-TryBot: Carlos Amedee TryBot-Result: Gopher Robot --- - src/archive/tar/format.go | 4 +++ - src/archive/tar/reader.go | 20 ++++++++--- - src/archive/tar/reader_test.go | 11 +++++- - src/archive/tar/writer.go | 3 ++ - src/archive/tar/writer_test.go | 27 ++++++++++++++ - src/io/io.go | 64 ++++++++++++++++++++++++++++++++++ - 6 files changed, 123 insertions(+), 6 deletions(-) + src/archive/tar/format.go | 4 ++++ + src/archive/tar/reader.go | 14 ++++++++++++-- + src/archive/tar/reader_test.go | 11 ++++++++++- + src/archive/tar/writer.go | 3 +++ + src/archive/tar/writer_test.go | 27 +++++++++++++++++++++++++++ + 5 files changed, 56 insertions(+), 3 deletions(-) diff --git a/src/archive/tar/format.go b/src/archive/tar/format.go index cfe24a5..6642364 100644 @@ -54,41 +53,28 @@ index cfe24a5..6642364 100644 // blockPadding computes the number of bytes needed to pad offset up to the diff --git a/src/archive/tar/reader.go b/src/archive/tar/reader.go -index 4f9135b..ec45ae3 100644 +index 1b1d5b4..f645af8 100644 --- a/src/archive/tar/reader.go +++ b/src/archive/tar/reader.go -@@ -104,7 +104,7 @@ func (tr *Reader) next() (*Header, error) { +@@ -103,7 +103,7 @@ func (tr *Reader) next() (*Header, error) { continue // This is a meta header affecting the next header case TypeGNULongName, TypeGNULongLink: format.mayOnlyBe(FormatGNU) -- realname, err := ioutil.ReadAll(tr) +- realname, err := io.ReadAll(tr) + realname, err := readSpecialFile(tr) if err != nil { return nil, err } -@@ -294,7 +294,7 @@ func mergePAX(hdr *Header, paxHdrs map[string]string) (err error) { +@@ -293,7 +293,7 @@ func mergePAX(hdr *Header, paxHdrs map[string]string) (err error) { // parsePAX parses PAX headers. // If an extended header (type 'x') is invalid, ErrHeader is returned func parsePAX(r io.Reader) (map[string]string, error) { -- buf, err := ioutil.ReadAll(r) +- buf, err := io.ReadAll(r) + buf, err := readSpecialFile(r) if err != nil { return nil, err } -@@ -337,9 +337,9 @@ func parsePAX(r io.Reader) (map[string]string, error) { - // header in case further processing is required. - // - // The err will be set to io.EOF only when one of the following occurs: --// * Exactly 0 bytes are read and EOF is hit. --// * Exactly 1 block of zeros is read and EOF is hit. --// * At least 2 blocks of zeros are read. -+// - Exactly 0 bytes are read and EOF is hit. -+// - Exactly 1 block of zeros is read and EOF is hit. -+// - At least 2 blocks of zeros are read. - func (tr *Reader) readHeader() (*Header, *block, error) { - // Two blocks of zero bytes marks the end of the archive. - if _, err := io.ReadFull(tr.r, tr.blk[:]); err != nil { -@@ -827,6 +827,16 @@ func tryReadFull(r io.Reader, b []byte) (n int, err error) { +@@ -826,6 +826,16 @@ func tryReadFull(r io.Reader, b []byte) (n int, err error) { return n, err } @@ -106,7 +92,7 @@ index 4f9135b..ec45ae3 100644 func discard(r io.Reader, n int64) error { // If possible, Seek to the last byte before the end of the data section. diff --git a/src/archive/tar/reader_test.go b/src/archive/tar/reader_test.go -index f153b66..c68a859 100644 +index 789ddc1..5a644a4 100644 --- a/src/archive/tar/reader_test.go +++ b/src/archive/tar/reader_test.go @@ -6,6 +6,7 @@ package tar @@ -117,7 +103,7 @@ index f153b66..c68a859 100644 "crypto/md5" "errors" "fmt" -@@ -244,6 +245,9 @@ func TestReader(t *testing.T) { +@@ -243,6 +244,9 @@ func TestReader(t *testing.T) { }, { file: "testdata/pax-bad-hdr-file.tar", err: ErrHeader, @@ -127,7 +113,7 @@ index f153b66..c68a859 100644 }, { file: "testdata/pax-bad-mtime-file.tar", err: ErrHeader, -@@ -626,9 +630,14 @@ func TestReader(t *testing.T) { +@@ -625,9 +629,14 @@ func TestReader(t *testing.T) { } defer f.Close() @@ -158,10 +144,10 @@ index e80498d..893eac0 100644 return err // Global headers return here } diff --git a/src/archive/tar/writer_test.go b/src/archive/tar/writer_test.go -index 30556d2..4bd69fd 100644 +index a00f02d..4e709e5 100644 --- a/src/archive/tar/writer_test.go +++ b/src/archive/tar/writer_test.go -@@ -1007,6 +1007,33 @@ func TestIssue12594(t *testing.T) { +@@ -1006,6 +1006,33 @@ func TestIssue12594(t *testing.T) { } } @@ -195,85 +181,6 @@ index 30556d2..4bd69fd 100644 // testNonEmptyWriter wraps an io.Writer and ensures that // Write is never called with an empty buffer. type testNonEmptyWriter struct{ io.Writer } -diff --git a/src/io/io.go b/src/io/io.go -index 3dea70b..f611ec9 100644 ---- a/src/io/io.go -+++ b/src/io/io.go -@@ -14,6 +14,7 @@ package io - - import ( - "errors" -+ "sync" - ) - - // Seek whence values. -@@ -547,3 +548,66 @@ func (t *teeReader) Read(p []byte) (n int, err error) { - } - return - } -+ -+// Discard is a Writer on which all Write calls succeed -+// without doing anything. -+var Discard Writer = discard{} -+ -+type discard struct{} -+ -+// discard implements ReaderFrom as an optimization so Copy to -+// io.Discard can avoid doing unnecessary work. -+var _ ReaderFrom = discard{} -+ -+func (discard) Write(p []byte) (int, error) { -+ return len(p), nil -+} -+ -+func (discard) WriteString(s string) (int, error) { -+ return len(s), nil -+} -+ -+var blackHolePool = sync.Pool{ -+ New: func() interface{} { -+ b := make([]byte, 8192) -+ return &b -+ }, -+} -+ -+func (discard) ReadFrom(r Reader) (n int64, err error) { -+ bufp := blackHolePool.Get().(*[]byte) -+ readSize := 0 -+ for { -+ readSize, err = r.Read(*bufp) -+ n += int64(readSize) -+ if err != nil { -+ blackHolePool.Put(bufp) -+ if err == EOF { -+ return n, nil -+ } -+ return -+ } -+ } -+} -+ -+// ReadAll reads from r until an error or EOF and returns the data it read. -+// A successful call returns err == nil, not err == EOF. Because ReadAll is -+// defined to read from src until EOF, it does not treat an EOF from Read -+// as an error to be reported. -+func ReadAll(r Reader) ([]byte, error) { -+ b := make([]byte, 0, 512) -+ for { -+ if len(b) == cap(b) { -+ // Add more capacity (let append pick how much). -+ b = append(b, 0)[:len(b)] -+ } -+ n, err := r.Read(b[len(b):cap(b)]) -+ b = b[:len(b)+n] -+ if err != nil { -+ if err == EOF { -+ err = nil -+ } -+ return b, err -+ } -+ } -+} -- 2.33.0 diff --git a/0023-release-branch.go1.15-cmd-go-don-t-report-missing-st.patch b/0023-release-branch.go1.15-cmd-go-don-t-report-missing-st.patch deleted file mode 100644 index 71642c7754b2049564dd838a781afd07bc682cbd..0000000000000000000000000000000000000000 --- a/0023-release-branch.go1.15-cmd-go-don-t-report-missing-st.patch +++ /dev/null @@ -1,121 +0,0 @@ -From ba3dc70dc5c9f2162024b09d6b13bda1f4575b01 Mon Sep 17 00:00:00 2001 -From: Jay Conrod -Date: Thu, 4 Mar 2021 11:50:31 -0500 -Subject: [PATCH 23/44] [release-branch.go1.15] cmd/go: don't report missing - std import errors for tidy and vendor - -'go mod tidy' and 'go mod vendor' normally report errors when a -package can't be imported, even if the import appears in a file that -wouldn't be compiled by the current version of Go. These errors are -common for packages introduced in higher versions of Go, like "embed" -in 1.16. - -This change causes 'go mod tidy' and 'go mod vendor' to ignore -missing package errors if the import path appears to come from the -standard library because it lacks a dot in the first path element. - -NOTE: This change is not a clean cherry-pick of CL 298749 because -parts of modload were substantially rewritten after 1.15. - -Fixes #44792 -Updates #27063 - -Change-Id: I61d6443e77ab95fd8c0d1514f57ef4c8885a77cc -Reviewed-on: https://go-review.googlesource.com/c/go/+/298749 -Trust: Jay Conrod -Run-TryBot: Jay Conrod -Reviewed-by: Bryan C. Mills -TryBot-Result: Go Bot -(cherry picked from commit 56d52e661114be60fb1893b034ac0c5976b622af) -Reviewed-on: https://go-review.googlesource.com/c/go/+/298950 - -Conflict:NA -Reference:https://github.com/golang/go/commit/ba3dc70dc5c9f2162024b09d6b13bda1f4575b01 - ---- - src/cmd/go/internal/modcmd/tidy.go | 1 + - src/cmd/go/internal/modcmd/vendor.go | 1 + - src/cmd/go/internal/modload/init.go | 6 ++++++ - src/cmd/go/internal/modload/load.go | 5 +++++ - src/cmd/go/testdata/script/mod_tidy_error.txt | 4 ++-- - 5 files changed, 15 insertions(+), 2 deletions(-) - -diff --git a/src/cmd/go/internal/modcmd/tidy.go b/src/cmd/go/internal/modcmd/tidy.go -index af2b04c0c2..5ff847485c 100644 ---- a/src/cmd/go/internal/modcmd/tidy.go -+++ b/src/cmd/go/internal/modcmd/tidy.go -@@ -42,6 +42,7 @@ func runTidy(cmd *base.Command, args []string) { - base.Fatalf("go mod tidy: no arguments allowed") - } - -+ modload.SilenceMissingStdImports = true - modload.LoadALL() - modload.TidyBuildList() - modTidyGoSum() // updates memory copy; WriteGoMod on next line flushes it out -diff --git a/src/cmd/go/internal/modcmd/vendor.go b/src/cmd/go/internal/modcmd/vendor.go -index 8509ceb7a8..5a5bb943a5 100644 ---- a/src/cmd/go/internal/modcmd/vendor.go -+++ b/src/cmd/go/internal/modcmd/vendor.go -@@ -47,6 +47,7 @@ func runVendor(cmd *base.Command, args []string) { - if len(args) != 0 { - base.Fatalf("go mod vendor: vendor takes no arguments") - } -+ modload.SilenceMissingStdImports = true - pkgs := modload.LoadVendor() - - vdir := filepath.Join(modload.ModRoot(), "vendor") -diff --git a/src/cmd/go/internal/modload/init.go b/src/cmd/go/internal/modload/init.go -index 664a2a1594..2360feef04 100644 ---- a/src/cmd/go/internal/modload/init.go -+++ b/src/cmd/go/internal/modload/init.go -@@ -56,6 +56,12 @@ var ( - CmdModModule string // module argument for 'go mod init' - - allowMissingModuleImports bool -+ -+ // SilenceMissingStdImports indicates that LoadALL should not print an error -+ // or terminate the process if an imported package is missing, and the import -+ // path looks like it might be in the standard library (perhaps in a future -+ // Go version). -+ SilenceMissingStdImports bool - ) - - // ModFile returns the parsed go.mod file. -diff --git a/src/cmd/go/internal/modload/load.go b/src/cmd/go/internal/modload/load.go -index 30992e0cc2..e5ea1a6c23 100644 ---- a/src/cmd/go/internal/modload/load.go -+++ b/src/cmd/go/internal/modload/load.go -@@ -433,6 +433,11 @@ func loadAll(testAll bool) []string { - var paths []string - for _, pkg := range loaded.pkgs { - if pkg.err != nil { -+ if impErr := (*ImportMissingError)(nil); SilenceMissingStdImports && -+ errors.As(pkg.err, &impErr) && -+ search.IsStandardImportPath(impErr.Path) { -+ continue -+ } - base.Errorf("%s: %v", pkg.stackText(), pkg.err) - continue - } -diff --git a/src/cmd/go/testdata/script/mod_tidy_error.txt b/src/cmd/go/testdata/script/mod_tidy_error.txt -index b6c24ceaf7..395537b1a7 100644 ---- a/src/cmd/go/testdata/script/mod_tidy_error.txt -+++ b/src/cmd/go/testdata/script/mod_tidy_error.txt -@@ -4,12 +4,12 @@ env GO111MODULE=on - # 'go mod tidy' and 'go mod vendor' should not hide loading errors. - - ! go mod tidy --stderr '^issue27063 imports\n\tnonexist: package nonexist is not in GOROOT \(.*\)' -+! stderr 'package nonexist is not in GOROOT' - stderr '^issue27063 imports\n\tnonexist.example.com: cannot find module providing package nonexist.example.com' - stderr '^issue27063 imports\n\tissue27063/other imports\n\tother.example.com/nonexist: cannot find module providing package other.example.com/nonexist' - - ! go mod vendor --stderr '^issue27063 imports\n\tnonexist: package nonexist is not in GOROOT \(.*\)' -+! stderr 'package nonexist is not in GOROOT' - stderr '^issue27063 imports\n\tnonexist.example.com: cannot find module providing package nonexist.example.com' - stderr '^issue27063 imports\n\tissue27063/other imports\n\tother.example.com/nonexist: cannot find module providing package other.example.com/nonexist' - --- -2.27.0 - diff --git a/0083-syscall-os-exec-reject-environment-variables-contain.patch b/0023-syscall-os-exec-reject-environment-variables-contain.patch similarity index 68% rename from 0083-syscall-os-exec-reject-environment-variables-contain.patch rename to 0023-syscall-os-exec-reject-environment-variables-contain.patch index 0d0a7324c9a094c52037fd0d7b1685a23008578e..50c3d7566db0ccfd43deb45c407a21c9ac98bb4c 100644 --- a/0083-syscall-os-exec-reject-environment-variables-contain.patch +++ b/0023-syscall-os-exec-reject-environment-variables-contain.patch @@ -1,4 +1,4 @@ -From 6157e640af242fd239cf2ff79f1760da81e69e32 Mon Sep 17 00:00:00 2001 +From 0c539fa7a4a9d29252523e41e073198195ba6691 Mon Sep 17 00:00:00 2001 From: Damien Neil Date: Mon, 17 Oct 2022 17:38:29 -0700 Subject: [PATCH] syscall, os/exec: reject environment variables containing @@ -34,12 +34,13 @@ Run-TryBot: Matthew Dempsky Reviewed-by: Heschi Kreinick Reference: https://go-review.googlesource.com/c/go/+/446916 -Conflict: src/os/exec/exec.go +Conflict: src/os/exec/exec.go;src/syscall/exec_windows.go --- - src/os/exec/env_test.go | 19 +++++++++++++------ - src/os/exec/exec.go | 38 +++++++++++++++++++++++++++++++++----- - src/os/exec/exec_test.go | 9 +++++++++ - 3 files changed, 55 insertions(+), 11 deletions(-) + src/os/exec/env_test.go | 19 +++++++++++++------ + src/os/exec/exec.go | 38 ++++++++++++++++++++++++++++++++----- + src/os/exec/exec_test.go | 9 +++++++++ + src/syscall/exec_windows.go | 20 ++++++++++++++----- + 4 files changed, 70 insertions(+), 16 deletions(-) diff --git a/src/os/exec/env_test.go b/src/os/exec/env_test.go index b5ac398..47b7c04 100644 @@ -163,10 +164,10 @@ index 0c49575..6f5c61b 100644 + return env +} diff --git a/src/os/exec/exec_test.go b/src/os/exec/exec_test.go -index dafbc64..8cdecdb 100644 +index d854e0d..d03eab2 100644 --- a/src/os/exec/exec_test.go +++ b/src/os/exec/exec_test.go -@@ -1107,6 +1107,15 @@ func TestDedupEnvEcho(t *testing.T) { +@@ -1104,6 +1104,15 @@ func TestDedupEnvEcho(t *testing.T) { } } @@ -182,6 +183,66 @@ index dafbc64..8cdecdb 100644 func TestString(t *testing.T) { echoPath, err := exec.LookPath("echo") if err != nil { +diff --git a/src/syscall/exec_windows.go b/src/syscall/exec_windows.go +index 9d10d6a..50892be 100644 +--- a/src/syscall/exec_windows.go ++++ b/src/syscall/exec_windows.go +@@ -7,6 +7,7 @@ + package syscall + + import ( ++ "internal/bytealg" + "runtime" + "sync" + "unicode/utf16" +@@ -115,12 +116,16 @@ func makeCmdLine(args []string) string { + // the representation required by CreateProcess: a sequence of NUL + // terminated strings followed by a nil. + // Last bytes are two UCS-2 NULs, or four NUL bytes. +-func createEnvBlock(envv []string) *uint16 { ++// If any string contains a NUL, it returns (nil, EINVAL). ++func createEnvBlock(envv []string) (*uint16, error) { + if len(envv) == 0 { +- return &utf16.Encode([]rune("\x00\x00"))[0] ++ return &utf16.Encode([]rune("\x00\x00"))[0], nil + } + length := 0 + for _, s := range envv { ++ if bytealg.IndexByteString(s, 0) != -1 { ++ return nil, EINVAL ++ } + length += len(s) + 1 + } + length += 1 +@@ -135,7 +140,7 @@ func createEnvBlock(envv []string) *uint16 { + } + copy(b[i:i+1], []byte{0}) + +- return &utf16.Encode([]rune(string(b)))[0] ++ return &utf16.Encode([]rune(string(b)))[0], nil + } + + func CloseOnExec(fd Handle) { +@@ -400,12 +405,17 @@ func StartProcess(argv0 string, argv []string, attr *ProcAttr) (pid int, handle + } + } + ++ envBlock, err := createEnvBlock(attr.Env) ++ if err != nil { ++ return 0, 0, err ++ } ++ + pi := new(ProcessInformation) + flags := sys.CreationFlags | CREATE_UNICODE_ENVIRONMENT | _EXTENDED_STARTUPINFO_PRESENT + if sys.Token != 0 { +- err = CreateProcessAsUser(sys.Token, argv0p, argvp, sys.ProcessAttributes, sys.ThreadAttributes, willInheritHandles, flags, createEnvBlock(attr.Env), dirp, &si.StartupInfo, pi) ++ err = CreateProcessAsUser(sys.Token, argv0p, argvp, sys.ProcessAttributes, sys.ThreadAttributes, willInheritHandles, flags, envBlock, dirp, &si.StartupInfo, pi) + } else { +- err = CreateProcess(argv0p, argvp, sys.ProcessAttributes, sys.ThreadAttributes, willInheritHandles, flags, createEnvBlock(attr.Env), dirp, &si.StartupInfo, pi) ++ err = CreateProcess(argv0p, argvp, sys.ProcessAttributes, sys.ThreadAttributes, willInheritHandles, flags, envBlock, dirp, &si.StartupInfo, pi) + } + if err != nil { + return 0, 0, err -- 2.33.0 diff --git a/0024-release-branch.go1.18-add-definition-byte-string-cut.patch b/0024-release-branch.go1.18-add-definition-byte-string-cut.patch new file mode 100644 index 0000000000000000000000000000000000000000..7f2be9c2404a51742b917e8a5bc48cd9c29fcb19 --- /dev/null +++ b/0024-release-branch.go1.18-add-definition-byte-string-cut.patch @@ -0,0 +1,430 @@ +From 2a7b541156a736984296282b816beac3dead4e8e Mon Sep 17 00:00:00 2001 +From: root +Date: Fri, 16 Dec 2022 18:14:16 +0800 +Subject: [PATCH] xxx + +Conflict: NA +Reference:https://github.com/golang/go/commit/8e36ab055162efa6f67f3b9ee62f625ac8874901 + +--- + src/bytes/bytes.go | 14 ++++ + src/bytes/bytes_test.go | 23 ++++++ + src/bytes/example_test.go | 139 ++++++++++++++++++------------------ + src/strings/example_test.go | 58 +++++++++------ + src/strings/strings.go | 11 +++ + src/strings/strings_test.go | 25 ++++++- + 6 files changed, 179 insertions(+), 91 deletions(-) + +diff --git a/src/bytes/bytes.go b/src/bytes/bytes.go +index ce52649..50b43a4 100644 +--- a/src/bytes/bytes.go ++++ b/src/bytes/bytes.go +@@ -1174,3 +1174,17 @@ func Index(s, sep []byte) int { + } + return -1 + } ++ ++ ++// Cut slices s around the first instance of sep, ++// returning the text before and after sep. ++// The found result reports whether sep appears in s. ++// If sep does not appear in s, cut returns s, "", false. ++// ++// Cut returns slices of the original slice s, not copies. ++func Cut(s, sep []byte) (before, after []byte, found bool) { ++ if i := Index(s, sep); i >= 0 { ++ return s[:i], s[i+len(sep):], true ++ } ++ return s, nil, false ++} +diff --git a/src/bytes/bytes_test.go b/src/bytes/bytes_test.go +index 544ee46..538e613 100644 +--- a/src/bytes/bytes_test.go ++++ b/src/bytes/bytes_test.go +@@ -1565,6 +1565,29 @@ func TestEqualFold(t *testing.T) { + } + } + ++var cutTests = []struct { ++ s, sep string ++ before, after string ++ found bool ++}{ ++ {"abc", "b", "a", "c", true}, ++ {"abc", "a", "", "bc", true}, ++ {"abc", "c", "ab", "", true}, ++ {"abc", "abc", "", "", true}, ++ {"abc", "", "", "abc", true}, ++ {"abc", "d", "abc", "", false}, ++ {"", "d", "", "", false}, ++ {"", "", "", "", true}, ++} ++ ++func TestCut(t *testing.T) { ++ for _, tt := range cutTests { ++ if before, after, found := Cut([]byte(tt.s), []byte(tt.sep)); string(before) != tt.before || string(after) != tt.after || found != tt.found { ++ t.Errorf("Cut(%q, %q) = %q, %q, %v, want %q, %q, %v", tt.s, tt.sep, before, after, found, tt.before, tt.after, tt.found) ++ } ++ } ++} ++ + func TestBufferGrowNegative(t *testing.T) { + defer func() { + if err := recover(); err == nil { +diff --git a/src/bytes/example_test.go b/src/bytes/example_test.go +index ae93202..82de99d 100644 +--- a/src/bytes/example_test.go ++++ b/src/bytes/example_test.go +@@ -92,36 +92,6 @@ func ExampleCompare_search() { + } + } + +-func ExampleTrimSuffix() { +- var b = []byte("Hello, goodbye, etc!") +- b = bytes.TrimSuffix(b, []byte("goodbye, etc!")) +- b = bytes.TrimSuffix(b, []byte("gopher")) +- b = append(b, bytes.TrimSuffix([]byte("world!"), []byte("x!"))...) +- os.Stdout.Write(b) +- // Output: Hello, world! +-} +- +-func ExampleTrimPrefix() { +- var b = []byte("Goodbye,, world!") +- b = bytes.TrimPrefix(b, []byte("Goodbye,")) +- b = bytes.TrimPrefix(b, []byte("See ya,")) +- fmt.Printf("Hello%s", b) +- // Output: Hello, world! +-} +- +-func ExampleFields() { +- fmt.Printf("Fields are: %q", bytes.Fields([]byte(" foo bar baz "))) +- // Output: Fields are: ["foo" "bar" "baz"] +-} +- +-func ExampleFieldsFunc() { +- f := func(c rune) bool { +- return !unicode.IsLetter(c) && !unicode.IsNumber(c) +- } +- fmt.Printf("Fields are: %q", bytes.FieldsFunc([]byte(" foo1;bar2,baz3..."), f)) +- // Output: Fields are: ["foo1" "bar2" "baz3"] +-} +- + func ExampleContains() { + fmt.Println(bytes.Contains([]byte("seafood"), []byte("foo"))) + fmt.Println(bytes.Contains([]byte("seafood"), []byte("bar"))) +@@ -168,6 +138,22 @@ func ExampleCount() { + // 5 + } + ++func ExampleCut() { ++ show := func(s, sep string) { ++ before, after, found := bytes.Cut([]byte(s), []byte(sep)) ++ fmt.Printf("Cut(%q, %q) = %q, %q, %v\n", s, sep, before, after, found) ++ } ++ show("Gopher", "Go") ++ show("Gopher", "ph") ++ show("Gopher", "er") ++ show("Gopher", "Badger") ++ // Output: ++ // Cut("Gopher", "Go") = "", "pher", true ++ // Cut("Gopher", "ph") = "Go", "er", true ++ // Cut("Gopher", "er") = "Goph", "", true ++ // Cut("Gopher", "Badger") = "Gopher", "", false ++} ++ + func ExampleEqual() { + fmt.Println(bytes.Equal([]byte("Go"), []byte("Go"))) + fmt.Println(bytes.Equal([]byte("Go"), []byte("C++"))) +@@ -181,6 +167,19 @@ func ExampleEqualFold() { + // Output: true + } + ++func ExampleFields() { ++ fmt.Printf("Fields are: %q", bytes.Fields([]byte(" foo bar baz "))) ++ // Output: Fields are: ["foo" "bar" "baz"] ++} ++ ++func ExampleFieldsFunc() { ++ f := func(c rune) bool { ++ return !unicode.IsLetter(c) && !unicode.IsNumber(c) ++ } ++ fmt.Printf("Fields are: %q", bytes.FieldsFunc([]byte(" foo1;bar2,baz3..."), f)) ++ // Output: Fields are: ["foo1" "bar2" "baz3"] ++} ++ + func ExampleHasPrefix() { + fmt.Println(bytes.HasPrefix([]byte("Gopher"), []byte("Go"))) + fmt.Println(bytes.HasPrefix([]byte("Gopher"), []byte("C"))) +@@ -246,6 +245,12 @@ func ExampleIndexRune() { + // -1 + } + ++func ExampleJoin() { ++ s := [][]byte{[]byte("foo"), []byte("bar"), []byte("baz")} ++ fmt.Printf("%s", bytes.Join(s, []byte(", "))) ++ // Output: foo, bar, baz ++} ++ + func ExampleLastIndex() { + fmt.Println(bytes.Index([]byte("go gopher"), []byte("go"))) + fmt.Println(bytes.LastIndex([]byte("go gopher"), []byte("go"))) +@@ -286,10 +291,12 @@ func ExampleLastIndexFunc() { + // -1 + } + +-func ExampleJoin() { +- s := [][]byte{[]byte("foo"), []byte("bar"), []byte("baz")} +- fmt.Printf("%s", bytes.Join(s, []byte(", "))) +- // Output: foo, bar, baz ++func ExampleReader_Len() { ++ fmt.Println(bytes.NewReader([]byte("Hi!")).Len()) ++ fmt.Println(bytes.NewReader([]byte("こんにちは!")).Len()) ++ // Output: ++ // 3 ++ // 16 + } + + func ExampleRepeat() { +@@ -399,20 +406,6 @@ func ExampleTrimFunc() { + // go-gopher! + } + +-func ExampleMap() { +- rot13 := func(r rune) rune { +- switch { +- case r >= 'A' && r <= 'Z': +- return 'A' + (r-'A'+13)%26 +- case r >= 'a' && r <= 'z': +- return 'a' + (r-'a'+13)%26 +- } +- return r +- } +- fmt.Printf("%s", bytes.Map(rot13, []byte("'Twas brillig and the slithy gopher..."))) +- // Output: 'Gjnf oevyyvt naq gur fyvgul tbcure... +-} +- + func ExampleTrimLeft() { + fmt.Print(string(bytes.TrimLeft([]byte("453gopher8257"), "0123456789"))) + // Output: +@@ -429,11 +422,28 @@ func ExampleTrimLeftFunc() { + // go-gopher!567 + } + ++func ExampleTrimPrefix() { ++ var b = []byte("Goodbye,, world!") ++ b = bytes.TrimPrefix(b, []byte("Goodbye,")) ++ b = bytes.TrimPrefix(b, []byte("See ya,")) ++ fmt.Printf("Hello%s", b) ++ // Output: Hello, world! ++} ++ + func ExampleTrimSpace() { + fmt.Printf("%s", bytes.TrimSpace([]byte(" \t\n a lone gopher \n\t\r\n"))) + // Output: a lone gopher + } + ++func ExampleTrimSuffix() { ++ var b = []byte("Hello, goodbye, etc!") ++ b = bytes.TrimSuffix(b, []byte("goodbye, etc!")) ++ b = bytes.TrimSuffix(b, []byte("gopher")) ++ b = append(b, bytes.TrimSuffix([]byte("world!"), []byte("x!"))...) ++ os.Stdout.Write(b) ++ // Output: Hello, world! ++} ++ + func ExampleTrimRight() { + fmt.Print(string(bytes.TrimRight([]byte("453gopher8257"), "0123456789"))) + // Output: +@@ -450,21 +460,6 @@ func ExampleTrimRightFunc() { + // 1234go-gopher! + } + +-func ExampleToUpper() { +- fmt.Printf("%s", bytes.ToUpper([]byte("Gopher"))) +- // Output: GOPHER +-} +- +-func ExampleToUpperSpecial() { +- str := []byte("ahoj vývojári golang") +- totitle := bytes.ToUpperSpecial(unicode.AzeriCase, str) +- fmt.Println("Original : " + string(str)) +- fmt.Println("ToUpper : " + string(totitle)) +- // Output: +- // Original : ahoj vývojári golang +- // ToUpper : AHOJ VÝVOJÁRİ GOLANG +-} +- + func ExampleToLower() { + fmt.Printf("%s", bytes.ToLower([]byte("Gopher"))) + // Output: gopher +@@ -480,10 +475,16 @@ func ExampleToLowerSpecial() { + // ToLower : ahoj vývojári golang + } + +-func ExampleReader_Len() { +- fmt.Println(bytes.NewReader([]byte("Hi!")).Len()) +- fmt.Println(bytes.NewReader([]byte("こんにちは!")).Len()) +- // Output: +- // 3 +- // 16 ++func ExampleToUpper() { ++ fmt.Printf("%s", bytes.ToUpper([]byte("Gopher"))) ++ // Output: GOPHER ++} ++ ++func ExampleToUpperSpecial() { ++ str := []byte("ahoj vyvojári golang") ++ totitle := bytes.ToUpperSpecial(unicode.AzeriCase, str) ++ fmt.Println("Original : " + string(str)) ++ fmt.Println("ToUpper : " + string(totitle)) ++ // Original : ahoj vyvojári golang ++ // ToUpper : AHOJ VYVOJáR? GOLANG + } +diff --git a/src/strings/example_test.go b/src/strings/example_test.go +index 375f9ca..b75424a 100644 +--- a/src/strings/example_test.go ++++ b/src/strings/example_test.go +@@ -9,18 +9,15 @@ import ( + "strings" + "unicode" + ) +- +-func ExampleFields() { +- fmt.Printf("Fields are: %q", strings.Fields(" foo bar baz ")) +- // Output: Fields are: ["foo" "bar" "baz"] +-} +- +-func ExampleFieldsFunc() { +- f := func(c rune) bool { +- return !unicode.IsLetter(c) && !unicode.IsNumber(c) ++func ExampleBuilder() { ++ var b strings.Builder ++ for i := 3; i >= 1; i-- { ++ fmt.Fprintf(&b, "%d...", i) + } +- fmt.Printf("Fields are: %q", strings.FieldsFunc(" foo1;bar2,baz3...", f)) +- // Output: Fields are: ["foo1" "bar2" "baz3"] ++ b.WriteString("ignition") ++ fmt.Println(b.String()) ++ ++ // Output: 3...2...1...ignition + } + + func ExampleCompare() { +@@ -79,11 +76,40 @@ func ExampleCount() { + // 5 + } + ++func ExampleCut() { ++ show := func(s, sep string) { ++ before, after, found := strings.Cut(s, sep) ++ fmt.Printf("Cut(%q, %q) = %q, %q, %v\n", s, sep, before, after, found) ++ } ++ show("Gopher", "Go") ++ show("Gopher", "ph") ++ show("Gopher", "er") ++ show("Gopher", "Badger") ++ // Output: ++ // Cut("Gopher", "Go") = "", "pher", true ++ // Cut("Gopher", "ph") = "Go", "er", true ++ // Cut("Gopher", "er") = "Goph", "", true ++ // Cut("Gopher", "Badger") = "Gopher", "", false ++} ++ + func ExampleEqualFold() { + fmt.Println(strings.EqualFold("Go", "go")) + // Output: true + } + ++func ExampleFields() { ++ fmt.Printf("Fields are: %q", strings.Fields(" foo bar baz ")) ++ // Output: Fields are: ["foo" "bar" "baz"] ++} ++ ++func ExampleFieldsFunc() { ++ f := func(c rune) bool { ++ return !unicode.IsLetter(c) && !unicode.IsNumber(c) ++ } ++ fmt.Printf("Fields are: %q", strings.FieldsFunc(" foo1;bar2,baz3...", f)) ++ // Output: Fields are: ["foo1" "bar2" "baz3"] ++} ++ + func ExampleHasPrefix() { + fmt.Println(strings.HasPrefix("Gopher", "Go")) + fmt.Println(strings.HasPrefix("Gopher", "C")) +@@ -370,14 +396,3 @@ func ExampleTrimRightFunc() { + })) + // Output: ¡¡¡Hello, Gophers + } +- +-func ExampleBuilder() { +- var b strings.Builder +- for i := 3; i >= 1; i-- { +- fmt.Fprintf(&b, "%d...", i) +- } +- b.WriteString("ignition") +- fmt.Println(b.String()) +- +- // Output: 3...2...1...ignition +-} +diff --git a/src/strings/strings.go b/src/strings/strings.go +index b429735..0c94395 100644 +--- a/src/strings/strings.go ++++ b/src/strings/strings.go +@@ -1100,3 +1100,14 @@ func Index(s, substr string) int { + } + return -1 + } ++ ++// Cut slices s around the first instance of sep, ++// returning the text before and after sep. ++// The found result reports whether sep appears in s. ++// If sep does not appear in s, cut returns s, "", false. ++func Cut(s, sep string) (before, after string, found bool) { ++ if i := Index(s, sep); i >= 0 { ++ return s[:i], s[i+len(sep):], true ++ } ++ return s, "", false ++} +diff --git a/src/strings/strings_test.go b/src/strings/strings_test.go +index 09e5b27..1ebce42 100644 +--- a/src/strings/strings_test.go ++++ b/src/strings/strings_test.go +@@ -1577,11 +1577,34 @@ var CountTests = []struct { + func TestCount(t *testing.T) { + for _, tt := range CountTests { + if num := Count(tt.s, tt.sep); num != tt.num { +- t.Errorf("Count(\"%s\", \"%s\") = %d, want %d", tt.s, tt.sep, num, tt.num) ++ t.Errorf("Count(%q, %q) = %d, want %d", tt.s, tt.sep, num, tt.num) + } + } + } + ++var cutTests = []struct { ++ s, sep string ++ before, after string ++ found bool ++}{ ++ {"abc", "b", "a", "c", true}, ++ {"abc", "a", "", "bc", true}, ++ {"abc", "c", "ab", "", true}, ++ {"abc", "abc", "", "", true}, ++ {"abc", "", "", "abc", true}, ++ {"abc", "d", "abc", "", false}, ++ {"", "d", "", "", false}, ++ {"", "", "", "", true}, ++} ++ ++func TestCut(t *testing.T) { ++ for _, tt := range cutTests { ++ if before, after, found := Cut(tt.s, tt.sep); before != tt.before || after != tt.after || found != tt.found { ++ t.Errorf("Cut(%q, %q) = %q, %q, %v, want %q, %q, %v", tt.s, tt.sep, before, after, found, tt.before, tt.after, tt.found) ++ } ++ } ++} ++ + func makeBenchInputHard() string { + tokens := [...]string{ + "", "

", "", "", +-- +2.27.0 diff --git a/0025-release-branch.go1.15-cmd-go-internal-modfetch-detec.patch b/0025-release-branch.go1.15-cmd-go-internal-modfetch-detec.patch deleted file mode 100644 index 9cf8ece8a9977690bf4cb9ecb8940397779d3f13..0000000000000000000000000000000000000000 --- a/0025-release-branch.go1.15-cmd-go-internal-modfetch-detec.patch +++ /dev/null @@ -1,310 +0,0 @@ -From 7038a380bcd0183842471c1984da491e044d3d34 Mon Sep 17 00:00:00 2001 -From: Jay Conrod -Date: Wed, 3 Mar 2021 16:30:22 -0500 -Subject: [PATCH 25/44] [release-branch.go1.15] cmd/go/internal/modfetch: - detect and recover from missing ziphash file - -Previously, if an extracted module directory existed in the module -cache, but the corresponding ziphash file did not, if the sum was -missing from go.sum, we would not verify the sum. This caused 'go get' -not to write missing sums. 'go build' in readonly mode (now the -default) checks for missing sums and doesn't attempt to fetch modules -that can't be verified against go.sum. - -With this change, when requesting the module directory with -modfetch.DownloadDir, if the ziphash file is missing, the go command -will re-hash the zip without downloading or re-extracting it again. - -Note that the go command creates the ziphash file before the module -directory, but another program could remove it separately, and it -might not be present after a crash. - -Fixes #44872 - -Change-Id: I64551e048a3ba17d069de1ec123d5b8b2757543c -Reviewed-on: https://go-review.googlesource.com/c/go/+/298352 -Trust: Jay Conrod -Run-TryBot: Jay Conrod -TryBot-Result: Go Bot -Reviewed-by: Bryan C. Mills -(cherry picked from commit 302a400316319501748c0f034464fa70e7815272) -Reviewed-on: https://go-review.googlesource.com/c/go/+/299830 - -Conflict:NA -Reference:https://github.com/golang/go/commit/7038a380bcd0183842471c1984da491e044d3d34 - ---- - src/cmd/go/internal/modfetch/cache.go | 17 ++++ - src/cmd/go/internal/modfetch/fetch.go | 77 ++++++++++++------- - .../script/mod_get_missing_ziphash.txt | 55 +++++++++++++ - src/cmd/go/testdata/script/mod_verify.txt | 7 +- - 4 files changed, 125 insertions(+), 31 deletions(-) - create mode 100644 src/cmd/go/testdata/script/mod_get_missing_ziphash.txt - -diff --git a/src/cmd/go/internal/modfetch/cache.go b/src/cmd/go/internal/modfetch/cache.go -index e3074b775e..0b64a6943b 100644 ---- a/src/cmd/go/internal/modfetch/cache.go -+++ b/src/cmd/go/internal/modfetch/cache.go -@@ -83,6 +83,7 @@ func DownloadDir(m module.Version) (string, error) { - return "", err - } - -+ // Check whether the directory itself exists. - dir := filepath.Join(cfg.GOMODCACHE, enc+"@"+encVer) - if fi, err := os.Stat(dir); os.IsNotExist(err) { - return dir, err -@@ -91,6 +92,9 @@ func DownloadDir(m module.Version) (string, error) { - } else if !fi.IsDir() { - return dir, &DownloadDirPartialError{dir, errors.New("not a directory")} - } -+ -+ // Check if a .partial file exists. This is created at the beginning of -+ // a download and removed after the zip is extracted. - partialPath, err := CachePath(m, "partial") - if err != nil { - return dir, err -@@ -100,6 +104,19 @@ func DownloadDir(m module.Version) (string, error) { - } else if !os.IsNotExist(err) { - return dir, err - } -+ -+ // Check if a .ziphash file exists. It should be created before the -+ // zip is extracted, but if it was deleted (by another program?), we need -+ // to re-calculate it. -+ ziphashPath, err := CachePath(m, "ziphash") -+ if err != nil { -+ return dir, err -+ } -+ if _, err := os.Stat(ziphashPath); os.IsNotExist(err) { -+ return dir, &DownloadDirPartialError{dir, errors.New("ziphash file is missing")} -+ } else if err != nil { -+ return dir, err -+ } - return dir, nil - } - -diff --git a/src/cmd/go/internal/modfetch/fetch.go b/src/cmd/go/internal/modfetch/fetch.go -index fd7a5cef83..6a6c972157 100644 ---- a/src/cmd/go/internal/modfetch/fetch.go -+++ b/src/cmd/go/internal/modfetch/fetch.go -@@ -206,13 +206,16 @@ func DownloadZip(mod module.Version) (zipfile string, err error) { - if err != nil { - return cached{"", err} - } -+ ziphashfile := zipfile + "hash" - -- // Skip locking if the zipfile already exists. -+ // Return without locking if the zip and ziphash files exist. - if _, err := os.Stat(zipfile); err == nil { -- return cached{zipfile, nil} -+ if _, err := os.Stat(ziphashfile); err == nil { -+ return cached{zipfile, nil} -+ } - } - -- // The zip file does not exist. Acquire the lock and create it. -+ // The zip or ziphash file does not exist. Acquire the lock and create them. - if cfg.CmdName != "mod download" { - fmt.Fprintf(os.Stderr, "go: downloading %s %s\n", mod.Path, mod.Version) - } -@@ -222,14 +225,6 @@ func DownloadZip(mod module.Version) (zipfile string, err error) { - } - defer unlock() - -- // Double-check that the zipfile was not created while we were waiting for -- // the lock. -- if _, err := os.Stat(zipfile); err == nil { -- return cached{zipfile, nil} -- } -- if err := os.MkdirAll(filepath.Dir(zipfile), 0777); err != nil { -- return cached{"", err} -- } - if err := downloadZip(mod, zipfile); err != nil { - return cached{"", err} - } -@@ -239,6 +234,25 @@ func DownloadZip(mod module.Version) (zipfile string, err error) { - } - - func downloadZip(mod module.Version, zipfile string) (err error) { -+ // Double-check that the zipfile was not created while we were waiting for -+ // the lock in DownloadZip. -+ ziphashfile := zipfile + "hash" -+ var zipExists, ziphashExists bool -+ if _, err := os.Stat(zipfile); err == nil { -+ zipExists = true -+ } -+ if _, err := os.Stat(ziphashfile); err == nil { -+ ziphashExists = true -+ } -+ if zipExists && ziphashExists { -+ return nil -+ } -+ -+ // Create parent directories. -+ if err := os.MkdirAll(filepath.Dir(zipfile), 0777); err != nil { -+ return err -+ } -+ - // Clean up any remaining tempfiles from previous runs. - // This is only safe to do because the lock file ensures that their - // writers are no longer active. -@@ -250,6 +264,12 @@ func downloadZip(mod module.Version, zipfile string) (err error) { - } - } - -+ // If the zip file exists, the ziphash file must have been deleted -+ // or lost after a file system crash. Re-hash the zip without downloading. -+ if zipExists { -+ return hashZip(mod, zipfile, ziphashfile) -+ } -+ - // From here to the os.Rename call below is functionally almost equivalent to - // renameio.WriteToFile, with one key difference: we want to validate the - // contents of the file (by hashing it) before we commit it. Because the file -@@ -306,15 +326,7 @@ func downloadZip(mod module.Version, zipfile string) (err error) { - } - - // Hash the zip file and check the sum before renaming to the final location. -- hash, err := dirhash.HashZip(f.Name(), dirhash.DefaultHash) -- if err != nil { -- return err -- } -- if err := checkModSum(mod, hash); err != nil { -- return err -- } -- -- if err := renameio.WriteFile(zipfile+"hash", []byte(hash), 0666); err != nil { -+ if err := hashZip(mod, f.Name(), ziphashfile); err != nil { - return err - } - if err := os.Rename(f.Name(), zipfile); err != nil { -@@ -326,6 +338,22 @@ func downloadZip(mod module.Version, zipfile string) (err error) { - return nil - } - -+// hashZip reads the zip file opened in f, then writes the hash to ziphashfile, -+// overwriting that file if it exists. -+// -+// If the hash does not match go.sum (or the sumdb if enabled), hashZip returns -+// an error and does not write ziphashfile. -+func hashZip(mod module.Version, zipfile, ziphashfile string) error { -+ hash, err := dirhash.HashZip(zipfile, dirhash.DefaultHash) -+ if err != nil { -+ return err -+ } -+ if err := checkModSum(mod, hash); err != nil { -+ return err -+ } -+ return renameio.WriteFile(ziphashfile, []byte(hash), 0666) -+} -+ - // makeDirsReadOnly makes a best-effort attempt to remove write permissions for dir - // and its transitive contents. - func makeDirsReadOnly(dir string) { -@@ -457,11 +485,6 @@ func readGoSum(dst map[module.Version][]string, file string, data []byte) error - - // checkMod checks the given module's checksum. - func checkMod(mod module.Version) { -- if cfg.GOMODCACHE == "" { -- // Do not use current directory. -- return -- } -- - // Do the file I/O before acquiring the go.sum lock. - ziphash, err := CachePath(mod, "ziphash") - if err != nil { -@@ -469,10 +492,6 @@ func checkMod(mod module.Version) { - } - data, err := renameio.ReadFile(ziphash) - if err != nil { -- if errors.Is(err, os.ErrNotExist) { -- // This can happen if someone does rm -rf GOPATH/src/cache/download. So it goes. -- return -- } - base.Fatalf("verifying %v", module.VersionError(mod, err)) - } - h := strings.TrimSpace(string(data)) -diff --git a/src/cmd/go/testdata/script/mod_get_missing_ziphash.txt b/src/cmd/go/testdata/script/mod_get_missing_ziphash.txt -new file mode 100644 -index 0000000000..afb5d2e844 ---- /dev/null -+++ b/src/cmd/go/testdata/script/mod_get_missing_ziphash.txt -@@ -0,0 +1,55 @@ -+# Test that if the module cache contains an extracted source directory but not -+# a ziphash, 'go build' complains about a missing sum, and 'go get' adds -+# the sum. Verifies #44749. -+ -+# With a tidy go.sum, go build succeeds. This also populates the module cache. -+cp go.sum.tidy go.sum -+go build -n use -+env GOPROXY=off -+env GOSUMDB=off -+ -+# Control case: if we delete the hash for rsc.io/quote v1.5.2, -+# 'go build' reports an error. 'go get' adds the sum. -+cp go.sum.bug go.sum -+! go build -n -mod=readonly use -+stderr '^go: updates to go.sum needed, disabled by -mod=readonly$' -+go get -d use -+cmp go.sum go.sum.tidy -+go build -n use -+ -+# If we delete the hash *and* the ziphash file, we should see the same behavior. -+cp go.sum.bug go.sum -+rm $WORK/gopath/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.ziphash -+! go build -n -mod=readonly use -+stderr '^go: updates to go.sum needed, disabled by -mod=readonly$' -+go get -d use -+cmp go.sum go.sum.tidy -+go build -n use -+ -+-- go.mod -- -+module use -+ -+go 1.17 -+ -+require rsc.io/quote v1.5.2 -+-- go.sum.tidy -- -+golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c h1:pvCbr/wm8HzDD3fVywevekufpn6tCGPY3spdHeZJEsw= -+golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -+rsc.io/quote v1.5.2 h1:3fEykkD9k7lYzXqCYrwGAf7iNhbk4yCjHmKBN9td4L0= -+rsc.io/quote v1.5.2/go.mod h1:LzX7hefJvL54yjefDEDHNONDjII0t9xZLPXsUe+TKr0= -+rsc.io/sampler v1.3.0 h1:HLGR/BgEtI3r0uymSP/nl2uPLsUnNJX8toRyhfpBTII= -+rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= -+rsc.io/testonly v1.0.0 h1:K/VWHdO+Jv7woUXG0GzVNx1czBXUt3Ib1deaMn+xk64= -+rsc.io/testonly v1.0.0/go.mod h1:OqmGbIFOcF+XrFReLOGZ6BhMM7uMBiQwZsyNmh74SzY= -+-- go.sum.bug -- -+golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c h1:pvCbr/wm8HzDD3fVywevekufpn6tCGPY3spdHeZJEsw= -+golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -+rsc.io/quote v1.5.2/go.mod h1:LzX7hefJvL54yjefDEDHNONDjII0t9xZLPXsUe+TKr0= -+rsc.io/sampler v1.3.0 h1:HLGR/BgEtI3r0uymSP/nl2uPLsUnNJX8toRyhfpBTII= -+rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= -+rsc.io/testonly v1.0.0 h1:K/VWHdO+Jv7woUXG0GzVNx1czBXUt3Ib1deaMn+xk64= -+rsc.io/testonly v1.0.0/go.mod h1:OqmGbIFOcF+XrFReLOGZ6BhMM7uMBiQwZsyNmh74SzY= -+-- use.go -- -+package use -+ -+import _ "rsc.io/quote" -diff --git a/src/cmd/go/testdata/script/mod_verify.txt b/src/cmd/go/testdata/script/mod_verify.txt -index 646bc62bb7..7163d1a64b 100644 ---- a/src/cmd/go/testdata/script/mod_verify.txt -+++ b/src/cmd/go/testdata/script/mod_verify.txt -@@ -50,10 +50,13 @@ go mod tidy - grep '^rsc.io/quote v1.1.0/go.mod ' go.sum - grep '^rsc.io/quote v1.1.0 ' go.sum - --# sync should ignore missing ziphash; verify should not -+# verify should fail on a missing ziphash. tidy should restore it. - rm $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.1.0.ziphash --go mod tidy - ! go mod verify -+stderr '^rsc.io/quote v1.1.0: missing ziphash: open '$GOPATH'[/\\]pkg[/\\]mod[/\\]cache[/\\]download[/\\]rsc.io[/\\]quote[/\\]@v[/\\]v1.1.0.ziphash' -+go mod tidy -+exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.1.0.ziphash -+go mod verify - - # Packages below module root should not be mentioned in go.sum. - rm go.sum --- -2.27.0 - diff --git a/0026-release-branch.go1.15-cmd-link-generate-trampoline-f.patch b/0026-release-branch.go1.15-cmd-link-generate-trampoline-f.patch deleted file mode 100644 index 5a6ef3e1bd21455e52c202c17cfe25b02076c724..0000000000000000000000000000000000000000 --- a/0026-release-branch.go1.15-cmd-link-generate-trampoline-f.patch +++ /dev/null @@ -1,133 +0,0 @@ -From 7c88ae4117c16c1e5b80189b81d67845e1c40d9d Mon Sep 17 00:00:00 2001 -From: Cherry Zhang -Date: Tue, 16 Feb 2021 10:20:58 -0500 -Subject: [PATCH 26/44] [release-branch.go1.15] cmd/link: generate trampoline - for inter-dependent packages - -Currently, in the trampoline generation pass we expect packages -are laid out in dependency order, so a cross-package jump always -has a known target address so we can check if a trampoline is -needed. With linknames, there can be cycles in the package -dependency graph, making this algorithm no longer work. For them, -as the target address is unkown we conservatively generate a -trampoline. This may generate unnecessary trampolines (if the -packages turn out laid together), but package cycles are extremely -rare so this is fine. - -Updates #44639. -Fixes #44748. - -Change-Id: I2dc2998edacbda27d726fc79452313a21d07787a -Reviewed-on: https://go-review.googlesource.com/c/go/+/292490 -Trust: Cherry Zhang -Reviewed-by: Than McIntosh -(cherry picked from commit 098504c73ff6ece19566a1ac811ceed73be7c81d) -Reviewed-on: https://go-review.googlesource.com/c/go/+/298030 -Run-TryBot: Cherry Zhang -TryBot-Result: Go Bot - -Conflict:NA -Reference:https://github.com/golang/go/commit/7c88ae4117c16c1e5b80189b81d67845e1c40d9d - ---- - src/cmd/link/internal/arm/asm.go | 16 +++++++++++----- - src/cmd/link/internal/ld/data.go | 12 +++++------- - src/cmd/link/internal/ppc64/asm.go | 12 +++++++++--- - 3 files changed, 25 insertions(+), 15 deletions(-) - -diff --git a/src/cmd/link/internal/arm/asm.go b/src/cmd/link/internal/arm/asm.go -index 903e62108e..43643341d2 100644 ---- a/src/cmd/link/internal/arm/asm.go -+++ b/src/cmd/link/internal/arm/asm.go -@@ -373,10 +373,16 @@ func trampoline(ctxt *ld.Link, ldr *loader.Loader, ri int, rs, s loader.Sym) { - r := relocs.At2(ri) - switch r.Type() { - case objabi.R_CALLARM: -- // r.Add is the instruction -- // low 24-bit encodes the target address -- t := (ldr.SymValue(rs) + int64(signext24(r.Add()&0xffffff)*4) - (ldr.SymValue(s) + int64(r.Off()))) / 4 -- if t > 0x7fffff || t < -0x800000 || (*ld.FlagDebugTramp > 1 && ldr.SymPkg(s) != ldr.SymPkg(rs)) { -+ var t int64 -+ // ldr.SymValue(rs) == 0 indicates a cross-package jump to a function that is not yet -+ // laid out. Conservatively use a trampoline. This should be rare, as we lay out packages -+ // in dependency order. -+ if ldr.SymValue(rs) != 0 { -+ // r.Add is the instruction -+ // low 24-bit encodes the target address -+ t = (ldr.SymValue(rs) + int64(signext24(r.Add()&0xffffff)*4) - (ldr.SymValue(s) + int64(r.Off()))) / 4 -+ } -+ if t > 0x7fffff || t < -0x800000 || ldr.SymValue(rs) == 0 || (*ld.FlagDebugTramp > 1 && ldr.SymPkg(s) != ldr.SymPkg(rs)) { - // direct call too far, need to insert trampoline. - // look up existing trampolines first. if we found one within the range - // of direct call, we can reuse it. otherwise create a new one. -@@ -447,7 +453,7 @@ func gentramp(arch *sys.Arch, linkmode ld.LinkMode, ldr *loader.Loader, tramp *l - arch.ByteOrder.PutUint32(P[8:], o3) - tramp.SetData(P) - -- if linkmode == ld.LinkExternal { -+ if linkmode == ld.LinkExternal || ldr.SymValue(target) == 0 { - r := loader.Reloc{ - Off: 8, - Type: objabi.R_ADDR, -diff --git a/src/cmd/link/internal/ld/data.go b/src/cmd/link/internal/ld/data.go -index d3f308c8fa..2b55a5f6fc 100644 ---- a/src/cmd/link/internal/ld/data.go -+++ b/src/cmd/link/internal/ld/data.go -@@ -105,14 +105,12 @@ func trampoline(ctxt *Link, s loader.Sym) { - } - rs = ldr.ResolveABIAlias(rs) - if ldr.SymValue(rs) == 0 && (ldr.SymType(rs) != sym.SDYNIMPORT && ldr.SymType(rs) != sym.SUNDEFEXT) { -- if ldr.SymPkg(rs) != ldr.SymPkg(s) { -- if !isRuntimeDepPkg(ldr.SymPkg(s)) || !isRuntimeDepPkg(ldr.SymPkg(rs)) { -- ctxt.Errorf(s, "unresolved inter-package jump to %s(%s) from %s", ldr.SymName(rs), ldr.SymPkg(rs), ldr.SymPkg(s)) -- } -- // runtime and its dependent packages may call to each other. -- // they are fine, as they will be laid down together. -+ if ldr.SymPkg(rs) == ldr.SymPkg(s) { -+ continue // symbols in the same package are laid out together -+ } -+ if isRuntimeDepPkg(ldr.SymPkg(s)) && isRuntimeDepPkg(ldr.SymPkg(rs)) { -+ continue // runtime packages are laid out together - } -- continue - } - - thearch.Trampoline(ctxt, ldr, ri, rs, s) -diff --git a/src/cmd/link/internal/ppc64/asm.go b/src/cmd/link/internal/ppc64/asm.go -index b1c0873d7a..a3ecd43f89 100644 ---- a/src/cmd/link/internal/ppc64/asm.go -+++ b/src/cmd/link/internal/ppc64/asm.go -@@ -672,13 +672,19 @@ func trampoline(ctxt *ld.Link, ldr *loader.Loader, ri int, rs, s loader.Sym) { - - relocs := ldr.Relocs(s) - r := relocs.At2(ri) -- t := ldr.SymValue(rs) + r.Add() - (ldr.SymValue(s) + int64(r.Off())) -+ var t int64 -+ // ldr.SymValue(rs) == 0 indicates a cross-package jump to a function that is not yet -+ // laid out. Conservatively use a trampoline. This should be rare, as we lay out packages -+ // in dependency order. -+ if ldr.SymValue(rs) != 0 { -+ t = ldr.SymValue(rs) + r.Add() - (ldr.SymValue(s) + int64(r.Off())) -+ } - switch r.Type() { - case objabi.R_CALLPOWER: - - // If branch offset is too far then create a trampoline. - -- if (ctxt.IsExternal() && ldr.SymSect(s) != ldr.SymSect(rs)) || (ctxt.IsInternal() && int64(int32(t<<6)>>6) != t) || (*ld.FlagDebugTramp > 1 && ldr.SymPkg(s) != ldr.SymPkg(rs)) { -+ if (ctxt.IsExternal() && ldr.SymSect(s) != ldr.SymSect(rs)) || (ctxt.IsInternal() && int64(int32(t<<6)>>6) != t) || ldr.SymValue(rs) == 0 || (*ld.FlagDebugTramp > 1 && ldr.SymPkg(s) != ldr.SymPkg(rs)) { - var tramp loader.Sym - for i := 0; ; i++ { - -@@ -769,7 +775,7 @@ func gentramp(ctxt *ld.Link, ldr *loader.Loader, tramp *loader.SymbolBuilder, ta - - // With external linking, the target address must be - // relocated using LO and HA -- if ctxt.IsExternal() { -+ if ctxt.IsExternal() || ldr.SymValue(target) == 0 { - r := loader.Reloc{ - Off: 0, - Type: objabi.R_ADDRPOWER, --- -2.27.0 - diff --git a/0027-release-branch.go1.15-net-http-update-bundled-x-net-.patch b/0027-release-branch.go1.15-net-http-update-bundled-x-net-.patch deleted file mode 100644 index a6196290d6d9d2208dd93a4a153e444521f788b7..0000000000000000000000000000000000000000 --- a/0027-release-branch.go1.15-net-http-update-bundled-x-net-.patch +++ /dev/null @@ -1,49 +0,0 @@ -From 69b943102868747ff2b62d9ada02c464d9984aef Mon Sep 17 00:00:00 2001 -From: Dmitri Shuralyov -Date: Mon, 29 Mar 2021 11:19:23 -0400 -Subject: [PATCH 27/44] [release-branch.go1.15] net/http: update bundled - x/net/http2 - -Bring in the change in CL 304309 with: - - go mod edit -replace=golang.org/x/net=golang.org/x/net@release-branch.go1.15-bundle - GOFLAGS='-mod=mod' go generate -run=bundle std - go mod edit -dropreplace=golang.org/x/net - go get -d golang.org/x/net@release-branch.go1.15 - go mod tidy - go mod vendor - -For #45076. -Updates #40213. - -Change-Id: I68d5e1f2394508c9cf8627fb852dd9e906d45016 -Reviewed-on: https://go-review.googlesource.com/c/go/+/305489 -Trust: Dmitri Shuralyov -Trust: Emmanuel Odeke -Run-TryBot: Dmitri Shuralyov -Reviewed-by: Emmanuel Odeke -TryBot-Result: Go Bot - -Conflict:NA -Reference:https://github.com/golang/go/commit/69b943102868747ff2b62d9ada02c464d9984aef - ---- - src/net/http/h2_bundle.go | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/src/net/http/h2_bundle.go b/src/net/http/h2_bundle.go -index 678c6eb9d4..3d83084702 100644 ---- a/src/net/http/h2_bundle.go -+++ b/src/net/http/h2_bundle.go -@@ -8985,6 +8985,8 @@ func http2strSliceContains(ss []string, s string) bool { - - type http2erringRoundTripper struct{ err error } - -+func (rt http2erringRoundTripper) RoundTripErr() error { return rt.err } -+ - func (rt http2erringRoundTripper) RoundTrip(*Request) (*Response, error) { return nil, rt.err } - - // gzipReader wraps a response body so it can lazily --- -2.27.0 - diff --git a/0028-release-branch.go1.15-net-http-fix-detection-of-Roun.patch b/0028-release-branch.go1.15-net-http-fix-detection-of-Roun.patch deleted file mode 100644 index ecd987ac95779268059a530e49ff52765ec4515f..0000000000000000000000000000000000000000 --- a/0028-release-branch.go1.15-net-http-fix-detection-of-Roun.patch +++ /dev/null @@ -1,81 +0,0 @@ -From be872812063f29e9c0d280fb37289d40330d96db Mon Sep 17 00:00:00 2001 -From: Michael Fraenkel -Date: Thu, 16 Jul 2020 21:30:12 -0600 -Subject: [PATCH 28/44] [release-branch.go1.15] net/http: fix detection of - Roundtrippers that always error - -CL 220905 added code to identify alternate transports that always error -by using http2erringRoundTripper. This does not work when the transport -is from another package, e.g., http2.erringRoundTripper. -Expose a new method that allow detection of such a RoundTripper. -Switch to an interface that is both a RoundTripper and can return the -underlying error. - -Fixes #45076. -Updates #40213. - -Change-Id: I170739857ab9e99dffb5fa55c99b24b23c2f9c54 -Reviewed-on: https://go-review.googlesource.com/c/go/+/243258 -Reviewed-by: Emmanuel Odeke -Run-TryBot: Emmanuel Odeke -TryBot-Result: Gobot Gobot -Reviewed-on: https://go-review.googlesource.com/c/go/+/304210 -Trust: Dmitri Shuralyov -Trust: Emmanuel Odeke -Run-TryBot: Dmitri Shuralyov -TryBot-Result: Go Bot -Reviewed-by: Emmanuel Odeke - -Conflict:NA -Reference:https://github.com/golang/go/commit/be872812063f29e9c0d280fb37289d40330d96db - ---- - src/net/http/omithttp2.go | 4 ---- - src/net/http/transport.go | 8 ++++++-- - 2 files changed, 6 insertions(+), 6 deletions(-) - -diff --git a/src/net/http/omithttp2.go b/src/net/http/omithttp2.go -index 7e2f492579..c8f5c28a59 100644 ---- a/src/net/http/omithttp2.go -+++ b/src/net/http/omithttp2.go -@@ -32,10 +32,6 @@ type http2Transport struct { - func (*http2Transport) RoundTrip(*Request) (*Response, error) { panic(noHTTP2) } - func (*http2Transport) CloseIdleConnections() {} - --type http2erringRoundTripper struct{ err error } -- --func (http2erringRoundTripper) RoundTrip(*Request) (*Response, error) { panic(noHTTP2) } -- - type http2noDialH2RoundTripper struct{} - - func (http2noDialH2RoundTripper) RoundTrip(*Request) (*Response, error) { panic(noHTTP2) } -diff --git a/src/net/http/transport.go b/src/net/http/transport.go -index 6e430b9885..88d15a5919 100644 ---- a/src/net/http/transport.go -+++ b/src/net/http/transport.go -@@ -1531,6 +1531,10 @@ func (pconn *persistConn) addTLS(name string, trace *httptrace.ClientTrace) erro - return nil - } - -+type erringRoundTripper interface { -+ RoundTripErr() error -+} -+ - func (t *Transport) dialConn(ctx context.Context, cm connectMethod) (pconn *persistConn, err error) { - pconn = &persistConn{ - t: t, -@@ -1697,9 +1701,9 @@ func (t *Transport) dialConn(ctx context.Context, cm connectMethod) (pconn *pers - if s := pconn.tlsState; s != nil && s.NegotiatedProtocolIsMutual && s.NegotiatedProtocol != "" { - if next, ok := t.TLSNextProto[s.NegotiatedProtocol]; ok { - alt := next(cm.targetAddr, pconn.conn.(*tls.Conn)) -- if e, ok := alt.(http2erringRoundTripper); ok { -+ if e, ok := alt.(erringRoundTripper); ok { - // pconn.conn was closed by next (http2configureTransport.upgradeFn). -- return nil, e.err -+ return nil, e.RoundTripErr() - } - return &persistConn{t: t, cacheKey: pconn.cacheKey, alt: alt}, nil - } --- -2.27.0 - diff --git a/0029-release-branch.go1.15-build-set-GOPATH-consistently-.patch b/0029-release-branch.go1.15-build-set-GOPATH-consistently-.patch deleted file mode 100644 index a0a7d65710220c71eebe65c149e9d0bc7e842679..0000000000000000000000000000000000000000 --- a/0029-release-branch.go1.15-build-set-GOPATH-consistently-.patch +++ /dev/null @@ -1,105 +0,0 @@ -From 6df5d3a581380a85183c591d1fd9063a5e8e4b23 Mon Sep 17 00:00:00 2001 -From: Russ Cox -Date: Tue, 26 Jan 2021 21:14:43 -0500 -Subject: [PATCH 29/44] [release-branch.go1.15] build: set GOPATH consistently - in run.bash, run.bat, run.rc - -We used to clear GOPATH in all the build scripts. -Clearing GOPATH is misleading at best, since you just end up -with the default GOPATH (%USERPROFILE%\go on Windows). -Unless that's your GOROOT, in which case you end up with a -fatal error from the go command (#43938). - -run.bash changed to setting GOPATH=/dev/null, which has no -clear analogue on Windows. - -run.rc still clears GOPATH. - -Change them all to set GOPATH to a non-existent directory -/nonexist-gopath or c:\nonexist-gopath. - -For #45238. -Fixes #45239. - -Change-Id: I51edd66d37ff6a891b0d0541d91ecba97fbbb03d -Reviewed-on: https://go-review.googlesource.com/c/go/+/288818 -Trust: Russ Cox -Trust: Jason A. Donenfeld -Reviewed-by: Cherry Zhang -Reviewed-by: Alex Brainman -Reviewed-by: Jason A. Donenfeld -(cherry picked from commit bb6efb96092cc8ae398c29e3b052a0051c746f88) -Reviewed-on: https://go-review.googlesource.com/c/go/+/304773 -Run-TryBot: Dmitri Shuralyov -TryBot-Result: Go Bot -Reviewed-by: Alexander Rakoczy -Reviewed-by: Carlos Amedee -Trust: Carlos Amedee - -Conflict:NA -Reference:https://github.com/golang/go/commit/6df5d3a581380a85183c591d1fd9063a5e8e4b23 - ---- - src/run.bash | 10 +--------- - src/run.bat | 4 +--- - src/run.rc | 9 ++++----- - 3 files changed, 6 insertions(+), 17 deletions(-) - -diff --git a/src/run.bash b/src/run.bash -index 706b4b60ee..2123c509f8 100755 ---- a/src/run.bash -+++ b/src/run.bash -@@ -23,15 +23,7 @@ fi - - eval $(../bin/go env) - export GOROOT # The api test requires GOROOT to be set, so set it to match ../bin/go. -- --# We disallow local import for non-local packages, if $GOROOT happens --# to be under $GOPATH, then some tests below will fail. $GOPATH needs --# to be set to a non-empty string, else Go will set a default value --# that may also conflict with $GOROOT. The $GOPATH value doesn't need --# to point to an actual directory, it just needs to pass the semantic --# checks performed by Go. Use $GOROOT to define $GOPATH so that we --# don't blunder into a user-defined symbolic link. --export GOPATH=/dev/null -+export GOPATH=/nonexist-gopath - - unset CDPATH # in case user has it set - export GOBIN=$GOROOT/bin # Issue 14340 -diff --git a/src/run.bat b/src/run.bat -index c299671c13..edcaf52659 100644 ---- a/src/run.bat -+++ b/src/run.bat -@@ -18,9 +18,7 @@ setlocal - - set GOBUILDFAIL=0 - --:: we disallow local import for non-local packages, if %GOROOT% happens --:: to be under %GOPATH%, then some tests below will fail --set GOPATH= -+set GOPATH=c:\nonexist-gopath - :: Issue 14340: ignore GOBIN during all.bat. - set GOBIN= - set GOFLAGS= -diff --git a/src/run.rc b/src/run.rc -index ab7abfa991..a7b4801207 100755 ---- a/src/run.rc -+++ b/src/run.rc -@@ -12,10 +12,9 @@ if(! test -f ../bin/go){ - - eval `{../bin/go env} - --GOPATH = () # we disallow local import for non-local packages, if $GOROOT happens -- # to be under $GOPATH, then some tests below will fail --GOBIN = () # Issue 14340 --GOFLAGS = () --GO111MODULE = () -+GOPATH=/nonexist-gopath -+GOBIN=() # Issue 14340 -+GOFLAGS=() -+GO111MODULE=() - - exec ../bin/go tool dist test -rebuild $* --- -2.27.0 - diff --git a/0030-release-branch.go1.15-database-sql-fix-tx-stmt-deadl.patch b/0030-release-branch.go1.15-database-sql-fix-tx-stmt-deadl.patch deleted file mode 100644 index 4d1c4ea520131417e0afae93f0555b402414ef8b..0000000000000000000000000000000000000000 --- a/0030-release-branch.go1.15-database-sql-fix-tx-stmt-deadl.patch +++ /dev/null @@ -1,134 +0,0 @@ -From c77418f4cac41c42566ca90921a1f928995cfba2 Mon Sep 17 00:00:00 2001 -From: Emmanuel T Odeke -Date: Mon, 18 Jan 2021 16:18:11 -0800 -Subject: [PATCH 30/44] [release-branch.go1.15] database/sql: fix tx stmt - deadlock when rollback - -Tx acquires tx.closemu W-lock and then acquires stmt.closemu.W-lock -to fully close the transaction and associated prepared statement. -Stmt query and execution run in reverse ways - acquires -stmt.closemu.R-lock and then acquires tx.closemu.R-lock to grab tx -connection, which may cause deadlock. - -Prevent the lock is held around tx.closePrepared to ensure no -deadlock happens. - -Includes a test fix from CL 266097. -Fixes #42884 -Updates #40985 -Updates #42259 - -Change-Id: Id52737660ada3cebdfff6efc23366cdc3224b8e8 -Reviewed-on: https://go-review.googlesource.com/c/go/+/250178 -Run-TryBot: Emmanuel Odeke -TryBot-Result: Go Bot -Reviewed-by: Daniel Theophanes -Trust: Emmanuel Odeke -(cherry picked from commit d4c1ad882973e407ff85b977f4ce5b9435451190) -Reviewed-on: https://go-review.googlesource.com/c/go/+/284513 -Reviewed-by: Dmitri Shuralyov - -Conflict:NA -Reference:https://github.com/golang/go/commit/c77418f4cac41c42566ca90921a1f928995cfba2 - ---- - src/database/sql/sql.go | 14 +++++++------- - src/database/sql/sql_test.go | 28 ++++++++++++++++++++++++++++ - 2 files changed, 35 insertions(+), 7 deletions(-) - -diff --git a/src/database/sql/sql.go b/src/database/sql/sql.go -index b3d0653f5c..3d1367d28f 100644 ---- a/src/database/sql/sql.go -+++ b/src/database/sql/sql.go -@@ -2080,10 +2080,10 @@ func (tx *Tx) isDone() bool { - // that has already been committed or rolled back. - var ErrTxDone = errors.New("sql: transaction has already been committed or rolled back") - --// closeLocked returns the connection to the pool and -+// close returns the connection to the pool and - // must only be called by Tx.rollback or Tx.Commit while --// closemu is Locked and tx already canceled. --func (tx *Tx) closeLocked(err error) { -+// tx is already canceled and won't be executed concurrently. -+func (tx *Tx) close(err error) { - tx.releaseConn(err) - tx.dc = nil - tx.txi = nil -@@ -2157,7 +2157,7 @@ func (tx *Tx) Commit() error { - // to ensure no other connection has an active query. - tx.cancel() - tx.closemu.Lock() -- defer tx.closemu.Unlock() -+ tx.closemu.Unlock() - - var err error - withLock(tx.dc, func() { -@@ -2166,7 +2166,7 @@ func (tx *Tx) Commit() error { - if err != driver.ErrBadConn { - tx.closePrepared() - } -- tx.closeLocked(err) -+ tx.close(err) - return err - } - -@@ -2189,7 +2189,7 @@ func (tx *Tx) rollback(discardConn bool) error { - // to ensure no other connection has an active query. - tx.cancel() - tx.closemu.Lock() -- defer tx.closemu.Unlock() -+ tx.closemu.Unlock() - - var err error - withLock(tx.dc, func() { -@@ -2201,7 +2201,7 @@ func (tx *Tx) rollback(discardConn bool) error { - if discardConn { - err = driver.ErrBadConn - } -- tx.closeLocked(err) -+ tx.close(err) - return err - } - -diff --git a/src/database/sql/sql_test.go b/src/database/sql/sql_test.go -index 5727f0d8aa..d7d4642608 100644 ---- a/src/database/sql/sql_test.go -+++ b/src/database/sql/sql_test.go -@@ -2810,6 +2810,34 @@ func TestTxCannotCommitAfterRollback(t *testing.T) { - } - } - -+// Issue 40985 transaction statement deadlock while context cancel. -+func TestTxStmtDeadlock(t *testing.T) { -+ db := newTestDB(t, "people") -+ defer closeDB(t, db) -+ -+ ctx, cancel := context.WithTimeout(context.Background(), 5*time.Millisecond) -+ defer cancel() -+ tx, err := db.BeginTx(ctx, nil) -+ if err != nil { -+ t.Fatal(err) -+ } -+ -+ stmt, err := tx.Prepare("SELECT|people|name,age|age=?") -+ if err != nil { -+ t.Fatal(err) -+ } -+ // Run number of stmt queries to reproduce deadlock from context cancel -+ for i := 0; i < 1e3; i++ { -+ // Encounter any close related errors (e.g.. ErrTxDone, stmt is closed) -+ // is expected due to context cancel. -+ _, err = stmt.Query(1) -+ if err != nil { -+ break -+ } -+ } -+ _ = tx.Rollback() -+} -+ - // Issue32530 encounters an issue where a connection may - // expire right after it comes out of a used connection pool - // even when a new connection is requested. --- -2.27.0 - diff --git a/0031-release-branch.go1.15-cmd-compile-disable-shortcircu.patch b/0031-release-branch.go1.15-cmd-compile-disable-shortcircu.patch deleted file mode 100644 index fda0c965c47f0ec413492e77fe6c0d5844a44535..0000000000000000000000000000000000000000 --- a/0031-release-branch.go1.15-cmd-compile-disable-shortcircu.patch +++ /dev/null @@ -1,107 +0,0 @@ -From f17b659d0a9a43235f67c155b08023124b3fc35b Mon Sep 17 00:00:00 2001 -From: Keith Randall -Date: Tue, 23 Mar 2021 14:48:47 -0700 -Subject: [PATCH 31/44] [release-branch.go1.15] cmd/compile: disable - shortcircuit optimization for intertwined phi values - -We need to be careful that when doing value graph surgery, we not -re-substitute a value that has already been substituted. That can lead -to confusing a previous iteration's value with the current iteration's -value. - -The simple fix in this CL just aborts the optimization if it detects -intertwined phis (a phi which is the argument to another phi). It -might be possible to keep the optimization with a more complicated -CL, but: - 1) This CL is clearly safe to backport. - 2) There were no instances of this abort triggering in - all.bash, prior to the test introduced in this CL. - -Fixes #45187 - -Change-Id: I2411dca03948653c053291f6829a76bec0c32330 -Reviewed-on: https://go-review.googlesource.com/c/go/+/304251 -Trust: Keith Randall -Trust: Josh Bleecher Snyder -Run-TryBot: Keith Randall -TryBot-Result: Go Bot -Reviewed-by: Josh Bleecher Snyder -(cherry picked from commit 771c57e68ed5ef2bbb0eafc0d48419f59d143932) -Reviewed-on: https://go-review.googlesource.com/c/go/+/304529 - -Conflict:NA -Reference:https://github.com/golang/go/commit/f17b659d0a9a43235f67c155b08023124b3fc35b - ---- - src/cmd/compile/internal/ssa/shortcircuit.go | 18 ++++++++++++ - test/fixedbugs/issue45175.go | 29 ++++++++++++++++++++ - 2 files changed, 47 insertions(+) - create mode 100644 test/fixedbugs/issue45175.go - -diff --git a/src/cmd/compile/internal/ssa/shortcircuit.go b/src/cmd/compile/internal/ssa/shortcircuit.go -index c5df457c4e..9cf29fe413 100644 ---- a/src/cmd/compile/internal/ssa/shortcircuit.go -+++ b/src/cmd/compile/internal/ssa/shortcircuit.go -@@ -138,6 +138,24 @@ func shortcircuitBlock(b *Block) bool { - if len(b.Values) != nval+nOtherPhi { - return false - } -+ if nOtherPhi > 0 { -+ // Check for any phi which is the argument of another phi. -+ // These cases are tricky, as substitutions done by replaceUses -+ // are no longer trivial to do in any ordering. See issue 45175. -+ m := make(map[*Value]bool, 1+nOtherPhi) -+ for _, v := range b.Values { -+ if v.Op == OpPhi { -+ m[v] = true -+ } -+ } -+ for v := range m { -+ for _, a := range v.Args { -+ if a != v && m[a] { -+ return false -+ } -+ } -+ } -+ } - - // Locate index of first const phi arg. - cidx := -1 -diff --git a/test/fixedbugs/issue45175.go b/test/fixedbugs/issue45175.go -new file mode 100644 -index 0000000000..02dfe8a0a9 ---- /dev/null -+++ b/test/fixedbugs/issue45175.go -@@ -0,0 +1,29 @@ -+// run -+ -+// Copyright 2021 The Go Authors. All rights reserved. -+// Use of this source code is governed by a BSD-style -+// license that can be found in the LICENSE file. -+ -+package main -+ -+//go:noinline -+func f(c bool) int { -+ b := true -+ x := 0 -+ y := 1 -+ for b { -+ b = false -+ y = x -+ x = 2 -+ if c { -+ return 3 -+ } -+ } -+ return y -+} -+ -+func main() { -+ if got := f(false); got != 0 { -+ panic(got) -+ } -+} --- -2.27.0 - diff --git a/0032-release-branch.go1.15-runtime-non-strict-InlTreeInde.patch b/0032-release-branch.go1.15-runtime-non-strict-InlTreeInde.patch deleted file mode 100644 index 58ee86968d78f89cde41cd25d32a8f0c209f278a..0000000000000000000000000000000000000000 --- a/0032-release-branch.go1.15-runtime-non-strict-InlTreeInde.patch +++ /dev/null @@ -1,157 +0,0 @@ -From a07f9d2f82598d2f5cc0df0e813a6a2309cb96e6 Mon Sep 17 00:00:00 2001 -From: Michael Pratt -Date: Thu, 11 Mar 2021 12:28:45 -0500 -Subject: [PATCH 32/44] [release-branch.go1.15] runtime: non-strict - InlTreeIndex lookup in Frames.Next - -When using cgo, some of the frames can be provided by cgoTraceback, a -cgo-provided function to generate C tracebacks. Unlike Go tracebacks, -cgoTraceback has no particular guarantees that it produces valid -tracebacks. - -If one of the (invalid) frames happens to put the PC in the alignment -region at the end of a function (filled with int 3's on amd64), then -Frames.Next will find a valid funcInfo for the PC, but pcdatavalue will -panic because PCDATA doesn't cover this PC. - -Tolerate this case by doing a non-strict PCDATA lookup. We'll still show -a bogus frame, but at least avoid throwing. - -For #44971 -Fixes #45302 - -Change-Id: I9eed728470d6f264179a7615bd19845c941db78c -Reviewed-on: https://go-review.googlesource.com/c/go/+/301369 -Trust: Michael Pratt -Run-TryBot: Michael Pratt -TryBot-Result: Go Bot -Reviewed-by: Cherry Zhang -(cherry picked from commit e4a4161f1f3157550846e1b6bd4fe83aae15778e) -Reviewed-on: https://go-review.googlesource.com/c/go/+/305890 - -Conflict:NA -Reference:https://github.com/golang/go/commit/a07f9d2f82598d2f5cc0df0e813a6a2309cb96e6 - ---- - src/runtime/symtab.go | 4 +- - src/runtime/symtab_test.go | 85 ++++++++++++++++++++++++++++++++++++++ - 2 files changed, 88 insertions(+), 1 deletion(-) - -diff --git a/src/runtime/symtab.go b/src/runtime/symtab.go -index 1e86662adc..c77d513e74 100644 ---- a/src/runtime/symtab.go -+++ b/src/runtime/symtab.go -@@ -102,7 +102,9 @@ func (ci *Frames) Next() (frame Frame, more bool) { - name := funcname(funcInfo) - if inldata := funcdata(funcInfo, _FUNCDATA_InlTree); inldata != nil { - inltree := (*[1 << 20]inlinedCall)(inldata) -- ix := pcdatavalue(funcInfo, _PCDATA_InlTreeIndex, pc, nil) -+ // Non-strict as cgoTraceback may have added bogus PCs -+ // with a valid funcInfo but invalid PCDATA. -+ ix := pcdatavalue1(funcInfo, _PCDATA_InlTreeIndex, pc, nil, false) - if ix >= 0 { - // Note: entry is not modified. It always refers to a real frame, not an inlined one. - f = nil -diff --git a/src/runtime/symtab_test.go b/src/runtime/symtab_test.go -index 01e5002659..ffa07c7f3a 100644 ---- a/src/runtime/symtab_test.go -+++ b/src/runtime/symtab_test.go -@@ -8,6 +8,7 @@ import ( - "runtime" - "strings" - "testing" -+ "unsafe" - ) - - func TestCaller(t *testing.T) { -@@ -165,3 +166,87 @@ func TestNilName(t *testing.T) { - t.Errorf("Name() = %q, want %q", got, "") - } - } -+ -+var dummy int -+ -+func inlined() { -+ // Side effect to prevent elimination of this entire function. -+ dummy = 42 -+} -+ -+// A function with an InlTree. Returns a PC within the function body. -+// -+// No inline to ensure this complete function appears in output. -+// -+//go:noinline -+func tracebackFunc(t *testing.T) uintptr { -+ // This body must be more complex than a single call to inlined to get -+ // an inline tree. -+ inlined() -+ inlined() -+ -+ // Acquire a PC in this function. -+ pc, _, _, ok := runtime.Caller(0) -+ if !ok { -+ t.Fatalf("Caller(0) got ok false, want true") -+ } -+ -+ return pc -+} -+ -+// Test that CallersFrames handles PCs in the alignment region between -+// functions (int 3 on amd64) without crashing. -+// -+// Go will never generate a stack trace containing such an address, as it is -+// not a valid call site. However, the cgo traceback function passed to -+// runtime.SetCgoTraceback may not be completely accurate and may incorrect -+// provide PCs in Go code or the alignement region between functions. -+// -+// Go obviously doesn't easily expose the problematic PCs to running programs, -+// so this test is a bit fragile. Some details: -+// -+// * tracebackFunc is our target function. We want to get a PC in the -+// alignment region following this function. This function also has other -+// functions inlined into it to ensure it has an InlTree (this was the source -+// of the bug in issue 44971). -+// -+// * We acquire a PC in tracebackFunc, walking forwards until FuncForPC says -+// we're in a new function. The last PC of the function according to FuncForPC -+// should be in the alignment region (assuming the function isn't already -+// perfectly aligned). -+// -+// This is a regression test for issue 44971. -+func TestFunctionAlignmentTraceback(t *testing.T) { -+ pc := tracebackFunc(t) -+ -+ // Double-check we got the right PC. -+ f := runtime.FuncForPC(pc) -+ if !strings.HasSuffix(f.Name(), "tracebackFunc") { -+ t.Fatalf("Caller(0) = %+v, want tracebackFunc", f) -+ } -+ -+ // Iterate forward until we find a different function. Back up one -+ // instruction is (hopefully) an alignment instruction. -+ for runtime.FuncForPC(pc) == f { -+ pc++ -+ } -+ pc-- -+ -+ // Is this an alignment region filler instruction? We only check this -+ // on amd64 for simplicity. If this function has no filler, then we may -+ // get a false negative, but will never get a false positive. -+ if runtime.GOARCH == "amd64" { -+ code := *(*uint8)(unsafe.Pointer(pc)) -+ if code != 0xcc { // INT $3 -+ t.Errorf("PC %v code got %#x want 0xcc", pc, code) -+ } -+ } -+ -+ // Finally ensure that Frames.Next doesn't crash when processing this -+ // PC. -+ frames := runtime.CallersFrames([]uintptr{pc}) -+ frame, _ := frames.Next() -+ if frame.Func != f { -+ t.Errorf("frames.Next() got %+v want %+v", frame.Func, f) -+ } -+} --- -2.27.0 - diff --git a/0033-release-branch.go1.15-cmd-cgo-avoid-exporting-all-sy.patch b/0033-release-branch.go1.15-cmd-cgo-avoid-exporting-all-sy.patch deleted file mode 100644 index 39bc904fedfa8ff11eefd382c235f5f4e87ba7fe..0000000000000000000000000000000000000000 --- a/0033-release-branch.go1.15-cmd-cgo-avoid-exporting-all-sy.patch +++ /dev/null @@ -1,172 +0,0 @@ -From 5055314a5749664ab66a24beed8158552e276959 Mon Sep 17 00:00:00 2001 -From: Quim Muntal -Date: Thu, 15 Oct 2020 23:12:49 +0200 -Subject: [PATCH 33/44] [release-branch.go1.15] cmd/cgo: avoid exporting all - symbols on windows buildmode=c-shared - -Disable default symbol auto-export behaviour by marking exported -function with the __declspec(dllexport) attribute. Old behaviour can -still be used by setting -extldflags=-Wl,--export-all-symbols. - -See https://sourceware.org/binutils/docs/ld/WIN32.html for more info. - -This change cuts 50kb of a "hello world" dll. - -Updates #6853. -Updates #30674. -Fixes #43591. - -Change-Id: I9c7fb09c677cc760f24d0f7d199740ae73981413 -Reviewed-on: https://go-review.googlesource.com/c/go/+/262797 -Run-TryBot: Ian Lance Taylor -TryBot-Result: Go Bot -Reviewed-by: Ian Lance Taylor -Reviewed-by: Alex Brainman -Trust: Alex Brainman -Reviewed-on: https://go-review.googlesource.com/c/go/+/300693 -Trust: Dmitri Shuralyov -Run-TryBot: Dmitri Shuralyov -Reviewed-by: David Chase - -Conflict:NA -Reference:https://github.com/golang/go/commit/5055314a5749664ab66a24beed8158552e276959 - ---- - misc/cgo/testcshared/cshared_test.go | 96 ++++++++++++++++++++++++++++ - src/cmd/cgo/out.go | 6 +- - 2 files changed, 101 insertions(+), 1 deletion(-) - -diff --git a/misc/cgo/testcshared/cshared_test.go b/misc/cgo/testcshared/cshared_test.go -index bd4d341820..d717b4dfb3 100644 ---- a/misc/cgo/testcshared/cshared_test.go -+++ b/misc/cgo/testcshared/cshared_test.go -@@ -7,6 +7,8 @@ package cshared_test - import ( - "bytes" - "debug/elf" -+ "debug/pe" -+ "encoding/binary" - "flag" - "fmt" - "io/ioutil" -@@ -355,6 +357,100 @@ func TestExportedSymbols(t *testing.T) { - } - } - -+func checkNumberOfExportedFunctionsWindows(t *testing.T, exportAllSymbols bool) { -+ const prog = ` -+package main -+ -+import "C" -+ -+//export GoFunc -+func GoFunc() { -+ println(42) -+} -+ -+//export GoFunc2 -+func GoFunc2() { -+ println(24) -+} -+ -+func main() { -+} -+` -+ -+ tmpdir := t.TempDir() -+ -+ srcfile := filepath.Join(tmpdir, "test.go") -+ objfile := filepath.Join(tmpdir, "test.dll") -+ if err := ioutil.WriteFile(srcfile, []byte(prog), 0666); err != nil { -+ t.Fatal(err) -+ } -+ argv := []string{"build", "-buildmode=c-shared"} -+ if exportAllSymbols { -+ argv = append(argv, "-ldflags", "-extldflags=-Wl,--export-all-symbols") -+ } -+ argv = append(argv, "-o", objfile, srcfile) -+ out, err := exec.Command("go", argv...).CombinedOutput() -+ if err != nil { -+ t.Fatalf("build failure: %s\n%s\n", err, string(out)) -+ } -+ -+ f, err := pe.Open(objfile) -+ if err != nil { -+ t.Fatalf("pe.Open failed: %v", err) -+ } -+ defer f.Close() -+ section := f.Section(".edata") -+ if section == nil { -+ t.Error(".edata section is not present") -+ } -+ -+ // TODO: deduplicate this struct from cmd/link/internal/ld/pe.go -+ type IMAGE_EXPORT_DIRECTORY struct { -+ _ [2]uint32 -+ _ [2]uint16 -+ _ [2]uint32 -+ NumberOfFunctions uint32 -+ NumberOfNames uint32 -+ _ [3]uint32 -+ } -+ var e IMAGE_EXPORT_DIRECTORY -+ if err := binary.Read(section.Open(), binary.LittleEndian, &e); err != nil { -+ t.Fatalf("binary.Read failed: %v", err) -+ } -+ -+ expectedNumber := uint32(2) -+ -+ if exportAllSymbols { -+ if e.NumberOfFunctions <= expectedNumber { -+ t.Fatalf("missing exported functions: %v", e.NumberOfFunctions) -+ } -+ if e.NumberOfNames <= expectedNumber { -+ t.Fatalf("missing exported names: %v", e.NumberOfNames) -+ } -+ } else { -+ if e.NumberOfFunctions != expectedNumber { -+ t.Fatalf("too many exported functions: %v", e.NumberOfFunctions) -+ } -+ if e.NumberOfNames != expectedNumber { -+ t.Fatalf("too many exported names: %v", e.NumberOfNames) -+ } -+ } -+} -+ -+func TestNumberOfExportedFunctions(t *testing.T) { -+ if GOOS != "windows" { -+ t.Skip("skipping windows only test") -+ } -+ t.Parallel() -+ -+ t.Run("OnlyExported", func(t *testing.T) { -+ checkNumberOfExportedFunctionsWindows(t, false) -+ }) -+ t.Run("All", func(t *testing.T) { -+ checkNumberOfExportedFunctionsWindows(t, true) -+ }) -+} -+ - // test1: shared library can be dynamically loaded and exported symbols are accessible. - func TestExportedSymbolsWithDynamicLoad(t *testing.T) { - t.Parallel() -diff --git a/src/cmd/cgo/out.go b/src/cmd/cgo/out.go -index b9043efbf7..ee1c563495 100644 ---- a/src/cmd/cgo/out.go -+++ b/src/cmd/cgo/out.go -@@ -961,7 +961,11 @@ func (p *Package) writeExports(fgo2, fm, fgcc, fgcch io.Writer) { - } - - // Build the wrapper function compiled by gcc. -- s := fmt.Sprintf("%s %s(", gccResult, exp.ExpName) -+ gccExport := "" -+ if goos == "windows" { -+ gccExport = "__declspec(dllexport)" -+ } -+ s := fmt.Sprintf("%s %s %s(", gccExport, gccResult, exp.ExpName) - if fn.Recv != nil { - s += p.cgoType(fn.Recv.List[0].Type).C.String() - s += " recv" --- -2.27.0 - diff --git a/0034-release-branch.go1.15-cmd-link-avoid-exporting-all-s.patch b/0034-release-branch.go1.15-cmd-link-avoid-exporting-all-s.patch deleted file mode 100644 index 123220ef79d8250938a12add5530ab6dbca9bb8f..0000000000000000000000000000000000000000 --- a/0034-release-branch.go1.15-cmd-link-avoid-exporting-all-s.patch +++ /dev/null @@ -1,188 +0,0 @@ -From 82f9c6cac1bcc6bc80f17d1415ac3f62c0afa6c5 Mon Sep 17 00:00:00 2001 -From: Quim Muntal -Date: Thu, 22 Oct 2020 22:32:20 +0200 -Subject: [PATCH 34/44] [release-branch.go1.15] cmd/link: avoid exporting all - symbols on windows buildmode=pie - -Marking one functions with __declspec(dllexport) forces mingw to -create .reloc section without having to export all symbols. - -See https://insights.sei.cmu.edu/cert/2018/08/when-aslr-is-not-really-aslr---the-case-of-incorrect-assumptions-and-bad-defaults.html for more info. - -This change cuts 73kb of a "hello world" pie binary. - -Updates #6853. -Updates #40795. -Fixes #43592. - -Change-Id: I3cc57c3b64f61187550bc8751dfa085f106c8475 -Reviewed-on: https://go-review.googlesource.com/c/go/+/264459 -Trust: Alex Brainman -Run-TryBot: Alex Brainman -TryBot-Result: Go Bot -Reviewed-by: Alex Brainman -Reviewed-by: Austin Clements -Reviewed-on: https://go-review.googlesource.com/c/go/+/300692 -Trust: Dmitri Shuralyov -Run-TryBot: Dmitri Shuralyov -Reviewed-by: David Chase - -Conflict:NA -Reference:https://github.com/golang/go/commit/82f9c6cac1bcc6bc80f17d1415ac3f62c0afa6c5 - ---- - misc/cgo/testcshared/cshared_test.go | 9 ++++---- - src/cmd/go/go_test.go | 33 ++++++++++++++++++++++++++++ - src/cmd/link/internal/ld/lib.go | 3 --- - src/runtime/cgo/gcc_windows_386.c | 1 + - src/runtime/cgo/gcc_windows_amd64.c | 1 + - src/runtime/cgo/libcgo_windows.h | 12 ++++++++++ - 6 files changed, 52 insertions(+), 7 deletions(-) - create mode 100644 src/runtime/cgo/libcgo_windows.h - -diff --git a/misc/cgo/testcshared/cshared_test.go b/misc/cgo/testcshared/cshared_test.go -index d717b4dfb3..dff2682e20 100644 ---- a/misc/cgo/testcshared/cshared_test.go -+++ b/misc/cgo/testcshared/cshared_test.go -@@ -401,7 +401,7 @@ func main() { - defer f.Close() - section := f.Section(".edata") - if section == nil { -- t.Error(".edata section is not present") -+ t.Fatalf(".edata section is not present") - } - - // TODO: deduplicate this struct from cmd/link/internal/ld/pe.go -@@ -418,7 +418,8 @@ func main() { - t.Fatalf("binary.Read failed: %v", err) - } - -- expectedNumber := uint32(2) -+ // Only the two exported functions and _cgo_dummy_export should be exported -+ expectedNumber := uint32(3) - - if exportAllSymbols { - if e.NumberOfFunctions <= expectedNumber { -@@ -429,10 +430,10 @@ func main() { - } - } else { - if e.NumberOfFunctions != expectedNumber { -- t.Fatalf("too many exported functions: %v", e.NumberOfFunctions) -+ t.Fatalf("got %d exported functions; want %d", e.NumberOfFunctions, expectedNumber) - } - if e.NumberOfNames != expectedNumber { -- t.Fatalf("too many exported names: %v", e.NumberOfNames) -+ t.Fatalf("got %d exported names; want %d", e.NumberOfNames, expectedNumber) - } - } - } -diff --git a/src/cmd/go/go_test.go b/src/cmd/go/go_test.go -index 021930a8a8..3f790cdeab 100644 ---- a/src/cmd/go/go_test.go -+++ b/src/cmd/go/go_test.go -@@ -9,6 +9,7 @@ import ( - "debug/elf" - "debug/macho" - "debug/pe" -+ "encoding/binary" - "flag" - "fmt" - "go/format" -@@ -2166,6 +2167,38 @@ func testBuildmodePIE(t *testing.T, useCgo, setBuildmodeToPIE bool) { - if (dc & pe.IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE) == 0 { - t.Error("IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE flag is not set") - } -+ if useCgo { -+ // Test that only one symbol is exported (#40795). -+ // PIE binaries don´t require .edata section but unfortunately -+ // binutils doesn´t generate a .reloc section unless there is -+ // at least one symbol exported. -+ // See https://sourceware.org/bugzilla/show_bug.cgi?id=19011 -+ section := f.Section(".edata") -+ if section == nil { -+ t.Fatalf(".edata section is not present") -+ } -+ // TODO: deduplicate this struct from cmd/link/internal/ld/pe.go -+ type IMAGE_EXPORT_DIRECTORY struct { -+ _ [2]uint32 -+ _ [2]uint16 -+ _ [2]uint32 -+ NumberOfFunctions uint32 -+ NumberOfNames uint32 -+ _ [3]uint32 -+ } -+ var e IMAGE_EXPORT_DIRECTORY -+ if err := binary.Read(section.Open(), binary.LittleEndian, &e); err != nil { -+ t.Fatalf("binary.Read failed: %v", err) -+ } -+ -+ // Only _cgo_dummy_export should be exported -+ if e.NumberOfFunctions != 1 { -+ t.Fatalf("got %d exported functions; want 1", e.NumberOfFunctions) -+ } -+ if e.NumberOfNames != 1 { -+ t.Fatalf("got %d exported names; want 1", e.NumberOfNames) -+ } -+ } - default: - panic("unreachable") - } -diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go -index fc89759997..d03fb6cf91 100644 ---- a/src/cmd/link/internal/ld/lib.go -+++ b/src/cmd/link/internal/ld/lib.go -@@ -1423,9 +1423,6 @@ func (ctxt *Link) hostlink() { - if ctxt.Arch.PtrSize >= 8 { - argv = append(argv, "-Wl,--high-entropy-va") - } -- // Work around binutils limitation that strips relocation table for dynamicbase. -- // See https://sourceware.org/bugzilla/show_bug.cgi?id=19011 -- argv = append(argv, "-Wl,--export-all-symbols") - default: - // ELF. - if ctxt.UseRelro() { -diff --git a/src/runtime/cgo/gcc_windows_386.c b/src/runtime/cgo/gcc_windows_386.c -index 9184b91393..60cb011bf2 100644 ---- a/src/runtime/cgo/gcc_windows_386.c -+++ b/src/runtime/cgo/gcc_windows_386.c -@@ -9,6 +9,7 @@ - #include - #include - #include "libcgo.h" -+#include "libcgo_windows.h" - - static void threadentry(void*); - -diff --git a/src/runtime/cgo/gcc_windows_amd64.c b/src/runtime/cgo/gcc_windows_amd64.c -index 7192a24631..0f8c817f0e 100644 ---- a/src/runtime/cgo/gcc_windows_amd64.c -+++ b/src/runtime/cgo/gcc_windows_amd64.c -@@ -9,6 +9,7 @@ - #include - #include - #include "libcgo.h" -+#include "libcgo_windows.h" - - static void threadentry(void*); - -diff --git a/src/runtime/cgo/libcgo_windows.h b/src/runtime/cgo/libcgo_windows.h -new file mode 100644 -index 0000000000..0013f06bae ---- /dev/null -+++ b/src/runtime/cgo/libcgo_windows.h -@@ -0,0 +1,12 @@ -+// Copyright 2020 The Go Authors. All rights reserved. -+// Use of this source code is governed by a BSD-style -+// license that can be found in the LICENSE file. -+ -+// Ensure there's one symbol marked __declspec(dllexport). -+// If there are no exported symbols, the unfortunate behavior of -+// the binutils linker is to also strip the relocations table, -+// resulting in non-PIE binary. The other option is the -+// --export-all-symbols flag, but we don't need to export all symbols -+// and this may overflow the export table (#40795). -+// See https://sourceware.org/bugzilla/show_bug.cgi?id=19011 -+__declspec(dllexport) int _cgo_dummy_export; --- -2.27.0 - diff --git a/0035-release-branch.go1.15-cmd-cgo-remove-unnecessary-spa.patch b/0035-release-branch.go1.15-cmd-cgo-remove-unnecessary-spa.patch deleted file mode 100644 index 8d3c8a51804ccd59f7c72a3b7bb4d15661698992..0000000000000000000000000000000000000000 --- a/0035-release-branch.go1.15-cmd-cgo-remove-unnecessary-spa.patch +++ /dev/null @@ -1,60 +0,0 @@ -From 1373d92a75f70c62d74f9e4714cd17811f75c48b Mon Sep 17 00:00:00 2001 -From: Quim Muntal -Date: Thu, 14 Jan 2021 21:29:49 +0100 -Subject: [PATCH 35/44] [release-branch.go1.15] cmd/cgo: remove unnecessary - space in cgo export header - -The cgo header has an unnecessary space in the exported function -definition on non-windows goos. - -This was introduced in go1.16 so it would be good to fix it before -release. - -Example: - -// Current behavior, notice there is an unecessary space -// between extern and void -extern void Foo(); - -// With this CL -extern void Foo(); - -Updates #43591. - -Change-Id: Ic2c21f8d806fe35a7be7183dbfe35ac605b6e4f6 -Reviewed-on: https://go-review.googlesource.com/c/go/+/283892 -Reviewed-by: Ian Lance Taylor -Trust: Katie Hockman -Reviewed-on: https://go-review.googlesource.com/c/go/+/300694 -Trust: Dmitri Shuralyov -Trust: Emmanuel Odeke -Run-TryBot: Dmitri Shuralyov -TryBot-Result: Go Bot -Reviewed-by: David Chase - -Conflict:NA -Reference:https://github.com/golang/go/commit/1373d92a75f70c62d74f9e4714cd17811f75c48b - ---- - src/cmd/cgo/out.go | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/src/cmd/cgo/out.go b/src/cmd/cgo/out.go -index ee1c563495..be4f6ad2d5 100644 ---- a/src/cmd/cgo/out.go -+++ b/src/cmd/cgo/out.go -@@ -963,9 +963,9 @@ func (p *Package) writeExports(fgo2, fm, fgcc, fgcch io.Writer) { - // Build the wrapper function compiled by gcc. - gccExport := "" - if goos == "windows" { -- gccExport = "__declspec(dllexport)" -+ gccExport = "__declspec(dllexport) " - } -- s := fmt.Sprintf("%s %s %s(", gccExport, gccResult, exp.ExpName) -+ s := fmt.Sprintf("%s%s %s(", gccExport, gccResult, exp.ExpName) - if fn.Recv != nil { - s += p.cgoType(fn.Recv.List[0].Type).C.String() - s += " recv" --- -2.27.0 - diff --git a/0037-release-branch.go1.15-time-use-offset-and-isDST-when.patch b/0037-release-branch.go1.15-time-use-offset-and-isDST-when.patch deleted file mode 100644 index dc7e32cccddee2a74d6ca4fdbfc57d5bc03e6642..0000000000000000000000000000000000000000 --- a/0037-release-branch.go1.15-time-use-offset-and-isDST-when.patch +++ /dev/null @@ -1,355 +0,0 @@ -From 06c9756333bb506dcbf322be77af85b3162b6345 Mon Sep 17 00:00:00 2001 -From: Ian Lance Taylor -Date: Mon, 5 Apr 2021 12:12:25 -0700 -Subject: [PATCH 37/44] [release-branch.go1.15] time: use offset and isDST when - caching zone from extend string - -If the current time is computed from extend string -and the zone file contains multiple zones with the -same name, the lookup by name might find incorrect -zone. - -This happens for example with the slim Europe/Dublin -time zone file in the embedded zip. This zone file -has last transition in 1996 and rest is covered by -extend string. -tzset returns IST as the zone name to use, but there -are two records with IST name. Lookup by name finds -the wrong one. We need to check offset and isDST too. - -In case we can't find an existing zone, we allocate -a new zone so that we use correct offset and isDST. - -I have renamed zone variable to zones as it shadowed -the zone type that we need to allocate the cached zone. - -Backport note: this change also incorporates portions of -CL 264077. - -For #45370 -Fixes #45384 - -Change-Id: I43d416d009e20878261156c821a5784e2407ed1f -Reviewed-on: https://go-review.googlesource.com/c/go/+/307212 -Trust: Ian Lance Taylor -Run-TryBot: Ian Lance Taylor -TryBot-Result: Go Bot -Reviewed-by: Emmanuel Odeke - -Conflict:NA -Reference:https://github.com/golang/go/commit/06c9756333bb506dcbf322be77af85b3162b6345 - ---- - src/time/zoneinfo.go | 27 ++++++++++++++---------- - src/time/zoneinfo_read.go | 44 ++++++++++++++++++++++++--------------- - src/time/zoneinfo_test.go | 37 +++++++++++++++++++++----------- - 3 files changed, 68 insertions(+), 40 deletions(-) - -diff --git a/src/time/zoneinfo.go b/src/time/zoneinfo.go -index 6db9443474..57052338d0 100644 ---- a/src/time/zoneinfo.go -+++ b/src/time/zoneinfo.go -@@ -178,7 +178,7 @@ func (l *Location) lookup(sec int64) (name string, offset int, start, end int64) - // If we're at the end of the known zone transitions, - // try the extend string. - if lo == len(tx)-1 && l.extend != "" { -- if ename, eoffset, estart, eend, ok := tzset(l.extend, end, sec); ok { -+ if ename, eoffset, estart, eend, _, ok := tzset(l.extend, end, sec); ok { - return ename, eoffset, estart, eend - } - } -@@ -244,7 +244,7 @@ func (l *Location) firstZoneUsed() bool { - // We call this a tzset string since in C the function tzset reads TZ. - // The return values are as for lookup, plus ok which reports whether the - // parse succeeded. --func tzset(s string, initEnd, sec int64) (name string, offset int, start, end int64, ok bool) { -+func tzset(s string, initEnd, sec int64) (name string, offset int, start, end int64, isDST, ok bool) { - var ( - stdName, dstName string - stdOffset, dstOffset int -@@ -255,7 +255,7 @@ func tzset(s string, initEnd, sec int64) (name string, offset int, start, end in - stdOffset, s, ok = tzsetOffset(s) - } - if !ok { -- return "", 0, 0, 0, false -+ return "", 0, 0, 0, false, false - } - - // The numbers in the tzset string are added to local time to get UTC, -@@ -265,7 +265,7 @@ func tzset(s string, initEnd, sec int64) (name string, offset int, start, end in - - if len(s) == 0 || s[0] == ',' { - // No daylight savings time. -- return stdName, stdOffset, initEnd, omega, true -+ return stdName, stdOffset, initEnd, omega, false, true - } - - dstName, s, ok = tzsetName(s) -@@ -278,7 +278,7 @@ func tzset(s string, initEnd, sec int64) (name string, offset int, start, end in - } - } - if !ok { -- return "", 0, 0, 0, false -+ return "", 0, 0, 0, false, false - } - - if len(s) == 0 { -@@ -287,19 +287,19 @@ func tzset(s string, initEnd, sec int64) (name string, offset int, start, end in - } - // The TZ definition does not mention ';' here but tzcode accepts it. - if s[0] != ',' && s[0] != ';' { -- return "", 0, 0, 0, false -+ return "", 0, 0, 0, false, false - } - s = s[1:] - - var startRule, endRule rule - startRule, s, ok = tzsetRule(s) - if !ok || len(s) == 0 || s[0] != ',' { -- return "", 0, 0, 0, false -+ return "", 0, 0, 0, false, false - } - s = s[1:] - endRule, s, ok = tzsetRule(s) - if !ok || len(s) > 0 { -- return "", 0, 0, 0, false -+ return "", 0, 0, 0, false, false - } - - year, _, _, yday := absDate(uint64(sec+unixToInternal+internalToAbsolute), false) -@@ -313,10 +313,15 @@ func tzset(s string, initEnd, sec int64) (name string, offset int, start, end in - - startSec := int64(tzruleTime(year, startRule, stdOffset)) - endSec := int64(tzruleTime(year, endRule, dstOffset)) -+ dstIsDST, stdIsDST := true, false -+ // Note: this is a flipping of "DST" and "STD" while retaining the labels -+ // This happens in southern hemispheres. The labelling here thus is a little -+ // inconsistent with the goal. - if endSec < startSec { - startSec, endSec = endSec, startSec - stdName, dstName = dstName, stdName - stdOffset, dstOffset = dstOffset, stdOffset -+ stdIsDST, dstIsDST = dstIsDST, stdIsDST - } - - // The start and end values that we return are accurate -@@ -324,11 +329,11 @@ func tzset(s string, initEnd, sec int64) (name string, offset int, start, end in - // just the start and end of the year. That suffices for - // the only caller that cares, which is Date. - if ysec < startSec { -- return stdName, stdOffset, abs, startSec + abs, true -+ return stdName, stdOffset, abs, startSec + abs, stdIsDST, true - } else if ysec >= endSec { -- return stdName, stdOffset, endSec + abs, abs + 365*secondsPerDay, true -+ return stdName, stdOffset, endSec + abs, abs + 365*secondsPerDay, stdIsDST, true - } else { -- return dstName, dstOffset, startSec + abs, endSec + abs, true -+ return dstName, dstOffset, startSec + abs, endSec + abs, dstIsDST, true - } - } - -diff --git a/src/time/zoneinfo_read.go b/src/time/zoneinfo_read.go -index 22a60f3211..f7fe59c385 100644 ---- a/src/time/zoneinfo_read.go -+++ b/src/time/zoneinfo_read.go -@@ -247,8 +247,8 @@ func LoadLocationFromTZData(name string, data []byte) (*Location, error) { - // This also avoids a panic later when we add and then use a fake transition (golang.org/issue/29437). - return nil, badData - } -- zone := make([]zone, nzone) -- for i := range zone { -+ zones := make([]zone, nzone) -+ for i := range zones { - var ok bool - var n uint32 - if n, ok = zonedata.big4(); !ok { -@@ -257,22 +257,22 @@ func LoadLocationFromTZData(name string, data []byte) (*Location, error) { - if uint32(int(n)) != n { - return nil, badData - } -- zone[i].offset = int(int32(n)) -+ zones[i].offset = int(int32(n)) - var b byte - if b, ok = zonedata.byte(); !ok { - return nil, badData - } -- zone[i].isDST = b != 0 -+ zones[i].isDST = b != 0 - if b, ok = zonedata.byte(); !ok || int(b) >= len(abbrev) { - return nil, badData - } -- zone[i].name = byteString(abbrev[b:]) -+ zones[i].name = byteString(abbrev[b:]) - if runtime.GOOS == "aix" && len(name) > 8 && (name[:8] == "Etc/GMT+" || name[:8] == "Etc/GMT-") { - // There is a bug with AIX 7.2 TL 0 with files in Etc, - // GMT+1 will return GMT-1 instead of GMT+1 or -01. - if name != "Etc/GMT+0" { - // GMT+0 is OK -- zone[i].name = name[4:] -+ zones[i].name = name[4:] - } - } - } -@@ -295,7 +295,7 @@ func LoadLocationFromTZData(name string, data []byte) (*Location, error) { - } - } - tx[i].when = n -- if int(txzones[i]) >= len(zone) { -+ if int(txzones[i]) >= len(zones) { - return nil, badData - } - tx[i].index = txzones[i] -@@ -314,7 +314,7 @@ func LoadLocationFromTZData(name string, data []byte) (*Location, error) { - } - - // Committed to succeed. -- l := &Location{zone: zone, tx: tx, name: name, extend: extend} -+ l := &Location{zone: zones, tx: tx, name: name, extend: extend} - - // Fill in the cache with information about right now, - // since that will be the most common lookup. -@@ -323,26 +323,27 @@ func LoadLocationFromTZData(name string, data []byte) (*Location, error) { - if tx[i].when <= sec && (i+1 == len(tx) || sec < tx[i+1].when) { - l.cacheStart = tx[i].when - l.cacheEnd = omega -- zoneIdx := tx[i].index -+ l.cacheZone = &l.zone[tx[i].index] - if i+1 < len(tx) { - l.cacheEnd = tx[i+1].when - } else if l.extend != "" { - // If we're at the end of the known zone transitions, - // try the extend string. -- if name, _, estart, eend, ok := tzset(l.extend, l.cacheEnd, sec); ok { -+ if name, offset, estart, eend, isDST, ok := tzset(l.extend, l.cacheEnd, sec); ok { - l.cacheStart = estart - l.cacheEnd = eend -- // Find the zone that is returned by tzset, -- // the last transition is not always the correct zone. -- for i, z := range l.zone { -- if z.name == name { -- zoneIdx = uint8(i) -- break -+ // Find the zone that is returned by tzset to avoid allocation if possible. -+ if zoneIdx := findZone(l.zone, name, offset, isDST); zoneIdx != -1 { -+ l.cacheZone = &l.zone[zoneIdx] -+ } else { -+ l.cacheZone = &zone{ -+ name: name, -+ offset: offset, -+ isDST: isDST, - } - } - } - } -- l.cacheZone = &l.zone[zoneIdx] - break - } - } -@@ -350,6 +351,15 @@ func LoadLocationFromTZData(name string, data []byte) (*Location, error) { - return l, nil - } - -+func findZone(zones []zone, name string, offset int, isDST bool) int { -+ for i, z := range zones { -+ if z.name == name && z.offset == offset && z.isDST == isDST { -+ return i -+ } -+ } -+ return -1 -+} -+ - // loadTzinfoFromDirOrZip returns the contents of the file with the given name - // in dir. dir can either be an uncompressed zip file, or a directory. - func loadTzinfoFromDirOrZip(dir, name string) ([]byte, error) { -diff --git a/src/time/zoneinfo_test.go b/src/time/zoneinfo_test.go -index d043e1e9f1..7ba1229741 100644 ---- a/src/time/zoneinfo_test.go -+++ b/src/time/zoneinfo_test.go -@@ -186,6 +186,7 @@ func TestMalformedTZData(t *testing.T) { - var slimTests = []struct { - zoneName string - tzData string -+ date func(*time.Location) time.Time - wantName string - wantOffset int - }{ -@@ -193,6 +194,7 @@ var slimTests = []struct { - // 2020b slim tzdata for Europe/Berlin. - zoneName: "Europe/Berlin", - tzData: "TZif2\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00TZif2\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00<\x00\x00\x00\x04\x00\x00\x00\x12\xff\xff\xff\xffo\xa2a\xf8\xff\xff\xff\xff\x9b\f\x17`\xff\xff\xff\xff\x9b\xd5\xda\xf0\xff\xff\xff\xff\x9cٮ\x90\xff\xff\xff\xff\x9d\xa4\xb5\x90\xff\xff\xff\xff\x9e\xb9\x90\x90\xff\xff\xff\xff\x9f\x84\x97\x90\xff\xff\xff\xff\xc8\tq\x90\xff\xff\xff\xff\xcc\xe7K\x10\xff\xff\xff\xffͩ\x17\x90\xff\xff\xff\xff\u03a2C\x10\xff\xff\xff\xffϒ4\x10\xff\xff\xff\xffЂ%\x10\xff\xff\xff\xff\xd1r\x16\x10\xff\xff\xff\xffѶ\x96\x00\xff\xff\xff\xff\xd2X\xbe\x80\xff\xff\xff\xffҡO\x10\xff\xff\xff\xff\xd3c\x1b\x90\xff\xff\xff\xff\xd4K#\x90\xff\xff\xff\xff\xd59\xd1 \xff\xff\xff\xff\xd5g\xe7\x90\xff\xff\xff\xffըs\x00\xff\xff\xff\xff\xd6)\xb4\x10\xff\xff\xff\xff\xd7,\x1a\x10\xff\xff\xff\xff\xd8\t\x96\x10\xff\xff\xff\xff\xd9\x02\xc1\x90\xff\xff\xff\xff\xd9\xe9x\x10\x00\x00\x00\x00\x13MD\x10\x00\x00\x00\x00\x143\xfa\x90\x00\x00\x00\x00\x15#\xeb\x90\x00\x00\x00\x00\x16\x13ܐ\x00\x00\x00\x00\x17\x03͐\x00\x00\x00\x00\x17\xf3\xbe\x90\x00\x00\x00\x00\x18㯐\x00\x00\x00\x00\x19Ӡ\x90\x00\x00\x00\x00\x1aÑ\x90\x00\x00\x00\x00\x1b\xbc\xbd\x10\x00\x00\x00\x00\x1c\xac\xae\x10\x00\x00\x00\x00\x1d\x9c\x9f\x10\x00\x00\x00\x00\x1e\x8c\x90\x10\x00\x00\x00\x00\x1f|\x81\x10\x00\x00\x00\x00 lr\x10\x00\x00\x00\x00!\\c\x10\x00\x00\x00\x00\"LT\x10\x00\x00\x00\x00#3<-02>,M3.5.0/-2,M10.5.0/-1\n", -+ date: func(loc *time.Location) time.Time { return time.Date(2020, time.October, 29, 15, 30, 0, 0, loc) }, - wantName: "-03", - wantOffset: -10800, - }, -@@ -207,9 +210,18 @@ var slimTests = []struct { - // 2021a slim tzdata for Asia/Gaza. - zoneName: "Asia/Gaza", - tzData: "TZif3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00TZif3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00s\x00\x00\x00\x05\x00\x00\x00\x15\xff\xff\xff\xff}\xbdJ\xb0\xff\xff\xff\xff\xc8Y\xcf\x00\xff\xff\xff\xff\xc8\xfa\xa6\x00\xff\xff\xff\xff\xc98\x9c\x80\xff\xff\xff\xff\xcc\xe5\xeb\x80\xff\xff\xff\xffͬ\xfe\x00\xff\xff\xff\xff\xce\xc7\x1f\x00\xff\xff\xff\xffϏ\x83\x00\xff\xff\xff\xffЩ\xa4\x00\xff\xff\xff\xffф}\x00\xff\xff\xff\xffҊ׀\xff\xff\xff\xff\xd3e\xb0\x80\xff\xff\xff\xff\xd4l\v\x00\xff\xff\xff\xff\xe86c`\xff\xff\xff\xff\xe8\xf4-P\xff\xff\xff\xff\xea\v\xb9`\xff\xff\xff\xff\xea\xd5`\xd0\xff\xff\xff\xff\xeb\xec\xfa\xf0\xff\xff\xff\xff\xec\xb5m\x00\xff\xff\xff\xff\xed\xcf\u007f\xf0\xff\xff\xff\xff\xee\x97\xf2\x00\xff\xff\xff\xffﰳp\xff\xff\xff\xff\xf0y%\x80\xff\xff\xff\xff\xf1\x91\xe6\xf0\xff\xff\xff\xff\xf2ZY\x00\xff\xff\xff\xff\xf3s\x1ap\xff\xff\xff\xff\xf4;\x8c\x80\xff\xff\xff\xff\xf5U\x9fp\xff\xff\xff\xff\xf6\x1e\x11\x80\xff\xff\xff\xff\xf76\xd2\xf0\xff\xff\xff\xff\xf7\xffE\x00\xff\xff\xff\xff\xf9\x18\x06p\xff\xff\xff\xff\xf9\xe1\xca\x00\xff\xff\xff\xff\xfa\xf99\xf0\xff\xff\xff\xff\xfb'BP\x00\x00\x00\x00\b|\x8b\xe0\x00\x00\x00\x00\b\xfd\xb0\xd0\x00\x00\x00\x00\t\xf6\xea`\x00\x00\x00\x00\n\xa63\xd0\x00\x00\x00\x00\x13\xe9\xfc`\x00\x00\x00\x00\x14![`\x00\x00\x00\x00\x1a\xfa\xc6`\x00\x00\x00\x00\x1b\x8en`\x00\x00\x00\x00\x1c\xbe\xf8\xe0\x00\x00\x00\x00\x1dw|\xd0\x00\x00\x00\x00\x1e\xcc\xff`\x00\x00\x00\x00\x1f`\x99P\x00\x00\x00\x00 \x82\xb1`\x00\x00\x00\x00!I\xb5\xd0\x00\x00\x00\x00\"^\x9e\xe0\x00\x00\x00\x00# ]P\x00\x00\x00\x00$Z0`\x00\x00\x00\x00%\x00?P\x00\x00\x00\x00&\v\xed\xe0\x00\x00\x00\x00&\xd6\xe6\xd0\x00\x00\x00\x00'\xeb\xcf\xe0\x00\x00\x00\x00(\xc0\x03P\x00\x00\x00\x00)\xd4\xec`\x00\x00\x00\x00*\xa9\x1f\xd0\x00\x00\x00\x00+\xbbe\xe0\x00\x00\x00\x00,\x89\x01\xd0\x00\x00\x00\x00-\x9bG\xe0\x00\x00\x00\x00._\xa9P\x00\x00\x00\x00/{)\xe0\x00\x00\x00\x000H\xc5\xd0\x00\x00\x00\x000\xe7\a\xe0\x00\x00\x00\x001dF`\x00\x00\x00\x002A\xc2`\x00\x00\x00\x003D(`\x00\x00\x00\x004!\xa4`\x00\x00\x00\x005$\n`\x00\x00\x00\x006\x01\x86`\x00\x00\x00\x007\x16a`\x00\x00\x00\x008\x06DP\x00\x00\x00\x008\xff}\xe0\x00\x00\x00\x009\xef`\xd0\x00\x00\x00\x00:\xdf_\xe0\x00\x00\x00\x00;\xcfB\xd0\x00\x00\x00\x00<\xbfA\xe0\x00\x00\x00\x00=\xaf$\xd0\x00\x00\x00\x00>\x9f#\xe0\x00\x00\x00\x00?\x8f\x06\xd0\x00\x00\x00\x00@\u007f\x05\xe0\x00\x00\x00\x00A\\\x81\xe0\x00\x00\x00\x00B^\xe7\xe0\x00\x00\x00\x00CA\xb7\xf0\x00\x00\x00\x00D-\xa6`\x00\x00\x00\x00E\x12\xfdP\x00\x00\x00\x00F\x0e\xd9\xe0\x00\x00\x00\x00F\xe8op\x00\x00\x00\x00G\xec\x18\xe0\x00\x00\x00\x00H\xb7\x11\xd0\x00\x00\x00\x00I\xcb\xfa\xe0\x00\x00\x00\x00J\xa0<`\x00\x00\x00\x00K\xad.\x9c\x00\x00\x00\x00La\xbd\xd0\x00\x00\x00\x00M\x94\xf9\x9c\x00\x00\x00\x00N5\xc2P\x00\x00\x00\x00Ot\xdb`\x00\x00\x00\x00P[\x91\xe0\x00\x00\x00\x00QT\xbd`\x00\x00\x00\x00RD\xa0P\x00\x00\x00\x00S4\x9f`\x00\x00\x00\x00TIlP\x00\x00\x00\x00U\x15\xd2\xe0\x00\x00\x00\x00V)\\`\x00\x00\x00\x00V\xf5\xc2\xf0\x00\x00\x00\x00X\x13\xca`\x00\x00\x00\x00Xդ\xf0\x00\x00\x00\x00Y\xf3\xac`\x00\x00\x00\x00Z\xb5\x86\xf0\x00\x00\x00\x00[ӎ`\x00\x00\x00\x00\\\x9dC\xe0\x00\x00\x00\x00]\xb3bP\x00\x00\x00\x00^~w`\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x00\x00 P\x00\x00\x00\x00*0\x01\x04\x00\x00\x1c \x00\t\x00\x00*0\x01\r\x00\x00\x1c \x00\x11LMT\x00EEST\x00EET\x00IDT\x00IST\x00\nEET-2EEST,M3.4.4/48,M10.4.4/49\n", -+ date: func(loc *time.Location) time.Time { return time.Date(2020, time.October, 29, 15, 30, 0, 0, loc) }, - wantName: "EET", - wantOffset: 7200, - }, -+ { -+ // 2021a slim tzdata for Europe/Dublin. -+ zoneName: "Europe/Dublin", -+ tzData: "TZif2\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00TZif2\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x91\x00\x00\x00\x08\x00\x00\x00\x14\xff\xff\xff\xffW\xd1\n\xdc\xff\xff\xff\xff\x9b&\xb3\x91\xff\xff\xff\xff\x9b\xd6\x0b\x11\xff\xff\xff\xff\x9c\xcf0\xa0\xff\xff\xff\xff\x9d\xa4\xc3\xa0\xff\xff\xff\xff\x9e\x9c\x9d\xa0\xff\xff\xff\xff\x9f\x97\x1a\xa0\xff\xff\xff\xff\xa0\x85\xba\x20\xff\xff\xff\xff\xa1v\xfc\xa0\xff\xff\xff\xff\xa2e\x9c\x20\xff\xff\xff\xff\xa3{\xc8\xa0\xff\xff\xff\xff\xa4N\xb8\xa0\xff\xff\xff\xff\xa5?\xfb\x20\xff\xff\xff\xff\xa6%`\x20\xff\xff\xff\xff\xa7'\xc6\x20\xff\xff\xff\xff\xa8*,\x20\xff\xff\xff\xff\xa8\xeb\xf8\xa0\xff\xff\xff\xff\xaa\x00\xd3\xa0\xff\xff\xff\xff\xaa\xd5\x15\x20\xff\xff\xff\xff\xab\xe9\xf0\x20\xff\xff\xff\xff\xac\xc7l\x20\xff\xff\xff\xff\xad\xc9\xd2\x20\xff\xff\xff\xff\xae\xa7N\x20\xff\xff\xff\xff\xaf\xa0y\xa0\xff\xff\xff\xff\xb0\x870\x20\xff\xff\xff\xff\xb1\x92\xd0\xa0\xff\xff\xff\xff\xb2pL\xa0\xff\xff\xff\xff\xb3r\xb2\xa0\xff\xff\xff\xff\xb4P.\xa0\xff\xff\xff\xff\xb5IZ\x20\xff\xff\xff\xff\xb60\x10\xa0\xff\xff\xff\xff\xb72v\xa0\xff\xff\xff\xff\xb8\x0f\xf2\xa0\xff\xff\xff\xff\xb9\x12X\xa0\xff\xff\xff\xff\xb9\xef\xd4\xa0\xff\xff\xff\xff\xba\xe9\x00\x20\xff\xff\xff\xff\xbb\xd8\xf1\x20\xff\xff\xff\xff\xbc\xdbW\x20\xff\xff\xff\xff\xbd\xb8\xd3\x20\xff\xff\xff\xff\xbe\xb1\xfe\xa0\xff\xff\xff\xff\xbf\x98\xb5\x20\xff\xff\xff\xff\xc0\x9b\x1b\x20\xff\xff\xff\xff\xc1x\x97\x20\xff\xff\xff\xff\xc2z\xfd\x20\xff\xff\xff\xff\xc3Xy\x20\xff\xff\xff\xff\xc4Q\xa4\xa0\xff\xff\xff\xff\xc58[\x20\xff\xff\xff\xff\xc6:\xc1\x20\xff\xff\xff\xff\xc7X\xd6\xa0\xff\xff\xff\xff\xc7\xda\x09\xa0\xff\xff\xff\xff\xd4I\xe0\x20\xff\xff\xff\xff\xd5\x1e!\xa0\xff\xff\xff\xff\xd6N\xac\x20\xff\xff\xff\xff\xd7,(\x20\xff\xff\xff\xff\xd8.\x8e\x20\xff\xff\xff\xff\xd8\xf9\x95\x20\xff\xff\xff\xff\xda\x0ep\x20\xff\xff\xff\xff\xda\xeb\xec\x20\xff\xff\xff\xff\xdb\xe5\x17\xa0\xff\xff\xff\xff\xdc\xcb\xce\x20\xff\xff\xff\xff\xdd\xc4\xf9\xa0\xff\xff\xff\xff\xde\xb4\xea\xa0\xff\xff\xff\xff\xdf\xae\x16\x20\xff\xff\xff\xff\xe0\x94\xcc\xa0\xff\xff\xff\xff\xe1rH\xa0\xff\xff\xff\xff\xe2kt\x20\xff\xff\xff\xff\xe3R*\xa0\xff\xff\xff\xff\xe4T\x90\xa0\xff\xff\xff\xff\xe52\x0c\xa0\xff\xff\xff\xff\xe6=\xad\x20\xff\xff\xff\xff\xe7\x1b)\x20\xff\xff\xff\xff\xe8\x14T\xa0\xff\xff\xff\xff\xe8\xfb\x0b\x20\xff\xff\xff\xff\xe9\xfdq\x20\xff\xff\xff\xff\xea\xda\xed\x20\xff\xff\xff\xff\xeb\xddS\x20\xff\xff\xff\xff\xec\xba\xcf\x20\xff\xff\xff\xff\xed\xb3\xfa\xa0\xff\xff\xff\xff\xee\x9a\xb1\x20\xff\xff\xff\xff\xef\x81g\xa0\xff\xff\xff\xff\xf0\x9f}\x20\xff\xff\xff\xff\xf1aI\xa0\xff\xff\xff\xff\xf2\x7f_\x20\xff\xff\xff\xff\xf3Jf\x20\xff\xff\xff\xff\xf4_A\x20\xff\xff\xff\xff\xf5!\x0d\xa0\xff\xff\xff\xff\xf6?#\x20\xff\xff\xff\xff\xf7\x00\xef\xa0\xff\xff\xff\xff\xf8\x1f\x05\x20\xff\xff\xff\xff\xf8\xe0\xd1\xa0\xff\xff\xff\xff\xf9\xfe\xe7\x20\xff\xff\xff\xff\xfa\xc0\xb3\xa0\xff\xff\xff\xff\xfb\xe8\x03\xa0\xff\xff\xff\xff\xfc{\xab\xa0\xff\xff\xff\xff\xfd\xc7\xbbp\x00\x00\x00\x00\x03p\xc6\x20\x00\x00\x00\x00\x04)X\x20\x00\x00\x00\x00\x05P\xa8\x20\x00\x00\x00\x00\x06\x09:\x20\x00\x00\x00\x00\x070\x8a\x20\x00\x00\x00\x00\x07\xe9\x1c\x20\x00\x00\x00\x00\x09\x10l\x20\x00\x00\x00\x00\x09\xc8\xfe\x20\x00\x00\x00\x00\n\xf0N\x20\x00\x00\x00\x00\x0b\xb2\x1a\xa0\x00\x00\x00\x00\x0c\xd00\x20\x00\x00\x00\x00\x0d\x91\xfc\xa0\x00\x00\x00\x00\x0e\xb0\x12\x20\x00\x00\x00\x00\x0fq\xde\xa0\x00\x00\x00\x00\x10\x99.\xa0\x00\x00\x00\x00\x11Q\xc0\xa0\x00\x00\x00\x00\x12y\x10\xa0\x00\x00\x00\x00\x131\xa2\xa0\x00\x00\x00\x00\x14X\xf2\xa0\x00\x00\x00\x00\x15#\xeb\x90\x00\x00\x00\x00\x168\xc6\x90\x00\x00\x00\x00\x17\x03\xcd\x90\x00\x00\x00\x00\x18\x18\xa8\x90\x00\x00\x00\x00\x18\xe3\xaf\x90\x00\x00\x00\x00\x19\xf8\x8a\x90\x00\x00\x00\x00\x1a\xc3\x91\x90\x00\x00\x00\x00\x1b\xe1\xa7\x10\x00\x00\x00\x00\x1c\xac\xae\x10\x00\x00\x00\x00\x1d\xc1\x89\x10\x00\x00\x00\x00\x1e\x8c\x90\x10\x00\x00\x00\x00\x1f\xa1k\x10\x00\x00\x00\x00\x20lr\x10\x00\x00\x00\x00!\x81M\x10\x00\x00\x00\x00\x22LT\x10\x00\x00\x00\x00#a/\x10\x00\x00\x00\x00$,6\x10\x00\x00\x00\x00%JK\x90\x00\x00\x00\x00&\x0c\x18\x10\x00\x00\x00\x00'*-\x90\x00\x00\x00\x00'\xf54\x90\x00\x00\x00\x00)\n\x0f\x90\x00\x00\x00\x00)\xd5\x16\x90\x00\x00\x00\x00*\xe9\xf1\x90\x00\x00\x00\x00+\xb4\xf8\x90\x00\x00\x00\x00,\xc9\xd3\x90\x00\x00\x00\x00-\x94\xda\x90\x00\x00\x00\x00.\xa9\xb5\x90\x00\x00\x00\x00/t\xbc\x90\x00\x00\x00\x000\x89\x97\x90\x00\x00\x00\x001]\xd9\x10\x01\x02\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x07\x06\x07\x06\x07\x06\x07\x06\x07\x06\x07\x06\x07\x06\x07\x06\x07\x06\x07\x06\x07\x06\x07\x06\x07\x06\x07\x06\x07\x06\x07\x06\x07\x06\x07\x06\x07\x06\x07\x06\x07\x06\x07\x06\x07\x06\x07\x06\x07\x06\x07\xff\xff\xfa$\x00\x00\xff\xff\xfa\x0f\x00\x04\x00\x00\x08\x1f\x01\x08\x00\x00\x0e\x10\x01\x0c\x00\x00\x00\x00\x00\x10\x00\x00\x0e\x10\x01\x08\x00\x00\x00\x00\x01\x10\x00\x00\x0e\x10\x00\x08LMT\x00DMT\x00IST\x00BST\x00GMT\x00\nIST-1GMT0,M10.5.0,M3.5.0/1\n", -+ date: func(loc *time.Location) time.Time { return time.Date(2021, time.April, 2, 11, 12, 13, 0, loc) }, -+ wantName: "IST", -+ wantOffset: 3600, -+ }, - } - - func TestLoadLocationFromTZDataSlim(t *testing.T) { -@@ -219,7 +231,7 @@ func TestLoadLocationFromTZDataSlim(t *testing.T) { - t.Fatal(err) - } - -- d := time.Date(2020, time.October, 29, 15, 30, 0, 0, reference) -+ d := test.date(reference) - tzName, tzOffset := d.Zone() - if tzName != test.wantName { - t.Errorf("Zone name == %s, want %s", tzName, test.wantName) -@@ -239,20 +251,21 @@ func TestTzset(t *testing.T) { - off int - start int64 - end int64 -+ isDST bool - ok bool - }{ -- {"", 0, 0, "", 0, 0, 0, false}, -- {"PST8PDT,M3.2.0,M11.1.0", 0, 2159200800, "PDT", -7 * 60 * 60, 2152173600, 2172733200, true}, -- {"PST8PDT,M3.2.0,M11.1.0", 0, 2152173599, "PST", -8 * 60 * 60, 2145916800, 2152173600, true}, -- {"PST8PDT,M3.2.0,M11.1.0", 0, 2152173600, "PDT", -7 * 60 * 60, 2152173600, 2172733200, true}, -- {"PST8PDT,M3.2.0,M11.1.0", 0, 2152173601, "PDT", -7 * 60 * 60, 2152173600, 2172733200, true}, -- {"PST8PDT,M3.2.0,M11.1.0", 0, 2172733199, "PDT", -7 * 60 * 60, 2152173600, 2172733200, true}, -- {"PST8PDT,M3.2.0,M11.1.0", 0, 2172733200, "PST", -8 * 60 * 60, 2172733200, 2177452800, true}, -- {"PST8PDT,M3.2.0,M11.1.0", 0, 2172733201, "PST", -8 * 60 * 60, 2172733200, 2177452800, true}, -+ {"", 0, 0, "", 0, 0, 0, false, false}, -+ {"PST8PDT,M3.2.0,M11.1.0", 0, 2159200800, "PDT", -7 * 60 * 60, 2152173600, 2172733200, true, true}, -+ {"PST8PDT,M3.2.0,M11.1.0", 0, 2152173599, "PST", -8 * 60 * 60, 2145916800, 2152173600, false, true}, -+ {"PST8PDT,M3.2.0,M11.1.0", 0, 2152173600, "PDT", -7 * 60 * 60, 2152173600, 2172733200, true, true}, -+ {"PST8PDT,M3.2.0,M11.1.0", 0, 2152173601, "PDT", -7 * 60 * 60, 2152173600, 2172733200, true, true}, -+ {"PST8PDT,M3.2.0,M11.1.0", 0, 2172733199, "PDT", -7 * 60 * 60, 2152173600, 2172733200, true, true}, -+ {"PST8PDT,M3.2.0,M11.1.0", 0, 2172733200, "PST", -8 * 60 * 60, 2172733200, 2177452800, false, true}, -+ {"PST8PDT,M3.2.0,M11.1.0", 0, 2172733201, "PST", -8 * 60 * 60, 2172733200, 2177452800, false, true}, - } { -- name, off, start, end, ok := time.Tzset(test.inStr, test.inEnd, test.inSec) -- if name != test.name || off != test.off || start != test.start || end != test.end || ok != test.ok { -- t.Errorf("tzset(%q, %d, %d) = %q, %d, %d, %d, %t, want %q, %d, %d, %d, %t", test.inStr, test.inEnd, test.inSec, name, off, start, end, ok, test.name, test.off, test.start, test.end, test.ok) -+ name, off, start, end, isDST, ok := time.Tzset(test.inStr, test.inEnd, test.inSec) -+ if name != test.name || off != test.off || start != test.start || end != test.end || isDST != test.isDST || ok != test.ok { -+ t.Errorf("tzset(%q, %d, %d) = %q, %d, %d, %d, %t, %t, want %q, %d, %d, %d, %t, %t", test.inStr, test.inEnd, test.inSec, name, off, start, end, isDST, ok, test.name, test.off, test.start, test.end, test.isDST, test.ok) - } - } - } --- -2.27.0 - diff --git a/0038-release-branch.go1.15-std-update-golang.org-x-net-to.patch b/0038-release-branch.go1.15-std-update-golang.org-x-net-to.patch deleted file mode 100644 index fe2ee89f3a6ca1062d6dd9a165a381084f1de269..0000000000000000000000000000000000000000 --- a/0038-release-branch.go1.15-std-update-golang.org-x-net-to.patch +++ /dev/null @@ -1,97 +0,0 @@ -From 5aed4ce3c854bdbbb6dd5c1ccfa15c23d4b6c989 Mon Sep 17 00:00:00 2001 -From: Katie Hockman -Date: Wed, 28 Apr 2021 14:47:48 -0400 -Subject: [PATCH 38/44] [release-branch.go1.15] std: update golang.org/x/net to - 20210428183841-261fb518b1ed - -Steps: - go get -d golang.org/x/net@release-branch.go1.15 - go mod tidy - go mod vendor - -This http2 bundle does not need to be updated. - -Fixes #45711 - -Change-Id: I085ca592dfc8d5d9c328a7979142e88e7130a813 -Reviewed-on: https://go-review.googlesource.com/c/go/+/314790 -Trust: Katie Hockman -Run-TryBot: Katie Hockman -Reviewed-by: Dmitri Shuralyov - -Conflict:NA -Reference:https://github.com/golang/go/commit/5aed4ce3c854bdbbb6dd5c1ccfa15c23d4b6c989 - ---- - src/go.mod | 2 +- - src/go.sum | 4 ++-- - src/vendor/golang.org/x/net/http/httpguts/httplex.go | 10 ++++++---- - src/vendor/modules.txt | 2 +- - 4 files changed, 10 insertions(+), 8 deletions(-) - -diff --git a/src/go.mod b/src/go.mod -index 6b97366bbe..dfcba7a1c8 100644 ---- a/src/go.mod -+++ b/src/go.mod -@@ -4,7 +4,7 @@ go 1.15 - - require ( - golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 -- golang.org/x/net v0.0.0-20201008223702-a5fa9d4b7c91 -+ golang.org/x/net v0.0.0-20210428183841-261fb518b1ed - golang.org/x/sys v0.0.0-20200501145240-bc7a7d42d5c3 // indirect - golang.org/x/text v0.3.3-0.20200430171850-afb9336c4530 // indirect - ) -diff --git a/src/go.sum b/src/go.sum -index fbd3279aad..47e918848c 100644 ---- a/src/go.sum -+++ b/src/go.sum -@@ -2,8 +2,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk - golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI= - golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= - golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= --golang.org/x/net v0.0.0-20201008223702-a5fa9d4b7c91 h1:zd7kl5i5PDM0OnFbRWVM6B8mXojzv8LOkHN9LsOrRf4= --golang.org/x/net v0.0.0-20201008223702-a5fa9d4b7c91/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -+golang.org/x/net v0.0.0-20210428183841-261fb518b1ed h1:aunM0N/jnRHvQgZo3kYkfaAGet2kIMFOPIbopG5BhYw= -+golang.org/x/net v0.0.0-20210428183841-261fb518b1ed/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= - golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= - golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= - golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -diff --git a/src/vendor/golang.org/x/net/http/httpguts/httplex.go b/src/vendor/golang.org/x/net/http/httpguts/httplex.go -index e7de24ee64..c79aa73f28 100644 ---- a/src/vendor/golang.org/x/net/http/httpguts/httplex.go -+++ b/src/vendor/golang.org/x/net/http/httpguts/httplex.go -@@ -137,11 +137,13 @@ func trimOWS(x string) string { - // contains token amongst its comma-separated tokens, ASCII - // case-insensitively. - func headerValueContainsToken(v string, token string) bool { -- v = trimOWS(v) -- if comma := strings.IndexByte(v, ','); comma != -1 { -- return tokenEqual(trimOWS(v[:comma]), token) || headerValueContainsToken(v[comma+1:], token) -+ for comma := strings.IndexByte(v, ','); comma != -1; comma = strings.IndexByte(v, ',') { -+ if tokenEqual(trimOWS(v[:comma]), token) { -+ return true -+ } -+ v = v[comma+1:] - } -- return tokenEqual(v, token) -+ return tokenEqual(trimOWS(v), token) - } - - // lowerASCII returns the ASCII lowercase version of b. -diff --git a/src/vendor/modules.txt b/src/vendor/modules.txt -index 03ca3c3ae4..dd2296b694 100644 ---- a/src/vendor/modules.txt -+++ b/src/vendor/modules.txt -@@ -8,7 +8,7 @@ golang.org/x/crypto/curve25519 - golang.org/x/crypto/hkdf - golang.org/x/crypto/internal/subtle - golang.org/x/crypto/poly1305 --# golang.org/x/net v0.0.0-20201008223702-a5fa9d4b7c91 -+# golang.org/x/net v0.0.0-20210428183841-261fb518b1ed - ## explicit - golang.org/x/net/dns/dnsmessage - golang.org/x/net/http/httpguts --- -2.27.0 - diff --git a/0039-release-branch.go1.15-runtime-time-disable-preemptio.patch b/0039-release-branch.go1.15-runtime-time-disable-preemptio.patch deleted file mode 100644 index bde920dd557b423f4b43c278b5a0de121703a47c..0000000000000000000000000000000000000000 --- a/0039-release-branch.go1.15-runtime-time-disable-preemptio.patch +++ /dev/null @@ -1,95 +0,0 @@ -From 72ccabc99449b2cb5bb1438eb90244d55f7b02f5 Mon Sep 17 00:00:00 2001 -From: Michael Pratt -Date: Wed, 10 Mar 2021 16:06:47 -0500 -Subject: [PATCH 39/44] [release-branch.go1.15] runtime, time: disable - preemption in addtimer - -The timerpMask optimization updates a mask of Ps (potentially) -containing timers in pidleget / pidleput. For correctness, it depends on -the assumption that new timers can only be added to a P's own heap. - -addtimer violates this assumption if it is preempted after computing pp. -That G may then run on a different P, but adding a timer to the original -P's heap. - -Avoid this by disabling preemption while pp is in use. - -Other uses of doaddtimer should be OK: - -* moveTimers: always moves to the current P's heap -* modtimer, cleantimers, addAdjustedTimers, runtimer: does not add net - new timers to the heap while locked - -For #44868 -Fixes #45731 - -Change-Id: I4a5d080865e854931d0a3a09a51ca36879101d72 -Reviewed-on: https://go-review.googlesource.com/c/go/+/300610 -Trust: Michael Pratt -Run-TryBot: Michael Pratt -Reviewed-by: Michael Knyszek -Reviewed-by: Ian Lance Taylor -TryBot-Result: Go Bot -Reviewed-on: https://go-review.googlesource.com/c/go/+/313129 -Trust: Ian Lance Taylor -Run-TryBot: Ian Lance Taylor -Reviewed-by: Michael Pratt - -Conflict:NA -Reference:https://github.com/golang/go/commit/72ccabc99449b2cb5bb1438eb90244d55f7b02f5 - ---- - src/runtime/time.go | 5 +++++ - src/time/sleep_test.go | 16 ++++++++++++++++ - 2 files changed, 21 insertions(+) - -diff --git a/src/runtime/time.go b/src/runtime/time.go -index ec3eae9cca..de7468d129 100644 ---- a/src/runtime/time.go -+++ b/src/runtime/time.go -@@ -254,6 +254,9 @@ func addtimer(t *timer) { - - when := t.when - -+ // Disable preemption while using pp to avoid changing another P's heap. -+ mp := acquirem() -+ - pp := getg().m.p.ptr() - lock(&pp.timersLock) - cleantimers(pp) -@@ -261,6 +264,8 @@ func addtimer(t *timer) { - unlock(&pp.timersLock) - - wakeNetPoller(when) -+ -+ releasem(mp) - } - - // doaddtimer adds t to the current P's heap. -diff --git a/src/time/sleep_test.go b/src/time/sleep_test.go -index f5678020b9..ea253f8709 100644 ---- a/src/time/sleep_test.go -+++ b/src/time/sleep_test.go -@@ -501,3 +501,19 @@ func TestZeroTimerStopPanics(t *testing.T) { - var tr Timer - tr.Stop() - } -+ -+// Test that zero duration timers aren't missed by the scheduler. Regression test for issue 44868. -+func TestZeroTimer(t *testing.T) { -+ if testing.Short() { -+ t.Skip("-short") -+ } -+ -+ for i := 0; i < 1000000; i++ { -+ s := Now() -+ ti := NewTimer(0) -+ <-ti.C -+ if diff := Since(s); diff > 2*Second { -+ t.Errorf("Expected time to get value from Timer channel in less than 2 sec, took %v", diff) -+ } -+ } -+} --- -2.27.0 - diff --git a/0040-release-branch.go1.15-runtime-non-strict-InlTreeInde.patch b/0040-release-branch.go1.15-runtime-non-strict-InlTreeInde.patch deleted file mode 100644 index e13ccf7ff64825089e7764a93a305b17d5f223e6..0000000000000000000000000000000000000000 --- a/0040-release-branch.go1.15-runtime-non-strict-InlTreeInde.patch +++ /dev/null @@ -1,54 +0,0 @@ -From c0a7ecfae775a9d50d338e8123fac32a5d04308c Mon Sep 17 00:00:00 2001 -From: Michael Pratt -Date: Fri, 9 Apr 2021 17:01:45 -0400 -Subject: [PATCH 40/44] [release-branch.go1.15] runtime: non-strict - InlTreeIndex lookup in expandFinalInlineFrame - -This is a follow-up to golang.org/cl/301369, which made the same change -in Frames.Next. The same logic applies here: a profile stack may have -been truncated at an invalid PC provided by cgoTraceback. -expandFinalInlineFrame will then try to lookup the inline tree and -crash. - -The same fix applies as well: upon encountering a bad PC, simply leave -it as-is and move on. - -For #44971 -For #45480 -Fixes #45481 - -Change-Id: I2823c67a1f3425466b05384cc6d30f5fc8ee6ddc -Reviewed-on: https://go-review.googlesource.com/c/go/+/309109 -Reviewed-by: Michael Knyszek -Trust: Michael Pratt -(cherry picked from commit aad13cbb749d1e6c085ff0556d306de1a2d5d063) -Reviewed-on: https://go-review.googlesource.com/c/go/+/309550 -Run-TryBot: Michael Pratt -Reviewed-by: Cherry Zhang -TryBot-Result: Go Bot - -Conflict:NA -Reference:https://github.com/golang/go/commit/c0a7ecfae775a9d50d338e8123fac32a5d04308c - ---- - src/runtime/symtab.go | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -diff --git a/src/runtime/symtab.go b/src/runtime/symtab.go -index c77d513e74..75772f4fd8 100644 ---- a/src/runtime/symtab.go -+++ b/src/runtime/symtab.go -@@ -185,7 +185,9 @@ func runtime_expandFinalInlineFrame(stk []uintptr) []uintptr { - var cache pcvalueCache - inltree := (*[1 << 20]inlinedCall)(inldata) - for { -- ix := pcdatavalue(f, _PCDATA_InlTreeIndex, tracepc, &cache) -+ // Non-strict as cgoTraceback may have added bogus PCs -+ // with a valid funcInfo but invalid PCDATA. -+ ix := pcdatavalue1(f, _PCDATA_InlTreeIndex, tracepc, &cache, false) - if ix < 0 { - break - } --- -2.27.0 - diff --git a/0041-release-branch.go1.15-runtime-pprof-skip-tests-for-A.patch b/0041-release-branch.go1.15-runtime-pprof-skip-tests-for-A.patch deleted file mode 100644 index dd2edf4e19747bcf3780e97fd239dd1c501ec4d7..0000000000000000000000000000000000000000 --- a/0041-release-branch.go1.15-runtime-pprof-skip-tests-for-A.patch +++ /dev/null @@ -1,48 +0,0 @@ -From ba7cac469b399b36e8d3e40ac57eb11688c53e00 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Cl=C3=A9ment=20Chigot?= -Date: Thu, 1 Apr 2021 10:06:05 +0200 -Subject: [PATCH 41/44] [release-branch.go1.15] runtime/pprof: skip tests for - AIX - -Most of the time, the pprof tests are passing, except -for the builder. The reason is still unknown but I'd rather release -the builder to avoid missing other more important bugs. - -Updates #45170 - -Change-Id: I667543ee1ae309b7319c5b3676a0901b4d0ecf2e -Reviewed-on: https://go-review.googlesource.com/c/go/+/306489 -Run-TryBot: Tobias Klauser -TryBot-Result: Go Bot -Reviewed-by: Cherry Zhang -Trust: Lynn Boger -(cherry picked from commit 7bfd681c2f11918c6245ad2906b2efc12eda2914) -Reviewed-on: https://go-review.googlesource.com/c/go/+/317369 -Reviewed-by: Heschi Kreinick -Trust: Dmitri Shuralyov -Run-TryBot: Dmitri Shuralyov - -Conflict:NA -Reference:https://github.com/golang/go/commit/ba7cac469b399b36e8d3e40ac57eb11688c53e00 - ---- - src/runtime/pprof/pprof_test.go | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/src/runtime/pprof/pprof_test.go b/src/runtime/pprof/pprof_test.go -index 7149bfb31f..9c1c097206 100644 ---- a/src/runtime/pprof/pprof_test.go -+++ b/src/runtime/pprof/pprof_test.go -@@ -280,7 +280,8 @@ func testCPUProfile(t *testing.T, matches matchFunc, need []string, avoid []stri - - broken := false - switch runtime.GOOS { -- case "darwin", "dragonfly", "netbsd", "illumos", "solaris": -+ // See https://golang.org/issue/45170 for AIX. -+ case "darwin", "dragonfly", "netbsd", "illumos", "solaris", "aix": - broken = true - case "openbsd": - if runtime.GOARCH == "arm" || runtime.GOARCH == "arm64" { --- -2.27.0 - diff --git a/0043-release-branch.go1.15-math-big-fix-TestShiftOverlap-.patch b/0043-release-branch.go1.15-math-big-fix-TestShiftOverlap-.patch deleted file mode 100644 index 61e4a7658747c36b5c3c47407f90550dd93333dc..0000000000000000000000000000000000000000 --- a/0043-release-branch.go1.15-math-big-fix-TestShiftOverlap-.patch +++ /dev/null @@ -1,65 +0,0 @@ -From 44a6805ca92b00f30d5ed3f9e8d0b464d3f402bf Mon Sep 17 00:00:00 2001 -From: SparrowLii -Date: Mon, 24 Aug 2020 14:43:32 +0800 -Subject: [PATCH 43/44] [release-branch.go1.15] math/big: fix TestShiftOverlap - for test -count arguments > 1 - -Don't overwrite incoming test data. - -The change uses copy instead of assigning statement to avoid this. - -For #45335 - -Change-Id: Ib907101822d811de5c45145cb9d7961907e212c3 -Reviewed-on: https://go-review.googlesource.com/c/go/+/250137 -Run-TryBot: Emmanuel Odeke -TryBot-Result: Gobot Gobot -Reviewed-by: Robert Griesemer -(cherry picked from commit 41bc0a1713b9436e96c2d64211ad94e42cafd591) -Reviewed-on: https://go-review.googlesource.com/c/go/+/319831 -Run-TryBot: Carlos Amedee -TryBot-Result: Go Bot -Trust: Carlos Amedee -Reviewed-by: Jonathan Albrecht -Reviewed-by: Emmanuel Odeke - -Conflict:NA -Reference:https://github.com/golang/go/commit/44a6805ca92b00f30d5ed3f9e8d0b464d3f402bf - ---- - src/math/big/arith_test.go | 10 +++++----- - 1 file changed, 5 insertions(+), 5 deletions(-) - -diff --git a/src/math/big/arith_test.go b/src/math/big/arith_test.go -index 05136f1895..e2b982c89c 100644 ---- a/src/math/big/arith_test.go -+++ b/src/math/big/arith_test.go -@@ -241,20 +241,20 @@ var argshrVU = []argVU{ - } - - func testShiftFunc(t *testing.T, f func(z, x []Word, s uint) Word, a argVU) { -- // save a.d for error message, or it will be overwritten. -+ // work on copy of a.d to preserve the original data. - b := make([]Word, len(a.d)) - copy(b, a.d) -- z := a.d[a.zp : a.zp+a.l] -- x := a.d[a.xp : a.xp+a.l] -+ z := b[a.zp : a.zp+a.l] -+ x := b[a.xp : a.xp+a.l] - c := f(z, x, a.s) - for i, zi := range z { - if zi != a.r[i] { -- t.Errorf("d := %v, %s(d[%d:%d], d[%d:%d], %d)\n\tgot z[%d] = %#x; want %#x", b, a.m, a.zp, a.zp+a.l, a.xp, a.xp+a.l, a.s, i, zi, a.r[i]) -+ t.Errorf("d := %v, %s(d[%d:%d], d[%d:%d], %d)\n\tgot z[%d] = %#x; want %#x", a.d, a.m, a.zp, a.zp+a.l, a.xp, a.xp+a.l, a.s, i, zi, a.r[i]) - break - } - } - if c != a.c { -- t.Errorf("d := %v, %s(d[%d:%d], d[%d:%d], %d)\n\tgot c = %#x; want %#x", b, a.m, a.zp, a.zp+a.l, a.xp, a.xp+a.l, a.s, c, a.c) -+ t.Errorf("d := %v, %s(d[%d:%d], d[%d:%d], %d)\n\tgot c = %#x; want %#x", a.d, a.m, a.zp, a.zp+a.l, a.xp, a.xp+a.l, a.s, c, a.c) - } - } - --- -2.27.0 - diff --git a/0044-release-branch.go1.15-math-big-remove-the-s390x-asse.patch b/0044-release-branch.go1.15-math-big-remove-the-s390x-asse.patch deleted file mode 100644 index 799505e68cfc601c9532cedc83ed7d393528e4b8..0000000000000000000000000000000000000000 --- a/0044-release-branch.go1.15-math-big-remove-the-s390x-asse.patch +++ /dev/null @@ -1,337 +0,0 @@ -From 963687891319d118c20a2a71f0234ceb3a8dade4 Mon Sep 17 00:00:00 2001 -From: Jonathan Albrecht -Date: Wed, 2 Dec 2020 10:44:10 -0500 -Subject: [PATCH 44/44] [release-branch.go1.15] math/big: remove the s390x - assembly for shlVU and shrVU - -The s390x assembly for shlVU does a forward copy when the shift amount s -is 0. This causes corruption of the result z when z is aliased to the -input x. - -This fix removes the s390x assembly for both shlVU and shrVU so the pure -go implementations will be used. - -Test cases have been added to the existing TestShiftOverlap test to -cover shift values of 0, 1 and (_W - 1). - -Fixes #45335 - -Change-Id: I75ca0e98f3acfaa6366a26355dcd9dd82499a48b -Reviewed-on: https://go-review.googlesource.com/c/go/+/274442 -Run-TryBot: Robert Griesemer -TryBot-Result: Go Bot -Reviewed-by: Robert Griesemer -Reviewed-by: Matthew Dempsky -Trust: Robert Griesemer -(cherry picked from commit b1369d5862bc78eaa902ae637c874e6a6133f1f9) -Reviewed-on: https://go-review.googlesource.com/c/go/+/320169 -Trust: Carlos Amedee -Run-TryBot: Carlos Amedee -Reviewed-by: Dmitri Shuralyov - -Conflict:NA -Reference:https://github.com/golang/go/commit/963687891319d118c20a2a71f0234ceb3a8dade4 - ---- - src/math/big/arith_s390x.s | 192 +------------------------------------ - src/math/big/arith_test.go | 55 ++++++++++- - 2 files changed, 54 insertions(+), 193 deletions(-) - -diff --git a/src/math/big/arith_s390x.s b/src/math/big/arith_s390x.s -index 4891768111..153c42679c 100644 ---- a/src/math/big/arith_s390x.s -+++ b/src/math/big/arith_s390x.s -@@ -702,199 +702,11 @@ returnC: - - // func shlVU(z, x []Word, s uint) (c Word) - TEXT ·shlVU(SB), NOSPLIT, $0 -- MOVD z_len+8(FP), R5 -- MOVD $0, R0 -- SUB $1, R5 // n-- -- BLT X8b // n < 0 (n <= 0) -- -- // n > 0 -- MOVD s+48(FP), R4 -- CMPBEQ R0, R4, Z80 // handle 0 case beq -- MOVD $64, R6 -- CMPBEQ R6, R4, Z864 // handle 64 case beq -- MOVD z+0(FP), R2 -- MOVD x+24(FP), R8 -- SLD $3, R5 // n = n*8 -- SUB R4, R6, R7 -- MOVD (R8)(R5*1), R10 // w1 = x[i-1] -- SRD R7, R10, R3 -- MOVD R3, c+56(FP) -- -- MOVD $0, R1 // i = 0 -- BR E8 -- -- // i < n-1 --L8: -- MOVD R10, R3 // w = w1 -- MOVD -8(R8)(R5*1), R10 // w1 = x[i+1] -- -- SLD R4, R3 // w<>ŝ -- SRD R7, R10, R6 -- OR R6, R3 -- MOVD R3, (R2)(R5*1) // z[i] = w<>ŝ -- SUB $8, R5 // i-- -- --E8: -- CMPBGT R5, R0, L8 // i < n-1 -- -- // i >= n-1 --X8a: -- SLD R4, R10 // w1<= n-1 -- MOVD R10, (R2)(R5*1) -- RET -- --Z864: -- MOVD z+0(FP), R2 -- MOVD x+24(FP), R8 -- SLD $3, R5 // n = n*8 -- MOVD (R8)(R5*1), R3 // w1 = x[n-1] -- MOVD R3, c+56(FP) // z[i] = x[n-1] -- -- BR E864 -- -- // i < n-1 --L864: -- MOVD -8(R8)(R5*1), R3 -- -- MOVD R3, (R2)(R5*1) // z[i] = x[n-1] -- SUB $8, R5 // i-- -- --E864: -- CMPBGT R5, R0, L864 // i < n-1 -- -- MOVD R0, (R2) // z[n-1] = 0 -- RET -+ BR ·shlVU_g(SB) - --// CX = R4, r8 = r8, r10 = r2 , r11 = r5, DX = r3, AX = r10 , BX = R1 , 64-count = r7 (R0 set to 0) temp = R6 - // func shrVU(z, x []Word, s uint) (c Word) - TEXT ·shrVU(SB), NOSPLIT, $0 -- MOVD z_len+8(FP), R5 -- MOVD $0, R0 -- SUB $1, R5 // n-- -- BLT X9b // n < 0 (n <= 0) -- -- // n > 0 -- MOVD s+48(FP), R4 -- CMPBEQ R0, R4, ZB0 // handle 0 case beq -- MOVD $64, R6 -- CMPBEQ R6, R4, ZB64 // handle 64 case beq -- MOVD z+0(FP), R2 -- MOVD x+24(FP), R8 -- SLD $3, R5 // n = n*8 -- SUB R4, R6, R7 -- MOVD (R8), R10 // w1 = x[0] -- SLD R7, R10, R3 -- MOVD R3, c+56(FP) -- -- MOVD $0, R1 // i = 0 -- BR E9 -- -- // i < n-1 --L9: -- MOVD R10, R3 // w = w1 -- MOVD 8(R8)(R1*1), R10 // w1 = x[i+1] -- -- SRD R4, R3 // w>>s | w1<>s | w1<= n-1 --X9a: -- SRD R4, R10 // w1>>s -- MOVD R10, (R2)(R5*1) // z[n-1] = w1>>s -- RET -- --X9b: -- MOVD R0, c+56(FP) -- RET -- --ZB0: -- MOVD z+0(FP), R2 -- MOVD x+24(FP), R8 -- SLD $3, R5 // n = n*8 -- -- MOVD (R8), R10 // w1 = x[0] -- MOVD $0, R3 // R10 << 64 -- MOVD R3, c+56(FP) -- -- MOVD $0, R1 // i = 0 -- BR E9Z -- -- // i < n-1 --L9Z: -- MOVD R10, R3 // w = w1 -- MOVD 8(R8)(R1*1), R10 // w1 = x[i+1] -- -- MOVD R3, (R2)(R1*1) // z[i] = w>>s | w1<= n-1 -- MOVD R10, (R2)(R5*1) // z[n-1] = w1>>s -- RET -- --ZB64: -- MOVD z+0(FP), R2 -- MOVD x+24(FP), R8 -- SLD $3, R5 // n = n*8 -- MOVD (R8), R3 // w1 = x[0] -- MOVD R3, c+56(FP) -- -- MOVD $0, R1 // i = 0 -- BR E964 -- -- // i < n-1 --L964: -- MOVD 8(R8)(R1*1), R3 // w1 = x[i+1] -- -- MOVD R3, (R2)(R1*1) // z[i] = w>>s | w1<= n-1 -- MOVD $0, R10 // w1>>s -- MOVD R10, (R2)(R5*1) // z[n-1] = w1>>s -- RET -+ BR ·shrVU_g(SB) - - // CX = R4, r8 = r8, r9=r9, r10 = r2 , r11 = r5, DX = r3, AX = r6 , BX = R1 , (R0 set to 0) + use R11 + use R7 for i - // func mulAddVWW(z, x []Word, y, r Word) (c Word) -diff --git a/src/math/big/arith_test.go b/src/math/big/arith_test.go -index e2b982c89c..fbbaa0e122 100644 ---- a/src/math/big/arith_test.go -+++ b/src/math/big/arith_test.go -@@ -224,13 +224,36 @@ type argVU struct { - m string // message. - } - -+var argshlVUIn = []Word{1, 2, 4, 8, 16, 32, 64, 0, 0, 0} -+var argshlVUr0 = []Word{1, 2, 4, 8, 16, 32, 64} -+var argshlVUr1 = []Word{2, 4, 8, 16, 32, 64, 128} -+var argshlVUrWm1 = []Word{1 << (_W - 1), 0, 1, 2, 4, 8, 16} -+ - var argshlVU = []argVU{ - // test cases for shlVU - {[]Word{1, _M, _M, _M, _M, _M, 3 << (_W - 2), 0}, 7, 0, 0, 1, []Word{2, _M - 1, _M, _M, _M, _M, 1<<(_W-1) + 1}, 1, "complete overlap of shlVU"}, - {[]Word{1, _M, _M, _M, _M, _M, 3 << (_W - 2), 0, 0, 0, 0}, 7, 0, 3, 1, []Word{2, _M - 1, _M, _M, _M, _M, 1<<(_W-1) + 1}, 1, "partial overlap by half of shlVU"}, - {[]Word{1, _M, _M, _M, _M, _M, 3 << (_W - 2), 0, 0, 0, 0, 0, 0, 0}, 7, 0, 6, 1, []Word{2, _M - 1, _M, _M, _M, _M, 1<<(_W-1) + 1}, 1, "partial overlap by 1 Word of shlVU"}, - {[]Word{1, _M, _M, _M, _M, _M, 3 << (_W - 2), 0, 0, 0, 0, 0, 0, 0, 0}, 7, 0, 7, 1, []Word{2, _M - 1, _M, _M, _M, _M, 1<<(_W-1) + 1}, 1, "no overlap of shlVU"}, --} -+ // additional test cases with shift values of 0, 1 and (_W-1) -+ {argshlVUIn, 7, 0, 0, 0, argshlVUr0, 0, "complete overlap of shlVU and shift of 0"}, -+ {argshlVUIn, 7, 0, 0, 1, argshlVUr1, 0, "complete overlap of shlVU and shift of 1"}, -+ {argshlVUIn, 7, 0, 0, _W - 1, argshlVUrWm1, 32, "complete overlap of shlVU and shift of _W - 1"}, -+ {argshlVUIn, 7, 0, 1, 0, argshlVUr0, 0, "partial overlap by 6 Words of shlVU and shift of 0"}, -+ {argshlVUIn, 7, 0, 1, 1, argshlVUr1, 0, "partial overlap by 6 Words of shlVU and shift of 1"}, -+ {argshlVUIn, 7, 0, 1, _W - 1, argshlVUrWm1, 32, "partial overlap by 6 Words of shlVU and shift of _W - 1"}, -+ {argshlVUIn, 7, 0, 2, 0, argshlVUr0, 0, "partial overlap by 5 Words of shlVU and shift of 0"}, -+ {argshlVUIn, 7, 0, 2, 1, argshlVUr1, 0, "partial overlap by 5 Words of shlVU and shift of 1"}, -+ {argshlVUIn, 7, 0, 2, _W - 1, argshlVUrWm1, 32, "partial overlap by 5 Words of shlVU abd shift of _W - 1"}, -+ {argshlVUIn, 7, 0, 3, 0, argshlVUr0, 0, "partial overlap by 4 Words of shlVU and shift of 0"}, -+ {argshlVUIn, 7, 0, 3, 1, argshlVUr1, 0, "partial overlap by 4 Words of shlVU and shift of 1"}, -+ {argshlVUIn, 7, 0, 3, _W - 1, argshlVUrWm1, 32, "partial overlap by 4 Words of shlVU and shift of _W - 1"}, -+} -+ -+var argshrVUIn = []Word{0, 0, 0, 1, 2, 4, 8, 16, 32, 64} -+var argshrVUr0 = []Word{1, 2, 4, 8, 16, 32, 64} -+var argshrVUr1 = []Word{0, 1, 2, 4, 8, 16, 32} -+var argshrVUrWm1 = []Word{4, 8, 16, 32, 64, 128, 0} - - var argshrVU = []argVU{ - // test cases for shrVU -@@ -238,6 +261,19 @@ var argshrVU = []argVU{ - {[]Word{0, 0, 0, 0, 3, _M, _M, _M, _M, _M, 1 << (_W - 1)}, 7, 4, 1, 1, []Word{1<<(_W-1) + 1, _M, _M, _M, _M, _M >> 1, 1 << (_W - 2)}, 1 << (_W - 1), "partial overlap by half of shrVU"}, - {[]Word{0, 0, 0, 0, 0, 0, 0, 3, _M, _M, _M, _M, _M, 1 << (_W - 1)}, 7, 7, 1, 1, []Word{1<<(_W-1) + 1, _M, _M, _M, _M, _M >> 1, 1 << (_W - 2)}, 1 << (_W - 1), "partial overlap by 1 Word of shrVU"}, - {[]Word{0, 0, 0, 0, 0, 0, 0, 0, 3, _M, _M, _M, _M, _M, 1 << (_W - 1)}, 7, 8, 1, 1, []Word{1<<(_W-1) + 1, _M, _M, _M, _M, _M >> 1, 1 << (_W - 2)}, 1 << (_W - 1), "no overlap of shrVU"}, -+ // additional test cases with shift values of 0, 1 and (_W-1) -+ {argshrVUIn, 7, 3, 3, 0, argshrVUr0, 0, "complete overlap of shrVU and shift of 0"}, -+ {argshrVUIn, 7, 3, 3, 1, argshrVUr1, 1 << (_W - 1), "complete overlap of shrVU and shift of 1"}, -+ {argshrVUIn, 7, 3, 3, _W - 1, argshrVUrWm1, 2, "complete overlap of shrVU and shift of _W - 1"}, -+ {argshrVUIn, 7, 3, 2, 0, argshrVUr0, 0, "partial overlap by 6 Words of shrVU and shift of 0"}, -+ {argshrVUIn, 7, 3, 2, 1, argshrVUr1, 1 << (_W - 1), "partial overlap by 6 Words of shrVU and shift of 1"}, -+ {argshrVUIn, 7, 3, 2, _W - 1, argshrVUrWm1, 2, "partial overlap by 6 Words of shrVU and shift of _W - 1"}, -+ {argshrVUIn, 7, 3, 1, 0, argshrVUr0, 0, "partial overlap by 5 Words of shrVU and shift of 0"}, -+ {argshrVUIn, 7, 3, 1, 1, argshrVUr1, 1 << (_W - 1), "partial overlap by 5 Words of shrVU and shift of 1"}, -+ {argshrVUIn, 7, 3, 1, _W - 1, argshrVUrWm1, 2, "partial overlap by 5 Words of shrVU and shift of _W - 1"}, -+ {argshrVUIn, 7, 3, 0, 0, argshrVUr0, 0, "partial overlap by 4 Words of shrVU and shift of 0"}, -+ {argshrVUIn, 7, 3, 0, 1, argshrVUr1, 1 << (_W - 1), "partial overlap by 4 Words of shrVU and shift of 1"}, -+ {argshrVUIn, 7, 3, 0, _W - 1, argshrVUrWm1, 2, "partial overlap by 4 Words of shrVU and shift of _W - 1"}, - } - - func testShiftFunc(t *testing.T, f func(z, x []Word, s uint) Word, a argVU) { -@@ -274,11 +310,24 @@ func TestIssue31084(t *testing.T) { - // compute 10^n via 5^n << n. - const n = 165 - p := nat(nil).expNN(nat{5}, nat{n}, nil) -- p = p.shl(p, uint(n)) -+ p = p.shl(p, n) - got := string(p.utoa(10)) - want := "1" + strings.Repeat("0", n) - if got != want { -- t.Errorf("shl(%v, %v)\n\tgot %s; want %s\n", p, uint(n), got, want) -+ t.Errorf("shl(%v, %v)\n\tgot %s\n\twant %s", p, n, got, want) -+ } -+} -+ -+const issue42838Value = "159309191113245227702888039776771180559110455519261878607388585338616290151305816094308987472018268594098344692611135542392730712890625" -+ -+func TestIssue42838(t *testing.T) { -+ const s = 192 -+ z, _, _, _ := nat(nil).scan(strings.NewReader(issue42838Value), 0, false) -+ z = z.shl(z, s) -+ got := string(z.utoa(10)) -+ want := "1" + strings.Repeat("0", s) -+ if got != want { -+ t.Errorf("shl(%v, %v)\n\tgot %s\n\twant %s", z, s, got, want) - } - } - --- -2.27.0 - diff --git a/0045-net-http-fix-hijack-hang-at-abortPendingRead.patch b/0045-net-http-fix-hijack-hang-at-abortPendingRead.patch deleted file mode 100644 index a80c86513946fde1390b2de1a8a40ec7d266a16f..0000000000000000000000000000000000000000 --- a/0045-net-http-fix-hijack-hang-at-abortPendingRead.patch +++ /dev/null @@ -1,59 +0,0 @@ -From 78770c121e8c2315d7bdf9e66870abffdaedbe9b Mon Sep 17 00:00:00 2001 -From: jingrui -Date: Thu, 20 May 2021 09:18:27 +0800 -Subject: [PATCH] net/http: fix hijack hang at abortPendingRead - -When concurrent many http requests which need hijack the connenction, -hijack may hang at abortPendingRead() on cr.cond.Wait(). - -The read can be from readRequest() from conn.serve() or -w.conn.r.startBackgroundRead(). especially in startBackgroundRead() -which always set the deadline time.Time{}. - -This problem seems easy reproduce on arm. - -Signed-off-by: jingrui - -Conflict:NA -Reference:https://github.com/golang/go/pull/46278/commits/78770c121e8c2315d7bdf9e66870abffdaedbe9b - ---- - src/net/http/server.go | 22 +++++++++++++++++++--- - 1 file changed, 19 insertions(+), 3 deletions(-) - -diff --git a/src/net/http/server.go b/src/net/http/server.go -index 4e73508973..01e7e10011 100644 ---- a/src/net/http/server.go -+++ b/src/net/http/server.go -@@ -736,9 +736,25 @@ func (cr *connReader) abortPendingRead() { - } - cr.aborted = true - cr.conn.rwc.SetReadDeadline(aLongTimeAgo) -- for cr.inRead { -- cr.cond.Wait() -- } -+ done := make(chan struct{}) -+ go func() { -+ for cr.inRead { -+ cr.cond.Wait() -+ } -+ close(done) -+ }() -+ -+ func() { -+ for { -+ select { -+ case <-done: -+ return -+ case <-time.After(100*time.Millisecond): -+ cr.conn.rwc.SetReadDeadline(aLongTimeAgo) -+ } -+ } -+ }() -+ - cr.conn.rwc.SetReadDeadline(time.Time{}) - } - --- -2.27.0 - diff --git a/0046-release-branch.go1.15-net-verify-results-from-Lookup.patch b/0046-release-branch.go1.15-net-verify-results-from-Lookup.patch deleted file mode 100644 index ea2d49a5a00c984bcce7cb4080ba525b38b961eb..0000000000000000000000000000000000000000 --- a/0046-release-branch.go1.15-net-verify-results-from-Lookup.patch +++ /dev/null @@ -1,375 +0,0 @@ -From 31d60cda1f58b7558fc5725d2b9e4531655d980e Mon Sep 17 00:00:00 2001 -From: Roland Shoemaker -Date: Thu, 27 May 2021 10:40:06 -0700 -Subject: [PATCH] [release-branch.go1.15] net: verify results from Lookup* are - valid domain names - -For the methods LookupCNAME, LookupSRV, LookupMX, LookupNS, and -LookupAddr check that the returned domain names are in fact valid DNS -names using the existing isDomainName function. - -Thanks to Philipp Jeitner and Haya Shulman from Fraunhofer SIT for -reporting this issue. - -Updates #46241 -Fixes #46356 -Fixes CVE-2021-33195 - -Conflict:NA -Reference:https://github.com/golang/go/commit/31d60cda1f58b7558fc5725d2b9e4531655d980e - -Change-Id: I47a4f58c031cb752f732e88bbdae7f819f0af4f3 -Reviewed-on: https://go-review.googlesource.com/c/go/+/323131 -Trust: Roland Shoemaker -Run-TryBot: Roland Shoemaker -TryBot-Result: Go Bot -Reviewed-by: Filippo Valsorda -Reviewed-by: Katie Hockman -(cherry picked from commit cdcd02842da7c004efd023881e3719105209c908) -Reviewed-on: https://go-review.googlesource.com/c/go/+/323269 ---- - src/net/dnsclient_unix_test.go | 157 +++++++++++++++++++++++++++++++++ - src/net/lookup.go | 111 ++++++++++++++++++++--- - 2 files changed, 255 insertions(+), 13 deletions(-) - -diff --git a/src/net/dnsclient_unix_test.go b/src/net/dnsclient_unix_test.go -index 06553636ee..819f20b887 100644 ---- a/src/net/dnsclient_unix_test.go -+++ b/src/net/dnsclient_unix_test.go -@@ -1799,3 +1799,160 @@ func TestPTRandNonPTR(t *testing.T) { - t.Errorf("names = %q; want %q", names, want) - } - } -+ -+func TestCVE202133195(t *testing.T) { -+ fake := fakeDNSServer{ -+ rh: func(n, _ string, q dnsmessage.Message, _ time.Time) (dnsmessage.Message, error) { -+ r := dnsmessage.Message{ -+ Header: dnsmessage.Header{ -+ ID: q.Header.ID, -+ Response: true, -+ RCode: dnsmessage.RCodeSuccess, -+ RecursionAvailable: true, -+ }, -+ Questions: q.Questions, -+ } -+ switch q.Questions[0].Type { -+ case dnsmessage.TypeCNAME: -+ r.Answers = []dnsmessage.Resource{} -+ case dnsmessage.TypeA: // CNAME lookup uses a A/AAAA as a proxy -+ r.Answers = append(r.Answers, -+ dnsmessage.Resource{ -+ Header: dnsmessage.ResourceHeader{ -+ Name: dnsmessage.MustNewName(".golang.org."), -+ Type: dnsmessage.TypeA, -+ Class: dnsmessage.ClassINET, -+ Length: 4, -+ }, -+ Body: &dnsmessage.AResource{ -+ A: TestAddr, -+ }, -+ }, -+ ) -+ case dnsmessage.TypeSRV: -+ n := q.Questions[0].Name -+ if n.String() == "_hdr._tcp.golang.org." { -+ n = dnsmessage.MustNewName(".golang.org.") -+ } -+ r.Answers = append(r.Answers, -+ dnsmessage.Resource{ -+ Header: dnsmessage.ResourceHeader{ -+ Name: n, -+ Type: dnsmessage.TypeSRV, -+ Class: dnsmessage.ClassINET, -+ Length: 4, -+ }, -+ Body: &dnsmessage.SRVResource{ -+ Target: dnsmessage.MustNewName(".golang.org."), -+ }, -+ }, -+ ) -+ case dnsmessage.TypeMX: -+ r.Answers = append(r.Answers, -+ dnsmessage.Resource{ -+ Header: dnsmessage.ResourceHeader{ -+ Name: dnsmessage.MustNewName(".golang.org."), -+ Type: dnsmessage.TypeMX, -+ Class: dnsmessage.ClassINET, -+ Length: 4, -+ }, -+ Body: &dnsmessage.MXResource{ -+ MX: dnsmessage.MustNewName(".golang.org."), -+ }, -+ }, -+ ) -+ case dnsmessage.TypeNS: -+ r.Answers = append(r.Answers, -+ dnsmessage.Resource{ -+ Header: dnsmessage.ResourceHeader{ -+ Name: dnsmessage.MustNewName(".golang.org."), -+ Type: dnsmessage.TypeNS, -+ Class: dnsmessage.ClassINET, -+ Length: 4, -+ }, -+ Body: &dnsmessage.NSResource{ -+ NS: dnsmessage.MustNewName(".golang.org."), -+ }, -+ }, -+ ) -+ case dnsmessage.TypePTR: -+ r.Answers = append(r.Answers, -+ dnsmessage.Resource{ -+ Header: dnsmessage.ResourceHeader{ -+ Name: dnsmessage.MustNewName(".golang.org."), -+ Type: dnsmessage.TypePTR, -+ Class: dnsmessage.ClassINET, -+ Length: 4, -+ }, -+ Body: &dnsmessage.PTRResource{ -+ PTR: dnsmessage.MustNewName(".golang.org."), -+ }, -+ }, -+ ) -+ } -+ return r, nil -+ }, -+ } -+ -+ r := Resolver{PreferGo: true, Dial: fake.DialContext} -+ // Change the default resolver to match our manipulated resolver -+ originalDefault := DefaultResolver -+ DefaultResolver = &r -+ defer func() { -+ DefaultResolver = originalDefault -+ }() -+ -+ _, err := r.LookupCNAME(context.Background(), "golang.org") -+ if expected := "lookup golang.org: CNAME target is invalid"; err == nil || err.Error() != expected { -+ t.Errorf("Resolver.LookupCNAME returned unexpected error, got %q, want %q", err.Error(), expected) -+ } -+ _, err = LookupCNAME("golang.org") -+ if expected := "lookup golang.org: CNAME target is invalid"; err == nil || err.Error() != expected { -+ t.Errorf("LookupCNAME returned unexpected error, got %q, want %q", err.Error(), expected) -+ } -+ -+ _, _, err = r.LookupSRV(context.Background(), "target", "tcp", "golang.org") -+ if expected := "lookup golang.org: SRV target is invalid"; err == nil || err.Error() != expected { -+ t.Errorf("Resolver.LookupSRV returned unexpected error, got %q, want %q", err.Error(), expected) -+ } -+ _, _, err = LookupSRV("target", "tcp", "golang.org") -+ if expected := "lookup golang.org: SRV target is invalid"; err == nil || err.Error() != expected { -+ t.Errorf("LookupSRV returned unexpected error, got %q, want %q", err.Error(), expected) -+ } -+ -+ _, _, err = r.LookupSRV(context.Background(), "hdr", "tcp", "golang.org") -+ if expected := "lookup golang.org: SRV header name is invalid"; err == nil || err.Error() != expected { -+ t.Errorf("Resolver.LookupSRV returned unexpected error, got %q, want %q", err.Error(), expected) -+ } -+ _, _, err = LookupSRV("hdr", "tcp", "golang.org") -+ if expected := "lookup golang.org: SRV header name is invalid"; err == nil || err.Error() != expected { -+ t.Errorf("LookupSRV returned unexpected error, got %q, want %q", err.Error(), expected) -+ } -+ -+ _, err = r.LookupMX(context.Background(), "golang.org") -+ if expected := "lookup golang.org: MX target is invalid"; err == nil || err.Error() != expected { -+ t.Errorf("Resolver.LookupMX returned unexpected error, got %q, want %q", err.Error(), expected) -+ } -+ _, err = LookupMX("golang.org") -+ if expected := "lookup golang.org: MX target is invalid"; err == nil || err.Error() != expected { -+ t.Errorf("LookupMX returned unexpected error, got %q, want %q", err.Error(), expected) -+ } -+ -+ _, err = r.LookupNS(context.Background(), "golang.org") -+ if expected := "lookup golang.org: NS target is invalid"; err == nil || err.Error() != expected { -+ t.Errorf("Resolver.LookupNS returned unexpected error, got %q, want %q", err.Error(), expected) -+ } -+ _, err = LookupNS("golang.org") -+ if expected := "lookup golang.org: NS target is invalid"; err == nil || err.Error() != expected { -+ t.Errorf("LookupNS returned unexpected error, got %q, want %q", err.Error(), expected) -+ } -+ -+ _, err = r.LookupAddr(context.Background(), "1.2.3.4") -+ if expected := "lookup 1.2.3.4: PTR target is invalid"; err == nil || err.Error() != expected { -+ t.Errorf("Resolver.LookupAddr returned unexpected error, got %q, want %q", err.Error(), expected) -+ } -+ _, err = LookupAddr("1.2.3.4") -+ if expected := "lookup 1.2.3.4: PTR target is invalid"; err == nil || err.Error() != expected { -+ t.Errorf("LookupAddr returned unexpected error, got %q, want %q", err.Error(), expected) -+ } -+} -diff --git a/src/net/lookup.go b/src/net/lookup.go -index 5f7119872a..0660268249 100644 ---- a/src/net/lookup.go -+++ b/src/net/lookup.go -@@ -389,8 +389,11 @@ func (r *Resolver) LookupPort(ctx context.Context, network, service string) (por - // LookupCNAME does not return an error if host does not - // contain DNS "CNAME" records, as long as host resolves to - // address records. -+// -+// The returned canonical name is validated to be a properly -+// formatted presentation-format domain name. - func LookupCNAME(host string) (cname string, err error) { -- return DefaultResolver.lookupCNAME(context.Background(), host) -+ return DefaultResolver.LookupCNAME(context.Background(), host) - } - - // LookupCNAME returns the canonical name for the given host. -@@ -403,8 +406,18 @@ func LookupCNAME(host string) (cname string, err error) { - // LookupCNAME does not return an error if host does not - // contain DNS "CNAME" records, as long as host resolves to - // address records. --func (r *Resolver) LookupCNAME(ctx context.Context, host string) (cname string, err error) { -- return r.lookupCNAME(ctx, host) -+// -+// The returned canonical name is validated to be a properly -+// formatted presentation-format domain name. -+func (r *Resolver) LookupCNAME(ctx context.Context, host string) (string, error) { -+ cname, err := r.lookupCNAME(ctx, host) -+ if err != nil { -+ return "", err -+ } -+ if !isDomainName(cname) { -+ return "", &DNSError{Err: "CNAME target is invalid", Name: host} -+ } -+ return cname, nil - } - - // LookupSRV tries to resolve an SRV query of the given service, -@@ -416,8 +429,11 @@ func (r *Resolver) LookupCNAME(ctx context.Context, host string) (cname string, - // That is, it looks up _service._proto.name. To accommodate services - // publishing SRV records under non-standard names, if both service - // and proto are empty strings, LookupSRV looks up name directly. -+// -+// The returned service names are validated to be properly -+// formatted presentation-format domain names. - func LookupSRV(service, proto, name string) (cname string, addrs []*SRV, err error) { -- return DefaultResolver.lookupSRV(context.Background(), service, proto, name) -+ return DefaultResolver.LookupSRV(context.Background(), service, proto, name) - } - - // LookupSRV tries to resolve an SRV query of the given service, -@@ -429,28 +445,82 @@ func LookupSRV(service, proto, name string) (cname string, addrs []*SRV, err err - // That is, it looks up _service._proto.name. To accommodate services - // publishing SRV records under non-standard names, if both service - // and proto are empty strings, LookupSRV looks up name directly. --func (r *Resolver) LookupSRV(ctx context.Context, service, proto, name string) (cname string, addrs []*SRV, err error) { -- return r.lookupSRV(ctx, service, proto, name) -+// -+// The returned service names are validated to be properly -+// formatted presentation-format domain names. -+func (r *Resolver) LookupSRV(ctx context.Context, service, proto, name string) (string, []*SRV, error) { -+ cname, addrs, err := r.lookupSRV(ctx, service, proto, name) -+ if err != nil { -+ return "", nil, err -+ } -+ if cname != "" && !isDomainName(cname) { -+ return "", nil, &DNSError{Err: "SRV header name is invalid", Name: name} -+ } -+ for _, addr := range addrs { -+ if addr == nil { -+ continue -+ } -+ if !isDomainName(addr.Target) { -+ return "", nil, &DNSError{Err: "SRV target is invalid", Name: name} -+ } -+ } -+ return cname, addrs, nil - } - - // LookupMX returns the DNS MX records for the given domain name sorted by preference. -+// -+// The returned mail server names are validated to be properly -+// formatted presentation-format domain names. - func LookupMX(name string) ([]*MX, error) { -- return DefaultResolver.lookupMX(context.Background(), name) -+ return DefaultResolver.LookupMX(context.Background(), name) - } - - // LookupMX returns the DNS MX records for the given domain name sorted by preference. -+// -+// The returned mail server names are validated to be properly -+// formatted presentation-format domain names. - func (r *Resolver) LookupMX(ctx context.Context, name string) ([]*MX, error) { -- return r.lookupMX(ctx, name) -+ records, err := r.lookupMX(ctx, name) -+ if err != nil { -+ return nil, err -+ } -+ for _, mx := range records { -+ if mx == nil { -+ continue -+ } -+ if !isDomainName(mx.Host) { -+ return nil, &DNSError{Err: "MX target is invalid", Name: name} -+ } -+ } -+ return records, nil - } - - // LookupNS returns the DNS NS records for the given domain name. -+// -+// The returned name server names are validated to be properly -+// formatted presentation-format domain names. - func LookupNS(name string) ([]*NS, error) { -- return DefaultResolver.lookupNS(context.Background(), name) -+ return DefaultResolver.LookupNS(context.Background(), name) - } - - // LookupNS returns the DNS NS records for the given domain name. -+// -+// The returned name server names are validated to be properly -+// formatted presentation-format domain names. - func (r *Resolver) LookupNS(ctx context.Context, name string) ([]*NS, error) { -- return r.lookupNS(ctx, name) -+ records, err := r.lookupNS(ctx, name) -+ if err != nil { -+ return nil, err -+ } -+ for _, ns := range records { -+ if ns == nil { -+ continue -+ } -+ if !isDomainName(ns.Host) { -+ return nil, &DNSError{Err: "NS target is invalid", Name: name} -+ } -+ } -+ return records, nil - } - - // LookupTXT returns the DNS TXT records for the given domain name. -@@ -466,14 +536,29 @@ func (r *Resolver) LookupTXT(ctx context.Context, name string) ([]string, error) - // LookupAddr performs a reverse lookup for the given address, returning a list - // of names mapping to that address. - // -+// The returned names are validated to be properly formatted presentation-format -+// domain names. -+// - // When using the host C library resolver, at most one result will be - // returned. To bypass the host resolver, use a custom Resolver. - func LookupAddr(addr string) (names []string, err error) { -- return DefaultResolver.lookupAddr(context.Background(), addr) -+ return DefaultResolver.LookupAddr(context.Background(), addr) - } - - // LookupAddr performs a reverse lookup for the given address, returning a list - // of names mapping to that address. --func (r *Resolver) LookupAddr(ctx context.Context, addr string) (names []string, err error) { -- return r.lookupAddr(ctx, addr) -+// -+// The returned names are validated to be properly formatted presentation-format -+// domain names. -+func (r *Resolver) LookupAddr(ctx context.Context, addr string) ([]string, error) { -+ names, err := r.lookupAddr(ctx, addr) -+ if err != nil { -+ return nil, err -+ } -+ for _, name := range names { -+ if !isDomainName(name) { -+ return nil, &DNSError{Err: "PTR target is invalid", Name: addr} -+ } -+ } -+ return names, nil - } --- -2.27.0 - diff --git a/0047-release-branch.go1.15-archive-zip-only-preallocate-F.patch b/0047-release-branch.go1.15-archive-zip-only-preallocate-F.patch deleted file mode 100644 index 4be111d1da11b2b4ec2b0df989003944e307ee00..0000000000000000000000000000000000000000 --- a/0047-release-branch.go1.15-archive-zip-only-preallocate-F.patch +++ /dev/null @@ -1,130 +0,0 @@ -From c92adf420a3d9a5510f9aea382d826f0c9216a10 Mon Sep 17 00:00:00 2001 -From: Roland Shoemaker -Date: Tue, 11 May 2021 11:31:31 -0700 -Subject: [PATCH] [release-branch.go1.15] archive/zip: only preallocate File - slice if reasonably sized - -Since the number of files in the EOCD record isn't validated, it isn't -safe to preallocate Reader.Files using that field. A malformed archive -can indicate it contains up to 1 << 128 - 1 files. We can still safely -preallocate the slice by checking if the specified number of files in -the archive is reasonable, given the size of the archive. - -Thanks to the OSS-Fuzz project for discovering this issue and to -Emmanuel Odeke for reporting it. - -Updates #46242 -Fixes #46396 -Fixes CVE-2021-33196 - -Conflict:NA -Reference:https://github.com/golang/go/commit/c92adf420a3d9a5510f9aea382d826f0c9216a10 - -Change-Id: I3c76d8eec178468b380d87fdb4a3f2cb06f0ee76 -Reviewed-on: https://go-review.googlesource.com/c/go/+/318909 -Trust: Roland Shoemaker -Trust: Katie Hockman -Trust: Joe Tsai -Run-TryBot: Roland Shoemaker -TryBot-Result: Go Bot -Reviewed-by: Katie Hockman -Reviewed-by: Joe Tsai -(cherry picked from commit 74242baa4136c7a9132a8ccd9881354442788c8c) -Reviewed-on: https://go-review.googlesource.com/c/go/+/322949 -Reviewed-by: Filippo Valsorda ---- - src/archive/zip/reader.go | 10 +++++- - src/archive/zip/reader_test.go | 59 ++++++++++++++++++++++++++++++++++ - 2 files changed, 68 insertions(+), 1 deletion(-) - -diff --git a/src/archive/zip/reader.go b/src/archive/zip/reader.go -index 13ff9ddcf4..2d5151af3d 100644 ---- a/src/archive/zip/reader.go -+++ b/src/archive/zip/reader.go -@@ -84,7 +84,15 @@ func (z *Reader) init(r io.ReaderAt, size int64) error { - return err - } - z.r = r -- z.File = make([]*File, 0, end.directoryRecords) -+ // Since the number of directory records is not validated, it is not -+ // safe to preallocate z.File without first checking that the specified -+ // number of files is reasonable, since a malformed archive may -+ // indicate it contains up to 1 << 128 - 1 files. Since each file has a -+ // header which will be _at least_ 30 bytes we can safely preallocate -+ // if (data size / 30) >= end.directoryRecords. -+ if (uint64(size)-end.directorySize)/30 >= end.directoryRecords { -+ z.File = make([]*File, 0, end.directoryRecords) -+ } - z.Comment = end.comment - rs := io.NewSectionReader(r, 0, size) - if _, err = rs.Seek(int64(end.directoryOffset), io.SeekStart); err != nil { -diff --git a/src/archive/zip/reader_test.go b/src/archive/zip/reader_test.go -index adca87a8b3..6f67d2e4a9 100644 ---- a/src/archive/zip/reader_test.go -+++ b/src/archive/zip/reader_test.go -@@ -1070,3 +1070,62 @@ func TestIssue12449(t *testing.T) { - t.Errorf("Error reading the archive: %v", err) - } - } -+ -+func TestCVE202133196(t *testing.T) { -+ // Archive that indicates it has 1 << 128 -1 files, -+ // this would previously cause a panic due to attempting -+ // to allocate a slice with 1 << 128 -1 elements. -+ data := []byte{ -+ 0x50, 0x4b, 0x03, 0x04, 0x14, 0x00, 0x08, 0x08, -+ 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -+ 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x02, -+ 0x03, 0x62, 0x61, 0x65, 0x03, 0x04, 0x00, 0x00, -+ 0xff, 0xff, 0x50, 0x4b, 0x07, 0x08, 0xbe, 0x20, -+ 0x5c, 0x6c, 0x09, 0x00, 0x00, 0x00, 0x03, 0x00, -+ 0x00, 0x00, 0x50, 0x4b, 0x01, 0x02, 0x14, 0x00, -+ 0x14, 0x00, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, -+ 0x00, 0x00, 0xbe, 0x20, 0x5c, 0x6c, 0x09, 0x00, -+ 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, -+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -+ 0x01, 0x02, 0x03, 0x50, 0x4b, 0x06, 0x06, 0x2c, -+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2d, -+ 0x00, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -+ 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, -+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, -+ 0xff, 0xff, 0xff, 0x31, 0x00, 0x00, 0x00, 0x00, -+ 0x00, 0x00, 0x00, 0x3a, 0x00, 0x00, 0x00, 0x00, -+ 0x00, 0x00, 0x00, 0x50, 0x4b, 0x06, 0x07, 0x00, -+ 0x00, 0x00, 0x00, 0x6b, 0x00, 0x00, 0x00, 0x00, -+ 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x50, -+ 0x4b, 0x05, 0x06, 0x00, 0x00, 0x00, 0x00, 0xff, -+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -+ 0xff, 0xff, 0xff, 0x00, 0x00, -+ } -+ _, err := NewReader(bytes.NewReader(data), int64(len(data))) -+ if err != ErrFormat { -+ t.Fatalf("unexpected error, got: %v, want: %v", err, ErrFormat) -+ } -+ -+ // Also check that an archive containing a handful of empty -+ // files doesn't cause an issue -+ b := bytes.NewBuffer(nil) -+ w := NewWriter(b) -+ for i := 0; i < 5; i++ { -+ _, err := w.Create("") -+ if err != nil { -+ t.Fatalf("Writer.Create failed: %s", err) -+ } -+ } -+ if err := w.Close(); err != nil { -+ t.Fatalf("Writer.Close failed: %s", err) -+ } -+ r, err := NewReader(bytes.NewReader(b.Bytes()), int64(b.Len())) -+ if err != nil { -+ t.Fatalf("NewReader failed: %s", err) -+ } -+ if len(r.File) != 5 { -+ t.Errorf("Archive has unexpected number of files, got %d, want 5", len(r.File)) -+ } -+} --- -2.27.0 - diff --git a/0048-release-branch.go1.15-net-http-httputil-always-remov.patch b/0048-release-branch.go1.15-net-http-httputil-always-remov.patch deleted file mode 100644 index 0a404bee420c8d8781de3362a98b5fde690ba5fc..0000000000000000000000000000000000000000 --- a/0048-release-branch.go1.15-net-http-httputil-always-remov.patch +++ /dev/null @@ -1,154 +0,0 @@ -From cbd1ca84453fecf3825a6bb9f985823e8bc32b76 Mon Sep 17 00:00:00 2001 -From: Filippo Valsorda -Date: Fri, 21 May 2021 14:02:30 -0400 -Subject: [PATCH] [release-branch.go1.15] net/http/httputil: always remove - hop-by-hop headers - -Previously, we'd fail to remove the Connection header from a request -like this: - - Connection: - Connection: x-header - -Updates #46313 -Fixes #46314 -Fixes CVE-2021-33197 - -Change-Id: Ie3009e926ceecfa86dfa6bcc6fe14ff01086be7d -Reviewed-on: https://go-review.googlesource.com/c/go/+/321929 -Run-TryBot: Filippo Valsorda -Reviewed-by: Katie Hockman -Trust: Katie Hockman -Trust: Filippo Valsorda -TryBot-Result: Go Bot -Reviewed-on: https://go-review.googlesource.com/c/go/+/323091 -Run-TryBot: Katie Hockman - -Conflict:NA -Reference:https://github.com/golang/go/commit/cbd1ca84453fecf3825a6bb9f985823e8bc32b76 - ---- - src/net/http/httputil/reverseproxy.go | 22 ++++---- - src/net/http/httputil/reverseproxy_test.go | 63 +++++++++++++++++++++- - 2 files changed, 70 insertions(+), 15 deletions(-) - -diff --git a/src/net/http/httputil/reverseproxy.go b/src/net/http/httputil/reverseproxy.go -index 3f48fab544..f49cefbb4f 100644 ---- a/src/net/http/httputil/reverseproxy.go -+++ b/src/net/http/httputil/reverseproxy.go -@@ -248,22 +248,18 @@ func (p *ReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) { - // important is "Connection" because we want a persistent - // connection, regardless of what the client sent to us. - for _, h := range hopHeaders { -- hv := outreq.Header.Get(h) -- if hv == "" { -- continue -- } -- if h == "Te" && hv == "trailers" { -- // Issue 21096: tell backend applications that -- // care about trailer support that we support -- // trailers. (We do, but we don't go out of -- // our way to advertise that unless the -- // incoming client request thought it was -- // worth mentioning) -- continue -- } - outreq.Header.Del(h) - } - -+ // Issue 21096: tell backend applications that care about trailer support -+ // that we support trailers. (We do, but we don't go out of our way to -+ // advertise that unless the incoming client request thought it was worth -+ // mentioning.) Note that we look at req.Header, not outreq.Header, since -+ // the latter has passed through removeConnectionHeaders. -+ if httpguts.HeaderValuesContainsToken(req.Header["Te"], "trailers") { -+ outreq.Header.Set("Te", "trailers") -+ } -+ - // After stripping all the hop-by-hop connection headers above, add back any - // necessary for protocol upgrades, such as for websockets. - if reqUpType != "" { -diff --git a/src/net/http/httputil/reverseproxy_test.go b/src/net/http/httputil/reverseproxy_test.go -index 764939fb0f..1f2dfb9867 100644 ---- a/src/net/http/httputil/reverseproxy_test.go -+++ b/src/net/http/httputil/reverseproxy_test.go -@@ -91,8 +91,9 @@ func TestReverseProxy(t *testing.T) { - - getReq, _ := http.NewRequest("GET", frontend.URL, nil) - getReq.Host = "some-name" -- getReq.Header.Set("Connection", "close") -- getReq.Header.Set("Te", "trailers") -+ getReq.Header.Set("Connection", "close, TE") -+ getReq.Header.Add("Te", "foo") -+ getReq.Header.Add("Te", "bar, trailers") - getReq.Header.Set("Proxy-Connection", "should be deleted") - getReq.Header.Set("Upgrade", "foo") - getReq.Close = true -@@ -236,6 +237,64 @@ func TestReverseProxyStripHeadersPresentInConnection(t *testing.T) { - } - } - -+func TestReverseProxyStripEmptyConnection(t *testing.T) { -+ // See Issue 46313. -+ const backendResponse = "I am the backend" -+ -+ // someConnHeader is some arbitrary header to be declared as a hop-by-hop header -+ // in the Request's Connection header. -+ const someConnHeader = "X-Some-Conn-Header" -+ -+ backend := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { -+ if c := r.Header.Values("Connection"); len(c) != 0 { -+ t.Errorf("handler got header %q = %v; want empty", "Connection", c) -+ } -+ if c := r.Header.Get(someConnHeader); c != "" { -+ t.Errorf("handler got header %q = %q; want empty", someConnHeader, c) -+ } -+ w.Header().Add("Connection", "") -+ w.Header().Add("Connection", someConnHeader) -+ w.Header().Set(someConnHeader, "should be deleted") -+ io.WriteString(w, backendResponse) -+ })) -+ defer backend.Close() -+ backendURL, err := url.Parse(backend.URL) -+ if err != nil { -+ t.Fatal(err) -+ } -+ proxyHandler := NewSingleHostReverseProxy(backendURL) -+ frontend := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { -+ proxyHandler.ServeHTTP(w, r) -+ if c := r.Header.Get(someConnHeader); c != "should be deleted" { -+ t.Errorf("handler modified header %q = %q; want %q", someConnHeader, c, "should be deleted") -+ } -+ })) -+ defer frontend.Close() -+ -+ getReq, _ := http.NewRequest("GET", frontend.URL, nil) -+ getReq.Header.Add("Connection", "") -+ getReq.Header.Add("Connection", someConnHeader) -+ getReq.Header.Set(someConnHeader, "should be deleted") -+ res, err := frontend.Client().Do(getReq) -+ if err != nil { -+ t.Fatalf("Get: %v", err) -+ } -+ defer res.Body.Close() -+ bodyBytes, err := ioutil.ReadAll(res.Body) -+ if err != nil { -+ t.Fatalf("reading body: %v", err) -+ } -+ if got, want := string(bodyBytes), backendResponse; got != want { -+ t.Errorf("got body %q; want %q", got, want) -+ } -+ if c := res.Header.Get("Connection"); c != "" { -+ t.Errorf("handler got header %q = %q; want empty", "Connection", c) -+ } -+ if c := res.Header.Get(someConnHeader); c != "" { -+ t.Errorf("handler got header %q = %q; want empty", someConnHeader, c) -+ } -+} -+ - func TestXForwardedFor(t *testing.T) { - const prevForwardedFor = "client ip" - const backendResponse = "I am the backend" --- -2.27.0 - diff --git a/0049-release-branch.go1.15-math-big-check-for-excessive-e.patch b/0049-release-branch.go1.15-math-big-check-for-excessive-e.patch deleted file mode 100644 index 745e88c108dea4440ca1aaf5798c81e37d7ab99e..0000000000000000000000000000000000000000 --- a/0049-release-branch.go1.15-math-big-check-for-excessive-e.patch +++ /dev/null @@ -1,114 +0,0 @@ -From df9ce19db6df32d94eae8760927bdfbc595433c3 Mon Sep 17 00:00:00 2001 -From: Robert Griesemer -Date: Sun, 2 May 2021 11:27:03 -0700 -Subject: [PATCH] [release-branch.go1.15] math/big: check for excessive - exponents in Rat.SetString - -Found by OSS-Fuzz https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=33284 - -Thanks to Emmanuel Odeke for reporting this issue. - -Updates #45910 -Fixes #46305 -Fixes CVE-2021-33198 - -Change-Id: I61e7b04dbd80343420b57eede439e361c0f7b79c -Reviewed-on: https://go-review.googlesource.com/c/go/+/316149 -Trust: Robert Griesemer -Trust: Katie Hockman -Run-TryBot: Robert Griesemer -TryBot-Result: Go Bot -Reviewed-by: Katie Hockman -Reviewed-by: Emmanuel Odeke -(cherry picked from commit 6c591f79b0b5327549bd4e94970f7a279efb4ab0) -Reviewed-on: https://go-review.googlesource.com/c/go/+/321831 -Run-TryBot: Katie Hockman -Reviewed-by: Roland Shoemaker - -Conflict:NA -Reference:https://github.com/golang/go/commit/df9ce19db6df32d94eae8760927bdfbc595433c3 - ---- - src/math/big/ratconv.go | 15 ++++++++------- - src/math/big/ratconv_test.go | 25 +++++++++++++++++++++++++ - 2 files changed, 33 insertions(+), 7 deletions(-) - -diff --git a/src/math/big/ratconv.go b/src/math/big/ratconv.go -index 941139e72d..ac3c8bd11f 100644 ---- a/src/math/big/ratconv.go -+++ b/src/math/big/ratconv.go -@@ -51,7 +51,8 @@ func (z *Rat) Scan(s fmt.ScanState, ch rune) error { - // An optional base-10 ``e'' or base-2 ``p'' (or their upper-case variants) - // exponent may be provided as well, except for hexadecimal floats which - // only accept an (optional) ``p'' exponent (because an ``e'' or ``E'' cannot --// be distinguished from a mantissa digit). -+// be distinguished from a mantissa digit). If the exponent's absolute value -+// is too large, the operation may fail. - // The entire string, not just a prefix, must be valid for success. If the - // operation failed, the value of z is undefined but the returned value is nil. - func (z *Rat) SetString(s string) (*Rat, bool) { -@@ -169,6 +170,9 @@ func (z *Rat) SetString(s string) (*Rat, bool) { - if n < 0 { - n = -n - } -+ if n > 1e6 { -+ return nil, false // avoid excessively large exponents -+ } - pow5 := z.b.abs.expNN(natFive, nat(nil).setWord(Word(n)), nil) // use underlying array of z.b.abs - if exp5 > 0 { - z.a.abs = z.a.abs.mul(z.a.abs, pow5) -@@ -181,15 +185,12 @@ func (z *Rat) SetString(s string) (*Rat, bool) { - } - - // apply exp2 contributions -+ if exp2 < -1e7 || exp2 > 1e7 { -+ return nil, false // avoid excessively large exponents -+ } - if exp2 > 0 { -- if int64(uint(exp2)) != exp2 { -- panic("exponent too large") -- } - z.a.abs = z.a.abs.shl(z.a.abs, uint(exp2)) - } else if exp2 < 0 { -- if int64(uint(-exp2)) != -exp2 { -- panic("exponent too large") -- } - z.b.abs = z.b.abs.shl(z.b.abs, uint(-exp2)) - } - -diff --git a/src/math/big/ratconv_test.go b/src/math/big/ratconv_test.go -index ba0d1ba9e1..15d206cb38 100644 ---- a/src/math/big/ratconv_test.go -+++ b/src/math/big/ratconv_test.go -@@ -589,3 +589,28 @@ func TestIssue31184(t *testing.T) { - } - } - } -+ -+func TestIssue45910(t *testing.T) { -+ var x Rat -+ for _, test := range []struct { -+ input string -+ want bool -+ }{ -+ {"1e-1000001", false}, -+ {"1e-1000000", true}, -+ {"1e+1000000", true}, -+ {"1e+1000001", false}, -+ -+ {"0p1000000000000", true}, -+ {"1p-10000001", false}, -+ {"1p-10000000", true}, -+ {"1p+10000000", true}, -+ {"1p+10000001", false}, -+ {"1.770p02041010010011001001", false}, // test case from issue -+ } { -+ _, got := x.SetString(test.input) -+ if got != test.want { -+ t.Errorf("SetString(%s) got ok = %v; want %v", test.input, got, test.want) -+ } -+ } -+} --- -2.27.0 - diff --git a/0050-release-branch.go1.15-crypto-tls-test-key-type-when-.patch b/0050-release-branch.go1.15-crypto-tls-test-key-type-when-.patch deleted file mode 100644 index e946b5d0067d3e30d5be1c2f6fab9b2fe06d8e76..0000000000000000000000000000000000000000 --- a/0050-release-branch.go1.15-crypto-tls-test-key-type-when-.patch +++ /dev/null @@ -1,53 +0,0 @@ -From c77980bc077f3774276ab2deba78d8e6bfe4b3bd Mon Sep 17 00:00:00 2001 -From: Roland Shoemaker -Date: Wed, 9 Jun 2021 11:31:27 -0700 -Subject: [PATCH] [release-branch.go1.15] crypto/tls: test key type when - casting - -When casting the certificate public key in generateClientKeyExchange, -check the type is appropriate. This prevents a panic when a server -agrees to a RSA based key exchange, but then sends an ECDSA (or -other) certificate. - -Updates #47143 -Fixes #47144 -Fixes CVE-2021-34558 - -Thanks to Imre Rad for reporting this issue. - -Change-Id: Iabccacca6052769a605cccefa1216a9f7b7f6aea -Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1116723 -Reviewed-by: Filippo Valsorda -Reviewed-by: Katie Hockman -Reviewed-on: https://go-review.googlesource.com/c/go/+/334030 -Trust: Filippo Valsorda -Run-TryBot: Filippo Valsorda -Reviewed-by: Dmitri Shuralyov - -Conflict:NA -Reference:https://github.com/golang/go/commit/c77980bc077f3774276ab2deba78d8e6bfe4b3bd - ---- - src/crypto/tls/key_agreement.go | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - -diff --git a/src/crypto/tls/key_agreement.go b/src/crypto/tls/key_agreement.go -index 7e6534bd46..22f1b2e1f2 100644 ---- a/src/crypto/tls/key_agreement.go -+++ b/src/crypto/tls/key_agreement.go -@@ -67,7 +67,11 @@ func (ka rsaKeyAgreement) generateClientKeyExchange(config *Config, clientHello - return nil, nil, err - } - -- encrypted, err := rsa.EncryptPKCS1v15(config.rand(), cert.PublicKey.(*rsa.PublicKey), preMasterSecret) -+ rsaKey, ok := cert.PublicKey.(*rsa.PublicKey) -+ if !ok { -+ return nil, nil, errors.New("tls: server certificate contains incorrect key type for selected ciphersuite") -+ } -+ encrypted, err := rsa.EncryptPKCS1v15(config.rand(), rsaKey, preMasterSecret) - if err != nil { - return nil, nil, err - } --- -2.27.0 - diff --git a/0051-net-reject-leading-zeros-in-IP-address-parsers.patch b/0051-net-reject-leading-zeros-in-IP-address-parsers.patch deleted file mode 100644 index 57c4d064e222bbdd3699c7cc51af59ecedbd6506..0000000000000000000000000000000000000000 --- a/0051-net-reject-leading-zeros-in-IP-address-parsers.patch +++ /dev/null @@ -1,124 +0,0 @@ -From d3e3d03666bbd8784007bbb78a75864aac786967 Mon Sep 17 00:00:00 2001 -From: Roland Shoemaker -Date: Mon, 7 Jun 2021 10:21:29 -0700 -Subject: [PATCH] net: reject leading zeros in IP address parsers - -In both net.ParseIP and net.ParseCIDR reject leading zeros in the -dot-decimal notation of IPv4 addresses. - -Fixes #30999 -Fixes #43389 - -Change-Id: I2b6a31fe84db89ac828cf5ed03eaa586ee96ab68 -Reviewed-on: https://go-review.googlesource.com/c/go/+/325829 -Trust: Roland Shoemaker -Trust: Katie Hockman -Run-TryBot: Roland Shoemaker -Reviewed-by: Filippo Valsorda -Reviewed-by: Katie Hockman -TryBot-Result: Go Bot - -Conflict:NA -Reference:https://github.com/golang/go/commit/d3e3d03666bbd8784007bbb78a75864aac786967 - ---- - src/net/hosts_test.go | 4 ++-- - src/net/ip.go | 4 ++++ - src/net/ip_test.go | 8 ++++++-- - src/net/testdata/ipv4-hosts | 8 ++------ - 5 files changed, 24 insertions(+), 10 deletions(-) - - -diff --git a/src/net/hosts_test.go b/src/net/hosts_test.go -index f850e2fccf..19c43999f9 100644 ---- a/src/net/hosts_test.go -+++ b/src/net/hosts_test.go -@@ -36,7 +36,7 @@ var lookupStaticHostTests = []struct { - }, - }, - { -- "testdata/ipv4-hosts", // see golang.org/issue/8996 -+ "testdata/ipv4-hosts", - []staticHostEntry{ - {"localhost", []string{"127.0.0.1", "127.0.0.2", "127.0.0.3"}}, - {"localhost.localdomain", []string{"127.0.0.3"}}, -@@ -102,7 +102,7 @@ var lookupStaticAddrTests = []struct { - }, - }, - { -- "testdata/ipv4-hosts", // see golang.org/issue/8996 -+ "testdata/ipv4-hosts", - []staticHostEntry{ - {"127.0.0.1", []string{"localhost"}}, - {"127.0.0.2", []string{"localhost"}}, -diff --git a/src/net/ip.go b/src/net/ip.go -index 0477269761..38e1aa2247 100644 ---- a/src/net/ip.go -+++ b/src/net/ip.go -@@ -574,6 +574,10 @@ func parseIPv4(s string) IP { - if !ok || n > 0xFF { - return nil - } -+ if c > 1 && s[0] == '0' { -+ // Reject non-zero components with leading zeroes. -+ return nil -+ } - s = s[c:] - p[i] = byte(n) - } -diff --git a/src/net/ip_test.go b/src/net/ip_test.go -index 3af5e41ceb..5bbda6024d 100644 ---- a/src/net/ip_test.go -+++ b/src/net/ip_test.go -@@ -21,9 +21,7 @@ var parseIPTests = []struct { - }{ - {"127.0.1.2", IPv4(127, 0, 1, 2)}, - {"127.0.0.1", IPv4(127, 0, 0, 1)}, -- {"127.001.002.003", IPv4(127, 1, 2, 3)}, - {"::ffff:127.1.2.3", IPv4(127, 1, 2, 3)}, -- {"::ffff:127.001.002.003", IPv4(127, 1, 2, 3)}, - {"::ffff:7f01:0203", IPv4(127, 1, 2, 3)}, - {"0:0:0:0:0000:ffff:127.1.2.3", IPv4(127, 1, 2, 3)}, - {"0:0:0:0:000000:ffff:127.1.2.3", IPv4(127, 1, 2, 3)}, -@@ -43,6 +41,11 @@ var parseIPTests = []struct { - {"fe80::1%911", nil}, - {"", nil}, - {"a1:a2:a3:a4::b1:b2:b3:b4", nil}, // Issue 6628 -+ {"127.001.002.003", nil}, -+ {"::ffff:127.001.002.003", nil}, -+ {"123.000.000.000", nil}, -+ {"1.2..4", nil}, -+ {"0123.0.0.1", nil}, - } - - func TestParseIP(t *testing.T) { -@@ -358,6 +361,7 @@ var parseCIDRTests = []struct { - {"0.0.-2.0/32", nil, nil, &ParseError{Type: "CIDR address", Text: "0.0.-2.0/32"}}, - {"0.0.0.-3/32", nil, nil, &ParseError{Type: "CIDR address", Text: "0.0.0.-3/32"}}, - {"0.0.0.0/-0", nil, nil, &ParseError{Type: "CIDR address", Text: "0.0.0.0/-0"}}, -+ {"127.000.000.001/32", nil, nil, &ParseError{Type: "CIDR address", Text: "127.000.000.001/32"}}, - {"", nil, nil, &ParseError{Type: "CIDR address", Text: ""}}, - } - -diff --git a/src/net/testdata/ipv4-hosts b/src/net/testdata/ipv4-hosts -index 5208bb44ac..6b99675dfc 100644 ---- a/src/net/testdata/ipv4-hosts -+++ b/src/net/testdata/ipv4-hosts -@@ -1,12 +1,8 @@ - # See https://tools.ietf.org/html/rfc1123. --# --# The literal IPv4 address parser in the net package is a relaxed --# one. It may accept a literal IPv4 address in dotted-decimal notation --# with leading zeros such as "001.2.003.4". - - # internet address and host name - 127.0.0.1 localhost # inline comment separated by tab --127.000.000.002 localhost # inline comment separated by space -+127.0.0.2 localhost # inline comment separated by space - - # internet address, host name and aliases --127.000.000.003 localhost localhost.localdomain -+127.0.0.3 localhost localhost.localdomain --- -2.27.0 - diff --git a/0052-release-branch.go1.16-misc-wasm-cmd-link-do-not-let-.patch b/0052-release-branch.go1.16-misc-wasm-cmd-link-do-not-let-.patch deleted file mode 100644 index cf2d264d5b2bff034474365e4626a7a46dad66c8..0000000000000000000000000000000000000000 --- a/0052-release-branch.go1.16-misc-wasm-cmd-link-do-not-let-.patch +++ /dev/null @@ -1,89 +0,0 @@ -From 4548fcc8dfd933c237f29bba6f90040a85922564 Mon Sep 17 00:00:00 2001 -From: Michael Knyszek -Date: Thu, 2 Sep 2021 16:51:59 -0400 -Subject: [PATCH] [release-branch.go1.16] misc/wasm, cmd/link: do not let - command line args overwrite global data - -On Wasm, wasm_exec.js puts command line arguments at the beginning -of the linear memory (following the "zero page"). Currently there -is no limit for this, and a very long command line can overwrite -the program's data section. Prevent this by limiting the command -line to 4096 bytes, and in the linker ensuring the data section -starts at a high enough address (8192). - -(Arguably our address assignment on Wasm is a bit confusing. This -is the minimum fix I can come up with.) - -Thanks to Ben Lubar for reporting this issue. - -Change by Cherry Mui . - -For #48797 -Fixes #48799 -Fixes CVE-2021-38297 - -Change-Id: I0f50fbb2a5b6d0d047e3c134a88988d9133e4ab3 -Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1205933 -Reviewed-by: Roland Shoemaker -Reviewed-by: Than McIntosh -Reviewed-on: https://go-review.googlesource.com/c/go/+/354591 -Trust: Michael Knyszek -Reviewed-by: Heschi Kreinick ---- - misc/wasm/wasm_exec.js | 7 +++++++ - src/cmd/link/internal/ld/data.go | 11 ++++++++++- - 2 files changed, 17 insertions(+), 1 deletion(-) - -diff --git a/misc/wasm/wasm_exec.js b/misc/wasm/wasm_exec.js -index 82041e6bb9..a0a264278b 100644 ---- a/misc/wasm/wasm_exec.js -+++ b/misc/wasm/wasm_exec.js -@@ -564,6 +564,13 @@ - offset += 8; - }); - -+ // The linker guarantees global data starts from at least wasmMinDataAddr. -+ // Keep in sync with cmd/link/internal/ld/data.go:wasmMinDataAddr. -+ const wasmMinDataAddr = 4096 + 4096; -+ if (offset >= wasmMinDataAddr) { -+ throw new Error("command line too long"); -+ } -+ - this._inst.exports.run(argc, argv); - if (this.exited) { - this._resolveExitPromise(); -diff --git a/src/cmd/link/internal/ld/data.go b/src/cmd/link/internal/ld/data.go -index 52035e9630..54a1d188cd 100644 ---- a/src/cmd/link/internal/ld/data.go -+++ b/src/cmd/link/internal/ld/data.go -@@ -2330,6 +2330,11 @@ func assignAddress(ctxt *Link, sect *sym.Section, n int, s loader.Sym, va uint64 - return sect, n, va - } - -+// On Wasm, we reserve 4096 bytes for zero page, then 4096 bytes for wasm_exec.js -+// to store command line args. Data sections starts from at least address 8192. -+// Keep in sync with wasm_exec.js. -+const wasmMinDataAddr = 4096 + 4096 -+ - // address assigns virtual addresses to all segments and sections and - // returns all segments in file order. - func (ctxt *Link) address() []*sym.Segment { -@@ -2339,10 +2344,14 @@ func (ctxt *Link) address() []*sym.Segment { - order = append(order, &Segtext) - Segtext.Rwx = 05 - Segtext.Vaddr = va -- for _, s := range Segtext.Sections { -+ for i, s := range Segtext.Sections { - va = uint64(Rnd(int64(va), int64(s.Align))) - s.Vaddr = va - va += s.Length -+ -+ if ctxt.IsWasm() && i == 0 && va < wasmMinDataAddr { -+ va = wasmMinDataAddr -+ } - } - - Segtext.Length = va - uint64(*FlagTextAddr) --- -2.27.0 - diff --git a/0053-net-http-httputil-close-incoming-ReverseProxy-reques.patch b/0053-net-http-httputil-close-incoming-ReverseProxy-reques.patch deleted file mode 100644 index a6f58e4b484789c839cf1def9af53a3622051685..0000000000000000000000000000000000000000 --- a/0053-net-http-httputil-close-incoming-ReverseProxy-reques.patch +++ /dev/null @@ -1,49 +0,0 @@ -From b7a85e0003cedb1b48a1fd3ae5b746ec6330102e Mon Sep 17 00:00:00 2001 -From: Damien Neil -Date: Wed, 7 Jul 2021 16:34:34 -0700 -Subject: [PATCH] net/http/httputil: close incoming ReverseProxy request body - -Reading from an incoming request body after the request handler aborts -with a panic can cause a panic, becuse http.Server does not (contrary -to its documentation) close the request body in this case. - -Always close the incoming request body in ReverseProxy.ServeHTTP to -ensure that any in-flight outgoing requests using the body do not -read from it. - -Updates #46866 -Fixes CVE-2021-36221 - -Change-Id: I310df269200ad8732c5d9f1a2b00de68725831df -Reviewed-on: https://go-review.googlesource.com/c/go/+/333191 -Trust: Damien Neil -Reviewed-by: Brad Fitzpatrick -Reviewed-by: Filippo Valsorda ---- - src/net/http/httputil/reverseproxy.go | 9 +++++ - src/net/http/httputil/reverseproxy_test.go | 39 ++++++++++++++++++++++ - 2 files changed, 48 insertions(+) - -diff --git a/src/net/http/httputil/reverseproxy.go b/src/net/http/httputil/reverseproxy.go -index 5d39955d62..8b63368386 100644 ---- a/src/net/http/httputil/reverseproxy.go -+++ b/src/net/http/httputil/reverseproxy.go -@@ -235,6 +235,15 @@ func (p *ReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) { - if req.ContentLength == 0 { - outreq.Body = nil // Issue 16036: nil Body for http.Transport retries - } -+ if outreq.Body != nil { -+ // Reading from the request body after returning from a handler is not -+ // allowed, and the RoundTrip goroutine that reads the Body can outlive -+ // this handler. This can lead to a crash if the handler panics (see -+ // Issue 46866). Although calling Close doesn't guarantee there isn't -+ // any Read in flight after the handle returns, in practice it's safe to -+ // read after closing it. -+ defer outreq.Body.Close() -+ } - if outreq.Header == nil { - outreq.Header = make(http.Header) // Issue 33142: historical behavior was to always allocate - } --- -2.27.0 - diff --git a/0054-release-branch.go1.16-net-http-update-bundled-golang.patch b/0054-release-branch.go1.16-net-http-update-bundled-golang.patch deleted file mode 100644 index 4436b9edf80479aa869b44d63fd200b789ca0bf7..0000000000000000000000000000000000000000 --- a/0054-release-branch.go1.16-net-http-update-bundled-golang.patch +++ /dev/null @@ -1,50 +0,0 @@ -From 97b9a8c1e595e2527654e8e4124e4ebc048548a2 Mon Sep 17 00:00:00 2001 -From: Filippo Valsorda -Date: Wed, 19 Jan 2022 11:31:33 +0800 -Subject: [PATCH] [release-branch.go1.16] net/http: update bundled - golang.org/x/net/http2 - -Pull in security fix - - a5309b3 http2: cap the size of the server's canonical header cache - -Updates #50058 -Fixes CVE-2021-44716 - -Change-Id: Ifdd13f97fce168de5fb4b2e74ef2060d059800b9 -Reviewed-on: https://go-review.googlesource.com/c/go/+/370575 -Trust: Filippo Valsorda -Run-TryBot: Filippo Valsorda -Reviewed-by: Alex Rakoczy -TryBot-Result: Gopher Robot - -Conflict:NA -Reference:https://github.com/golang/go/commit/d0aebe3e74fe14799f97ddd3f01129697c6a290a ---- - src/net/http/h2_bundle.go | 10 +++++++++- - 1 file changed, 9 insertions(+), 1 deletion(-) - -diff --git a/src/net/http/h2_bundle.go b/src/net/http/h2_bundle.go -index 3d83084..06f8808 100644 ---- a/src/net/http/h2_bundle.go -+++ b/src/net/http/h2_bundle.go -@@ -4289,7 +4289,15 @@ func (sc *http2serverConn) canonicalHeader(v string) string { - sc.canonHeader = make(map[string]string) - } - cv = CanonicalHeaderKey(v) -- sc.canonHeader[v] = cv -+ // 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 { -+ sc.canonHeader[v] = cv -+ } - return cv - } - --- -2.30.0 - diff --git a/0055-release-branch.go1.16-archive-zip-prevent-preallocat.patch b/0055-release-branch.go1.16-archive-zip-prevent-preallocat.patch deleted file mode 100644 index b8e83dd34fc41507470ba5a2aadec32f1298d011..0000000000000000000000000000000000000000 --- a/0055-release-branch.go1.16-archive-zip-prevent-preallocat.patch +++ /dev/null @@ -1,73 +0,0 @@ -From 6c480017ae600b2c90a264a922e041df04dfa785 Mon Sep 17 00:00:00 2001 -From: Roland Shoemaker -Date: Wed, 18 Aug 2021 11:49:29 -0700 -Subject: [PATCH] [release-branch.go1.16] archive/zip: prevent preallocation check from overflowing - -If the indicated directory size in the archive header is so large that -subtracting it from the archive size overflows a uint64, the check that -the indicated number of files in the archive can be effectively -bypassed. Prevent this from happening by checking that the indicated -directory size is less than the size of the archive. - -Thanks to the OSS-Fuzz project for discovering this issue and to -Emmanuel Odeke for reporting it. - -Fixes #47985 -Updates #47801 -Fixes CVE-2021-39293 - -Change-Id: Ifade26b98a40f3b37398ca86bd5252d12394dd24 -Reviewed-on: https://go-review.googlesource.com/c/go/+/343434 -Trust: Roland Shoemaker -Run-TryBot: Roland Shoemaker -TryBot-Result: Go Bot -Reviewed-by: Russ Cox -(cherry picked from commit bacbc33439b124ffd7392c91a5f5d96eca8c0c0b) -Reviewed-on: https://go-review.googlesource.com/c/go/+/345409 -Reviewed-by: Emmanuel Odeke -Run-TryBot: Emmanuel Odeke -Trust: Cherry Mui - -Reference:https://go-review.googlesource.com/c/go/+/345409 -Conflict:NA ---- - -diff --git a/src/archive/zip/reader.go b/src/archive/zip/reader.go -index ddef2b7..801d131 100644 ---- a/src/archive/zip/reader.go -+++ b/src/archive/zip/reader.go -@@ -105,7 +105,7 @@ - // indicate it contains up to 1 << 128 - 1 files. Since each file has a - // header which will be _at least_ 30 bytes we can safely preallocate - // if (data size / 30) >= end.directoryRecords. -- if (uint64(size)-end.directorySize)/30 >= end.directoryRecords { -+ if end.directorySize < uint64(size) && (uint64(size)-end.directorySize)/30 >= end.directoryRecords { - z.File = make([]*File, 0, end.directoryRecords) - } - z.Comment = end.comment -diff --git a/src/archive/zip/reader_test.go b/src/archive/zip/reader_test.go -index 471be27..99f1334 100644 ---- a/src/archive/zip/reader_test.go -+++ b/src/archive/zip/reader_test.go -@@ -1225,3 +1225,21 @@ - t.Errorf("Archive has unexpected number of files, got %d, want 5", len(r.File)) - } - } -+ -+func TestCVE202139293(t *testing.T) { -+ // directory size is so large, that the check in Reader.init -+ // overflows when subtracting from the archive size, causing -+ // the pre-allocation check to be bypassed. -+ data := []byte{ -+ 0x50, 0x4b, 0x06, 0x06, 0x05, 0x06, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x4b, -+ 0x06, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, -+ 0x00, 0x00, 0x50, 0x4b, 0x05, 0x06, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x4b, -+ 0x06, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, -+ 0x00, 0x00, 0x00, 0x50, 0x4b, 0x05, 0x06, 0x00, 0x31, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, -+ 0xff, 0x50, 0xfe, 0x00, 0xff, 0x00, 0x3a, 0x00, 0x00, 0x00, 0xff, -+ } -+ _, err := NewReader(bytes.NewReader(data), int64(len(data))) -+ if err != ErrFormat { -+ t.Fatalf("unexpected error, got: %v, want: %v", err, ErrFormat) -+ } -+} diff --git a/0056-release-branch.go1.16-debug-macho-fail-on-invalid-dy.patch b/0056-release-branch.go1.16-debug-macho-fail-on-invalid-dy.patch deleted file mode 100644 index 7a7812f8838a6375420e3b9dbd47b037ee2f180b..0000000000000000000000000000000000000000 --- a/0056-release-branch.go1.16-debug-macho-fail-on-invalid-dy.patch +++ /dev/null @@ -1,84 +0,0 @@ -From d19c5bdb24e093a2d5097b7623284eb02726cede Mon Sep 17 00:00:00 2001 -From: Roland Shoemaker -Date: Thu, 14 Oct 2021 13:02:01 -0700 -Subject: [PATCH] [release-branch.go1.16] debug/macho: fail on invalid dynamic - symbol table command -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Fail out when loading a file that contains a dynamic symbol table -command that indicates a larger number of symbols than exist in the -loaded symbol table. - -Thanks to Burak Çarıkçı - Yunus Yıldırım (CT-Zer0 Crypttech) for -reporting this issue. - -Updates #48990 -Fixes #48991 -Fixes CVE-2021-41771 - -Change-Id: Ic3d6e6529241afcc959544b326b21b663262bad5 -Reviewed-on: https://go-review.googlesource.com/c/go/+/355990 -Reviewed-by: Julie Qiu -Reviewed-by: Katie Hockman -Reviewed-by: Emmanuel Odeke -Run-TryBot: Roland Shoemaker -TryBot-Result: Go Bot -Trust: Katie Hockman -(cherry picked from commit 61536ec03063b4951163bd09609c86d82631fa27) -Reviewed-on: https://go-review.googlesource.com/c/go/+/359454 -Reviewed-by: Dmitri Shuralyov ---- - src/debug/macho/file.go | 9 +++++++++ - src/debug/macho/file_test.go | 7 +++++++ - .../testdata/gcc-amd64-darwin-exec-with-bad-dysym.base64 | 1 + - 3 files changed, 17 insertions(+) - create mode 100644 src/debug/macho/testdata/gcc-amd64-darwin-exec-with-bad-dysym.base64 - -diff --git a/src/debug/macho/file.go b/src/debug/macho/file.go -index 085b0c8219..73cfce3c76 100644 ---- a/src/debug/macho/file.go -+++ b/src/debug/macho/file.go -@@ -345,6 +345,15 @@ func NewFile(r io.ReaderAt) (*File, error) { - if err := binary.Read(b, bo, &hdr); err != nil { - return nil, err - } -+ if hdr.Iundefsym > uint32(len(f.Symtab.Syms)) { -+ return nil, &FormatError{offset, fmt.Sprintf( -+ "undefined symbols index in dynamic symbol table command is greater than symbol table length (%d > %d)", -+ hdr.Iundefsym, len(f.Symtab.Syms)), nil} -+ } else if hdr.Iundefsym+hdr.Nundefsym > uint32(len(f.Symtab.Syms)) { -+ return nil, &FormatError{offset, fmt.Sprintf( -+ "number of undefined symbols after index in dynamic symbol table command is greater than symbol table length (%d > %d)", -+ hdr.Iundefsym+hdr.Nundefsym, len(f.Symtab.Syms)), nil} -+ } - dat := make([]byte, hdr.Nindirectsyms*4) - if _, err := r.ReadAt(dat, int64(hdr.Indirectsymoff)); err != nil { - return nil, err -diff --git a/src/debug/macho/file_test.go b/src/debug/macho/file_test.go -index 03915c86e2..9beeb80dd2 100644 ---- a/src/debug/macho/file_test.go -+++ b/src/debug/macho/file_test.go -@@ -416,3 +416,10 @@ func TestTypeString(t *testing.T) { - t.Errorf("got %v, want %v", TypeExec.GoString(), "macho.Exec") - } - } -+ -+func TestOpenBadDysymCmd(t *testing.T) { -+ _, err := openObscured("testdata/gcc-amd64-darwin-exec-with-bad-dysym.base64") -+ if err == nil { -+ t.Fatal("openObscured did not fail when opening a file with an invalid dynamic symbol table command") -+ } -+} -diff --git a/src/debug/macho/testdata/gcc-amd64-darwin-exec-with-bad-dysym.base64 b/src/debug/macho/testdata/gcc-amd64-darwin-exec-with-bad-dysym.base64 -new file mode 100644 -index 0000000000..8e0436639c ---- /dev/null -+++ b/src/debug/macho/testdata/gcc-amd64-darwin-exec-with-bad-dysym.base64 -@@ -0,0 +1 @@ -+z/rt/gcAAAEDAACAAgAAAAsAAABoBQAAhQAAAAAAAAAZAAAASAAAAF9fUEFHRVpFUk8AAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAZAAAA2AEAAF9fVEVYVAAAAAAAAAAAAAAAAAAAAQAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAcAAAAFAAAABQAAAAAAAABfX3RleHQAAAAAAAAAAAAAX19URVhUAAAAAAAAAAAAABQPAAABAAAAbQAAAAAAAAAUDwAAAgAAAAAAAAAAAAAAAAQAgAAAAAAAAAAAAAAAAF9fc3ltYm9sX3N0dWIxAABfX1RFWFQAAAAAAAAAAAAAgQ8AAAEAAAAMAAAAAAAAAIEPAAAAAAAAAAAAAAAAAAAIBACAAAAAAAYAAAAAAAAAX19zdHViX2hlbHBlcgAAAF9fVEVYVAAAAAAAAAAAAACQDwAAAQAAABgAAAAAAAAAkA8AAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABfX2NzdHJpbmcAAAAAAAAAX19URVhUAAAAAAAAAAAAAKgPAAABAAAADQAAAAAAAACoDwAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAF9fZWhfZnJhbWUAAAAAAABfX1RFWFQAAAAAAAAAAAAAuA8AAAEAAABIAAAAAAAAALgPAAADAAAAAAAAAAAAAAALAABgAAAAAAAAAAAAAAAAGQAAADgBAABfX0RBVEEAAAAAAAAAAAAAABAAAAEAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAHAAAAAwAAAAMAAAAAAAAAX19kYXRhAAAAAAAAAAAAAF9fREFUQQAAAAAAAAAAAAAAEAAAAQAAABwAAAAAAAAAABAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABfX2R5bGQAAAAAAAAAAAAAX19EQVRBAAAAAAAAAAAAACAQAAABAAAAOAAAAAAAAAAgEAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAF9fbGFfc3ltYm9sX3B0cgBfX0RBVEEAAAAAAAAAAAAAWBAAAAEAAAAQAAAAAAAAAFgQAAACAAAAAAAAAAAAAAAHAAAAAgAAAAAAAAAAAAAAGQAAAEgAAABfX0xJTktFRElUAAAAAAAAACAAAAEAAAAAEAAAAAAAAAAgAAAAAAAAQAEAAAAAAAAHAAAAAQAAAAAAAAAAAAAAAgAAABgAAAAAIAAACwAAAMAgAACAAAAACwAAAFAAAAAAAAAAAgAAAAIAAAAHAAAACQAAAP8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwIAAABAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAIAAAAAwAAAAvdXNyL2xpYi9keWxkAAAAAAAAABsAAAAYAAAAOyS4cg5FdtQoqu6JsMEhXQUAAAC4AAAABAAAACoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQPAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAOAAAABgAAAACAAAAAAABAAAAAQAvdXNyL2xpYi9saWJnY2Nfcy4xLmR5bGliAAAAAAAAAAwAAAA4AAAAGAAAAAIAAAAEAW8AAAABAC91c3IvbGliL2xpYlN5c3RlbS5CLmR5bGliAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABqAEiJ5UiD5PBIi30ISI11EIn6g8IBweIDSAHySInR6wRIg8EISIM5AHX2SIPBCOgiAAAAicfoMgAAAPRBU0yNHafw//9BU/8lvwAAAA8fAP8lvgAAAFVIieVIjT0zAAAA6A0AAAC4AAAAAMnD/yXRAAAA/yXTAAAAAAAATI0dwQAAAOm0////TI0dvQAAAOmo////aGVsbG8sIHdvcmxkAAAAABQAAAAAAAAAAXpSAAF4EAEQDAcIkAEAACwAAAAcAAAAkv////////8XAAAAAAAAAAAEAQAAAA4QhgIEAwAAAA0GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABDAX/9/AAAIEMBf/38AAAAAAAABAAAAGBAAAAEAAAAQEAAAAQAAAAgQAAABAAAAABAAAAEAAACQDwAAAQAAAJwPAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAHgEAAFAPAAABAAAAGwAAAB4BAABkDwAAAQAAAC4AAAAPBgAAGBAAAAEAAAA2AAAADwYAABAQAAABAAAAPgAAAA8GAAAAEAAAAQAAAEoAAAADABAAAAAAAAEAAABeAAAADwYAAAgQAAABAAAAZwAAAA8BAABqDwAAAQAAAG0AAAAPAQAAFA8AAAEAAABzAAAAAQABAgAAAAAAAAAAeQAAAAEAAQIAAAAAAAAAAAkAAAAKAAAACQAAAAoAAAAgAGR5bGRfc3R1Yl9iaW5kaW5nX2hlbHBlcgBfX2R5bGRfZnVuY19sb29rdXAAX05YQXJnYwBfTlhBcmd2AF9fX3Byb2duYW1lAF9fbWhfZXhlY3V0ZV9oZWFkZXIAX2Vudmlyb24AX21haW4Ac3RhcnQAX2V4aXQAX3B1dHMAAA== -\ No newline at end of file --- -2.21.0 (Apple Git-122) - diff --git a/0057-release-branch.go1.16-math-big-prevent-overflow-in-R.patch b/0057-release-branch.go1.16-math-big-prevent-overflow-in-R.patch deleted file mode 100644 index e2217de269410893e4bc60720bec39c4cb2525b2..0000000000000000000000000000000000000000 --- a/0057-release-branch.go1.16-math-big-prevent-overflow-in-R.patch +++ /dev/null @@ -1,64 +0,0 @@ -From 3ebb1762fb1942b4ffe932000f873e16c194a2d7 Mon Sep 17 00:00:00 2001 -From: Katie Hockman -Date: Wed, 2 Mar 2022 10:52:56 +0800 -Subject: [Backport 1/3] [release-branch.go1.16] math/big: prevent overflow in - (*Rat).SetString - -Credit to rsc@ for the original patch. - -Thanks to the OSS-Fuzz project for discovering this -issue and to Emmanuel Odeke (@odeke_et) for reporting it. - -Updates #50699 -Fixes #50700 -Fixes CVE-2022-23772 - -Change-Id: I590395a3d55689625390cf1e58f5f40623b26ee5 -Reviewed-on: https://go-review.googlesource.com/c/go/+/379537 -Trust: Katie Hockman -Run-TryBot: Katie Hockman -TryBot-Result: Gopher Robot -Reviewed-by: Emmanuel Odeke -Reviewed-by: Roland Shoemaker -Reviewed-by: Julie Qiu -(cherry picked from commit ad345c265916bbf6c646865e4642eafce6d39e78) -Reviewed-on: https://go-review.googlesource.com/c/go/+/381337 - -Reference:https://go-review.googlesource.com/c/go/+/381337 -Conflict:NA ---- - src/math/big/ratconv.go | 5 +++++ - src/math/big/ratconv_test.go | 1 + - 2 files changed, 6 insertions(+) - -diff --git a/src/math/big/ratconv.go b/src/math/big/ratconv.go -index ac3c8bd..90053a9 100644 ---- a/src/math/big/ratconv.go -+++ b/src/math/big/ratconv.go -@@ -169,6 +169,11 @@ func (z *Rat) SetString(s string) (*Rat, bool) { - n := exp5 - if n < 0 { - n = -n -+ if n < 0 { -+ // This can occur if -n overflows. -(-1 << 63) would become -+ // -1 << 63, which is still negative. -+ return nil, false -+ } - } - if n > 1e6 { - return nil, false // avoid excessively large exponents -diff --git a/src/math/big/ratconv_test.go b/src/math/big/ratconv_test.go -index 15d206c..e55e655 100644 ---- a/src/math/big/ratconv_test.go -+++ b/src/math/big/ratconv_test.go -@@ -104,6 +104,7 @@ var setStringTests = []StringTest{ - {in: "4/3/"}, - {in: "4/3."}, - {in: "4/"}, -+ {in: "13e-9223372036854775808"}, // CVE-2022-23772 - - // valid - {"0", "0", true}, --- -2.30.0 - diff --git a/0058-release-branch.go1.16-crypto-elliptic-make-IsOnCurve.patch b/0058-release-branch.go1.16-crypto-elliptic-make-IsOnCurve.patch deleted file mode 100644 index 6f232542416a44d890712ac6d585ed6db0ce8768..0000000000000000000000000000000000000000 --- a/0058-release-branch.go1.16-crypto-elliptic-make-IsOnCurve.patch +++ /dev/null @@ -1,149 +0,0 @@ -From 126bdb9ae49d443850459b55cf7c0686eef2f476 Mon Sep 17 00:00:00 2001 -From: Filippo Valsorda -Date: Wed, 2 Mar 2022 10:56:28 +0800 -Subject: [Backport 3/3] [release-branch.go1.16] crypto/elliptic: make - IsOnCurve return false for invalid field elements - -Updates #50974 -Fixes #50977 -Fixes CVE-2022-23806 - -Change-Id: I0201c2c88f13dd82910985a495973f1683af9259 -Reviewed-on: https://go-review.googlesource.com/c/go/+/382855 -Trust: Filippo Valsorda -Run-TryBot: Filippo Valsorda -Reviewed-by: Katie Hockman -Trust: Katie Hockman -TryBot-Result: Gopher Robot - -Conflict:NA -Reference:https://go-review.googlesource.com/c/go/+/382855 ---- - src/crypto/elliptic/elliptic.go | 4 ++ - src/crypto/elliptic/elliptic_test.go | 81 ++++++++++++++++++++++++++++ - src/crypto/elliptic/p224.go | 5 ++ - 3 files changed, 90 insertions(+) - -diff --git a/src/crypto/elliptic/elliptic.go b/src/crypto/elliptic/elliptic.go -index f93dc16..321f926 100644 ---- a/src/crypto/elliptic/elliptic.go -+++ b/src/crypto/elliptic/elliptic.go -@@ -71,6 +71,10 @@ func (curve *CurveParams) polynomial(x *big.Int) *big.Int { - } - - func (curve *CurveParams) IsOnCurve(x, y *big.Int) bool { -+ if x.Sign() < 0 || x.Cmp(curve.P) >= 0 || -+ y.Sign() < 0 || y.Cmp(curve.P) >= 0 { -+ return false -+ } - // y² = x³ - 3x + b - y2 := new(big.Int).Mul(y, y) - y2.Mod(y2, curve.P) -diff --git a/src/crypto/elliptic/elliptic_test.go b/src/crypto/elliptic/elliptic_test.go -index e80e773..bb16b0d 100644 ---- a/src/crypto/elliptic/elliptic_test.go -+++ b/src/crypto/elliptic/elliptic_test.go -@@ -721,3 +721,84 @@ func testMarshalCompressed(t *testing.T, curve Curve, x, y *big.Int, want []byte - t.Errorf("point did not round-trip correctly: got (%v, %v), want (%v, %v)", X, Y, x, y) - } - } -+ -+func testAllCurves(t *testing.T, f func(*testing.T, Curve)) { -+ tests := []struct { -+ name string -+ curve Curve -+ }{ -+ {"P256", P256()}, -+ {"P256/Params", P256().Params()}, -+ {"P224", P224()}, -+ {"P224/Params", P224().Params()}, -+ {"P384", P384()}, -+ {"P384/Params", P384().Params()}, -+ {"P521", P521()}, -+ {"P521/Params", P521().Params()}, -+ } -+ if testing.Short() { -+ tests = tests[:1] -+ } -+ for _, test := range tests { -+ curve := test.curve -+ t.Run(test.name, func(t *testing.T) { -+ t.Parallel() -+ f(t, curve) -+ }) -+ } -+} -+ -+// TestInvalidCoordinates tests big.Int values that are not valid field elements -+// (negative or bigger than P). They are expected to return false from -+// IsOnCurve, all other behavior is undefined. -+func TestInvalidCoordinates(t *testing.T) { -+ testAllCurves(t, testInvalidCoordinates) -+} -+ -+func testInvalidCoordinates(t *testing.T, curve Curve) { -+ checkIsOnCurveFalse := func(name string, x, y *big.Int) { -+ if curve.IsOnCurve(x, y) { -+ t.Errorf("IsOnCurve(%s) unexpectedly returned true", name) -+ } -+ } -+ -+ p := curve.Params().P -+ _, x, y, _ := GenerateKey(curve, rand.Reader) -+ xx, yy := new(big.Int), new(big.Int) -+ -+ // Check if the sign is getting dropped. -+ xx.Neg(x) -+ checkIsOnCurveFalse("-x, y", xx, y) -+ yy.Neg(y) -+ checkIsOnCurveFalse("x, -y", x, yy) -+ -+ // Check if negative values are reduced modulo P. -+ xx.Sub(x, p) -+ checkIsOnCurveFalse("x-P, y", xx, y) -+ yy.Sub(y, p) -+ checkIsOnCurveFalse("x, y-P", x, yy) -+ -+ // Check if positive values are reduced modulo P. -+ xx.Add(x, p) -+ checkIsOnCurveFalse("x+P, y", xx, y) -+ yy.Add(y, p) -+ checkIsOnCurveFalse("x, y+P", x, yy) -+ -+ // Check if the overflow is dropped. -+ xx.Add(x, new(big.Int).Lsh(big.NewInt(1), 535)) -+ checkIsOnCurveFalse("x+2⁵³⁵, y", xx, y) -+ yy.Add(y, new(big.Int).Lsh(big.NewInt(1), 535)) -+ checkIsOnCurveFalse("x, y+2⁵³⁵", x, yy) -+ -+ // Check if P is treated like zero (if possible). -+ // y^2 = x^3 - 3x + B -+ // y = mod_sqrt(x^3 - 3x + B) -+ // y = mod_sqrt(B) if x = 0 -+ // If there is no modsqrt, there is no point with x = 0, can't test x = P. -+ if yy := new(big.Int).ModSqrt(curve.Params().B, p); yy != nil { -+ if !curve.IsOnCurve(big.NewInt(0), yy) { -+ t.Fatal("(0, mod_sqrt(B)) is not on the curve?") -+ } -+ checkIsOnCurveFalse("P, y", p, yy) -+ } -+} -diff --git a/src/crypto/elliptic/p224.go b/src/crypto/elliptic/p224.go -index 8c76021..ff5c834 100644 ---- a/src/crypto/elliptic/p224.go -+++ b/src/crypto/elliptic/p224.go -@@ -48,6 +48,11 @@ func (curve p224Curve) Params() *CurveParams { - } - - func (curve p224Curve) IsOnCurve(bigX, bigY *big.Int) bool { -+ if bigX.Sign() < 0 || bigX.Cmp(curve.P) >= 0 || -+ bigY.Sign() < 0 || bigY.Cmp(curve.P) >= 0 { -+ return false -+ } -+ - var x, y p224FieldElement - p224FromBig(&x, bigX) - p224FromBig(&y, bigY) --- -2.30.0 - diff --git a/0059-release-branch.go1.16-regexp-syntax-reject-very-deep.patch b/0059-release-branch.go1.16-regexp-syntax-reject-very-deep.patch deleted file mode 100644 index 443521ce1ef7306aff3fece5b6f7d16ef3338311..0000000000000000000000000000000000000000 --- a/0059-release-branch.go1.16-regexp-syntax-reject-very-deep.patch +++ /dev/null @@ -1,197 +0,0 @@ -From c8544ba60a2a4e5973aae3ae96cfa723deff3048 Mon Sep 17 00:00:00 2001 -From: Russ Cox -Date: Wed, 2 Feb 2022 16:41:32 -0500 -Subject: [Backport] [release-branch.go1.16] regexp/syntax: reject very deeply - nested regexps in Parse -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -The regexp code assumes it can recurse over the structure of -a regexp safely. Go's growable stacks make that reasonable -for all plausible regexps, but implausible ones can reach the -“infinite recursion?” stack limit. - -This CL limits the depth of any parsed regexp to 1000. -That is, the depth of the parse tree is required to be ≤ 1000. -Regexps that require deeper parse trees will return ErrInternalError. -A future CL will change the error to ErrInvalidDepth, -but using ErrInternalError for now avoids introducing new API -in point releases when this is backported. - -Fixes #51112. -Fixes #51117. - -Change-Id: I97d2cd82195946eb43a4ea8561f5b95f91fb14c5 -Reviewed-on: https://go-review.googlesource.com/c/go/+/384616 -Trust: Russ Cox -Run-TryBot: Russ Cox -Reviewed-by: Ian Lance Taylor -Reviewed-on: https://go-review.googlesource.com/c/go/+/384855 ---- - src/regexp/syntax/parse.go | 72 ++++++++++++++++++++++++++++++++- - src/regexp/syntax/parse_test.go | 7 ++++ - 2 files changed, 77 insertions(+), 2 deletions(-) - -diff --git a/src/regexp/syntax/parse.go b/src/regexp/syntax/parse.go -index 7b4030935a..d7cf2afa5e 100644 ---- a/src/regexp/syntax/parse.go -+++ b/src/regexp/syntax/parse.go -@@ -76,13 +76,29 @@ const ( - opVerticalBar - ) - -+// maxHeight is the maximum height of a regexp parse tree. -+// It is somewhat arbitrarily chosen, but the idea is to be large enough -+// that no one will actually hit in real use but at the same time small enough -+// that recursion on the Regexp tree will not hit the 1GB Go stack limit. -+// The maximum amount of stack for a single recursive frame is probably -+// closer to 1kB, so this could potentially be raised, but it seems unlikely -+// that people have regexps nested even this deeply. -+// We ran a test on Google's C++ code base and turned up only -+// a single use case with depth > 100; it had depth 128. -+// Using depth 1000 should be plenty of margin. -+// As an optimization, we don't even bother calculating heights -+// until we've allocated at least maxHeight Regexp structures. -+const maxHeight = 1000 -+ - type parser struct { - flags Flags // parse mode flags - stack []*Regexp // stack of parsed expressions - free *Regexp - numCap int // number of capturing groups seen - wholeRegexp string -- tmpClass []rune // temporary char class work space -+ tmpClass []rune // temporary char class work space -+ numRegexp int // number of regexps allocated -+ height map[*Regexp]int // regexp height for height limit check - } - - func (p *parser) newRegexp(op Op) *Regexp { -@@ -92,16 +108,52 @@ func (p *parser) newRegexp(op Op) *Regexp { - *re = Regexp{} - } else { - re = new(Regexp) -+ p.numRegexp++ - } - re.Op = op - return re - } - - func (p *parser) reuse(re *Regexp) { -+ if p.height != nil { -+ delete(p.height, re) -+ } - re.Sub0[0] = p.free - p.free = re - } - -+func (p *parser) checkHeight(re *Regexp) { -+ if p.numRegexp < maxHeight { -+ return -+ } -+ if p.height == nil { -+ p.height = make(map[*Regexp]int) -+ for _, re := range p.stack { -+ p.checkHeight(re) -+ } -+ } -+ if p.calcHeight(re, true) > maxHeight { -+ panic(ErrInternalError) -+ } -+} -+ -+func (p *parser) calcHeight(re *Regexp, force bool) int { -+ if !force { -+ if h, ok := p.height[re]; ok { -+ return h -+ } -+ } -+ h := 1 -+ for _, sub := range re.Sub { -+ hsub := p.calcHeight(sub, false) -+ if h < 1+hsub { -+ h = 1 + hsub -+ } -+ } -+ p.height[re] = h -+ return h -+} -+ - // Parse stack manipulation. - - // push pushes the regexp re onto the parse stack and returns the regexp. -@@ -137,6 +189,7 @@ func (p *parser) push(re *Regexp) *Regexp { - } - - p.stack = append(p.stack, re) -+ p.checkHeight(re) - return re - } - -@@ -246,6 +299,7 @@ func (p *parser) repeat(op Op, min, max int, before, after, lastRepeat string) ( - re.Sub = re.Sub0[:1] - re.Sub[0] = sub - p.stack[n-1] = re -+ p.checkHeight(re) - - if op == OpRepeat && (min >= 2 || max >= 2) && !repeatIsValid(re, 1000) { - return "", &Error{ErrInvalidRepeatSize, before[:len(before)-len(after)]} -@@ -693,6 +747,21 @@ func literalRegexp(s string, flags Flags) *Regexp { - // Flags, and returns a regular expression parse tree. The syntax is - // described in the top-level comment. - func Parse(s string, flags Flags) (*Regexp, error) { -+ return parse(s, flags) -+} -+ -+func parse(s string, flags Flags) (_ *Regexp, err error) { -+ defer func() { -+ switch r := recover(); r { -+ default: -+ panic(r) -+ case nil: -+ // ok -+ case ErrInternalError: -+ err = &Error{Code: ErrInternalError, Expr: s} -+ } -+ }() -+ - if flags&Literal != 0 { - // Trivial parser for literal string. - if err := checkUTF8(s); err != nil { -@@ -704,7 +773,6 @@ func Parse(s string, flags Flags) (*Regexp, error) { - // Otherwise, must do real work. - var ( - p parser -- err error - c rune - op Op - lastRepeat string -diff --git a/src/regexp/syntax/parse_test.go b/src/regexp/syntax/parse_test.go -index 5581ba1ca5..1ef6d8a3fe 100644 ---- a/src/regexp/syntax/parse_test.go -+++ b/src/regexp/syntax/parse_test.go -@@ -207,6 +207,11 @@ var parseTests = []parseTest{ - // Valid repetitions. - {`((((((((((x{2}){2}){2}){2}){2}){2}){2}){2}){2}))`, ``}, - {`((((((((((x{1}){2}){2}){2}){2}){2}){2}){2}){2}){2})`, ``}, -+ -+ // Valid nesting. -+ {strings.Repeat("(", 999) + strings.Repeat(")", 999), ``}, -+ {strings.Repeat("(?:", 999) + strings.Repeat(")*", 999), ``}, -+ {"(" + strings.Repeat("|", 12345) + ")", ``}, // not nested at all - } - - const testFlags = MatchNL | PerlX | UnicodeGroups -@@ -482,6 +487,8 @@ var invalidRegexps = []string{ - `a{100000}`, - `a{100000,}`, - "((((((((((x{2}){2}){2}){2}){2}){2}){2}){2}){2}){2})", -+ strings.Repeat("(", 1000) + strings.Repeat(")", 1000), -+ strings.Repeat("(?:", 1000) + strings.Repeat(")*", 1000), - `\Q\E*`, - } - --- -2.30.0 - diff --git a/0060-cmd-go-internal-modfetch-do-not-short-circuit-canoni.patch b/0060-cmd-go-internal-modfetch-do-not-short-circuit-canoni.patch deleted file mode 100644 index de778f52ddc7fa9933aef8b3427ebe5e4b860e23..0000000000000000000000000000000000000000 --- a/0060-cmd-go-internal-modfetch-do-not-short-circuit-canoni.patch +++ /dev/null @@ -1,472 +0,0 @@ -From 2d036d30f6f9290874c9220335e70ef6dec7470d Mon Sep 17 00:00:00 2001 -From: Bryan Mills -Date: Wed, 23 Mar 2022 20:37:48 +0800 -Subject: [PATCH 1/2] cmd/go/internal/modfetch: do not short-circuit canonical - versions - -Since at least CL 121857, the conversion logic in -(*modfetch).codeRepo.Stat has had a short-circuit to use the version -requested by the caller if it successfully resolves and is already -canonical. - -However, we should not use that version if it refers to a branch -instead of a tag, because branches (unlike tags) usually do not refer -to a single, stable release: a branch named "v1.0.0" may be for the -development of the v1.0.0 release, or for the development of patches -based on v1.0.0, but only one commit (perhaps at the end of that -branch but possibly not even written yet!) can be that specific -version. - -We already have some logic to prefer tags that are semver-equivalent -to the version requested by the caller. That more general case -suffices for exact equality too so we can eliminate the -special-case, fixing the bug and (happily!) also somewhat simplifying -the code. - -Fixes #35671 -Updates #41512 - -Change-Id: I2fd290190b8a99a580deec7e26d15659b58a50b0 -Reviewed-on: https://go-review.googlesource.com/c/go/+/378400 -Trust: Bryan Mills -Run-TryBot: Bryan Mills -Reviewed-by: Russ Cox -TryBot-Result: Gopher Robot - -Conflict:src/cmd/go/internal/modfetch/coderepo.go;src/cmd/go/internal/modfetch/coderepo_test.go -Reference:https://go-review.googlesource.com/c/go/+/378400/ ---- - src/cmd/go/internal/modfetch/coderepo.go | 278 ++++++++++-------- - src/cmd/go/internal/modfetch/coderepo_test.go | 40 +++ - 2 files changed, 201 insertions(+), 117 deletions(-) - -diff --git a/src/cmd/go/internal/modfetch/coderepo.go b/src/cmd/go/internal/modfetch/coderepo.go -index d043903..c654b36 100644 ---- a/src/cmd/go/internal/modfetch/coderepo.go -+++ b/src/cmd/go/internal/modfetch/coderepo.go -@@ -298,42 +298,61 @@ func (r *codeRepo) Latest() (*RevInfo, error) { - // If statVers is a valid module version, it is used for the Version field. - // Otherwise, the Version is derived from the passed-in info and recent tags. - func (r *codeRepo) convert(info *codehost.RevInfo, statVers string) (*RevInfo, error) { -- info2 := &RevInfo{ -- Name: info.Name, -- Short: info.Short, -- Time: info.Time, -- } -- - // If this is a plain tag (no dir/ prefix) - // and the module path is unversioned, - // and if the underlying file tree has no go.mod, - // then allow using the tag with a +incompatible suffix. -- var canUseIncompatible func() bool -- canUseIncompatible = func() bool { -- var ok bool -- if r.codeDir == "" && r.pathMajor == "" { -+ // -+ // (If the version is +incompatible, then the go.mod file must not exist: -+ // +incompatible is not an ongoing opt-out from semantic import versioning.) -+ incompatibleOk := map[string]bool{} -+ canUseIncompatible := func(v string) bool { -+ if r.codeDir != "" || r.pathMajor != "" { -+ // A non-empty codeDir indicates a module within a subdirectory, -+ // which necessarily has a go.mod file indicating the module boundary. -+ // A non-empty pathMajor indicates a module path with a major-version -+ // suffix, which must match. -+ return false -+ } -+ -+ ok, seen := incompatibleOk[""] -+ if !seen { - _, errGoMod := r.code.ReadFile(info.Name, "go.mod", codehost.MaxGoMod) -- if errGoMod != nil { -- ok = true -- } -+ ok = (errGoMod != nil) -+ incompatibleOk[""] = ok -+ } -+ if !ok { -+ // A go.mod file exists at the repo root. -+ return false - } -- canUseIncompatible = func() bool { return ok } -- return ok -- } - -- invalidf := func(format string, args ...interface{}) error { -- return &module.ModuleError{ -- Path: r.modPath, -- Err: &module.InvalidVersionError{ -- Version: info2.Version, -- Err: fmt.Errorf(format, args...), -- }, -+ // Per https://go.dev/issue/51324, previous versions of the 'go' command -+ // didn't always check for go.mod files in subdirectories, so if the user -+ // requests a +incompatible version explicitly, we should continue to allow -+ // it. Otherwise, if vN/go.mod exists, expect that release tags for that -+ // major version are intended for the vN module. -+ if v != "" && !strings.HasSuffix(statVers, "+incompatible") { -+ major := semver.Major(v) -+ ok, seen = incompatibleOk[major] -+ if !seen { -+ _, errGoModSub := r.code.ReadFile(info.Name, path.Join(major, "go.mod"), codehost.MaxGoMod) -+ ok = (errGoModSub != nil) -+ incompatibleOk[major] = ok -+ } -+ if !ok { -+ return false -+ } - } -+ -+ return true - } - -- // checkGoMod verifies that the go.mod file for the module exists or does not -- // exist as required by info2.Version and the module path represented by r. -- checkGoMod := func() (*RevInfo, error) { -+ // checkCanonical verifies that the canonical version v is compatible with the -+ // module path represented by r, adding a "+incompatible" suffix if needed. -+ // -+ // If statVers is also canonical, checkCanonical also verifies that v is -+ // either statVers or statVers with the added "+incompatible" suffix. -+ checkCanonical := func(v string) (*RevInfo, error) { - // If r.codeDir is non-empty, then the go.mod file must exist: the module - // author — not the module consumer, — gets to decide how to carve up the repo - // into modules. -@@ -344,73 +363,91 @@ func (r *codeRepo) convert(info *codehost.RevInfo, statVers string) (*RevInfo, e - // r.findDir verifies both of these conditions. Execute it now so that - // r.Stat will correctly return a notExistError if the go.mod location or - // declared module path doesn't match. -- _, _, _, err := r.findDir(info2.Version) -+ _, _, _, err := r.findDir(v) - if err != nil { - // TODO: It would be nice to return an error like "not a module". - // Right now we return "missing go.mod", which is a little confusing. - return nil, &module.ModuleError{ - Path: r.modPath, - Err: &module.InvalidVersionError{ -- Version: info2.Version, -+ Version: v, - Err: notExistError{err: err}, - }, - } - } - -- // If the version is +incompatible, then the go.mod file must not exist: -- // +incompatible is not an ongoing opt-out from semantic import versioning. -- if strings.HasSuffix(info2.Version, "+incompatible") { -- if !canUseIncompatible() { -+ invalidf := func(format string, args ...interface{}) error { -+ return &module.ModuleError{ -+ Path: r.modPath, -+ Err: &module.InvalidVersionError{ -+ Version: v, -+ Err: fmt.Errorf(format, args...), -+ }, -+ } -+ } -+ -+ // Add the +incompatible suffix if needed or requested explicitly, and -+ // verify that its presence or absence is appropriate for this version -+ // (which depends on whether it has an explicit go.mod file). -+ -+ if v == strings.TrimSuffix(statVers, "+incompatible") { -+ v = statVers -+ } -+ base := strings.TrimSuffix(v, "+incompatible") -+ var errIncompatible error -+ if !module.MatchPathMajor(base, r.pathMajor) { -+ if canUseIncompatible(base) { -+ v = base + "+incompatible" -+ } else { - if r.pathMajor != "" { -- return nil, invalidf("+incompatible suffix not allowed: module path includes a major version suffix, so major version must match") -+ errIncompatible = invalidf("module path includes a major version suffix, so major version must match") - } else { -- return nil, invalidf("+incompatible suffix not allowed: module contains a go.mod file, so semantic import versioning is required") -+ errIncompatible = invalidf("module contains a go.mod file, so module path must match major version (%q)", path.Join(r.pathPrefix, semver.Major(v))) - } - } -+ } else if strings.HasSuffix(v, "+incompatible") { -+ errIncompatible = invalidf("+incompatible suffix not allowed: major version %s is compatible", semver.Major(v)) -+ } - -- if err := module.CheckPathMajor(strings.TrimSuffix(info2.Version, "+incompatible"), r.pathMajor); err == nil { -- return nil, invalidf("+incompatible suffix not allowed: major version %s is compatible", semver.Major(info2.Version)) -+ if statVers != "" && statVers == module.CanonicalVersion(statVers) { -+ // Since the caller-requested version is canonical, it would be very -+ // confusing to resolve it to anything but itself, possibly with a -+ // "+incompatible" suffix. Error out explicitly. -+ if statBase := strings.TrimSuffix(statVers, "+incompatible"); statBase != base { -+ return nil, &module.ModuleError{ -+ Path: r.modPath, -+ Err: &module.InvalidVersionError{ -+ Version: statVers, -+ Err: fmt.Errorf("resolves to version %v (%s is not a tag)", v, statBase), -+ }, -+ } - } - } - -- return info2, nil -+ if errIncompatible != nil { -+ return nil, errIncompatible -+ } -+ -+ return &RevInfo{ -+ Name: info.Name, -+ Short: info.Short, -+ Time: info.Time, -+ Version: v, -+ }, nil - } - - // Determine version. -- // -- // If statVers is canonical, then the original call was repo.Stat(statVers). -- // Since the version is canonical, we must not resolve it to anything but -- // itself, possibly with a '+incompatible' annotation: we do not need to do -- // the work required to look for an arbitrary pseudo-version. -- if statVers != "" && statVers == module.CanonicalVersion(statVers) { -- info2.Version = statVers -- -- if IsPseudoVersion(info2.Version) { -- if err := r.validatePseudoVersion(info, info2.Version); err != nil { -- return nil, err -- } -- return checkGoMod() -- } - -- if err := module.CheckPathMajor(info2.Version, r.pathMajor); err != nil { -- if canUseIncompatible() { -- info2.Version += "+incompatible" -- return checkGoMod() -- } else { -- if vErr, ok := err.(*module.InvalidVersionError); ok { -- // We're going to describe why the version is invalid in more detail, -- // so strip out the existing “invalid version” wrapper. -- err = vErr.Err -- } -- return nil, invalidf("module contains a go.mod file, so major version must be compatible: %v", err) -- } -+ if IsPseudoVersion(statVers) { -+ if err := r.validatePseudoVersion(info, statVers); err != nil { -+ return nil, err - } -- -- return checkGoMod() -+ return checkCanonical(statVers) - } - -- // statVers is empty or non-canonical, so we need to resolve it to a canonical -- // version or pseudo-version. -+ // statVers is not a pseudo-version, so we need to either resolve it to a -+ // canonical version or verify that it is already a canonical tag -+ // (not a branch). - - // Derive or verify a version from a code repo tag. - // Tag must have a prefix matching codeDir. -@@ -419,9 +456,14 @@ func (r *codeRepo) convert(info *codehost.RevInfo, statVers string) (*RevInfo, e - tagPrefix = r.codeDir + "/" - } - -+ isRetracted, err := r.retractedVersions() -+ if err != nil { -+ isRetracted = func(string) bool { return false } -+ } -+ - // tagToVersion returns the version obtained by trimming tagPrefix from tag. -- // If the tag is invalid or a pseudo-version, tagToVersion returns an empty -- // version. -+ // If the tag is invalid, retracted, or a pseudo-version, tagToVersion returns -+ // an empty version. - tagToVersion := func(tag string) (v string, tagIsCanonical bool) { - if !strings.HasPrefix(tag, tagPrefix) { - return "", false -@@ -439,83 +481,85 @@ func (r *codeRepo) convert(info *codehost.RevInfo, statVers string) (*RevInfo, e - if v == trimmed { - tagIsCanonical = true - } -- -- if err := module.CheckPathMajor(v, r.pathMajor); err != nil { -- if canUseIncompatible() { -- return v + "+incompatible", tagIsCanonical -- } -- return "", false -- } -- - return v, tagIsCanonical - } - - // If the VCS gave us a valid version, use that. - if v, tagIsCanonical := tagToVersion(info.Version); tagIsCanonical { -- info2.Version = v -- return checkGoMod() -+ if info, err := checkCanonical(v); err == nil { -+ return info, err -+ } - } - - // Look through the tags on the revision for either a usable canonical version - // or an appropriate base for a pseudo-version. -- var pseudoBase string -+ var ( -+ highestCanonical string -+ pseudoBase string -+ ) - for _, pathTag := range info.Tags { - v, tagIsCanonical := tagToVersion(pathTag) -- if tagIsCanonical { -- if statVers != "" && semver.Compare(v, statVers) == 0 { -- // The user requested a non-canonical version, but the tag for the -- // canonical equivalent refers to the same revision. Use it. -- info2.Version = v -- return checkGoMod() -+ if statVers != "" && semver.Compare(v, statVers) == 0 { -+ // The tag is equivalent to the version requested by the user. -+ if tagIsCanonical { -+ // This tag is the canonical form of the requested version, -+ // not some other form with extra build metadata. -+ // Use this tag so that the resolved version will match exactly. -+ // (If it isn't actually allowed, we'll error out in checkCanonical.) -+ return checkCanonical(v) - } else { -- // Save the highest canonical tag for the revision. If we don't find a -- // better match, we'll use it as the canonical version. -+ // The user explicitly requested something equivalent to this tag. We -+ // can't use the version from the tag directly: since the tag is not -+ // canonical, it could be ambiguous. For example, tags v0.0.1+a and -+ // v0.0.1+b might both exist and refer to different revisions. - // -- // NOTE: Do not replace this with semver.Max. Despite the name, -- // semver.Max *also* canonicalizes its arguments, which uses -- // semver.Canonical instead of module.CanonicalVersion and thereby -- // strips our "+incompatible" suffix. -- if semver.Compare(info2.Version, v) < 0 { -- info2.Version = v -- } -+ // The tag is otherwise valid for the module, so we can at least use it as -+ // the base of an unambiguous pseudo-version. -+ // -+ // If multiple tags match, tagToVersion will canonicalize them to the same -+ // base version. -+ pseudoBase = v -+ } -+ } -+ // Save the highest non-retracted canonical tag for the revision. -+ // If we don't find a better match, we'll use it as the canonical version. -+ if tagIsCanonical && semver.Compare(highestCanonical, v) < 0 && !isRetracted(v) { -+ if module.MatchPathMajor(v, r.pathMajor) || canUseIncompatible(v) { -+ highestCanonical = v - } -- } else if v != "" && semver.Compare(v, statVers) == 0 { -- // The user explicitly requested something equivalent to this tag. We -- // can't use the version from the tag directly: since the tag is not -- // canonical, it could be ambiguous. For example, tags v0.0.1+a and -- // v0.0.1+b might both exist and refer to different revisions. -- // -- // The tag is otherwise valid for the module, so we can at least use it as -- // the base of an unambiguous pseudo-version. -- // -- // If multiple tags match, tagToVersion will canonicalize them to the same -- // base version. -- pseudoBase = v - } - } - -- // If we found any canonical tag for the revision, return it. -+ // If we found a valid canonical tag for the revision, return it. - // Even if we found a good pseudo-version base, a canonical version is better. -- if info2.Version != "" { -- return checkGoMod() -+ if highestCanonical != "" { -+ return checkCanonical(highestCanonical) - } - -+ // Find the highest tagged version in the revision's history, subject to -+ // major version and +incompatible constraints. Use that version as the -+ // pseudo-version base so that the pseudo-version sorts higher. Ignore -+ // retracted versions. -+ allowedMajor := func(major string) func(v string) bool { -+ return func(v string) bool { -+ return ((major == "" && canUseIncompatible(v)) || semver.Major(v) == major) && !isRetracted(v) -+ } -+ } - if pseudoBase == "" { - var tag string -- if r.pseudoMajor != "" || canUseIncompatible() { -- tag, _ = r.code.RecentTag(info.Name, tagPrefix, r.pseudoMajor) -+ if r.pseudoMajor != "" || canUseIncompatible("") { -+ tag, _ = r.code.RecentTag(info.Name, tagPrefix, allowedMajor(r.pseudoMajor)) - } else { - // Allow either v1 or v0, but not incompatible higher versions. -- tag, _ = r.code.RecentTag(info.Name, tagPrefix, "v1") -+ tag, _ = r.code.RecentTag(info.Name, tagPrefix, allowedMajor("v1")) - if tag == "" { -- tag, _ = r.code.RecentTag(info.Name, tagPrefix, "v0") -+ tag, _ = r.code.RecentTag(info.Name, tagPrefix, allowedMajor("v0")) - } - } -- pseudoBase, _ = tagToVersion(tag) // empty if the tag is invalid -+ pseudoBase, _ = tagToVersion(tag) - } - -- info2.Version = PseudoVersion(r.pseudoMajor, pseudoBase, info.Time, info.Short) -- return checkGoMod() -+ return checkCanonical(PseudoVersion(r.pseudoMajor, pseudoBase, info.Time, info.Short)) - } - - // validatePseudoVersion checks that version has a major version compatible with -diff --git a/src/cmd/go/internal/modfetch/coderepo_test.go b/src/cmd/go/internal/modfetch/coderepo_test.go -index 9a0cd7d..ee1ec9e 100644 ---- a/src/cmd/go/internal/modfetch/coderepo_test.go -+++ b/src/cmd/go/internal/modfetch/coderepo_test.go -@@ -420,6 +420,46 @@ var codeRepoTests = []codeRepoTest{ - zipSum: "h1:JItBZ+gwA5WvtZEGEbuDL4lUttGtLrs53lmdurq3bOg=", - zipFileHash: "9ea9ae1673cffcc44b7fdd3cc89953d68c102449b46c982dbf085e4f2e394da5", - }, -+ { -+ // Git branch with a semver name, +incompatible version, and no go.mod file. -+ vcs: "git", -+ path: "vcs-test.golang.org/go/mod/gitrepo1", -+ rev: "v2.3.4+incompatible", -+ err: `resolves to version v2.0.1+incompatible (v2.3.4 is not a tag)`, -+ }, -+ { -+ // Git branch with a semver name, matching go.mod file, and compatible version. -+ vcs: "git", -+ path: "vcs-test.golang.org/git/semver-branch.git", -+ rev: "v1.0.0", -+ err: `resolves to version v0.1.1-0.20220202191944-09c4d8f6938c (v1.0.0 is not a tag)`, -+ }, -+ { -+ // Git branch with a semver name, matching go.mod file, and disallowed +incompatible version. -+ // The version/tag mismatch takes precedence over the +incompatible mismatched. -+ vcs: "git", -+ path: "vcs-test.golang.org/git/semver-branch.git", -+ rev: "v2.0.0+incompatible", -+ err: `resolves to version v0.1.0 (v2.0.0 is not a tag)`, -+ }, -+ { -+ // Git branch with a semver name, matching go.mod file, and mismatched version. -+ // The version/tag mismatch takes precedence over the +incompatible mismatched. -+ vcs: "git", -+ path: "vcs-test.golang.org/git/semver-branch.git", -+ rev: "v2.0.0", -+ err: `resolves to version v0.1.0 (v2.0.0 is not a tag)`, -+ }, -+ { -+ // v3.0.0-devel is the same as tag v4.0.0-beta.1, but v4.0.0-beta.1 would -+ // not be allowed because it is incompatible and a go.mod file exists. -+ // The error message should refer to a valid pseudo-version, not the -+ // unusable semver tag. -+ vcs: "git", -+ path: "vcs-test.golang.org/git/semver-branch.git", -+ rev: "v3.0.0-devel", -+ err: `resolves to version v0.1.1-0.20220203155313-d59622f6e4d7 (v3.0.0-devel is not a tag)`, -+ }, - } - - func TestCodeRepo(t *testing.T) { --- -2.30.0 - diff --git a/0077-release-branch.go1.16-runtime-consistently-access-po.patch b/0077-release-branch.go1.16-runtime-consistently-access-po.patch deleted file mode 100644 index cab604d692054fce63dfc1b460f10007773b2ba9..0000000000000000000000000000000000000000 --- a/0077-release-branch.go1.16-runtime-consistently-access-po.patch +++ /dev/null @@ -1,177 +0,0 @@ -From 55d5b4cd27af9070cbbbef4449dc56d528cdd9aa Mon Sep 17 00:00:00 2001 -From: Michael Pratt -Date: Thu, 14 Oct 2021 18:18:49 -0400 -Subject: [PATCH] [release-branch.go1.16] runtime: consistently access pollDesc - r/w Gs with atomics - -Both netpollblock and netpollunblock read gpp using a non-atomic load. -When consuming a ready event, netpollblock clears gpp using a non-atomic -store, thus skipping a barrier. - -Thus on systems with weak memory ordering, a sequence like so this is -possible: - - T1 T2 - -1. netpollblock: read gpp -> pdReady -2. netpollblock: store gpp -> 0 - - 3. netpollunblock: read gpp -> pdReady - 4. netpollunblock: return - -i.e., without a happens-before edge between (2) and (3), netpollunblock -may read the stale value of gpp. - -Switch these access to use atomic loads and stores in order to create -these edges. - -For ease of future maintainance, I've simply changed rg and wg to always -be accessed atomically, though I don't believe pollOpen or pollClose -require atomics today. - -For #48925 -Fixes #49009 - -Change-Id: I903ea667eea320277610b4f969129935731520c3 -Reviewed-on: https://go-review.googlesource.com/c/go/+/355952 -Trust: Michael Pratt -Run-TryBot: Michael Pratt -TryBot-Result: Go Bot -Reviewed-by: Michael Knyszek -Reviewed-by: David Chase -(cherry picked from commit 1b072b3ed56c18619587354f499fcda5279718a2) -Reviewed-on: https://go-review.googlesource.com/c/go/+/356370 - -Reference:https://go-review.googlesource.com/c/go/+/356370 -Conflict:NA ---- - src/runtime/netpoll.go | 43 +++++++++++++++++++++++++----------------- - 1 file changed, 26 insertions(+), 17 deletions(-) - -diff --git a/src/runtime/netpoll.go b/src/runtime/netpoll.go -index 77eb3aa4c6..f296b0a4db 100644 ---- a/src/runtime/netpoll.go -+++ b/src/runtime/netpoll.go -@@ -74,6 +74,7 @@ type pollDesc struct { - // pollReset, pollWait, pollWaitCanceled and runtime·netpollready (IO readiness notification) - // proceed w/o taking the lock. So closing, everr, rg, rd, wg and wd are manipulated - // in a lock-free way by all operations. -+ // TODO(golang.org/issue/49008): audit these lock-free fields for continued correctness. - // NOTE(dvyukov): the following code uses uintptr to store *g (rg/wg), - // that will blow up when GC starts moving objects. - lock mutex // protects the following fields -@@ -82,11 +83,11 @@ type pollDesc struct { - everr bool // marks event scanning error happened - user uint32 // user settable cookie - rseq uintptr // protects from stale read timers -- rg uintptr // pdReady, pdWait, G waiting for read or nil -+ rg uintptr // pdReady, pdWait, G waiting for read or nil. Accessed atomically. - rt timer // read deadline timer (set if rt.f != nil) - rd int64 // read deadline - wseq uintptr // protects from stale write timers -- wg uintptr // pdReady, pdWait, G waiting for write or nil -+ wg uintptr // pdReady, pdWait, G waiting for write or nil. Accessed atomically. - wt timer // write deadline timer - wd int64 // write deadline - self *pollDesc // storage for indirect interface. See (*pollDesc).makeArg. -@@ -143,20 +144,22 @@ func poll_runtime_isPollServerDescriptor(fd uintptr) bool { - func poll_runtime_pollOpen(fd uintptr) (*pollDesc, int) { - pd := pollcache.alloc() - lock(&pd.lock) -- if pd.wg != 0 && pd.wg != pdReady { -+ wg := atomic.Loaduintptr(&pd.wg) -+ if wg != 0 && wg != pdReady { - throw("runtime: blocked write on free polldesc") - } -- if pd.rg != 0 && pd.rg != pdReady { -+ rg := atomic.Loaduintptr(&pd.rg) -+ if rg != 0 && rg != pdReady { - throw("runtime: blocked read on free polldesc") - } - pd.fd = fd - pd.closing = false - pd.everr = false - pd.rseq++ -- pd.rg = 0 -+ atomic.Storeuintptr(&pd.rg, 0) - pd.rd = 0 - pd.wseq++ -- pd.wg = 0 -+ atomic.Storeuintptr(&pd.wg, 0) - pd.wd = 0 - pd.self = pd - unlock(&pd.lock) -@@ -171,10 +174,12 @@ func poll_runtime_pollClose(pd *pollDesc) { - if !pd.closing { - throw("runtime: close polldesc w/o unblock") - } -- if pd.wg != 0 && pd.wg != pdReady { -+ wg := atomic.Loaduintptr(&pd.wg) -+ if wg != 0 && wg != pdReady { - throw("runtime: blocked write on closing polldesc") - } -- if pd.rg != 0 && pd.rg != pdReady { -+ rg := atomic.Loaduintptr(&pd.rg) -+ if rg != 0 && rg != pdReady { - throw("runtime: blocked read on closing polldesc") - } - netpollclose(pd.fd) -@@ -198,9 +203,9 @@ func poll_runtime_pollReset(pd *pollDesc, mode int) int { - return errcode - } - if mode == 'r' { -- pd.rg = 0 -+ atomic.Storeuintptr(&pd.rg, 0) - } else if mode == 'w' { -- pd.wg = 0 -+ atomic.Storeuintptr(&pd.wg, 0) - } - return pollNoError - } -@@ -410,6 +415,8 @@ func netpollgoready(gp *g, traceskip int) { - - // returns true if IO is ready, or false if timedout or closed - // waitio - wait only for completed IO, ignore errors -+// Concurrent calls to netpollblock in the same mode are forbidden, as pollDesc -+// can hold only a single waiting goroutine for each mode. - func netpollblock(pd *pollDesc, mode int32, waitio bool) bool { - gpp := &pd.rg - if mode == 'w' { -@@ -418,17 +425,19 @@ func netpollblock(pd *pollDesc, mode int32, waitio bool) bool { - - // set the gpp semaphore to pdWait - for { -- old := *gpp -- if old == pdReady { -- *gpp = 0 -+ // Consume notification if already ready. -+ if atomic.Casuintptr(gpp, pdReady, 0) { - return true - } -- if old != 0 { -- throw("runtime: double wait") -- } - if atomic.Casuintptr(gpp, 0, pdWait) { - break - } -+ -+ // Double check that this isn't corrupt; otherwise we'd loop -+ // forever. -+ if v := atomic.Loaduintptr(gpp); v != pdReady && v != 0 { -+ throw("runtime: double wait") -+ } - } - - // need to recheck error states after setting gpp to pdWait -@@ -452,7 +461,7 @@ func netpollunblock(pd *pollDesc, mode int32, ioready bool) *g { - } - - for { -- old := *gpp -+ old := atomic.Loaduintptr(gpp) - if old == pdReady { - return nil - } --- -2.30.2 - diff --git a/0082-net-url-reject-query-values-with-semicolons.patch b/0082-net-url-reject-query-values-with-semicolons.patch deleted file mode 100644 index 5916a555f466a5f6072443552f27b8df68c4e1b6..0000000000000000000000000000000000000000 --- a/0082-net-url-reject-query-values-with-semicolons.patch +++ /dev/null @@ -1,348 +0,0 @@ -From 5149d86130fc0a57856f2dede41f0c3f14214ec3 Mon Sep 17 00:00:00 2001 -From: Katie Hockman -Date: Mon, 7 Jun 2021 14:29:43 -0400 -Subject: [PATCH] net/url: reject query values with semicolons - -Semicolons are no longer valid separators, so -net/url.ParseQuery will now return an error -if any part of the query contains a semicolon. - -net/http.(*Request).ParseMultipartForm has been -changed to fall through and continue parsing -even if the call to (*Request).ParseForm fails. - -This change also includes a few minor refactors -to existing tests. - -Fixes #25192 - -Change-Id: Iba3f108950fb99b9288e402c41fe71ca3a2ababd -Reviewed-on: https://go-review.googlesource.com/c/go/+/325697 -Trust: Katie Hockman -Run-TryBot: Katie Hockman -TryBot-Result: Go Bot -Reviewed-by: Filippo Valsorda ---- - src/net/http/request.go | 12 ++-- - src/net/http/request_test.go | 31 +++++++++- - src/net/http/server.go | 5 ++ - src/net/url/example_test.go | 4 +- - src/net/url/url.go | 13 ++-- - src/net/url/url_test.go | 116 +++++++++++++++++++++++++++-------- - 6 files changed, 145 insertions(+), 36 deletions(-) - -diff --git a/src/net/http/request.go b/src/net/http/request.go -index 54ec1c5593..bc28db95e3 100644 ---- a/src/net/http/request.go -+++ b/src/net/http/request.go -@@ -1273,16 +1273,18 @@ func (r *Request) ParseForm() error { - // its file parts are stored in memory, with the remainder stored on - // disk in temporary files. - // ParseMultipartForm calls ParseForm if necessary. -+// If ParseForm returns an error, ParseMultipartForm returns it but also -+// continues parsing the request body. - // After one call to ParseMultipartForm, subsequent calls have no effect. - func (r *Request) ParseMultipartForm(maxMemory int64) error { - if r.MultipartForm == multipartByReader { - return errors.New("http: multipart handled by MultipartReader") - } -+ var parseFormErr error - if r.Form == nil { -- err := r.ParseForm() -- if err != nil { -- return err -- } -+ // Let errors in ParseForm fall through, and just -+ // return it at the end. -+ parseFormErr = r.ParseForm() - } - if r.MultipartForm != nil { - return nil -@@ -1309,7 +1311,7 @@ func (r *Request) ParseMultipartForm(maxMemory int64) error { - - r.MultipartForm = f - -- return nil -+ return parseFormErr - } - - // FormValue returns the first value for the named component of the query. -diff --git a/src/net/http/request_test.go b/src/net/http/request_test.go -index 461d66e05d..72316c4e21 100644 ---- a/src/net/http/request_test.go -+++ b/src/net/http/request_test.go -@@ -32,9 +32,26 @@ func TestQuery(t *testing.T) { - } - } - -+// Issue #25192: Test that ParseForm fails but still parses the form when an URL -+// containing a semicolon is provided. -+func TestParseFormSemicolonSeparator(t *testing.T) { -+ for _, method := range []string{"POST", "PATCH", "PUT", "GET"} { -+ req, _ := NewRequest(method, "http://www.google.com/search?q=foo;q=bar&a=1", -+ strings.NewReader("q")) -+ err := req.ParseForm() -+ if err == nil { -+ t.Fatalf(`for method %s, ParseForm expected an error, got success`, method) -+ } -+ wantForm := url.Values{"a": []string{"1"}} -+ if !reflect.DeepEqual(req.Form, wantForm) { -+ t.Fatalf("for method %s, ParseForm expected req.Form = %v, want %v", method, req.Form, wantForm) -+ } -+ } -+} -+ - func TestParseFormQuery(t *testing.T) { - req, _ := NewRequest("POST", "http://www.google.com/search?q=foo&q=bar&both=x&prio=1&orphan=nope&empty=not", -- strings.NewReader("z=post&both=y&prio=2&=nokey&orphan;empty=&")) -+ strings.NewReader("z=post&both=y&prio=2&=nokey&orphan&empty=&")) - req.Header.Set("Content-Type", "application/x-www-form-urlencoded; param=value") - - if q := req.FormValue("q"); q != "foo" { -@@ -298,6 +315,18 @@ func TestMultipartRequest(t *testing.T) { - validateTestMultipartContents(t, req, false) - } - -+// Issue #25192: Test that ParseMultipartForm fails but still parses the -+// multi-part form when an URL containing a semicolon is provided. -+func TestParseMultipartFormSemicolonSeparator(t *testing.T) { -+ req := newTestMultipartRequest(t) -+ req.URL = &url.URL{RawQuery: "q=foo;q=bar"} -+ if err := req.ParseMultipartForm(25); err == nil { -+ t.Fatal("ParseMultipartForm expected error due to invalid semicolon, got nil") -+ } -+ defer req.MultipartForm.RemoveAll() -+ validateTestMultipartContents(t, req, false) -+} -+ - func TestMultipartRequestAuto(t *testing.T) { - // Test that FormValue and FormFile automatically invoke - // ParseMultipartForm and return the right values. -diff --git a/src/net/http/server.go b/src/net/http/server.go -index 6948ff4dd0..d0c82a183c 100644 ---- a/src/net/http/server.go -+++ b/src/net/http/server.go -@@ -2857,6 +2857,11 @@ func (sh serverHandler) ServeHTTP(rw ResponseWriter, req *Request) { - handler = globalOptionsHandler{} - } - handler.ServeHTTP(rw, req) -+ if req.URL != nil && strings.Contains(req.URL.RawQuery, ";") { -+ // TODO(filippo): update this not to log if the special -+ // semicolon handler was called. -+ sh.srv.logf("http: URL query contains semicolon, which is no longer a supported separator; parts of the query may be stripped when parsed; see golang.org/issue/25192") -+ } - } - - // ListenAndServe listens on the TCP network address srv.Addr and then -diff --git a/src/net/url/example_test.go b/src/net/url/example_test.go -index cb9e8922a2..476132a1c9 100644 ---- a/src/net/url/example_test.go -+++ b/src/net/url/example_test.go -@@ -72,13 +72,13 @@ func ExampleURL_ResolveReference() { - } - - func ExampleParseQuery() { -- m, err := url.ParseQuery(`x=1&y=2&y=3;z`) -+ m, err := url.ParseQuery(`x=1&y=2&y=3`) - if err != nil { - log.Fatal(err) - } - fmt.Println(toJSON(m)) - // Output: -- // {"x":["1"], "y":["2", "3"], "z":[""]} -+ // {"x":["1"], "y":["2", "3"]} - } - - func ExampleURL_EscapedPath() { -diff --git a/src/net/url/url.go b/src/net/url/url.go -index c93def0bd7..413236f843 100644 ---- a/src/net/url/url.go -+++ b/src/net/url/url.go -@@ -915,9 +915,10 @@ func (v Values) Del(key string) { - // valid query parameters found; err describes the first decoding error - // encountered, if any. - // --// Query is expected to be a list of key=value settings separated by --// ampersands or semicolons. A setting without an equals sign is --// interpreted as a key set to an empty value. -+// Query is expected to be a list of key=value settings separated by ampersands. -+// A setting without an equals sign is interpreted as a key set to an empty -+// value. -+// Settings containing a non-URL-encoded semicolon are considered invalid. - func ParseQuery(query string) (Values, error) { - m := make(Values) - err := parseQuery(m, query) -@@ -927,11 +928,15 @@ func ParseQuery(query string) (Values, error) { - func parseQuery(m Values, query string) (err error) { - for query != "" { - key := query -- if i := strings.IndexAny(key, "&;"); i >= 0 { -+ if i := strings.IndexAny(key, "&"); i >= 0 { - key, query = key[:i], key[i+1:] - } else { - query = "" - } -+ if strings.Contains(key, ";") { -+ err = fmt.Errorf("invalid semicolon separator in query") -+ continue -+ } - if key == "" { - continue - } -diff --git a/src/net/url/url_test.go b/src/net/url/url_test.go -index 92b15afad4..8a4dd934a2 100644 ---- a/src/net/url/url_test.go -+++ b/src/net/url/url_test.go -@@ -1314,57 +1314,125 @@ func TestQueryValues(t *testing.T) { - type parseTest struct { - query string - out Values -+ ok bool - } - - var parseTests = []parseTest{ -+ { -+ query: "a=1", -+ out: Values{"a": []string{"1"}}, -+ ok: true, -+ }, - { - query: "a=1&b=2", - out: Values{"a": []string{"1"}, "b": []string{"2"}}, -+ ok: true, - }, - { - query: "a=1&a=2&a=banana", - out: Values{"a": []string{"1", "2", "banana"}}, -+ ok: true, - }, - { - query: "ascii=%3Ckey%3A+0x90%3E", - out: Values{"ascii": []string{""}}, -+ ok: true, -+ }, { -+ query: "a=1;b=2", -+ out: Values{}, -+ ok: false, -+ }, { -+ query: "a;b=1", -+ out: Values{}, -+ ok: false, -+ }, { -+ query: "a=%3B", // hex encoding for semicolon -+ out: Values{"a": []string{";"}}, -+ ok: true, - }, - { -- query: "a=1;b=2", -- out: Values{"a": []string{"1"}, "b": []string{"2"}}, -+ query: "a%3Bb=1", -+ out: Values{"a;b": []string{"1"}}, -+ ok: true, - }, - { - query: "a=1&a=2;a=banana", -- out: Values{"a": []string{"1", "2", "banana"}}, -+ out: Values{"a": []string{"1"}}, -+ ok: false, -+ }, -+ { -+ query: "a;b&c=1", -+ out: Values{"c": []string{"1"}}, -+ ok: false, -+ }, -+ { -+ query: "a=1&b=2;a=3&c=4", -+ out: Values{"a": []string{"1"}, "c": []string{"4"}}, -+ ok: false, -+ }, -+ { -+ query: "a=1&b=2;c=3", -+ out: Values{"a": []string{"1"}}, -+ ok: false, -+ }, -+ { -+ query: ";", -+ out: Values{}, -+ ok: false, -+ }, -+ { -+ query: "a=1;", -+ out: Values{}, -+ ok: false, -+ }, -+ { -+ query: "a=1&;", -+ out: Values{"a": []string{"1"}}, -+ ok: false, -+ }, -+ { -+ query: ";a=1&b=2", -+ out: Values{"b": []string{"2"}}, -+ ok: false, -+ }, -+ { -+ query: "a=1&b=2;", -+ out: Values{"a": []string{"1"}}, -+ ok: false, - }, - } - - func TestParseQuery(t *testing.T) { -- for i, test := range parseTests { -- form, err := ParseQuery(test.query) -- if err != nil { -- t.Errorf("test %d: Unexpected error: %v", i, err) -- continue -- } -- if len(form) != len(test.out) { -- t.Errorf("test %d: len(form) = %d, want %d", i, len(form), len(test.out)) -- } -- for k, evs := range test.out { -- vs, ok := form[k] -- if !ok { -- t.Errorf("test %d: Missing key %q", i, k) -- continue -+ for _, test := range parseTests { -+ t.Run(test.query, func(t *testing.T) { -+ form, err := ParseQuery(test.query) -+ if test.ok != (err == nil) { -+ want := "" -+ if test.ok { -+ want = "" -+ } -+ t.Errorf("Unexpected error: %v, want %v", err, want) - } -- if len(vs) != len(evs) { -- t.Errorf("test %d: len(form[%q]) = %d, want %d", i, k, len(vs), len(evs)) -- continue -+ if len(form) != len(test.out) { -+ t.Errorf("len(form) = %d, want %d", len(form), len(test.out)) - } -- for j, ev := range evs { -- if v := vs[j]; v != ev { -- t.Errorf("test %d: form[%q][%d] = %q, want %q", i, k, j, v, ev) -+ for k, evs := range test.out { -+ vs, ok := form[k] -+ if !ok { -+ t.Errorf("Missing key %q", k) -+ continue -+ } -+ if len(vs) != len(evs) { -+ t.Errorf("len(form[%q]) = %d, want %d", k, len(vs), len(evs)) -+ continue -+ } -+ for j, ev := range evs { -+ if v := vs[j]; v != ev { -+ t.Errorf("form[%q][%d] = %q, want %q", k, j, v, ev) -+ } - } - } -- } -+ }) - } - } - --- -2.33.0 - diff --git a/go1.15.7.src.tar.gz b/go1.17.3.src.tar.gz similarity index 68% rename from go1.15.7.src.tar.gz rename to go1.17.3.src.tar.gz index aff1b44d465236814ec342f27071a13e894398a8..44c4f49fb37bd15237686ef83e5a0741e0e406df 100644 Binary files a/go1.15.7.src.tar.gz and b/go1.17.3.src.tar.gz differ diff --git a/golang.spec b/golang.spec index 9462f8a14cd79a9c1cb8beca2c6dedd9f8809bc3..5de473a9ca164daba52a28303abaffbb84a42224 100644 --- a/golang.spec +++ b/golang.spec @@ -2,28 +2,29 @@ %global _binaries_in_noarch_packages_terminate_build 0 %global golibdir %{_libdir}/golang %global goroot /usr/lib/%{name} -%global go_api 1.15 -%global go_version 1.15 +%global go_api 1.17 +%global go_version 1.17 %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 +%global vendor %{?_vendor:%{_vendor}}%{!?_vendor:openEuler} %define _use_internal_dependency_generator 0 %define __find_requires %{nil} %bcond_with bootstrap -%ifarch x86_64 aarch64 +%ifarch x86_64 aarch64 riscv64 %bcond_without ignore_tests %else %bcond_with ignore_tests %endif -%ifarch x86_64 aarch64 +%ifarch x86_64 aarch64 riscv64 %global external_linker 1 %else %global external_linker 0 %endif -%ifarch x86_64 aarch64 +%ifarch x86_64 aarch64 riscv64 %global cgo_enabled 1 %else %global cgo_enabled 0 @@ -55,14 +56,18 @@ %ifarch aarch64 %global gohostarch arm64 %endif +%ifarch riscv64 +%global gohostarch riscv64 +%endif + Name: golang -Version: 1.15.7 -Release: 22 +Version: 1.17.3 +Release: 13 Summary: The Go Programming Language License: BSD and Public Domain URL: https://golang.org/ -Source0: https://dl.google.com/go/go%{version}.src.tar.gz +Source0: https://dl.google.com/go/go1.17.3.src.tar.gz %if !%{golang_bootstrap} BuildRequires: gcc-go >= 5 @@ -87,7 +92,7 @@ Obsoletes: %{name}-cover < 0-12.1 Requires(post): %{_sbindir}/update-alternatives Requires(postun): %{_sbindir}/update-alternatives -Requires: glibc gcc git subversion +Recommends: glibc gcc git subversion # generated by: @@ -143,92 +148,35 @@ Obsoletes: %{name}-docs Obsoletes: %{name}-data < 1.1.1-4 Obsoletes: %{name}-vim < 1.4 Obsoletes: emacs-%{name} < 1.4 -Requires: openEuler-rpm-config +Requires: %{vendor}-rpm-config + +Patch6001: 0001-release-branch.go1.17-crypto-elliptic-tolerate-zero-.patch +Patch6002: 0002-release-branch.go1.17-encoding-pem-fix-stack-overflo.patch +Patch6003: 0003-release-branch.go1.17-syscall-fix-ForkLock-spurious-.patch +Patch6004: 0004-backport-cmd-link-mark-unexported-methods-for-plugins.patch +Patch6005: 0005-release-branch.go1.17-net-http-preserve-nil-values-i.patch +Patch6006: 0006-release-branch.go1.17-go-parser-limit-recursion-dept.patch +Patch6007: 0007-release-branch.go1.17-net-http-don-t-strip-whitespac.patch +Patch6008: 0008-release-branch.go1.17-encoding-xml-limit-depth-of-ne.patch +Patch6009: 0009-release-branch.go1.17-encoding-gob-add-a-depth-limit.patch +Patch6010: 0010-release-branch.go1.17-io-fs-fix-stack-exhaustion-in-.patch +Patch6011: 0011-release-branch.go1.17-path-filepath-fix-stack-exhaus.patch +Patch6012: 0012-release-branch.go1.17-encoding-xml-use-iterative-Ski.patch +Patch6013: 0013-release-branch.go1.17-compress-gzip-fix-stack-exhaus.patch +Patch6014: 0014-release-branch.go1.17-crypto-tls-randomly-generate-t.patch +Patch6015: 0015-release-branch.go1.17-crypto-rand-properly-handle-la.patch +Patch6016: 0016-release-branch.go1.17-math-big-check-buffer-lengths-.patch +Patch6017: 0017-path-filepath-do-not-remove-prefix-.-when-following-.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 +Patch6020: 0020-release-branch.go1.18-regexp-limit-size-of-parsed-re.patch +Patch6021: 0021-release-branch.go1.18-net-http-httputil-avoid-query-.patch +Patch6022: 0022-release-branch.go1.18-archive-tar-limit-size-of-head.patch +Patch6023: 0023-syscall-os-exec-reject-environment-variables-contain.patch +Patch6024: 0024-release-branch.go1.18-add-definition-byte-string-cut.patch ExclusiveArch: %{golang_arches} -Patch6001: 0001-release-branch.go1.15-doc-go1.15-mention-1.15.3-cgo-.patch -Patch6002: 0002-release-branch.go1.15-cmd-go-fix-mod_get_fallback-te.patch -Patch6003: 0003-release-branch.go1.15-internal-execabs-only-run-test.patch -Patch6004: 0004-release-branch.go1.15-cmd-compile-don-t-short-circui.patch -Patch6005: 0005-release-branch.go1.15-cmd-go-fix-get_update_unknown_.patch -Patch6006: 0006-release-branch.go1.15-net-http-update-bundled-x-net-.patch -Patch6007: 0007-release-branch.go1.15-cmd-go-don-t-lookup-the-path-f.patch -Patch6008: 0008-release-branch.go1.15-cmd-link-internal-ld-pe-fix-se.patch -Patch6009: 0009-release-branch.go1.15-cmd-internal-goobj2-fix-buglet.patch -Patch6010: 0010-release-branch.go1.15-runtime-don-t-adjust-timer-pp-.patch -Patch6011: 0011-release-branch.go1.15-runtime-cgo-fix-Android-build-.patch -Patch6013: 0013-release-branch.go1.15-internal-poll-if-copy_file_ran.patch -Patch6014: 0014-release-branch.go1.15-internal-poll-netpollcheckerr-.patch -Patch6015: 0015-release-branch.go1.15-cmd-compile-do-not-assume-TST-.patch -Patch6016: 0016-release-branch.go1.15-syscall-do-not-overflow-key-me.patch -Patch6017: 0017-release-branch.go1.15-time-correct-unusual-extension.patch -Patch6018: 0018-release-branch.go1.15-cmd-compile-fix-escape-analysi.patch -Patch6019: 0019-release-branch.go1.15-net-http-ignore-connection-clo.patch -Patch6020: 0020-release-branch.go1.15-net-http-add-connections-back-.patch -Patch6021: 0021-release-branch.go1.15-security-encoding-xml-prevent-.patch -Patch6023: 0023-release-branch.go1.15-cmd-go-don-t-report-missing-st.patch -Patch6025: 0025-release-branch.go1.15-cmd-go-internal-modfetch-detec.patch -Patch6026: 0026-release-branch.go1.15-cmd-link-generate-trampoline-f.patch -Patch6027: 0027-release-branch.go1.15-net-http-update-bundled-x-net-.patch -Patch6028: 0028-release-branch.go1.15-net-http-fix-detection-of-Roun.patch -Patch6029: 0029-release-branch.go1.15-build-set-GOPATH-consistently-.patch -Patch6030: 0030-release-branch.go1.15-database-sql-fix-tx-stmt-deadl.patch -Patch6031: 0031-release-branch.go1.15-cmd-compile-disable-shortcircu.patch -Patch6032: 0032-release-branch.go1.15-runtime-non-strict-InlTreeInde.patch -Patch6033: 0033-release-branch.go1.15-cmd-cgo-avoid-exporting-all-sy.patch -Patch6034: 0034-release-branch.go1.15-cmd-link-avoid-exporting-all-s.patch -Patch6035: 0035-release-branch.go1.15-cmd-cgo-remove-unnecessary-spa.patch -Patch6037: 0037-release-branch.go1.15-time-use-offset-and-isDST-when.patch -Patch6038: 0038-release-branch.go1.15-std-update-golang.org-x-net-to.patch -Patch6039: 0039-release-branch.go1.15-runtime-time-disable-preemptio.patch -Patch6040: 0040-release-branch.go1.15-runtime-non-strict-InlTreeInde.patch -Patch6041: 0041-release-branch.go1.15-runtime-pprof-skip-tests-for-A.patch -Patch6043: 0043-release-branch.go1.15-math-big-fix-TestShiftOverlap-.patch -Patch6044: 0044-release-branch.go1.15-math-big-remove-the-s390x-asse.patch -Patch6045: 0045-net-http-fix-hijack-hang-at-abortPendingRead.patch -Patch6046: 0046-release-branch.go1.15-net-verify-results-from-Lookup.patch -Patch6047: 0047-release-branch.go1.15-archive-zip-only-preallocate-F.patch -Patch6048: 0048-release-branch.go1.15-net-http-httputil-always-remov.patch -Patch6049: 0049-release-branch.go1.15-math-big-check-for-excessive-e.patch -Patch6050: 0050-release-branch.go1.15-crypto-tls-test-key-type-when-.patch -Patch6051: 0051-net-reject-leading-zeros-in-IP-address-parsers.patch -Patch6052: 0052-release-branch.go1.16-misc-wasm-cmd-link-do-not-let-.patch -Patch6053: 0053-net-http-httputil-close-incoming-ReverseProxy-reques.patch -Patch6054: 0054-release-branch.go1.16-net-http-update-bundled-golang.patch -Patch6055: 0055-release-branch.go1.16-archive-zip-prevent-preallocat.patch -Patch6056: 0056-release-branch.go1.16-debug-macho-fail-on-invalid-dy.patch -Patch6057: 0057-release-branch.go1.16-math-big-prevent-overflow-in-R.patch -Patch6058: 0058-release-branch.go1.16-crypto-elliptic-make-IsOnCurve.patch -Patch6059: 0059-release-branch.go1.16-regexp-syntax-reject-very-deep.patch -Patch6060: 0060-cmd-go-internal-modfetch-do-not-short-circuit-canoni.patch -Patch6061: 0061-release-branch.go1.17-crypto-elliptic-tolerate-zero-.patch -Patch6062: 0062-release-branch.go1.17-encoding-pem-fix-stack-overflo.patch -Patch6063: 0063-release-branch.go1.16-syscall-fix-ForkLock-spurious-.patch -Patch6064: 0064-release-branch.go1.17-net-http-preserve-nil-values-i.patch -Patch6065: 0065-release-branch.go1.17-go-parser-limit-recursion-dept.patch -Patch6066: 0066-release-branch.go1.17-net-http-don-t-strip-whitespac.patch -Patch6067: 0067-release-branch.go1.17-encoding-xml-limit-depth-of-ne.patch -Patch6068: 0068-release-branch.go1.17-encoding-gob-add-a-depth-limit.patch -Patch6069: 0069-release-branch.go1.17-path-filepath-fix-stack-exhaus.patch -Patch6070: 0070-release-branch.go1.17-encoding-xml-use-iterative-Ski.patch -Patch6071: 0071-release-branch.go1.17-compress-gzip-fix-stack-exhaus.patch -Patch6072: 0072-release-branch.go1.17-crypto-tls-randomly-generate-t.patch -Patch6073: 0073-release-branch.go1.17-crypto-rand-properly-handle-la.patch -Patch6074: 0074-release-branch.go1.17-math-big-check-buffer-lengths-.patch -Patch6075: 0075-path-filepath-do-not-remove-prefix-.-when-following-.patch -Patch6076: 0076-release-branch.go1.17-syscall-check-correct-group-in.patch -Patch6077: 0077-release-branch.go1.16-runtime-consistently-access-po.patch -Patch6078: 0078-release-branch.go1.18-net-http-update-bundled-golang.patch -Patch6079: 0079-release-branch.go1.18-regexp-limit-size-of-parsed-re.patch -Patch6080: 0080-release-branch.go1.18-net-http-httputil-avoid-query-.patch -Patch6081: 0081-release-branch.go1.18-archive-tar-limit-size-of-head.patch -Patch6082: 0082-net-url-reject-query-values-with-semicolons.patch -Patch6083: 0083-syscall-os-exec-reject-environment-variables-contain.patch - -Patch9001: 0001-drop-hard-code-cert.patch -Patch9002: 0002-fix-patch-cmd-go-internal-modfetch-do-not-sho.patch - %description %{summary}. @@ -323,7 +271,7 @@ rm -rf pkg/obj/go-build/* mkdir -p %{buildroot}%{_bindir} mkdir -p %{buildroot}%{goroot} -cp -apv api bin doc favicon.ico lib pkg robots.txt src misc test VERSION \ +cp -apv api bin doc lib pkg src misc test VERSION \ %{buildroot}%{goroot} # bz1099206 @@ -464,113 +412,79 @@ fi %files devel -f go-tests.list -f go-misc.list -f go-src.list %changelog -* Thu Nov 17 2022 hanchao - 1.15.7-22 +* Sat Dec 17 2022 wanglimin - 1.17.3-13 +- Add string cut + +* Fri Oct 11 2022 hanchao - 1.17.3-12 - Type:CVE - CVE:CVE-2022-41716 - SUG:NA -- DESC:fix CVE-2022-41716 +- DESC: remove hard code and strong dependency of git, subversion and mercurial -* Mon Oct 10 2022 hanchao - 1.15.7-21 +* Fri Oct 11 2022 hanchao - 1.17.3-11 - Type:CVE -- CVE:CVE-2022-41715,CVE-2022-2880,CVE-2022-2879 +- CVE:CVE-2022-41716 - SUG:NA -- DESC:fix CVE-2022-41715,CVE-2022-2880,CVE-2022-2879 +- DESC: fix CVE-2022-41716 -* Wed Oct 05 2022 wangshuo - 1.15.7-20 -- Type:bugfix -- CVE:NA +* Mon Oct 10 2022 hanchao - 1.17.3-10 +- Type:CVE +- CVE:CVE-2022-41715,CVE-2022-2880,CVE-2022-2879 - SUG:NA -- DESC:fix bad %goroot}/lib/ macro +- DESC: fix CVE-2022-41715,CVE-2022-2880,CVE-2022-2879 -* Thu Spe 15 2022 hanchao - 1.15.7-19 +* Thu Sep 15 2022 hanchao - 1.17.3-9 - Type:CVE - CVE:CVE-2022-27664 - SUG:NA -- DESC:fix CVE-2022-27664 - -* Thu Spe 8 2022 hanchao - 1.15.7-18 -- Type:bugfix -- CVE:NA -- SUG:NA -- DESC: runtime: consistently access pollDesc r/w Gs with atomics +- DESC: fix CVE-2022-27664 -* Tue Aug 30 2022 hanchao - 1.15.7-17 +* Thu Sep 8 2022 hanchao - 1.17.3-8 - Type:bugfix - CVE:NA - SUG:NA - DESC: golang: modify the golang.spec to remove unnecessary files from golang-help package -* Tue Aug 18 2022 hanchao - 1.15.7-16 -- fix CVE-2022-29804,CVE-2022-29526 +* Thu Aug 18 2022 hanchao - 1.17.3-7 +- Type:CVE +- CVE:CVE-2022-29804,CVE-2022-29526 +- SUG:NA +- DESC: fix CVE-2022-29804,CVE-2022-29526 + +* Mon Aug 8 2022 hanchao - 1.17.3-6 +- Type:CVE +- CVE:NA +- SUG:NA +- DESC: fix CVE-2022-32189 -* Mon Aug 8 2022 hanchao - 1.15.7-15 -- fix CVE-2022-32189 +* Tue Jul 26 2022 hanchao - 1.17.3-5 +- Type:CVE +- CVE:NA +- SUG:NA +- DESC: fix CVE-2022-32148,CVE-2022-1962,CVE-2022-1705,CVE-2022-30633, + CVE-2022-30635,CVE-2022-30630,CVE-2022-30632,CVE-2022-28131, + CVE-2022-30631,CVE-2022-30629,CVE-2022-30634 -* Thu Jul 26 2022 hanchao - 1.15.7-14 -- fix CVE-2022-32148,CVE-2022-1962,CVE-2022-1705,CVE-2022-30633, - CVE-2022-30635,CVE-2022-30632,CVE-2022-28131, - CVE-2022-30631,CVE-2022-30629,CVE-2022-30634 +* Tue Jun 28 2022 Bin Hu - 1.17.3-4 +- Type:bugfix +- CVE:NA +- SUG:NA +- DESC:backport patch to fix bug of golang plugin mode -* Thu May 12 2022 hanchao - 1.15.7-13 +* Fri May 6 2022 hanchao - 1.17.3-3 +- Type:CVE +- CVE:CVE-2021-44717 +- SUG:NA +- DESC:fix CVE-2021-44717 - fix CVE-2021-44717 -* Wed May 11 2022 hanchao - 1.15.7-12 +* Fri May 6 2022 hanchao - 1.17.3-2 +- Type:CVE +- CVE:CVE-2022-28327,CVE-2022-24675 +- SUG:NA +- DESC:fix CVE-2022-28327,CVE-2022-24675 - fix CVE-2022-28327 CVE-2022-24675 -* Thu Mar 24 2022 hanchao - 1.15.7-11 -- fix CVE-2022-23773 - -* Fri Mar 11 2022 hanchao - 1.15.7-10 -- fix CVE-2022-24921 - -* Fri Mar 4 2022 hanchao - 1.15.7-9 -- fix CVE-2022-23772 CVE-2022-23806 - -* Wed Mar 2 2022 hanchao - 1.15.7-8 -- fix CVE-2021-41771 - -* Tue Feb 8 2022 hanchao - 1.15.7-7 -- fix CVE-2021-39293 - -* Wed Jan 19 2022 hanchao - 1.15.7-6 -- fix CVE-2021-44716 - -* Wed Oct 27 2021 chenjiankun - 1.15.7-5 -- fix CVE-2021-33195,CVE-2021-33196,CVE-2021-33197,CVE-2021-33198,CVE-2021-34558,CVE-2021-29923,CVE-2021-38297,CVE-2021-36221 - -* Fri Jun 18 2021 chenjiankun - 1.15.7-4 -- batch synchronization - -* Fri Apr 23 2021 chenjiankun - 1.15.7-3 -- fix CVE-2021-27918 - -* Thu Apr 15 2021 lixiang - 1.15.7-2 -- speed up build progress - -* Thu Jan 28 2021 xingweizheng - 1.15.7-1 -- upgrade to 1.15.7 - -* Mon Jan 18 2021 jingrui - 1.13.15-2 -- sync cve fix - -* Tue Aug 18 2020 xiadanni - 1.13.15-1 -- upgrade to 1.13.15 - -* Tue May 12 2020 lixiang - 1.13.6 -- rename tar name and make it same with upstream - -* Tue Mar 17 2020 jingrui - 1.13.5 -- drop hard code cert - -* Mon Mar 23 2020 jingrui - 1.13.4 -- fix CVE-2020-7919 - -* Thu Feb 20 2020 openEuler Buildteam - 1.13-3.2 -- requires remove mercurial - -* Tue Dec 10 2019 jingrui - 1.13-3.1 -- upgrade to golang 1.13.3 - -* Tue Sep 03 2019 leizhongkai - 1.11-1 -- backport fix CVE-2019-9512 and CVE-2019-9514 +* Mon Nov 29 2021 chenjiankun - 1.17.3-1 +- upgrade to 1.17.3