Development discussion of WireGuard
 help / color / mirror / Atom feed
* wireguard-go - peer goroutines can SIGSEGV on device.Close()
@ 2022-07-21 15:38 Spike Curtis
  0 siblings, 0 replies; only message in thread
From: Spike Curtis @ 2022-07-21 15:38 UTC (permalink / raw)
  To: wireguard

I have encountered what I think is a bug in wireguard-go which causes
a SIGSEGV like:

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

goroutine 150 [running]:*netTun).Write(0x140004501e0,
{0x14000192000, 0x58, 0x100000000000000?}, 0x3?)
created by*Peer).Start

I believe this happens when I call `Close()` on the Device with this
Peer.  Closing the device triggers gVisor to Attach a nil
NetworkDispatcher to the tun, which the Peer goroutine attempts to
dereference via Write.  This is a race condition that depends on
whether any packets are queued up at the time: if the queues are
empty, we are fine.

I'm able to work around this issue by calling RemoveAllPeers() prior
to Close() on the device, but presumably it wasn't the intention to
make Close() on its own dangerous in this way.

I'm happy to offer a patch if you're interested.

Spike Curtis
Principal Engineer

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-07-26 13:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-21 15:38 wireguard-go - peer goroutines can SIGSEGV on device.Close() Spike Curtis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).