]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
2 years ago[release-branch.go1.15] go1.15.14 go1.15.14
Dmitri Shuralyov [Mon, 12 Jul 2021 18:57:25 +0000 (14:57 -0400)]
[release-branch.go1.15] go1.15.14

Change-Id: Id56b45b4911db7f659d53b8797daebe954964c34
Reviewed-on: https://go-review.googlesource.com/c/go/+/334090
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2 years ago[release-branch.go1.15] crypto/tls: test key type when casting
Roland Shoemaker [Wed, 9 Jun 2021 18:31:27 +0000 (11:31 -0700)]
[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 <valsorda@google.com>
Reviewed-by: Katie Hockman <katiehockman@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/334030
Trust: Filippo Valsorda <filippo@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2 years ago[release-branch.go1.15] net: filter bad names from Lookup functions instead of hard...
Roland Shoemaker [Fri, 2 Jul 2021 17:25:49 +0000 (10:25 -0700)]
[release-branch.go1.15] net: filter bad names from Lookup functions instead of hard failing

Instead of hard failing on a single bad record, filter the bad records
and return anything valid. This only applies to the methods which can
return multiple records, LookupMX, LookupNS, LookupSRV, and LookupAddr.

When bad results are filtered out, also return an error, indicating
that this filtering has happened.

Updates #46241
Updates #46979
Fixes #47012

Change-Id: I6493e0002beaf89f5a9795333a93605abd30d171
Reviewed-on: https://go-review.googlesource.com/c/go/+/332549
Trust: Roland Shoemaker <roland@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
(cherry picked from commit 296ddf2a936a30866303a64d49bc0e3e034730a8)
Reviewed-on: https://go-review.googlesource.com/c/go/+/333331
Run-TryBot: Roland Shoemaker <roland@golang.org>

2 years ago[release-branch.go1.15] net: don't reject null mx records
Roland Shoemaker [Wed, 30 Jun 2021 21:28:18 +0000 (14:28 -0700)]
[release-branch.go1.15] net: don't reject null mx records

Bypass hostname validity checking when a null mx record is returned as,
defined in RFC 7505.

Updates #46979
Updates #47012

Change-Id: Ibe683bd6b47333a8ff30909fb2680ec8e10696ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/332094
Trust: Roland Shoemaker <roland@golang.org>
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
(cherry picked from commit 03761ede028d811dd7d7cf8a2690d4bfa2771d85)
Reviewed-on: https://go-review.googlesource.com/c/go/+/332372
Run-TryBot: Katie Hockman <katie@golang.org>

2 years ago[release-branch.go1.15] cmd/link: fix handling of dupok mapzero syms
Than McIntosh [Wed, 9 Jun 2021 00:09:49 +0000 (20:09 -0400)]
[release-branch.go1.15] cmd/link: fix handling of dupok mapzero syms

The compiler machinery that generates "map.zero" symbols marks them as
RODATA and DUPOK, which is problematic when a given application has
multiple map zero symbols (from different packages) with varying
sizes: the dupok path in the loader assumes that if two symbols have
the same name, it is safe to pick any of the versions. In the case of
map.zero, the link needs to select the largest symbol, not an
arbitrary sym.

This patch changes the linker's dupok symbol loading path to detect
this problem, and in situations where we're loading a dupok symbol
whose name is the same as an existing symbol but whose size is large,
select the new dup over the old. Note: this fix differs from the one
used in 1.16/1.17, which uses content-addressable symbols instead.

Fixes #46656.

Change-Id: Iabd2feef01d448670ba795c7eaddc48c191ea276
Reviewed-on: https://go-review.googlesource.com/c/go/+/326211
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
(cherry picked from commit aa5540cd82170f82c6fe11511e12de96aa58cbc1)
Reviewed-on: https://go-review.googlesource.com/c/go/+/326213

2 years ago[release-branch.go1.15] syscall: fix TestGroupCleanupUserNamespace test failure on...
Rahul Bajaj [Tue, 15 Jun 2021 11:32:13 +0000 (11:32 +0000)]
[release-branch.go1.15] syscall: fix TestGroupCleanupUserNamespace test failure on Fedora

For #46752
Fixes #46768

Change-Id: I2eaa9d15fac4e859e18191fcf1372e5be94899df
GitHub-Last-Rev: f533c37ff9d259e307b200a01e3606bfaff10464
GitHub-Pull-Request: golang/go#46753
Reviewed-on: https://go-review.googlesource.com/c/go/+/328069
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>

2 years ago[release-branch.go1.15] cmd/link: pass arch-specific flags to external linker when...
Cherry Zhang [Tue, 15 Dec 2020 23:31:21 +0000 (18:31 -0500)]
[release-branch.go1.15] cmd/link: pass arch-specific flags to external linker when testing supported flag

When testing if a flag (e.g. "-no-pie") is supported by the
external linker, pass arch-specific flags (like "-marm").

In particular, on the ARM builder, if CGO_LDFLAGS=-march=armv6
is set, the C toolchain fails to build if -marm is not passed.

# cc -march=armv6 1.c
1.c: In function 'main':
1.c:3:1: sorry, unimplemented: Thumb-1 hard-float VFP ABI
 int main() {
 ^~~

This makes the Go linker think "-no-pie" is not supported when it
actually is.

Passing -marm makes it work.

Fixes #46684.

Change-Id: I4e8b71f08818993cbbcb2494b310c68d812d6b50
Reviewed-on: https://go-review.googlesource.com/c/go/+/278592
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
(cherry picked from commit a318d56c1e6e89996a3852a780f45c792d860d64)
Reviewed-on: https://go-review.googlesource.com/c/go/+/326711
Run-TryBot: Carlos Amedee <carlos@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Dmitri Shuralyov <dmitshur@golang.org>

3 years ago[release-branch.go1.15] go1.15.13 go1.15.13
David Chase [Thu, 3 Jun 2021 15:22:10 +0000 (15:22 +0000)]
[release-branch.go1.15] go1.15.13

Change-Id: Ib0907538e78ef9b272be8858bc8b52c8b7d6c71a
Reviewed-on: https://go-review.googlesource.com/c/go/+/324551
Run-TryBot: David Chase <drchase@google.com>
Trust: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
3 years ago[release-branch.go1.15] net: don't rely on system hosts in TestCVE202133195
Roland Shoemaker [Wed, 2 Jun 2021 16:20:22 +0000 (09:20 -0700)]
[release-branch.go1.15] net: don't rely on system hosts in TestCVE202133195

Also don't unnecessarily deref the error return.

Updates #46504
Fixes #46531

Change-Id: I22d14ac76776f8988fa0774bdcb5fcd801ce0185
Reviewed-on: https://go-review.googlesource.com/c/go/+/324190
Trust: David Chase <drchase@google.com>
Trust: Damien Neil <dneil@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
(cherry picked from commit dd7ba3ba2c860c40be6d70b63d4a678449cae80f)
Reviewed-on: https://go-review.googlesource.com/c/go/+/324333
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years ago[release-branch.go1.15] cmd/go: error out of 'go mod tidy' if the go version is newer...
Bryan C. Mills [Thu, 13 May 2021 13:48:40 +0000 (09:48 -0400)]
[release-branch.go1.15] cmd/go: error out of 'go mod tidy' if the go version is newer than supported

This backports the test from CL 319669, but — because of extensive
changes to the module loader during the Go 1.16 and 1.17 cycles — the
implementation is entirely different. (This implementation is based on
the addGoStmt function already present in init.go.)

Fixes #46143
Updates #46142

Change-Id: Ib7a0a159e53cbe476be6aa9a050add10cc750dec
Reviewed-on: https://go-review.googlesource.com/c/go/+/319710
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years ago[release-branch.go1.15] cmd/go: use a real Go version in the go.mod files in TestScri...
Bryan C. Mills [Tue, 27 Apr 2021 06:31:23 +0000 (02:31 -0400)]
[release-branch.go1.15] cmd/go: use a real Go version in the go.mod files in TestScript/mod_readonly

For some reason, the go.mod file added to this test in CL 147281 lists
'go 1.20' instead of the version that was actually current when the
go.mod file was added.

That causes the test's behavior to change under lazy loading, because
1.20 is above the threshold to trigger lazy-loading invariants (1.17).

This backports CL 314049 to Go 1.15 in order to fix a spurious test
failure in a subsequent change.

For #46143
Updates #46142
Updates #36460

Change-Id: I92400996cb051ab30e99bfffafd91ff32a1e7087
Reviewed-on: https://go-review.googlesource.com/c/go/+/314049
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-on: https://go-review.googlesource.com/c/go/+/319709
Reviewed-by: Jay Conrod <jayconrod@google.com>
3 years ago[release-branch.go1.15] cmd/link/internal: fix use of DynlinkingGo with ppc64le tramp...
Lynn Boger [Thu, 29 Apr 2021 21:07:25 +0000 (16:07 -0500)]
[release-branch.go1.15] cmd/link/internal: fix use of DynlinkingGo with ppc64le trampolines

When creating programs with large text sections on ppc64le,
trampolines are needed for calls that are too far; however
they are not created if the code is generated such that the TOC
register r2 is initialized and maintained in the code because
then the external linker can create the trampolines. Previously
the function DynlinkingGo was used to determine this but in the
case where plugins are used, this could return true even though
r2 is not valid.

To fix this problem I've added a new function r2Valid which returns
true when the build options indicate that the r2 is
initialized and maintained. Because of the ways that
DynlinkingGo is used I wanted to maintain its previous
behavior.

Fixes #46002

Change-Id: I6d902eba6ad41757aa6474948b79acdbd479cb38
Reviewed-on: https://go-review.googlesource.com/c/go/+/315289
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
(cherry picked from commit 9ed736ac2a99aa2e7ef7d8bed3b01ca8b20a6f80)
Reviewed-on: https://go-review.googlesource.com/c/go/+/317974
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years ago[release-branch.go1.15] net/http: prevent infinite wait during TestMissingStatusNoPanic
Michael Fraenkel [Thu, 13 May 2021 15:41:45 +0000 (09:41 -0600)]
[release-branch.go1.15] net/http: prevent infinite wait during TestMissingStatusNoPanic

If the client request never makes it to the server, the outstanding
accept is never broken. Change the test to always close the listening
socket when the client request completes.

Updates #45358

Change-Id: I744a91dfa11704e7e528163d7669c394e90456dc
Reviewed-on: https://go-review.googlesource.com/c/go/+/319275
Trust: Heschi Kreinick <heschi@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
(cherry picked from commit c0a7ecfae775a9d50d338e8123fac32a5d04308c)
Reviewed-on: https://go-review.googlesource.com/c/go/+/320189
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years ago[release-branch.go1.15] net/http/httputil: always remove hop-by-hop headers
Filippo Valsorda [Fri, 21 May 2021 18:02:30 +0000 (14:02 -0400)]
[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 <filippo@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
Trust: Katie Hockman <katie@golang.org>
Trust: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-on: https://go-review.googlesource.com/c/go/+/323091
Run-TryBot: Katie Hockman <katie@golang.org>

3 years ago[release-branch.go1.15] archive/zip: only preallocate File slice if reasonably sized
Roland Shoemaker [Tue, 11 May 2021 18:31:31 +0000 (11:31 -0700)]
[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

Change-Id: I3c76d8eec178468b380d87fdb4a3f2cb06f0ee76
Reviewed-on: https://go-review.googlesource.com/c/go/+/318909
Trust: Roland Shoemaker <roland@golang.org>
Trust: Katie Hockman <katie@golang.org>
Trust: Joe Tsai <thebrokentoaster@gmail.com>
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
(cherry picked from commit 74242baa4136c7a9132a8ccd9881354442788c8c)
Reviewed-on: https://go-review.googlesource.com/c/go/+/322949
Reviewed-by: Filippo Valsorda <filippo@golang.org>
3 years ago[release-branch.go1.15] net: verify results from Lookup* are valid domain names
Roland Shoemaker [Thu, 27 May 2021 17:40:06 +0000 (10:40 -0700)]
[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

Change-Id: I47a4f58c031cb752f732e88bbdae7f819f0af4f3
Reviewed-on: https://go-review.googlesource.com/c/go/+/323131
Trust: Roland Shoemaker <roland@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
(cherry picked from commit cdcd02842da7c004efd023881e3719105209c908)
Reviewed-on: https://go-review.googlesource.com/c/go/+/323269

3 years ago[release-branch.go1.15] math/big: check for excessive exponents in Rat.SetString
Robert Griesemer [Sun, 2 May 2021 18:27:03 +0000 (11:27 -0700)]
[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 <gri@golang.org>
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
(cherry picked from commit 6c591f79b0b5327549bd4e94970f7a279efb4ab0)
Reviewed-on: https://go-review.googlesource.com/c/go/+/321831
Run-TryBot: Katie Hockman <katie@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
3 years ago[release-branch.go1.15] cmd/link: don't cast end address to int32
Cherry Mui [Wed, 12 May 2021 02:40:02 +0000 (22:40 -0400)]
[release-branch.go1.15] cmd/link: don't cast end address to int32

When linking a very large binary, the section address may not fit
in int32. Don't truncate it.

Fixes #46127.
Updates #46126.

Change-Id: Ibcc8d74bf5662611949e547ce44ca8b973de383f
Reviewed-on: https://go-review.googlesource.com/c/go/+/319289
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
(cherry picked from commit af0f8c149e8a4b237910fc7b41739bedc546473c)
Reviewed-on: https://go-review.googlesource.com/c/go/+/319370

3 years ago[release-branch.go1.15] math/big: remove the s390x assembly for shlVU and shrVU
Jonathan Albrecht [Wed, 2 Dec 2020 15:44:10 +0000 (10:44 -0500)]
[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 <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Trust: Robert Griesemer <gri@golang.org>
(cherry picked from commit b1369d5862bc78eaa902ae637c874e6a6133f1f9)
Reviewed-on: https://go-review.googlesource.com/c/go/+/320169
Trust: Carlos Amedee <carlos@golang.org>
Run-TryBot: Carlos Amedee <carlos@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
3 years ago[release-branch.go1.15] math/big: fix TestShiftOverlap for test -count arguments > 1
SparrowLii [Mon, 24 Aug 2020 06:43:32 +0000 (14:43 +0800)]
[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 <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
(cherry picked from commit 41bc0a1713b9436e96c2d64211ad94e42cafd591)
Reviewed-on: https://go-review.googlesource.com/c/go/+/319831
Run-TryBot: Carlos Amedee <carlos@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Carlos Amedee <carlos@golang.org>
Reviewed-by: Jonathan Albrecht <jonathan.albrecht@ibm.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
3 years ago[release-branch.go1.15] go1.15.12 go1.15.12
Heschi Kreinick [Thu, 6 May 2021 14:16:50 +0000 (10:16 -0400)]
[release-branch.go1.15] go1.15.12

Change-Id: I2d5e242a8324ae76e9d78b94cbc2825561b0c2de
Reviewed-on: https://go-review.googlesource.com/c/go/+/317650
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Trust: Carlos Amedee <carlos@golang.org>
Trust: Heschi Kreinick <heschi@google.com>

3 years ago[release-branch.go1.15] runtime/pprof: skip tests for AIX
Clément Chigot [Thu, 1 Apr 2021 08:06:05 +0000 (10:06 +0200)]
[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 <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
(cherry picked from commit 7bfd681c2f11918c6245ad2906b2efc12eda2914)
Reviewed-on: https://go-review.googlesource.com/c/go/+/317369
Reviewed-by: Heschi Kreinick <heschi@google.com>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>

3 years ago[release-branch.go1.15] runtime: non-strict InlTreeIndex lookup in expandFinalInlineFrame
Michael Pratt [Fri, 9 Apr 2021 21:01:45 +0000 (17:01 -0400)]
[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 <mknyszek@google.com>
Trust: Michael Pratt <mpratt@google.com>
(cherry picked from commit aad13cbb749d1e6c085ff0556d306de1a2d5d063)
Reviewed-on: https://go-review.googlesource.com/c/go/+/309550
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years ago[release-branch.go1.15] runtime, time: disable preemption in addtimer
Michael Pratt [Wed, 10 Mar 2021 21:06:47 +0000 (16:06 -0500)]
[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 <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Knyszek <mknyszek@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/+/313129
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
3 years ago[release-branch.go1.15] std: update golang.org/x/net to 20210428183841-261fb518b1ed
Katie Hockman [Wed, 28 Apr 2021 18:47:48 +0000 (14:47 -0400)]
[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 <katie@golang.org>
Run-TryBot: Katie Hockman <katie@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
3 years ago[release-branch.go1.15] time: use offset and isDST when caching zone from extend...
Ian Lance Taylor [Mon, 5 Apr 2021 19:12:25 +0000 (12:12 -0700)]
[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 <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
3 years ago[release-branch.go1.15] go1.15.11 go1.15.11
Carlos Amedee [Thu, 1 Apr 2021 14:09:59 +0000 (10:09 -0400)]
[release-branch.go1.15] go1.15.11

Change-Id: I601bb0b69e8204055ce37150b50779818a339169
Reviewed-on: https://go-review.googlesource.com/c/go/+/306570
Run-TryBot: Carlos Amedee <carlos@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
3 years ago[release-branch.go1.15] cmd/cgo: remove unnecessary space in cgo export header
Quim Muntal [Thu, 14 Jan 2021 20:29:49 +0000 (21:29 +0100)]
[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 <iant@golang.org>
Trust: Katie Hockman <katie@golang.org>
Reviewed-on: https://go-review.googlesource.com/c/go/+/300694
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
3 years ago[release-branch.go1.15] cmd/link: avoid exporting all symbols on windows buildmode=pie
Quim Muntal [Thu, 22 Oct 2020 20:32:20 +0000 (22:32 +0200)]
[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 <alex.brainman@gmail.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/300692
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: David Chase <drchase@google.com>
3 years ago[release-branch.go1.15] cmd/cgo: avoid exporting all symbols on windows buildmode...
Quim Muntal [Thu, 15 Oct 2020 21:12:49 +0000 (23:12 +0200)]
[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 <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Trust: Alex Brainman <alex.brainman@gmail.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/300693
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: David Chase <drchase@google.com>
3 years ago[release-branch.go1.15] runtime: non-strict InlTreeIndex lookup in Frames.Next
Michael Pratt [Thu, 11 Mar 2021 17:28:45 +0000 (12:28 -0500)]
[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 <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
(cherry picked from commit e4a4161f1f3157550846e1b6bd4fe83aae15778e)
Reviewed-on: https://go-review.googlesource.com/c/go/+/305890

3 years ago[release-branch.go1.15] cmd/compile: disable shortcircuit optimization for intertwine...
Keith Randall [Tue, 23 Mar 2021 21:48:47 +0000 (14:48 -0700)]
[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 <khr@golang.org>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
(cherry picked from commit 771c57e68ed5ef2bbb0eafc0d48419f59d143932)
Reviewed-on: https://go-review.googlesource.com/c/go/+/304529

3 years ago[release-branch.go1.15] database/sql: fix tx stmt deadlock when rollback
Emmanuel T Odeke [Tue, 19 Jan 2021 00:18:11 +0000 (16:18 -0800)]
[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 <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
(cherry picked from commit d4c1ad882973e407ff85b977f4ce5b9435451190)
Reviewed-on: https://go-review.googlesource.com/c/go/+/284513
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
3 years ago[release-branch.go1.15] build: set GOPATH consistently in run.bash, run.bat, run.rc
Russ Cox [Wed, 27 Jan 2021 02:14:43 +0000 (21:14 -0500)]
[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 <rsc@golang.org>
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
(cherry picked from commit bb6efb96092cc8ae398c29e3b052a0051c746f88)
Reviewed-on: https://go-review.googlesource.com/c/go/+/304773
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Alexander Rakoczy <alex@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Trust: Carlos Amedee <carlos@golang.org>

3 years ago[release-branch.go1.15] net/http: fix detection of Roundtrippers that always error
Michael Fraenkel [Fri, 17 Jul 2020 03:30:12 +0000 (21:30 -0600)]
[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 <emm.odeke@gmail.com>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-on: https://go-review.googlesource.com/c/go/+/304210
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
3 years ago[release-branch.go1.15] net/http: update bundled x/net/http2
Dmitri Shuralyov [Mon, 29 Mar 2021 15:19:23 +0000 (11:19 -0400)]
[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 <dmitshur@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years ago[release-branch.go1.15] cmd/link: generate trampoline for inter-dependent packages
Cherry Zhang [Tue, 16 Feb 2021 15:20:58 +0000 (10:20 -0500)]
[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 <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
(cherry picked from commit 098504c73ff6ece19566a1ac811ceed73be7c81d)
Reviewed-on: https://go-review.googlesource.com/c/go/+/298030
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years ago[release-branch.go1.15] cmd/go/internal/modfetch: detect and recover from missing...
Jay Conrod [Wed, 3 Mar 2021 21:30:22 +0000 (16:30 -0500)]
[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 <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
(cherry picked from commit 302a400316319501748c0f034464fa70e7815272)
Reviewed-on: https://go-review.googlesource.com/c/go/+/299830

3 years ago[release-branch.go1.15] go1.15.10 go1.15.10
Carlos Amedee [Thu, 11 Mar 2021 16:22:22 +0000 (11:22 -0500)]
[release-branch.go1.15] go1.15.10

Change-Id: Ib4e90da6307bb80be8b9d67e0efa35d9dd5dd463
Reviewed-on: https://go-review.googlesource.com/c/go/+/300970
Run-TryBot: Carlos Amedee <carlos@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Trust: Carlos Amedee <carlos@golang.org>

3 years ago[release-branch.go1.15] cmd/go: don't report missing std import errors for tidy and...
Jay Conrod [Thu, 4 Mar 2021 16:50:31 +0000 (11:50 -0500)]
[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 <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
(cherry picked from commit 56d52e661114be60fb1893b034ac0c5976b622af)
Reviewed-on: https://go-review.googlesource.com/c/go/+/298950

3 years ago[release-branch.go1.15] all: merge release-branch.go1.15-security into release-branch...
Katie Hockman [Wed, 10 Mar 2021 16:52:19 +0000 (11:52 -0500)]
[release-branch.go1.15] all: merge release-branch.go1.15-security into release-branch.go1.15

Change-Id: I755738ad72337dcb4f942ffd1dc5d699e6bb027d

3 years ago[release-branch.go1.15-security] go1.15.9 go1.15.9
Alexander Rakoczy [Tue, 9 Mar 2021 21:22:28 +0000 (16:22 -0500)]
[release-branch.go1.15-security] go1.15.9

Change-Id: I99864b29d3bcbd07f3d8116d5997407152f1d462
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1014540
Reviewed-by: Katie Hockman <katiehockman@google.com>
3 years ago[release-branch.go1.15-security] encoding/xml: prevent infinite loop while decoding
Katie Hockman [Mon, 1 Mar 2021 14:54:00 +0000 (09:54 -0500)]
[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 <rsc@google.com>
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Filippo Valsorda <valsorda@google.com>
(cherry picked from commit e7ce1f6746223ec7b4caa3b1ece25d9be3864710)
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1014236

3 years ago[release-branch.go1.15] net/http: add connections back that haven't been canceled
Michael Fraenkel [Thu, 3 Dec 2020 00:07:27 +0000 (17:07 -0700)]
[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 <dmitshur@golang.org>
Trust: Damien Neil <dneil@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
(cherry picked from commit 854a2f8e01a554d8052445563863775406a04b71)
Reviewed-on: https://go-review.googlesource.com/c/go/+/297910
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

3 years ago[release-branch.go1.15] net/http: ignore connection closes once done with the connection
Michael Fraenkel [Sat, 26 Sep 2020 15:20:16 +0000 (09:20 -0600)]
[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 <bradfitz@golang.org>
Trust: Damien Neil <dneil@google.com>
(cherry picked from commit 212d385a2f723a8dd5e7d2e83efb478ddd139349)
Reviewed-on: https://go-review.googlesource.com/c/go/+/297909
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
3 years ago[release-branch.go1.15] cmd/compile: fix escape analysis of heap-allocated results
Matthew Dempsky [Sat, 27 Feb 2021 17:41:19 +0000 (09:41 -0800)]
[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 <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-on: https://go-review.googlesource.com/c/go/+/297291

3 years ago[release-branch.go1.15] time: correct unusual extension string cases
Ian Lance Taylor [Thu, 25 Feb 2021 18:01:56 +0000 (10:01 -0800)]
[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 <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
(cherry picked from commit d9fd38e68ba00a51c2c7363150688d0e7687ef84)
Reviewed-on: https://go-review.googlesource.com/c/go/+/297229

3 years ago[release-branch.go1.15] syscall: do not overflow key memory in GetQueuedCompletionStatus
Jason A. Donenfeld [Tue, 23 Feb 2021 12:29:40 +0000 (13:29 +0100)]
[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 <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
3 years ago[release-branch.go1.15] cmd/compile: do not assume TST and TEQ set V on arm
Jason A. Donenfeld [Mon, 30 Nov 2020 09:41:46 +0000 (10:41 +0100)]
[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 <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
3 years ago[release-branch.go1.15] internal/poll: netpollcheckerr before sendfile
Wei Fu [Sun, 24 Jan 2021 10:21:06 +0000 (18:21 +0800)]
[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 <emmanuel@orijtech.com>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
(cherry picked from commit f0d23c9dbb2142b975fa8fb13a57213d0c15bdd1)
Reviewed-on: https://go-review.googlesource.com/c/go/+/296530
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

3 years ago[release-branch.go1.15] internal/poll: if copy_file_range returns 0, assume it failed
Ian Lance Taylor [Mon, 15 Feb 2021 01:14:41 +0000 (17:14 -0800)]
[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 <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
(cherry picked from commit 30641e36aa5b547eee48565caa3078b0a2e7c185)
Reviewed-on: https://go-review.googlesource.com/c/go/+/292289

3 years ago[release-branch.go1.15] go1.15.8 go1.15.8
Carlos Amedee [Thu, 4 Feb 2021 16:17:11 +0000 (11:17 -0500)]
[release-branch.go1.15] go1.15.8

Change-Id: Ic8824cabbc8ae62360e0cda4b7c5604db7d405f3
Reviewed-on: https://go-review.googlesource.com/c/go/+/289694
Run-TryBot: Carlos Amedee <carlos@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Alexander Rakoczy <alex@golang.org>
Trust: Alexander Rakoczy <alex@golang.org>
Trust: Carlos Amedee <carlos@golang.org>

3 years ago[release-branch.go1.15] runtime/cgo: fix Android build with NDK 22
Elias Naur [Fri, 25 Dec 2020 10:14:11 +0000 (11:14 +0100)]
[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 <mail@eliasnaur.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Elias Naur <mail@eliasnaur.com>
(cherry picked from commit 1d78139128d6d839d7da0aeb10b3e51b6c7c0749)
Reviewed-on: https://go-review.googlesource.com/c/go/+/289149

3 years ago[release-branch.go1.15] runtime: don't adjust timer pp field in timerWaiting status
Ian Lance Taylor [Wed, 20 Jan 2021 05:30:36 +0000 (21:30 -0800)]
[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 <iant@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
(cherry picked from commit d2d155d1ae8c704a37f42fd3ebb1f3846f78e4d4)
Reviewed-on: https://go-review.googlesource.com/c/go/+/287092
Run-TryBot: Carlos Amedee <carlos@golang.org>

3 years ago[release-branch.go1.15] cmd/internal/goobj2: fix buglet in object file reader
Than McIntosh [Tue, 15 Dec 2020 20:54:25 +0000 (15:54 -0500)]
[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 <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Trust: Than McIntosh <thanm@google.com>
(cherry picked from commit f4e7a6b905ce60448e506a3f6578d01b60602cdd)
Reviewed-on: https://go-review.googlesource.com/c/go/+/278673

3 years ago[release-branch.go1.15] cmd/link/internal/ld/pe: fix segfault adding resource section
Derek Parker [Wed, 25 Nov 2020 16:31:57 +0000 (16:31 +0000)]
[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 <carlos@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Trust: Carlos Amedee <carlos@golang.org>

3 years ago[release-branch.go1.15] cmd/go: don't lookup the path for CC when invoking cgo
Jay Conrod [Fri, 22 Jan 2021 19:27:24 +0000 (14:27 -0500)]
[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 <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
(cherry picked from commit a2cef9b544708ecae983ed8836ee2425a28aab68)
Reviewed-on: https://go-review.googlesource.com/c/go/+/285954
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>

3 years ago[release-branch.go1.15] net/http: update bundled x/net/http2
Damien Neil [Fri, 29 Jan 2021 19:01:37 +0000 (11:01 -0800)]
[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 <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
3 years ago[release-branch.go1.15] cmd/go: fix get_update_unknown_protocol test
Jay Conrod [Fri, 22 Jan 2021 21:59:16 +0000 (16:59 -0500)]
[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 <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
3 years ago[release-branch.go1.15] cmd/compile: don't short-circuit copies whose source is volatile
Keith Randall [Thu, 7 Jan 2021 22:57:53 +0000 (14:57 -0800)]
[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 <khr@golang.org>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
(cherry picked from commit 304f769ffc68e64244266b3aadbf91e6738c0064)
Reviewed-on: https://go-review.googlesource.com/c/go/+/282558
Trust: Dmitri Shuralyov <dmitshur@golang.org>

3 years ago[release-branch.go1.15] internal/execabs: only run tests on platforms that support...
Roland Shoemaker [Wed, 20 Jan 2021 17:06:12 +0000 (09:06 -0800)]
[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 <roland@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
3 years ago[release-branch.go1.15] cmd/go: fix mod_get_fallback test
Jay Conrod [Wed, 20 Jan 2021 14:45:03 +0000 (09:45 -0500)]
[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 <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
(cherry picked from commit be28e5abc5ddca0d6b2d8c91b7bb9c05717154e7)
Reviewed-on: https://go-review.googlesource.com/c/go/+/284799

3 years ago[release-branch.go1.15] all: merge release-branch.go1.15-security into release-branch...
Roland Shoemaker [Tue, 19 Jan 2021 23:52:45 +0000 (15:52 -0800)]
[release-branch.go1.15] all: merge release-branch.go1.15-security into release-branch.go1.15

Change-Id: I0b607475b3d767b712bfb3c9a350b32f3491517c

3 years ago[release-branch.go1.15-security] go1.15.7 go1.15.7
Dmitri Shuralyov [Tue, 19 Jan 2021 18:59:33 +0000 (13:59 -0500)]
[release-branch.go1.15-security] go1.15.7

Change-Id: Ieec3576afa00cadf91166bf4df39037702635b86
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/957920
Reviewed-by: Roland Shoemaker <bracewell@google.com>
3 years ago[release-branch.go1.15-security] cmd/go: overwrite program name with full path
Roland Shoemaker [Tue, 19 Jan 2021 17:59:24 +0000 (09:59 -0800)]
[release-branch.go1.15-security] cmd/go: overwrite program name with full path

If the program path is resolved, replace the first argument of the
exec.Cmd, which is the bare program name with the resolved path.

Change-Id: I92cf5e6f4bb7c8fef9b59f5eab963f4e75b90d07
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/957908
Reviewed-by: Katie Hockman <katiehockman@google.com>
Reviewed-by: Russ Cox <rsc@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
(cherry picked from commit a863cb56b33a24aad88f23f1d48629dc4b4b9539)
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/958254
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
3 years ago[release-branch.go1.15-security] all: introduce and use internal/execabs
Roland Shoemaker [Fri, 15 Jan 2021 20:14:06 +0000 (12:14 -0800)]
[release-branch.go1.15-security] all: introduce and use internal/execabs

Introduces a wrapper around os/exec, internal/execabs, for use in
all commands. This wrapper prevents exec.LookPath and exec.Command from
running executables in the current directory.

All imports of os/exec in non-test files in cmd/ are replaced with
imports of internal/execabs.

This issue was reported by RyotaK.

Fixes CVE-2021-3115

Change-Id: I0423451a6e27ec1e1d6f3fe929ab1ef69145c08f
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/955304
Reviewed-by: Russ Cox <rsc@google.com>
Reviewed-by: Katie Hockman <katiehockman@google.com>
(cherry picked from commit 44f09a6990ccf4db601cbf8208c89ac4e888f884)
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/955308

3 years ago[release-branch.go1.15-security] cmd/go: add test case for cgo CC setting
Russ Cox [Mon, 11 Jan 2021 14:43:08 +0000 (09:43 -0500)]
[release-branch.go1.15-security] cmd/go: add test case for cgo CC setting

Change-Id: Ied986053a64447c5eac6369f6c9b69ed3d3f94d9
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/949415
Reviewed-by: Ian Lance Taylor <iant@google.com>
(cherry picked from commit e97d4ed8dcc1fed64fe44b56dfdfb0f929aabb65)
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/955297
Reviewed-by: Katie Hockman <katiehockman@google.com>
3 years ago[release-branch.go1.15-security] cmd/cgo: report exec errors a bit more clearly
Russ Cox [Mon, 11 Jan 2021 15:01:24 +0000 (10:01 -0500)]
[release-branch.go1.15-security] cmd/cgo: report exec errors a bit more clearly

Change-Id: I0e6bebf0e2e6efdef4be880e0c6c7451b938924b
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/949417
Reviewed-by: Katie Hockman <katiehockman@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
(cherry picked from commit 4c2e5f85dda6ad5cc1d5be863ae62f2050f12be9)
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/955295

3 years ago[release-branch.go1.15-security] cmd/go: pass resolved CC, GCCGO to cgo
Russ Cox [Mon, 11 Jan 2021 14:41:54 +0000 (09:41 -0500)]
[release-branch.go1.15-security] cmd/go: pass resolved CC, GCCGO to cgo

This makes sure the go command and cgo agree about
exactly which compiler is being used.

This issue was reported by RyotaK.

Fixes CVE-2021-3115.

Change-Id: If171c5c8b2523efb5ea2d957e5ad1380a038149c
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/949416
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
(cherry picked from commit 4cf399ca38587a6e4a3e85b494cd9a9b4cc53378)
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/955293
Reviewed-by: Katie Hockman <katiehockman@google.com>
3 years ago[release-branch.go1.15-security] crypto/elliptic: fix P-224 field reduction
Filippo Valsorda [Fri, 8 Jan 2021 02:56:58 +0000 (03:56 +0100)]
[release-branch.go1.15-security] crypto/elliptic: fix P-224 field reduction

This patch fixes two independent bugs in p224Contract, the function that
performs the final complete reduction in the P-224 field. Incorrect
outputs due to these bugs were observable from a high-level
P224().ScalarMult() call.

The first bug was in the calculation of out3GT. That mask was supposed
to be all ones if the third limb of the value is greater than the third
limb of P (out[3] > 0xffff000). Instead, it was also set if they are
equal. That meant that if the third limb was equal, the value was always
considered greater than or equal to P, even when the three bottom limbs
were all zero. There is exactly one affected value, P - 1, which would
trigger the subtraction by P even if it's lower than P already.

The second bug was more easily hit, and is the one that caused the known
high-level incorrect output: after the conditional subtraction by P, a
potential underflow of the lowest limb was not handled. Any values that
trigger the subtraction by P (values between P and 2^224-1, and P - 1
due to the bug above) but have a zero lowest limb would produce invalid
outputs. Those conditions apply to the intermediate representation
before the subtraction, so they are hard to trace to precise inputs.

This patch also adds a test suite for the P-224 field arithmetic,
including a custom fuzzer that automatically explores potential edge
cases by combining limb values that have various meanings in the code.
contractMatchesBigInt in TestP224Contract finds the second bug in less
than a second without being tailored to it, and could eventually find
the first one too by combining 0, (1 << 28) - 1, and the difference of
(1 << 28) and (1 << 12).

The incorrect P224().ScalarMult() output was found by the
elliptic-curve-differential-fuzzer project running on OSS-Fuzz and
reported by Philippe Antoine (Catena cyber).

Fixes CVE-2021-3114

Change-Id: I50176602d544de3da854270d66a293bcaca57ad7
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/947792
Reviewed-by: Katie Hockman <katiehockman@google.com>
(cherry picked from commit 5fa534e9c7eaeaf875e53b98eac9342b0855b283)
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/955175

3 years ago[release-branch.go1.15] doc/go1.15: mention 1.15.3 cgo restriction on empty structs
Ian Lance Taylor [Sat, 12 Dec 2020 03:10:00 +0000 (19:10 -0800)]
[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 <iant@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
(cherry picked from commit 129bb1917b4914f0743ec9b4ef0dfb74df39c07d)
Reviewed-on: https://go-review.googlesource.com/c/go/+/278573
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
3 years ago[release-branch.go1.15] go1.15.6 go1.15.6
Carlos Amedee [Thu, 3 Dec 2020 16:05:59 +0000 (11:05 -0500)]
[release-branch.go1.15] go1.15.6

Change-Id: I9e050e1463f1bc01c04d1817aef2f81a5aac4d42
Reviewed-on: https://go-review.googlesource.com/c/go/+/275132
Run-TryBot: Carlos Amedee <carlos@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Trust: Carlos Amedee <carlos@golang.org>

3 years ago[release-branch.go1.15] cmd/link: recompute heapPos after copyHeap
Cherry Zhang [Wed, 18 Nov 2020 00:10:51 +0000 (19:10 -0500)]
[release-branch.go1.15] cmd/link: recompute heapPos after copyHeap

Immediately after a forward Seek, the offset we're writing to is
beyond len(buf)+len(heap):

|<--- buf --->|<--- heap --->|
                                    ^
                                    off

If we do a copyHeap at this point, the new heapPos should not be
0:

|<---------- buf ----------->|<-heap->|
                                    ^
                                    off

Recompute it.

Updates #42082
Fixes #42948

Change-Id: Icb3e4e1c7bf7d1fd3d76a2e0d7dfcb319c661534
Reviewed-on: https://go-review.googlesource.com/c/go/+/270942
Run-TryBot: Carlos Amedee <carlos@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Trust: Cherry Zhang <cherryyz@google.com>

3 years ago[release-branch.go1.15] cmd/compile: sign extend consant folding properly
Keith Randall [Fri, 20 Nov 2020 21:53:05 +0000 (13:53 -0800)]
[release-branch.go1.15] cmd/compile: sign extend consant folding properly

MOVLconst must have a properly sign-extended auxint constant.
The bit operations in these rules don't enforce that invariant.

The easiest fix is just to turn on properly typed auxint fields
(which is what fixed this issue at tip).

Fixes #42753

Change-Id: I264245fad45067a6ade65326f7fe681feb5f3739
Reviewed-on: https://go-review.googlesource.com/c/go/+/272028
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
3 years ago[release-branch.go1.15] cmd/compile: do not emit an extra debug_line entry for the...
Alessandro Arzilli [Thu, 12 Nov 2020 13:58:46 +0000 (14:58 +0100)]
[release-branch.go1.15] cmd/compile: do not emit an extra debug_line entry for the end of seq addr

Uses DW_LNS_advance_pc directly, instead of calling putpclcdelta
because the latter will create a new debug_line entry for the end of
sequence address.

Updates #42484.
Fixes #42521.

Change-Id: Ib6355605cac101b9bf37a3b4961ab0cee678a839
Reviewed-on: https://go-review.googlesource.com/c/go/+/268937
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/269517

3 years ago[release-branch.go1.15] internal/poll: use copy_file_range only on Linux kernel ...
Tobias Klauser [Mon, 9 Nov 2020 10:25:38 +0000 (11:25 +0100)]
[release-branch.go1.15] internal/poll: use copy_file_range only on Linux kernel >= 5.3

https://man7.org/linux/man-pages/man2/copy_file_range.2.html#VERSIONS states:

  A major rework of the kernel implementation occurred in 5.3.  Areas
  of the API that weren't clearly defined were clarified and the API
  bounds are much more strictly checked than on earlier kernels.
  Applications should target the behaviour and requirements of 5.3
  kernels.

Rather than attempting to detect the file system for source and
destination files (which means two additional statfs syscalls) and skip
copy_file_range in case of known defects (e.g. CIFS -> CIFS), just
assume copy_file_range to be broken on kernels < 5.3.

Fixes #42550

Change-Id: I3a531296182c1d6e341772cc9d2be5bf83e52575
Reviewed-on: https://go-review.googlesource.com/c/go/+/268338
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
(cherry picked from commit 1c7650aa93bd53b7df0bbb34693fc5a16d9f67af)
Reviewed-on: https://go-review.googlesource.com/c/go/+/269759
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
3 years ago[release-branch.go1.15] runtime: block signals in needm before allocating M
Ian Lance Taylor [Tue, 27 Oct 2020 23:09:40 +0000 (16:09 -0700)]
[release-branch.go1.15] runtime: block signals in needm before allocating M

Otherwise, if a signal occurs just after we allocated the M,
we can deadlock if the signal handler needs to allocate an M
itself.

For #42207
Fixes #42636

Change-Id: I76f44547f419e8b1c14cbf49bf602c6e645d8c14
Reviewed-on: https://go-review.googlesource.com/c/go/+/265759
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
(cherry picked from commit 368c40116434532dc0b53b72fa04788ca6742898)
Reviewed-on: https://go-review.googlesource.com/c/go/+/271847

3 years ago[release-branch.go1.15] cmd/go: permit CGO_LDFLAGS to appear in //go:ldflag
Ian Lance Taylor [Fri, 13 Nov 2020 19:05:37 +0000 (11:05 -0800)]
[release-branch.go1.15] cmd/go: permit CGO_LDFLAGS to appear in //go:ldflag

For #42565
Fixes #42567

Change-Id: If7cf39905d124dbd54dfac6a53ee38270498efed
Reviewed-on: https://go-review.googlesource.com/c/go/+/269818
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
(cherry picked from commit 782cf560db4c919790fdb476d1bbe18e5ddf5ffd)
Reviewed-on: https://go-review.googlesource.com/c/go/+/270137

3 years ago[release-branch.go1.15] all: merge release-branch.go1.15-security into release-branch...
Katie Hockman [Thu, 12 Nov 2020 20:49:20 +0000 (15:49 -0500)]
[release-branch.go1.15] all: merge release-branch.go1.15-security into release-branch.go1.15

Change-Id: I5690e7f4f7f04b9df1881fa60f3d3c6841cefe40

3 years ago[release-branch.go1.15-security] go1.15.5 go1.15.5
Carlos Amedee [Thu, 12 Nov 2020 14:43:55 +0000 (09:43 -0500)]
[release-branch.go1.15-security] go1.15.5

Change-Id: Id3b116c0f54c2131111bc8afacb8d81d06f96461
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/901407
Reviewed-by: Katie Hockman <katiehockman@google.com>
3 years ago[release-branch.go1.15-security] math/big: fix shift for recursive division
Katie Hockman [Tue, 10 Nov 2020 20:54:12 +0000 (15:54 -0500)]
[release-branch.go1.15-security] math/big: fix shift for recursive division

The previous s value could cause a crash
for certain inputs.

Will check in tests and documentation improvements later.

Thanks to the Go Ethereum team and the OSS-Fuzz project for reporting this.
Thanks to Rémy Oudompheng and Robert Griesemer for their help
developing and validating the fix.

Fixes CVE-2020-28362

Change-Id: Ibbf455c4436bcdb07c84a34fa6551fb3422356d3
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/899974
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Filippo Valsorda <valsorda@google.com>
(cherry picked from commit 28015462c2a83239543dc2bef651e9a5f234b633)
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/901065

3 years ago[release-branch.go1.15-security] cmd/go: in cgoflags, permit -DX1, prohibit -Wp,...
Ian Lance Taylor [Tue, 3 Nov 2020 05:31:06 +0000 (21:31 -0800)]
[release-branch.go1.15-security] cmd/go: in cgoflags, permit -DX1, prohibit -Wp,-D,opt

Restrict -D and -U to ASCII C identifiers, but do permit trailing digits.
When using -Wp, prohibit commas in -D values.

Thanks to Imre Rad (https://www.linkedin.com/in/imre-rad-2358749b) for reporting this.

Fixes CVE-2020-28367

Change-Id: Ibfc4dfdd6e6c258e131448e7682610c44eee9492
Reviewed-on: https://go-review.googlesource.com/c/go/+/267277
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/899924
Reviewed-by: Filippo Valsorda <valsorda@google.com>
3 years ago[release-branch.go1.15-security] cmd/go, cmd/cgo: don't let bogus symbol set cgo_ldflag
Ian Lance Taylor [Fri, 6 Nov 2020 17:38:38 +0000 (09:38 -0800)]
[release-branch.go1.15-security] cmd/go, cmd/cgo: don't let bogus symbol set cgo_ldflag

A hand-edited object file can have a symbol name that uses newline and
other normally invalid characters. The cgo tool will generate Go files
containing symbol names, unquoted. That can permit those symbol names
to inject Go code into a cgo-generated file. If that Go code uses the
//go:cgo_ldflag pragma, it can cause the C linker to run arbitrary
code when building a package. If you build an imported package we
permit arbitrary code at run time, but we don't want to permit it at
package build time. This CL prevents this in two ways.

In cgo, reject invalid symbols that contain non-printable or space
characters, or that contain anything that looks like a Go comment.

In the go tool, double check all //go:cgo_ldflag directives in
generated code, to make sure they follow the existing LDFLAG restrictions.

Thanks to Chris Brown and Tempus Ex for reporting this.

Fixes CVE-2020-28366

Change-Id: Ia1ad8f3791ea79612690fa7d26ac451d0f6df7c1
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/895832
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
(cherry picked from commit 6bc814dd2bbfeaafa41d314dd4cc591b575dfbf6)
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/901056
Reviewed-by: Filippo Valsorda <valsorda@google.com>
Reviewed-by: Roland Shoemaker <bracewell@google.com>
3 years ago[release-branch.go1.15] internal/poll: treat copy_file_range EIO as not-handled
Tobias Klauser [Mon, 2 Nov 2020 11:01:33 +0000 (12:01 +0100)]
[release-branch.go1.15] internal/poll: treat copy_file_range EIO as not-handled

For #42334
Fixes #42369

Change-Id: Ife51df4e7d2539a04393abfdec45e3f902975fca
Reviewed-on: https://go-review.googlesource.com/c/go/+/266940
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
(cherry picked from commit 633f9e206045176a12c301eb2c249c1c1d9a5d2e)
Reviewed-on: https://go-review.googlesource.com/c/go/+/267917
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
3 years ago[release-branch.go1.15] go1.15.4 go1.15.4
Alexander Rakoczy [Thu, 5 Nov 2020 18:12:55 +0000 (13:12 -0500)]
[release-branch.go1.15] go1.15.4

Change-Id: Ibcd61e2c7ef7cc6f8509dadea6c3952c5dd7016e
Reviewed-on: https://go-review.googlesource.com/c/go/+/267879
Run-TryBot: Alexander Rakoczy <alex@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Trust: Alexander Rakoczy <alex@golang.org>

3 years ago[release-branch.go1.15] net/http: update bundled x/net/http2
Dmitri Shuralyov [Thu, 29 Oct 2020 22:50:31 +0000 (18:50 -0400)]
[release-branch.go1.15] net/http: update bundled x/net/http2

Bring in the change in CL 266158 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

Updates #39337.
Fixes #42113.

Change-Id: I3ebef4b90c11ad271b7a3031aafd80c423c2c241
Reviewed-on: https://go-review.googlesource.com/c/go/+/266375
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
3 years ago[release-branch.go1.15] time: fix LoadLocationFromTZData with slim tzdata
Christopher Hlubek [Mon, 26 Oct 2020 12:44:44 +0000 (13:44 +0100)]
[release-branch.go1.15] time: fix LoadLocationFromTZData with slim tzdata

The extend information of a time zone file with last transition < now
could result in a wrong cached zone because it used the zone of the
last transition.

This could lead to wrong zones in systems with slim zoneinfo.

For #42216
Fixes #42138

Change-Id: I7c57c35b5cfa58482ac7925b5d86618c52f5444d
Reviewed-on: https://go-review.googlesource.com/c/go/+/264939
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
(cherry picked from commit 70e022e4a83dc996ac4f108e811fbc399ad5565b)
Reviewed-on: https://go-review.googlesource.com/c/go/+/266299
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
3 years ago[release-branch.go1.15] time: support slim tzdata format
Ian Lance Taylor [Thu, 22 Oct 2020 22:25:00 +0000 (15:25 -0700)]
[release-branch.go1.15] time: support slim tzdata format

Backport of part of https://golang.org/cl/261877 to support the slim
tzdata format. As of tzdata 2020b, the default is to use the slim format.
We need to support that format so that Go installations continue to
work when tzdata is updated.

Relevant part of the CL description:

    The reason for the failed tests was that when caching location data, the
    extended time format past the end of zone transitions was not
    considered. The respective change was introduced in (*Location).lookup
    by CL 215539.

For #42138

Change-Id: I37f52a0917b2c6e3957e6b4612c8ef104c736e65
Reviewed-on: https://go-review.googlesource.com/c/go/+/264301
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
3 years ago[release-branch.go1.15] compress/flate: fix corrupted output
Klaus Post [Sat, 17 Oct 2020 15:19:53 +0000 (15:19 +0000)]
[release-branch.go1.15] compress/flate: fix corrupted output

The fastest compression mode can pick up a false match for every 2GB
of input data resulting in incorrectly decompressed data.

Since matches are allowed to be up to and including at maxMatchOffset
we must offset the buffer by an additional element to prevent the first
4 bytes to match after an out-of-reach value after shiftOffsets has
been called.

We offset by `maxMatchOffset + 1` so offset 0 in the table will now
fail the `if offset > maxMatchOffset` in all cases.

Updates #41420.
Fixes #41463.

Change-Id: If1fbe01728e132b8a207e3f3f439edd832dcc710
GitHub-Last-Rev: 50fabab0da874c37543b139459a810e12e83cee2
GitHub-Pull-Request: golang/go#41477
Reviewed-on: https://go-review.googlesource.com/c/go/+/255879
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Joe Tsai <thebrokentoaster@gmail.com>
Trust: Matthew Dempsky <mdempsky@google.com>
(cherry picked from commit ab541a0560408999ac65d12bec2a3057994eda38)
Reviewed-on: https://go-review.googlesource.com/c/go/+/266177
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
3 years ago[release-branch.go1.15] cmd/go/internal/modfetch: drop gopkg.in/russross/blackfriday...
Tobias Klauser [Wed, 28 Oct 2020 12:44:53 +0000 (13:44 +0100)]
[release-branch.go1.15] cmd/go/internal/modfetch: drop gopkg.in/russross/blackfriday.v2 from TestCodeRepoVersions

Follow-up for CL 265819.

Given the -pre tag added recently, a new stable version is likely
tagged soon. This would break TestCodeRepoVersions on the longtest
builders again. Since the other test cases in codeRepoVersionsTests
already provide enough coverage, drop gopkg.in/russross/blackfriday.v2
to avoid breaking TestCodeRepoVersions once the release happens.

Updates #28856

Change-Id: If86a637b5e47f59faf9048fc1cbbae6e8f1dcc53
Reviewed-on: https://go-review.googlesource.com/c/go/+/265917
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
(cherry picked from commit 421d4e72de802ed65cb38317660654771cfb13e9)
Reviewed-on: https://go-review.googlesource.com/c/go/+/266178
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
3 years ago[release-branch.go1.15] cmd/compile: fix storeType to handle pointers to go:notinheap...
Keith Randall [Thu, 22 Oct 2020 20:11:16 +0000 (13:11 -0700)]
[release-branch.go1.15] cmd/compile: fix storeType to handle pointers to go:notinheap types

storeType splits compound stores up into a scalar parts and a pointer parts.
The scalar part happens unconditionally, and the pointer part happens
under the guard of a write barrier check.

Types which are declared as pointers, but are represented as scalars because
they might have "bad" values, were not handled correctly here. They ended
up not getting stored in either set.

Fixes #42151

Change-Id: I46f6600075c0c370e640b807066247237f93c7ac
Reviewed-on: https://go-review.googlesource.com/c/go/+/264300
Trust: Keith Randall <khr@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
(cherry picked from commit 933721b8c7f981229974e2603850c2e9a7ffc5a1)
Reviewed-on: https://go-review.googlesource.com/c/go/+/265719
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

3 years ago[release-branch.go1.15] cmd/compile, runtime: store pointers to go:notinheap types...
Keith Randall [Thu, 22 Oct 2020 23:37:19 +0000 (16:37 -0700)]
[release-branch.go1.15] cmd/compile, runtime: store pointers to go:notinheap types indirectly

pointers to go:notinheap types should be treated as scalars. That
means they shouldn't be stored directly in interfaces, or directly
in reflect.Value.ptr.

Also be sure to use uintpr to compare such pointers in reflect.DeepEqual.

Fixes #42169

Change-Id: I53735f6d434e9c3108d4940bd1bae14c61ef2a74
Reviewed-on: https://go-review.googlesource.com/c/go/+/264480
Trust: Keith Randall <khr@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
(cherry picked from commit 009d71409821a6ac4f1b32aaae2c856c20a29f92)
Reviewed-on: https://go-review.googlesource.com/c/go/+/265720
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

3 years ago[release-branch.go1.15] cmd/{compile,link}: backport fix for issue 39757
Than McIntosh [Wed, 30 Sep 2020 16:52:47 +0000 (12:52 -0400)]
[release-branch.go1.15] cmd/{compile,link}: backport fix for issue 39757

During Go 1.15 development, a fix was added to the toolchain for issue
information. The 1.15 line tables were slightly malformed in the way
that they used the DWARF "end sequence" operator, resulting in
incorrect line table info for the final instruction in the final
function of a compilation unit.

This problem was fixed in https://golang.org/cl/235739, which made it
into Go 1.15. It now appears that while the fix works OK for linux, in
certain cases it causes issues with the Darwin linker (the "address
not in any section" ld64 error reported in issue #40974).

During Go 1.16 development, the fix in https://golang.org/cl/235739
was revised so as to fix another related problem (described in issue #39757);
the newer fix does not trigger the problem in the Darwin linker however.

This CL back-ports the changes in https://golang.org/cl/239286 to the
1.15 release branch, so as to fix the Darwin linker error.

Updates #38192.
Updates #39757.
Fixes #40974.

Change-Id: I9350fec4503cd3a76b97aaea0d8aed1511662e29
Reviewed-on: https://go-review.googlesource.com/c/go/+/258422
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Trust: Than McIntosh <thanm@google.com>

3 years ago[release-branch.go1.15] net/http: deep copy Request.TransferEncoding
dqu123 [Sat, 10 Oct 2020 20:25:07 +0000 (16:25 -0400)]
[release-branch.go1.15] net/http: deep copy Request.TransferEncoding

The existing implementation in Request.Clone() assigns the wrong
pointer to r2.TransferEncoding.

Updates #41907.
Fixes #41914.

Change-Id: I7f220a41b1b46a55d1a1005e47c6dd69478cb025
Reviewed-on: https://go-review.googlesource.com/c/go/+/261378
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Carlos Amedee <carlos@golang.org>
Trust: Emmanuel Odeke <emm.odeke@gmail.com>

3 years ago[release-branch.go1.15] src, net/http: update vendor, regenerate h2_bundle.go
Emmanuel T Odeke [Wed, 30 Sep 2020 21:51:45 +0000 (14:51 -0700)]
[release-branch.go1.15] src, net/http: update vendor, regenerate h2_bundle.go

Features CL:

    net/http2: send WINDOW_UPDATE on a body's write failure
    https://golang.org/cl/258478 (updates #41387)

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

Updates #40423
Fixes #41387

Change-Id: I052037d6b6ed38b9d9782e19b8ce283875354c92
Reviewed-on: https://go-review.googlesource.com/c/go/+/258540
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Emmanuel Odeke <emm.odeke@gmail.com>

3 years ago[release-branch.go1.15] runtime: wait for preemption signals before syscall.Exec
Ian Lance Taylor [Thu, 15 Oct 2020 21:39:12 +0000 (14:39 -0700)]
[release-branch.go1.15] runtime: wait for preemption signals before syscall.Exec

For #41702
For #41704
For #42023

Change-Id: If07f40b1d73b8f276ee28ffb8b7214175e56c24d
Reviewed-on: https://go-review.googlesource.com/c/go/+/262817
Trust: Ian Lance Taylor <iant@golang.org>
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
(cherry picked from commit 05739d6f17c57f09264272621b88725a463234d0)
Reviewed-on: https://go-review.googlesource.com/c/go/+/264022

3 years ago[release-branch.go1.15] syscall: use MustHaveExec in TestExec
Ian Lance Taylor [Thu, 15 Oct 2020 21:19:10 +0000 (14:19 -0700)]
[release-branch.go1.15] syscall: use MustHaveExec in TestExec

For #41702
For #41704

Change-Id: Ib2b15e52aa1fef2f5e644b316c726150252fa9f8
Reviewed-on: https://go-review.googlesource.com/c/go/+/262738
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
(cherry picked from commit 11cfb48df192c14d185c1cfcaad1ba3e7b84c807)
Reviewed-on: https://go-review.googlesource.com/c/go/+/264020

3 years ago[release-branch.go1.15] runtime: stop preemption during syscall.Exec on Darwin
Ian Lance Taylor [Wed, 14 Oct 2020 23:03:48 +0000 (16:03 -0700)]
[release-branch.go1.15] runtime: stop preemption during syscall.Exec on Darwin

On current macOS versions a program that receives a signal during an
execve can fail with a SIGILL signal. This appears to be a macOS
kernel bug. It has been reported to Apple.

This CL partially works around the problem by using execLock to not
send preemption signals during execve. Of course some other stray
signal could occur, but at least we can avoid exacerbating the problem.
We can't simply disable signals, as that would mean that the exec'ed
process would start with all signals blocked, which it likely does not
expect.

For #41702
Fixes #41704

Change-Id: I91b0add967b315671ddcf73269c4d30136e579b4
Reviewed-on: https://go-review.googlesource.com/c/go/+/262438
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
(cherry picked from commit 64fb6ae95f1c322486cbfb758552bb8439a8e6e8)
Reviewed-on: https://go-review.googlesource.com/c/go/+/262717

3 years ago[release-branch.go1.15] go1.15.3 go1.15.3
Alexander Rakoczy [Wed, 14 Oct 2020 17:45:23 +0000 (13:45 -0400)]
[release-branch.go1.15] go1.15.3

Change-Id: I8a45870039d0d3f210d883c464a7fed2abd9e28b
Reviewed-on: https://go-review.googlesource.com/c/go/+/262337
Run-TryBot: Alexander Rakoczy <alex@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Alexander Rakoczy <alex@golang.org>

3 years ago[release-branch.go1.15] cmd/compile: fix left shift constant folding rule
Keith Randall [Thu, 1 Oct 2020 16:57:52 +0000 (09:57 -0700)]
[release-branch.go1.15] cmd/compile: fix left shift constant folding rule

The 32-bit left shift constant folding rule should keep its result
properly sign extended.

Fixes #41720
Fixes #41711

Change-Id: I0fc74444d444274e911952e1725dab0b7737a846
Reviewed-on: https://go-review.googlesource.com/c/go/+/258817
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>