aboutsummaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2021-11-03[release-branch.go1.17] archive/zip: don't panic on (*Reader).OpenJason7602
Previously, opening a zip with (*Reader).Open could result in a panic if the zip contained a file whose name was exclusively made up of slash characters or ".." path elements. Open could also panic if passed the empty string directly as an argument. Now, any files in the zip whose name could not be made valid for fs.FS.Open will be skipped, and no longer added to the fs.FS file list, although they are still accessible through (*Reader).File. Note that it was already the case that a file could be accessible from (*Reader).Open with a name different from the one in (*Reader).File, as the former is the cleaned name, while the latter is the original one. Finally, made the actual panic site robust as a defense-in-depth measure. Fixes CVE-2021-41772 Fixes #48252 Updates #48085 Co-authored-by: Filippo Valsorda <filippo@golang.org> Change-Id: I6271a3f2892e7746f52e213b8eba9a1bba974678 Reviewed-on: https://go-review.googlesource.com/c/go/+/349770 Run-TryBot: Filippo Valsorda <filippo@golang.org> Reviewed-by: Katie Hockman <katie@golang.org> Reviewed-by: Filippo Valsorda <filippo@golang.org> Trust: Katie Hockman <katie@golang.org> Trust: Julie Qiu <julie@golang.org> (cherry picked from commit b24687394b55a93449e2be4e6892ead58ea9a10f) Reviewed-on: https://go-review.googlesource.com/c/go/+/360859 Trust: Dmitri Shuralyov <dmitshur@golang.org> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Go Bot <gobot@golang.org>
2021-11-01[release-branch.go1.17] net/http: update bundled golang.org/x/net/http2Dmitri Shuralyov
Pull in approved backports to golang.org/x/net/http2: 95aca89 set ContentLength to -1 for HEAD response with no Content-Length bd5b1b8 set Response.ContentLength to 0 when headers end stream 27001ec don't abort half-closed streams on server connection close f0a8156 on write errors, close ClientConn before returning from RoundTrip 9a182eb deflake TestTransportReqBodyAfterResponse_200 821db7b close the Request's Body when aborting a stream 028e125 return unexpected eof on empty response with non-zero content length 5388f2f don't rely on system TCP buffer sizes in TestServer_MaxQueuedControlFrames fc298ce detect write-blocked PING frames e96ad84 avoid race in TestTransportReqBodyAfterResponse_403. 7f15435 avoid clientConnPool panic when NewClientConn fails 9572bae avoid extra GetConn trace call b04064c refactor request write flow 7e165c9 remove PingTimeout from TestTransportPingWhenReading ef976fc fix Transport connection pool TOCTOU max concurrent stream bug 1d9597c shut down idle Transport connections after protocol errors c173d09 remove check for read-after-close of request bodies 466a463 fix race in DATA frame padding refund 4028c5f avoid blocking while holding ClientConn.mu b91f72d fix off-by-one error in client check for max concurrent streams 21e6c63 close request body after early RoundTrip failures e79adf9 limit client initial MAX_CONCURRENT_STREAMS c0c2bc5 make Transport not reuse conns after a stream protocol error 14c0235 accept zero-length block fragments in HEADERS frames 0d2c43c close the request body if needed 5627bb0 reduce frameScratchBuffer caching aggressiveness c9f4fb0 also set "http/1.1" ALPN in ConfigureServer By doing: $ go get -d golang.org/x/net@internal-branch.go1.17-vendor go get: upgraded golang.org/x/net v0.0.0-20210901185426-6d2eada6345e => v0.0.0-20211101194204-95aca89e93de $ go mod tidy $ go mod vendor $ go generate -run=bundle std Fixes #49077. Fixes #48823. Fixes #48650. Change-Id: Idb972ba5313080626b60b4111d52b80197364ff4 Reviewed-on: https://go-review.googlesource.com/c/go/+/359776 Trust: Dmitri Shuralyov <dmitshur@golang.org> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Damien Neil <dneil@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-10-29[release-branch.go1.17] debug/macho: fail on invalid dynamic symbol table ↵Roland Shoemaker
command 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 #48992 Fixes CVE-2021-41771 Change-Id: Ic3d6e6529241afcc959544b326b21b663262bad5 Reviewed-on: https://go-review.googlesource.com/c/go/+/355990 Reviewed-by: Julie Qiu <julie@golang.org> Reviewed-by: Katie Hockman <katie@golang.org> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Run-TryBot: Roland Shoemaker <roland@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Trust: Katie Hockman <katie@golang.org> (cherry picked from commit 61536ec03063b4951163bd09609c86d82631fa27) Reviewed-on: https://go-review.googlesource.com/c/go/+/359455 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2021-10-28[release-branch.go1.17] cmd/go: update for //go:build linesRuss Cox
cmd/go has its own //go:build evaluator, which is needed for patterns like 'all'. The code is a modified copy of some unexported routines from the go/build package. Update it by copying those again and re-modifying them. The modifications are primarily the new func eval and also ignoring errors. This CL will need to be backported to Go 1.17, or else Go 1.17 will break when faced with certain //go:build-only repos during 'go list all' or 'go mod tidy'. For #41184. Fixes #49198. Change-Id: Ie0fe3caa8d49004935ecd76d7977f767fe50e317 Reviewed-on: https://go-review.googlesource.com/c/go/+/359355 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com> Reviewed-on: https://go-review.googlesource.com/c/go/+/359404
2021-10-28[release-branch.go1.17] cmd/link: increase reserved space for passing env on ↵Richard Musiol
wasm On wasm, the wasm_exec.js helper passes the command line arguments and environment variables via a reserved space in the wasm linear memory. Increase this reserved space from 4096 to 8192 bytes so more environment variables can fit into the limit. Later, after https://golang.org/cl/350737 landed, we can switch to the WASI interface for getting the arguments and environment. This would remove the limit entirely. Updates #49011. Fixes #49154. Change-Id: I48a6e952a97d33404ed692c98e9b49c5cd6b269b Reviewed-on: https://go-review.googlesource.com/c/go/+/358194 Trust: Richard Musiol <neelance@gmail.com> Run-TryBot: Richard Musiol <neelance@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> (cherry picked from commit 252324e879e32f948d885f787decf8af06f82be9) Reviewed-on: https://go-review.googlesource.com/c/go/+/359399 Trust: Dmitri Shuralyov <dmitshur@golang.org> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
2021-10-28[release-branch.go1.17] cmd/link: disable weak reference in itab if build ↵zhouguangyuan
with "-linkshared" When build with "-linkshared", we can't tell if the interface method will be used or not. It can be used in shared library. This CL backport this fix to 1.17. Fixes #49086 Change-Id: Iba12812f199b7679cf2fd41a304268d6d6dd03c6 Reviewed-on: https://go-review.googlesource.com/c/go/+/350189 Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Alexander Rakoczy <alex@golang.org> (cherry picked from commit f687831e4cfa06d19533d47ae93c0451bd1ca688) Reviewed-on: https://go-review.googlesource.com/c/go/+/357231 Trust: Ian Lance Taylor <iant@golang.org>
2021-10-28[release-branch.go1.17] runtime: consistently access pollDesc r/w Gs with ↵Michael Pratt
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 #49010 Change-Id: I903ea667eea320277610b4f969129935731520c3 Reviewed-on: https://go-review.googlesource.com/c/go/+/355952 Trust: Michael Pratt <mpratt@google.com> Run-TryBot: Michael Pratt <mpratt@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: David Chase <drchase@google.com> (cherry picked from commit 1b072b3ed56c18619587354f499fcda5279718a2) Reviewed-on: https://go-review.googlesource.com/c/go/+/356369
2021-10-27[release-branch.go1.17] cmd/compile: ensure constant shift amounts are in ↵Keith Randall
range for arm Ensure constant shift amounts are in the range [0-31]. When shift amounts are out of range, bad things happen. Shift amounts out of range occur when lowering 64-bit shifts (we take an in-range shift s in [0-63] and calculate s-32 and 32-s, both of which might be out of [0-31]). The constant shift operations themselves still work, but their shift amounts get copied unmolested to operations like ORshiftLL which use only the low 5 bits. That changes an operation like <<100 which unconditionally produces 0, to <<4, which doesn't. Fixes #48479 Change-Id: I87363ef2b4ceaf3b2e316426064626efdfbb8ee3 Reviewed-on: https://go-review.googlesource.com/c/go/+/350969 Trust: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> (cherry picked from commit eff27e858b771bf5e0b5e7e836827c7d2941e6d4) Reviewed-on: https://go-review.googlesource.com/c/go/+/351069 Reviewed-by: Austin Clements <austin@google.com>
2021-10-27[release-branch.go1.17] cmd/compile: fix simplification rules on arm/arm64Keith Randall
Fixes #48475 Change-Id: Ic1e918f916eae223a3b530a51a58f03031924670 Reviewed-on: https://go-review.googlesource.com/c/go/+/350913 Trust: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-on: https://go-review.googlesource.com/c/go/+/351071 Reviewed-by: Austin Clements <austin@google.com>
2021-10-25[release-branch.go1.17] syscall: do not use handle lists on windows when ↵Jason A. Donenfeld
NoInheritHandles is true If NoInheritHandles is passed, then we shouldn't attempt to do anything with handle lists. Otherwise CreateProcess fails with invalid param, because it's being told both to not inherit handles and to inherit certain handles. This commit fixes that by using the same logic for handle lists as it does for enabling or disabling handle inheritance. It also adds a test to make sure this doesn't regress again. Updates #48040 Fixes #48075 Change-Id: I507261baeec263091738ab90157a991d917dc92f Reviewed-on: https://go-review.googlesource.com/c/go/+/350416 Trust: Jason A. Donenfeld <Jason@zx2c4.com> Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Patrik Nyblom <pnyb@google.com>
2021-10-07[release-branch.go1.17] misc/wasm, cmd/link: do not let command line args ↵Michael Knyszek
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 <cherryyz@google.com>. For #48797 Fixes #48800 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 <bracewell@google.com> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-on: https://go-review.googlesource.com/c/go/+/354592 Trust: Michael Knyszek <mknyszek@google.com> Reviewed-by: Heschi Kreinick <heschi@google.com>
2021-10-06[release-branch.go1.17] cmd/compile: fold handling OCONV logic to separate ↵Cuong Manh Le
function So next CL can re-use the logic to perform checkptr instrumentation. For #48561 Change-Id: I3241e9c3c84da04db71fd1d4fd83cb76b2e18521 Reviewed-on: https://go-review.googlesource.com/c/go/+/345435 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> (cherry picked from commit 8fad81cd6294776c63a3e9a5820f196949974861) Reviewed-on: https://go-review.googlesource.com/c/go/+/354352 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org>
2021-09-28[release-branch.go1.17] cmd/go: write go.mod requirements more consistently ↵Jay Conrod
for go 1.17+ If go.mod declares 1.17 or higher, when the go command rewrites go.mod (for example, after 'go mod tidy'), it will be more consistent about moving requirements in two blocks, one containing only direct requirements, and one containing only indirect requirements. The go command will not move requirements into or out of a block with comments. It may still update versions and "// indirect" comments, and it may delete unneeded requirements though. Fixes #47756 Change-Id: Ia6fb3e302be53097893abf01aa7cea60ac7b069a Reviewed-on: https://go-review.googlesource.com/c/go/+/343432 Trust: Jay Conrod <jayconrod@google.com> Run-TryBot: Jay Conrod <jayconrod@google.com> Reviewed-by: Bryan C. Mills <bcmills@google.com> (cherry picked from commit 3c764babe7b5e01a4e04b1a2c7975cdb5c5651a0) Reviewed-on: https://go-review.googlesource.com/c/go/+/351465 TryBot-Result: Go Bot <gobot@golang.org>
2021-09-23[release-branch.go1.17] text/template: initialize template before locking itIan Lance Taylor
For #39807 For #48436 Fixes #48444 Change-Id: I75f82fd8738dd2f11f0c69b1230e1be1abc36024 Reviewed-on: https://go-review.googlesource.com/c/go/+/350730 Trust: Ian Lance Taylor <iant@golang.org> Trust: Daniel Martí <mvdan@mvdan.cc> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Daniel Martí <mvdan@mvdan.cc> (cherry picked from commit ba1c52d7d77724de4407572bd02421c36df3d78a) Reviewed-on: https://go-review.googlesource.com/c/go/+/351115
2021-09-15[release-branch.go1.17] runtime: in adjustTimers back up as far as necessaryIan Lance Taylor
When the adjustTimers function removed a timer it assumed it was sufficient to continue the heap traversal at that position. However, in some cases a timer will be moved to an earlier position in the heap. If that timer is timerModifiedEarlier, that can leave timerModifiedEarliest not correctly representing the earlier such timer. Fix the problem by restarting the heap traversal at the earliest changed position. For #47762 Fixes #47859 Change-Id: I152bbe62793ee40a680baf49967bcb89b1f94764 Reviewed-on: https://go-review.googlesource.com/c/go/+/343882 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> (cherry picked from commit 2da3375e9b4980e368a8641f54cc53c4af4d1a12) Reviewed-on: https://go-review.googlesource.com/c/go/+/350001
2021-09-15[release-branch.go1.17] time: propagate "," separator for fractional seconds ↵korzhao
into Format In CL 300996 that fixed issue #6189, we made Parse recognize "," as a separator for fractional seconds. However, we didn't modify Format to propagate the separator verbatim from Parse. Without this change, we break prior functionality that relied on a comma being used in Format. For #48037 Fixes #48177 Change-Id: I6565a25e8657ca3747a58b25acba58f27cdcddc0 Reviewed-on: https://go-review.googlesource.com/c/go/+/345438 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Trust: Cherry Mui <cherryyz@google.com> (cherry picked from commit e1c3f2158fe3129fb44cc92423cfa41e7b6d472c) Reviewed-on: https://go-review.googlesource.com/c/go/+/350149 Trust: Ian Lance Taylor <iant@golang.org>
2021-09-08[release-branch.go1.17] cmd/go/internal/modload: scan dependencies of root ↵Bryan C. Mills
paths when raising version limits in editRequirements Updates #47979 Fixes #48156 Change-Id: I1d9d854cda1378e20c70e6c6789b77e42e467ca7 Reviewed-on: https://go-review.googlesource.com/c/go/+/347290 Trust: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com> (cherry picked from commit 409434d62364cb362f0f17d0c7769dc680b2da99) Reviewed-on: https://go-review.googlesource.com/c/go/+/348411
2021-09-01[release-branch.go1.17] all: update golang.org/x/net to pull in CL 346890Damien Neil
For #47692. Change-Id: I40d5a3ed245b99de5e82e336f955c60b58880cdb Reviewed-on: https://go-review.googlesource.com/c/go/+/347009 Trust: Damien Neil <dneil@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-09-01[release-branch.go1.17] go/types: don't override x.mode before using itRobert Griesemer
Changing the mode of x before using the old value is clearly wrong. And x is not needed anymore afterward so besides being misplaced, the assignment is not needed in the first place. Tested manually as it's a bit complicated to set up a test. Fixes #47854. Change-Id: I06f1fa9443eb98009b4276f566d557fd52f1d6d3 Reviewed-on: https://go-review.googlesource.com/c/go/+/343809 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> (cherry picked from commit e17439e0877d6ddb6881d9eb59758c27cc62f930) Reviewed-on: https://go-review.googlesource.com/c/go/+/347149 Run-TryBot: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Findley <rfindley@google.com> Reviewed-by: Robert Findley <rfindley@google.com> Trust: Robert Findley <rfindley@google.com> Trust: Cherry Mui <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-09-01[release-branch.go1.17] go/types: fix panic with nil package nameRob Findley
This is a straightforward port of CL 320490 to go/types. Fixes #48082 Change-Id: I763c806c777f926a563d8f9384764e5b3f7f083c Reviewed-on: https://go-review.googlesource.com/c/go/+/324732 Trust: Robert Findley <rfindley@google.com> Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org> (cherry picked from commit e32fab145b488cf8bd1fb4a2466cb9be33ac3770) Reviewed-on: https://go-review.googlesource.com/c/go/+/347071
2021-09-01[release-branch.go1.17] cmd/go: ensure 'go get -u' can upgrade pruned ↵Jay Conrod
(1.17+) modules Fixes #47857 Change-Id: I981a31ba4ff716570ac4c6f35b289fa480faa5bb Reviewed-on: https://go-review.googlesource.com/c/go/+/343879 Trust: Jay Conrod <jayconrod@google.com> Run-TryBot: Jay Conrod <jayconrod@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com> (cherry picked from commit bdc1bef8a05d4524160d56a027f110257323033d) Reviewed-on: https://go-review.googlesource.com/c/go/+/346211
2021-09-01[release-branch.go1.17] crypto/rand, internal/syscall/unix: don't use ↵Tobias Klauser
getentropy on iOS CL 302489 switched crypto/rand to use getentropy on darwin, however this function is not available on iOS. Enable getentropy only on macOS and disable it on iOS. Fixes #47814 Change-Id: Ib7ba5d77346aee87904bb93d60cacc845f5c0089 Reviewed-on: https://go-review.googlesource.com/c/go/+/343609 Trust: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> (cherry picked from commit 700743137462471189f58ee85fe64754cd340322) Reviewed-on: https://go-review.googlesource.com/c/go/+/343989
2021-09-01[release-branch.go1.17] cmd/link: do not use GO_LDSO when cross compileCherry Mui
GO_LDSO is a setting that is set when the toolchain is build. It only makes sense to use it on the host platform. Do not use it when targetting a different platform. In the past it was not a problem as GO_LDSO was almost always unset. Now, with CL 301989 it is almost always set (maybe we want to revisit it). Updates #47760. Fixes #47782. Change-Id: I2704b9968781f46e2d2f8624090db19689b1a32f Reviewed-on: https://go-review.googlesource.com/c/go/+/343010 Trust: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> (cherry picked from commit ddfcc02352feb9e15ff9aa423bb49bfb37d689a3) Reviewed-on: https://go-review.googlesource.com/c/go/+/343309
2021-09-01[release-branch.go1.17] cmd/compile: allow embed into any byte slice typeKeith Randall
Fixes #47754 Change-Id: Ia21ea9a67f36a3edfef1b299ae4f3b00c306cd68 Reviewed-on: https://go-review.googlesource.com/c/go/+/345092 Trust: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-09-01[release-branch.go1.17] cmd/compile: fix method expression lookup during importCuong Manh Le
CL 309831 fixed importing of method expressions, by re-using the same code already have for ODOTMETH. But that code does not work with embedded field. To fix this, we need to calculate all methods of the receiver base type of method expression, before looking up the selection. Fixes #48102 Change-Id: Ia244d36a3ed0f989735eb57becdfa70a81912f57 Reviewed-on: https://go-review.googlesource.com/c/go/+/346489 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-on: https://go-review.googlesource.com/c/go/+/346670 Reviewed-by: Keith Randall <khr@golang.org>
2021-09-01[release-branch.go1.17] archive/zip: prevent preallocation check from ↵Roland Shoemaker
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 #47986 Updates #47801 Fixes CVE-2021-39293 Change-Id: Ifade26b98a40f3b37398ca86bd5252d12394dd24 Reviewed-on: https://go-review.googlesource.com/c/go/+/343434 Trust: Roland Shoemaker <roland@golang.org> Run-TryBot: Roland Shoemaker <roland@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org> (cherry picked from commit bacbc33439b124ffd7392c91a5f5d96eca8c0c0b) Reviewed-on: https://go-review.googlesource.com/c/go/+/345410 Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com> Trust: Cherry Mui <cherryyz@google.com>
2021-08-15[release-branch.go1.17] sync/atomic: fix documentation for CompareAndSwapJeff Wentworth
The documentation for CompareAndSwap atomic/value incorrectly labelled the function as CompareAndSwapPointer. This PR fixes that. Updates #47699. Fixes #47703. Change-Id: I6db08fdfe166570b775248fd24550f5d28e3434e GitHub-Last-Rev: 41f78707928f48c9cdac26b6a4f618d4284e1ca1 GitHub-Pull-Request: golang/go#47700 Reviewed-on: https://go-review.googlesource.com/c/go/+/342210 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Trust: Daniel Martí <mvdan@mvdan.cc> Run-TryBot: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Go Bot <gobot@golang.org> (cherry picked from commit 0a0a160d4df488939892a1adaca6c530fb784cc8) Reviewed-on: https://go-review.googlesource.com/c/go/+/342329 Trust: Dmitri Shuralyov <dmitshur@golang.org> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-08-13[release-branch.go1.17] runtime: drop SIGPROF while in ARM < 7 kernel helpersMichael Pratt
On Linux ARMv6 and below runtime/internal/atomic.Cas calls into a kernel cas helper at a fixed address. If a SIGPROF arrives while executing the kernel helper, the sigprof lostAtomic logic will miss that we are potentially in the spinlock critical section, which could cause a deadlock when using atomics later in sigprof. For #47505 Fixes #47688 Change-Id: If8ba0d0fc47e45d4e6c68eca98fac4c6ed4e43c1 Reviewed-on: https://go-review.googlesource.com/c/go/+/341889 Trust: Michael Pratt <mpratt@google.com> Run-TryBot: Michael Pratt <mpratt@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> (cherry picked from commit 20a620fd9f7bc35739c1af3602d53808d0430814) Reviewed-on: https://go-review.googlesource.com/c/go/+/341890
2021-08-13[release-branch.go1.17] time: fix docs for new comma layoutsRuss Cox
The current text is slightly inaccurate. Make it more correct. Change-Id: Iebe0051b74649d13982d7eefe3697f9e69c9b75d Reviewed-on: https://go-review.googlesource.com/c/go/+/340449 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-on: https://go-review.googlesource.com/c/go/+/341949 Trust: Dmitri Shuralyov <dmitshur@golang.org> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
2021-08-12os/exec: re-enable LookPathTest/16Dmitri Shuralyov
This failure was confirmed to be due to a bug in prerelease versions of Windows, and has been fixed by now. Remove the skip for this test. Fixes #44379. Change-Id: Idfb92ffd6b9d416d4c78ef3800a5ffdda06c6562 Reviewed-on: https://go-review.googlesource.com/c/go/+/341455 Trust: Dmitri Shuralyov <dmitshur@golang.org> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-08-11src/make.*: make --no-clean flag a no-op that prints a warningMatthew Dempsky
This flag is undocumented and is no longer useful. Users who want to install additional toolchains without cleaning the installed packages should just use `go install`. This CL changes cmd/dist to print a warning that --no-clean is deprecated and to advise users to use `go install std cmd` instead, and then otherwise ignores it: ``` $ ./make.bash --no-clean Building Go cmd/dist using $GOROOT_BOOTSTRAP. (devel +b7a85e0003 linux/amd64) warning: --no-clean is deprecated and has no effect; use 'go install std cmd' instead Building Go toolchain1 using $GOROOT_BOOTSTRAP. ``` Fixes #47204. Change-Id: I275031832098401a49e491e324e8de3427973630 Reviewed-on: https://go-review.googlesource.com/c/go/+/341392 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-08-10doc: use "high address/low address" instead of "top/bottom"fanzha02
The current document uses the "top" and "bottom" when talking about the address within a frame, which may easily lead to misunderstandings. This patch directly uses "high address" and "low address" to make the expression clearer. Change-Id: I7469330bbdc158672d7f0314fe6680ebdd9ab79a Reviewed-on: https://go-review.googlesource.com/c/go/+/339369 Trust: fannie zhang <Fannie.Zhang@arm.com> Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-08-09cmd/go: with -mod=vendor, don't panic if there are duplicate requirementsJay Conrod
In loadModFile with -mod=vendor, load the vendor list and use it to initialize the module graph before calling updateRoots. In updateLazyRoots with any mode other than "mod", return the original *Requirements if no roots needed to be upgraded, even if there are inconsistencies. This means 'go list -m -mod=readonly' and -mod=vendor may succeed if there are duplicate requirements or requirements on versions of the main module. Fixes #47565 Change-Id: I4640dffc4a7359367cc910da0d29e3538bfd1ca4 Reviewed-on: https://go-review.googlesource.com/c/go/+/340252 Trust: Jay Conrod <jayconrod@google.com> Trust: Bryan C. Mills <bcmills@google.com> Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-08-09runtime/cgo: when using msan explicitly unpoison cgoCallersIan Lance Taylor
This avoids an incorrect msan uninitialized memory report when using runtime.SetCgoTraceback when a signal occurs while the fifth argument register is undefined. See the issue for more details. Fixes #47543 Change-Id: I3d1b673e2c93471ccdae0171a99b88b5a6062840 Reviewed-on: https://go-review.googlesource.com/c/go/+/339902 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
2021-08-06make.bash: do not overwrite GO_LDSO if already setCherry Mui
Change-Id: I704bdb411bda3d8a40906c12f182e268dca4718f Reviewed-on: https://go-review.googlesource.com/c/go/+/340450 Trust: Cherry Mui <cherryyz@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org>
2021-08-06runtime: allow arm64 SEH to be called if illegal instructionJason A. Donenfeld
DLLs built with recent Microsoft toolchains for ARM64 test for ARMv8.1 atomics by potentially calling an illegal instruction, and then trapping the exception to disable use of them by way of a structured exception handler. However, vectored exception handlers are always called before structured exception handlers. When LoadLibrary-ing DLLs that do this probing during initialization, our lastcontinuehandler winds up being called, and then crashing, but actually it should give execution back to the library to handle the exception and fix up the state. So special case this for arm64 with illegal instructions, and hope that we're not masking other things in external DLLs that might more fatally trigger an illegal instruction exception. Updates #47576. Change-Id: I341ab99cd8d513ae999b75596749d49779072022 Reviewed-on: https://go-review.googlesource.com/c/go/+/340070 Trust: Jason A. Donenfeld <Jason@zx2c4.com> Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
2021-08-05runtime: warn that KeepAlive is not an unsafe.Pointer workaroundMatthew Dempsky
Even experienced users occasionally mistake that runtime.KeepAlive can be used as a workaround for following the unsafe.Pointer safety rules, but it cannot. Add an explicit warning to this effect to dissuade users from trying to use it as such. Fixes #47562. Change-Id: I842e33a3e1c080933c6b1bd1b6318448adbf495c Reviewed-on: https://go-review.googlesource.com/c/go/+/340269 Trust: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-08-04net/http: speed up and deflake TestCancelRequestWhenSharingConnectionDamien Neil
This test made many requests over the same connection for 10 seconds, trusting that this will exercise the request cancelation race from #41600. Change the test to exhibit the specific race in a targeted fashion with only two requests. Updates #41600. Updates #47016. Change-Id: If99c9b9331ff645f6bb67fe9fb79b8aab8784710 Reviewed-on: https://go-review.googlesource.com/c/go/+/339594 Trust: Damien Neil <dneil@google.com> Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com>
2021-08-02io/fs: don't use absolute path in DirEntry.Name docIan Lance Taylor
Fixes #47485 Change-Id: I64ac00905a403b7594c706141679051a93058a31 Reviewed-on: https://go-review.googlesource.com/c/go/+/338889 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2021-07-31all: gofmtJosh Bleecher Snyder
Change-Id: Icfafcfb62a389d9fd2e7a4d17809486ed91f15c3 Reviewed-on: https://go-review.googlesource.com/c/go/+/338629 Trust: Josh Bleecher Snyder <josharian@gmail.com> Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-07-30net/http/httputil: close incoming ReverseProxy request bodyDamien Neil
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 <dneil@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Filippo Valsorda <filippo@golang.org>
2021-07-29runtime: avoid possible preemption when returning from Go to CIan Lance Taylor
When returning from Go to C, it was possible for the goroutine to be preempted after calling unlockOSThread. This could happen when there a context function installed by SetCgoTraceback set a non-zero context, leading to a defer call in cgocallbackg1. The defer function wrapper, introduced in 1.17 as part of the regabi support, was not nosplit, and hence was a potential preemption point. If it did get preempted, the G would move to a new M. It would then attempt to return to C code on a different stack, typically leading to a SIGSEGV. Fix this in a simple way by postponing the unlockOSThread until after the other defer. Also check for the failure condition and fail early, rather than waiting for a SIGSEGV. Without the fix to cgocall.go, the test case fails about 50% of the time on my laptop. Fixes #47441 Change-Id: Ib8ca13215bd36cddc2a49e86698824a29c6a68ba Reviewed-on: https://go-review.googlesource.com/c/go/+/338197 Trust: Ian Lance Taylor <iant@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-07-28cmd/go: fix go.mod file name printed in error messages for replacementsJay Conrod
This fixes a logic error introduced in CL 337850. Fixes #47444 Change-Id: I6a49c8fc71fdde4ecb7f2e3329ad1f2cd286b7eb Reviewed-on: https://go-review.googlesource.com/c/go/+/338189 Run-TryBot: Jay Conrod <jayconrod@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org> Trust: Jay Conrod <jayconrod@google.com>
2021-07-28runtime: don't crash on nil pointers in checkptrAlignmentMatthew Dempsky
Ironically, checkptrAlignment had a latent case of bad pointer arithmetic: if ptr is nil, then `add(ptr, size-1)` might produce an illegal pointer value. The fix is to simply check for nil at the top of checkptrAlignment, and short-circuit if so. This CL also adds a more explicit bounds check in checkptrStraddles, rather than relying on `add(ptr, size-1)` to wrap around. I don't think this is necessary today, but it seems prudent to be careful. Fixes #47430. Change-Id: I5c50b2f7f41415dbebbd803e1b8e7766ca95e1fd Reviewed-on: https://go-review.googlesource.com/c/go/+/338029 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
2021-07-27cmd/go: use .mod instead of .zip to determine if version has go.mod fileJay Conrod
When checking for updates, the go command checks whether the highest compatible version has a go.mod file in order to determine whether +incompatible versions may be considered "latest". Previously, to perform this check, the go command would download the content of the module (the .zip file) to see whether a go.mod file was present at the root. This is slower than necessary, and it caused 'go list -m -u' to try to save the sum for the .zip file in go.sum in some cases. With this change, the go command only downloads the .mod file and checks whether it appears to be a fake file generated for a version that didn't have a go.mod file. This is faster and requires less verification. Fake files only have a "module" directive. It's possible to commit a file that passes this test, but it would be difficult to do accidentally: Go 1.12 and later at least add a "go" directive. A false positive here would cause version queries to have slightly different results but would not affect builds. Fixes #47377 Change-Id: Ie5ffd0b45e39bd0921328a60af99a9f6e5ab6346 Reviewed-on: https://go-review.googlesource.com/c/go/+/337850 Trust: Jay Conrod <jayconrod@google.com> Run-TryBot: Jay Conrod <jayconrod@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org>
2021-07-27cmd/go: add missing flag in UsageLine180909
Change-Id: I31689dc8de1f6b95bb35578b20533c63903f7258 GitHub-Last-Rev: 5bfee0535ded703f84d45390d5a87295b6e5fe5a GitHub-Pull-Request: golang/go#47418 Reviewed-on: https://go-review.googlesource.com/c/go/+/337691 Run-TryBot: Jay Conrod <jayconrod@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com> Trust: Jay Conrod <jayconrod@google.com> Trust: Russ Cox <rsc@golang.org>
2021-07-27testing: clarify T.Name returns a distinct name of the running testChangkun Ou
According to the discussion, it is clear that T.Name returns a distinct name among all tests. However, there is no specification of how sub-tests with the same specified test name are constructed. This change only clarifies the uniqueness and the components of the name without suggesting any explicit format of the returned name. Fixes #46488 Change-Id: I6cebd419b69fb08d8646cb744a129548452042ef Reviewed-on: https://go-review.googlesource.com/c/go/+/337392 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org>
2021-07-27go/types: preserve untyped constants on the RHS of a shift expressionRob Findley
CL 291316 fixed go/types to verify that untyped shift counts are representable by uint, but as a side effect also converted their types to uint. Rearrange the logic to keep the check for representability, but not actually convert untyped integer constants. Untyped non-integer constants are still converted, to preserve the behavior of 1.16. This behavior for non-integer types is a bug, filed as #47410. Updates #47410 Fixes #47243 Change-Id: I5eab4aab35b97f932fccdee2d4a18623ee2ccad5 Reviewed-on: https://go-review.googlesource.com/c/go/+/337529 Trust: Robert Findley <rfindley@google.com> Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
2021-07-26runtime: correct variable name in commentKoichi Shiraishi
Change-Id: Ic35ec2ed320c3c266afbeec8bdea1dedac4725e4 Reviewed-on: https://go-review.googlesource.com/c/go/+/336892 Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Austin Clements <austin@google.com>
2021-07-26runtime: remove adjustTimers counterIan Lance Taylor
In CL 336432 we changed adjusttimers so that it no longer cleared timerModifiedEarliest if there were no timersModifiedEarlier timers. This caused some Google internal tests to time out, presumably due to the increased contention on timersLock. We can avoid that by simply not skipping the loop in adjusttimers, which lets us safely clear timerModifiedEarliest. And if we don't skip the loop, then there isn't much reason to keep the count of timerModifiedEarlier timers at all. So remove it. The effect will be that for programs that create some timerModifiedEarlier timers and then remove them all, the program will do an occasional additional loop over all the timers. And, programs that have some timerModifiedEarlier timers will always loop over all the timers, without the quicker exit when they have all been seen. But the loops should not occur all that often, due to timerModifiedEarliest. For #47329 Change-Id: I7b244c1244d97b169a3c7fbc8f8a8b115731ddee Reviewed-on: https://go-review.googlesource.com/c/go/+/337309 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com>