You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tailscale/ipn
Nick Khyl fd7dd6433f ipn/ipnlocal: fix LocalBackend deadlock when packet arrives during profile switch (#18126)
If a packet arrives while WireGuard is being reconfigured with b.mu held, such as during a profile switch,
calling back into (*LocalBackend).GetPeerAPIPort from (*Wrapper).filterPacketInboundFromWireGuard
may deadlock when it tries to acquire b.mu.

This occurs because a peer cannot be removed while an inbound packet is being processed.
The reconfig and profile switch wait for (*Peer).RoutineSequentialReceiver to return, but it never finishes
because GetPeerAPIPort needs b.mu, which the waiting goroutine already holds.

In this PR, we make peerAPIPorts a new syncs.AtomicValue field that is written with b.mu held
but can be read by GetPeerAPIPort without holding the mutex, which fixes the deadlock.

There might be other long-term ways to address the issue, such as moving peer API listeners
from LocalBackend to nodeBackend so they can be accessed without holding b.mu,
but these changes are too large and risky at this stage in the v1.92 release cycle.

Updates #18124

Signed-off-by: Nick Khyl <nickk@tailscale.com>
(cherry picked from commit 557457f3c2)
3 weeks ago
..
auditlog syncs: add Mutex/RWMutex alias/wrappers for future mutex debugging 1 month ago
conffile cmd/tailscale/cli,ipn/conffile: add declarative config mode for Services (#17435) 2 months ago
desktop go.mod: bump golang.org/x/crypto (#17907) 1 month ago
ipnauth all: use buildfeature constants in a few more places 3 months ago
ipnext ipn/ipnlocal: remove all the weird locking (LockedOnEntry, UnlockEarly, etc) 1 month ago
ipnlocal ipn/ipnlocal: fix LocalBackend deadlock when packet arrives during profile switch (#18126) 3 weeks ago
ipnserver feature/featuretags, all: add build features, use existing ones in more places 3 months ago
ipnstate cmd/tailscale, ipn/ipnstate, wgengine/magicsock: update ping output for peer relay (#16515) 6 months ago
lapitest various: allow tailscaled shutdown via LocalAPI 3 months ago
localapi cmd/tailscaled,ipn: show a health warning when state store fails to open (#17883) 1 month ago
policy ipn,tailconfig: clean up unreleased and removed app connector service 2 years ago
store ipn/store, feature/condregister: permit callers to empty import optonal ipn stores 3 months ago
backend.go types/netmap: remove PrivateKey from NetworkMap 1 month ago
backend_test.go ipn: fix the string representation of an empty ipn.Notify 3 months ago
conf.go ipn: ensure that conffile is source of truth for advertised services. (#15361) 9 months ago
doc.go ipn: generate LoginProfileView and use it instead of *LoginProfile where appropriate 11 months ago
ipn_clone.go cmd/tailscale/cli,ipn,all: make peer relay server port a *uint16 4 weeks ago
ipn_test.go all: do not depend on the testing package 2 years ago
ipn_view.go cmd/tailscale/cli,ipn,all: make peer relay server port a *uint16 4 weeks ago
prefs.go cmd/tailscale/cli,ipn,all: make peer relay server port a *uint16 4 weeks ago
prefs_test.go cmd/tailscale/cli,ipn,all: make peer relay server port a *uint16 4 weeks ago
serve.go ipn/serve: validate service paths in HasPathHandler 4 weeks ago
serve_test.go ipn/serve: validate service paths in HasPathHandler 4 weeks ago
store.go cmd/tailscaled,ipn: show a health warning when state store fails to open (#17883) 1 month ago
store_test.go ipn/store: automatically migrate between plaintext and encrypted state (#16318) 6 months ago