From 9fc88e308f7601a81604a29e9da2f68dcc25570e Mon Sep 17 00:00:00 2001 From: Kristoffer Dalby Date: Sun, 7 Jun 2026 10:35:50 +0000 Subject: [PATCH] noise: drop write-only nodeKey field to fix data race noiseServer.nodeKey was assigned on every PollNetMap and Register request but never read anywhere. The inner HTTP/2 mux multiplexes concurrent requests over one Noise session, so those per-request writes to the shared field raced (caught by -race in servertest TestConnectDisconnectRace, reachable by a client issuing concurrent map requests). Remove the dead field and its two writes. --- hscontrol/noise.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/hscontrol/noise.go b/hscontrol/noise.go index 5abc6e97..82c119da 100644 --- a/hscontrol/noise.go +++ b/hscontrol/noise.go @@ -84,7 +84,6 @@ type noiseServer struct { http2Server *http2.Server conn *controlbase.Conn machineKey key.MachinePublic - nodeKey key.NodePublic // [tailcfg.EarlyNoise]-related stuff challenge key.ChallengePrivate @@ -716,8 +715,6 @@ func (ns *noiseServer) PollNetMapHandler( return } - ns.nodeKey = nv.NodeKey() - sess := ns.headscale.newMapSession(req.Context(), mapRequest, writer, nv.AsStruct()) sess.log.Trace().Caller().Msg("a node sending a MapRequest with Noise protocol") @@ -753,8 +750,6 @@ func (ns *noiseServer) RegistrationHandler( return ®Req, regErr(err) } - ns.nodeKey = regReq.NodeKey - resp, err = ns.headscale.handleRegister(req.Context(), regReq, ns.conn.Peer()) if err != nil { if httpErr, ok := errors.AsType[HTTPError](err); ok {