Skip to content

Commit 1d3d7d3

Browse files
FiloSottilegopherbot
authored andcommitted
crypto/tls: ensure GODEBUGs are initialized
IncNonDefault panics if Value was not called. That's too much DoS risk in crypto/tls, when the call to Value is distant from the call to IncNonDefault (see #65991). Value is cheap, though, so we can just call it before each isolated IncNonDefault. Change-Id: I6dbed345381e60e029b0a5ef2232e846aa089736 Reviewed-on: https://go-review.googlesource.com/c/go/+/586755 Reviewed-by: Roland Shoemaker <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> Auto-Submit: Filippo Valsorda <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent 3128ebf commit 1d3d7d3

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

src/crypto/tls/handshake_client.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,7 @@ func (hs *clientHandshakeState) pickCipherSuite() error {
527527
}
528528

529529
if hs.c.config.CipherSuites == nil && !needFIPS() && rsaKexCiphers[hs.suite.id] {
530+
tlsrsakex.Value() // ensure godebug is initialized
530531
tlsrsakex.IncNonDefault()
531532
}
532533

src/crypto/tls/handshake_server.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ func (c *Conn) readClientHello(ctx context.Context) (*clientHelloMsg, error) {
169169
c.out.version = c.vers
170170

171171
if c.config.MinVersion == 0 && c.vers < VersionTLS12 {
172+
tls10server.Value() // ensure godebug is initialized
172173
tls10server.IncNonDefault()
173174
}
174175

@@ -371,6 +372,7 @@ func (hs *serverHandshakeState) pickCipherSuite() error {
371372
c.cipherSuite = hs.suite.id
372373

373374
if c.config.CipherSuites == nil && !needFIPS() && rsaKexCiphers[hs.suite.id] {
375+
tlsrsakex.Value() // ensure godebug is initialized
374376
tlsrsakex.IncNonDefault()
375377
}
376378

0 commit comments

Comments
 (0)