wireguard-go/device
Josh Bleecher Snyder 4eab21a7b7 device: make RoutineReadFromTUN keep encryption queue alive
RoutineReadFromTUN can trigger a call to SendStagedPackets.
SendStagedPackets attempts to protect against sending
on the encryption queue by checking peer.isRunning and device.isClosed.
However, those are subject to TOCTOU bugs.

If that happens, we get this:

goroutine 1254 [running]:
golang.zx2c4.com/wireguard/device.(*Peer).SendStagedPackets(0xc000798300)
        .../wireguard-go/device/send.go:321 +0x125
golang.zx2c4.com/wireguard/device.(*Device).RoutineReadFromTUN(0xc000014780)
        .../wireguard-go/device/send.go:271 +0x21c
created by golang.zx2c4.com/wireguard/device.NewDevice
        .../wireguard-go/device/device.go:315 +0x298

Fix this with a simple, big hammer: Keep the encryption queue
alive as long as it might be written to.

Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-02-09 09:53:00 -08:00
..
alignment_test.go device: fix alignment on 32-bit machines and test for it 2021-02-09 15:37:04 +01:00
allowedips.go global: bump copyright 2021-01-28 17:52:15 +01:00
allowedips_rand_test.go global: bump copyright 2021-01-28 17:52:15 +01:00
allowedips_test.go global: bump copyright 2021-01-28 17:52:15 +01:00
bind_test.go global: bump copyright 2021-01-28 17:52:15 +01:00
channels.go device: remove nil elem check in finalizers 2021-02-09 18:28:55 +01:00
constants.go global: bump copyright 2021-01-28 17:52:15 +01:00
cookie.go global: bump copyright 2021-01-28 17:52:15 +01:00
cookie_test.go global: bump copyright 2021-01-28 17:52:15 +01:00
device.go device: make RoutineReadFromTUN keep encryption queue alive 2021-02-09 09:53:00 -08:00
device_test.go device: run fewer iterations in TestUpDown 2021-02-09 18:28:59 +01:00
devicestate_string.go device: remove deviceStateNew 2021-02-09 15:39:19 +01:00
endpoint_test.go global: bump copyright 2021-01-28 17:52:15 +01:00
indextable.go global: bump copyright 2021-01-28 17:52:15 +01:00
ip.go global: bump copyright 2021-01-28 17:52:15 +01:00
kdf_test.go global: bump copyright 2021-01-28 17:52:15 +01:00
keypair.go global: bump copyright 2021-01-28 17:52:15 +01:00
logger.go global: bump copyright 2021-01-28 17:52:15 +01:00
misc.go global: bump copyright 2021-01-28 17:52:15 +01:00
mobilequirks.go global: bump copyright 2021-01-28 17:52:15 +01:00
noise-helpers.go global: bump copyright 2021-01-28 17:52:15 +01:00
noise-protocol.go global: bump copyright 2021-01-28 17:52:15 +01:00
noise-types.go global: bump copyright 2021-01-28 17:52:15 +01:00
noise_test.go global: bump copyright 2021-01-28 17:52:15 +01:00
peer.go device: only allocate peer queues once 2021-02-09 18:33:48 +01:00
pools.go device: use a waiting sync.Pool instead of a channel 2021-02-02 19:32:13 +01:00
pools_test.go device: run fewer trials in TestWaitPool when race detector enabled 2021-02-09 18:28:58 +01:00
queueconstants_android.go global: bump copyright 2021-01-28 17:52:15 +01:00
queueconstants_default.go global: bump copyright 2021-01-28 17:52:15 +01:00
queueconstants_ios.go global: bump copyright 2021-01-28 17:52:15 +01:00
race_disabled_test.go device: run fewer trials in TestWaitPool when race detector enabled 2021-02-09 18:28:58 +01:00
race_enabled_test.go device: run fewer trials in TestWaitPool when race detector enabled 2021-02-09 18:28:58 +01:00
receive.go device: do not attach finalizer to non-returned object 2021-02-09 15:37:04 +01:00
send.go device: make RoutineReadFromTUN keep encryption queue alive 2021-02-09 09:53:00 -08:00
sticky_default.go device: do not include sticky sockets on android 2020-06-07 01:50:20 -06:00
sticky_linux.go global: bump copyright 2021-01-28 17:52:15 +01:00
timers.go device: separate timersInit from timersStart 2021-02-08 10:32:07 -08:00
tun.go device: don't track device interface state in RoutineTUNEventReader 2021-02-08 10:32:07 -08:00
tun_test.go global: bump copyright 2021-01-28 17:52:15 +01:00
uapi.go device: overhaul device state management 2021-02-08 10:32:07 -08:00
version.go version: bump snapshot 2020-11-18 14:24:17 +01:00