tailscale/ipn
Maisem Ali cb3b281e98 ipn/ipnlocal: fix race in enterState
It would acquire the lock, calculate `nextState`, relase
the lock, then call `enterState` which would acquire the lock
again. There were obvious races there which could lead to
nil panics as seen in a test in a different repo.

```
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x70 pc=0x1050f2c7c]

goroutine 42240 [running]:
tailscale.com/ipn/ipnlocal.(*LocalBackend).enterStateLockedOnEntry(0x14002154e00, 0x6)
        tailscale.com/ipn/ipnlocal/local.go:3715 +0x30c
tailscale.com/ipn/ipnlocal.(*LocalBackend).enterState(0x14002154e00?, 0x14002e3a140?)
        tailscale.com/ipn/ipnlocal/local.go:3663 +0x8c
tailscale.com/ipn/ipnlocal.(*LocalBackend).stateMachine(0x14001f5e280?)
        tailscale.com/ipn/ipnlocal/local.go:3836 +0x2c
tailscale.com/ipn/ipnlocal.(*LocalBackend).setWgengineStatus(0x14002154e00, 0x14002e3a190, {0x0?, 0x0?})
        tailscale.com/ipn/ipnlocal/local.go:1193 +0x4d0
tailscale.com/wgengine.(*userspaceEngine).RequestStatus(0x14005d90300)
        tailscale.com/wgengine/userspace.go:1051 +0x80
tailscale.com/wgengine.NewUserspaceEngine.func2({0x14002e3a0a0, 0x2, 0x140025cce40?})
        tailscale.com/wgengine/userspace.go:318 +0x1a0
tailscale.com/wgengine/magicsock.(*Conn).updateEndpoints(0x14002154700, {0x105c13eaf, 0xf})
        tailscale.com/wgengine/magicsock/magicsock.go:531 +0x424
created by tailscale.com/wgengine/magicsock.(*Conn).ReSTUN in goroutine 42077
        tailscale.com/wgengine/magicsock/magicsock.go:2142 +0x3a4
```

Updates tailscale/corp#14480

Signed-off-by: Maisem Ali <maisem@tailscale.com>
2023-09-05 10:45:11 -07:00
..
ipnauth all: update copyright and license headers 2023-01-27 15:36:29 -08:00
ipnlocal ipn/ipnlocal: fix race in enterState 2023-09-05 10:45:11 -07:00
ipnserver logpolicy, various: allow overriding log function 2023-07-10 18:08:50 -04:00
ipnstate ipn/ipnstate: add PeerStatus.AltSharerUserID, stop mangling Node.User 2023-08-20 08:18:52 -07:00
localapi util/rands: add package with HexString func 2023-09-05 09:17:21 -07:00
policy ipn: prefer allow/denylist terminology 2023-04-04 08:02:50 -07:00
store cmd/k8s-operator,ipn/store/kubestore: patch secrets instead of updating 2023-08-29 13:24:05 -07:00
backend.go ipn, ipn/ipnlocal: add session identifier for WatchIPNBus 2023-09-05 13:30:04 -04:00
doc.go all: update copyright and license headers 2023-01-27 15:36:29 -08:00
fake_test.go all: update copyright and license headers 2023-01-27 15:36:29 -08:00
ipn_clone.go cmd/tailscale,ipn: add auto-update flags and prefs (#8861) 2023-09-01 13:45:12 -07:00
ipn_view.go cmd/tailscale,ipn: add auto-update flags and prefs (#8861) 2023-09-01 13:45:12 -07:00
prefs.go cmd/tailscale,ipn: add auto-update flags and prefs (#8861) 2023-09-01 13:45:12 -07:00
prefs_test.go cmd/tailscale,ipn: add auto-update flags and prefs (#8861) 2023-09-01 13:45:12 -07:00
serve.go cmd/tailscale: combine serve and funnel for debug wip funnel stream model (#9169) 2023-09-01 12:28:29 -07:00
serve_test.go tailscale/cli: add interactive flow for enabling Funnel 2023-08-09 18:55:43 -04:00
store.go ipn: avoid useless no-op WriteState calls 2023-08-07 08:44:24 -07:00
store_test.go ipn: avoid useless no-op WriteState calls 2023-08-07 08:44:24 -07:00