Skip to content

device,cmd/check-lockorder: fix race on reading peer.deleteOnIdle - #108

Merged
illotum merged 1 commit into
tailscalefrom
illotum/lazypeer-race
Oct 2, 2026
Merged

illotum merged 1 commit into
tailscalefrom
illotum/lazypeer-race

Conversation

@illotum

@illotum illotum commented Oct 1, 2026 •

Copy link
Copy Markdown

deleteOnIdle is a read-only field after Start() and is accessed concurrently without locking. Except it is publshed to a shared registry before Start() is called, leading to a race condition.

Extend this contract to make it read-write only until published. Port all other configuration to happen before publishing as well.

One call-site that configures it after publishing, via a UAPI call, remains safe because of the global lock held by the NewPeer caller.

Also update cmd/check-lockorder to parse deferred unlocks and register AllowedIPs.mu in the graph.

Fixes tailscale/corp#48142
Change-Id: I239b62657ec4a666cb50402ba2420a656a6a6964

@illotum
illotum requested review from a team, cmol, creachadair, danderson and jwhited October 1, 2026 23:27
Comment thread device/device.go Outdated
Comment thread device/peer.go Outdated

@cmol cmol left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add something to the commit message on why some things are moving from device to peer?

deleteOnIdle is a read-only field after Start() and is accessed
concurrently without locking. Except it is publshed to a shared
registry before Start() is called, leading to a race condition.

Extend this contract to make it read-write only until published. Port
all other configuration to happen before publishing as well.

One call-site that configures it after publishing, via a UAPI call,
remains safe because of the global lock held by the NewPeer caller.

Also update cmd/check-lockorder to parse deferred unlocks and register
AllowedIPs.mu in the graph.

Fixes tailscale/corp#48142

Signed-off-by: Alex Valiushko <alexvaliushko@tailscale.com>
Change-Id: I239b62657ec4a666cb50402ba2420a656a6a6964
@illotum
illotum force-pushed the illotum/lazypeer-race branch from 11137ed to a3423f9 Compare October 2, 2026 16:20
@illotum
illotum merged commit 18e99eb into tailscale Oct 2, 2026
15 checks passed
@illotum
illotum deleted the illotum/lazypeer-race branch October 2, 2026 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants