Skip to content

Commit

Permalink
quic: fix data race caused by aliased DCID
Browse files Browse the repository at this point in the history
The initServer function was retaining a reference to a []byte that
aliases a packet buffer, which is subsequently recycled.

Make a copy of the data before retaining it.

Fixes golang/go#63783

Change-Id: I3dbb0cdfd78681014dec97ff9909ff6c7dbf82ba
Reviewed-on: https://go-review.googlesource.com/c/net/+/538615
LUCI-TryBot-Result: Go LUCI <[email protected]>
Auto-Submit: Damien Neil <[email protected]>
Reviewed-by: Jonathan Amsterdam <[email protected]>
  • Loading branch information
neild authored and gopherbot committed Oct 30, 2023
1 parent 6d267b1 commit 0526b49
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion internal/quic/conn_id.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,13 @@ func (s *connIDState) initClient(c *Conn) error {
}

func (s *connIDState) initServer(c *Conn, dstConnID []byte) error {
dstConnID = cloneBytes(dstConnID)
// Client-chosen, transient connection ID received in the first Initial packet.
// The server will not use this as the Source Connection ID of packets it sends,
// but remembers it because it may receive packets sent to this destination.
s.local = append(s.local, connID{
seq: -1,
cid: cloneBytes(dstConnID),
cid: dstConnID,
})

// Server chooses a connection ID, and sends it in the Source Connection ID of
Expand Down

0 comments on commit 0526b49

Please sign in to comment.