gvisor-lx/pkg
Leadaxe ffebe42860 tcp: guard handleConnecting against a zeroed handshake (sing-box-lx SPEC 048)
listenContext.performHandshake, in its failure branch, zeroes ep.h and
releases ep.mu before calling ep.Close(); the endpoint state only changes
later, inside closeLocked. In that window the endpoint is still
SynSent/SynRecv, so connecting() is true.

A segment arriving there wakes the dispatcher, which routes to
handleConnecting. Its gate checks the state but not h, so
ep.h.processSegments() runs on a nil handshake and panics with a nil
receiver at connect.go:534 — killing the whole process, not just the
connection. The two conditions used to coincide; they stopped coinciding
once zeroing h moved ahead of Close().

Fix: bail out early when ep.h is nil, releasing the mutex the same way the
existing state gate does. One guard covers all five ep.h dereferences in
handleConnecting (processSegments, listenEP in the error branch, and both
inside deliverAccepted, which is only reached from here).

Trigger in the field: TCP that never reaches established (silent server,
RST, timeout) while SYN retransmits keep arriving. Reproduced from a
device crash bundle (sing-box 1.14.0-lx.19-rc.3, android/arm64) where both
sides of the race hold the same endpoint address; the accompanying test
recreates that window and panics without this guard.

SPECS/TASKS/048-GVISOR_HANDSHAKE_NIL_CRASH
2026-08-04 15:51:12 +03:00
..
abi snapshot: sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1 2026-08-04 15:50:08 +03:00
atomicbitops snapshot: sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1 2026-08-04 15:50:08 +03:00
binary snapshot: sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1 2026-08-04 15:50:08 +03:00
bits snapshot: sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1 2026-08-04 15:50:08 +03:00
buffer snapshot: sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1 2026-08-04 15:50:08 +03:00
cleanup snapshot: sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1 2026-08-04 15:50:08 +03:00
compressio snapshot: sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1 2026-08-04 15:50:08 +03:00
context snapshot: sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1 2026-08-04 15:50:08 +03:00
coretag snapshot: sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1 2026-08-04 15:50:08 +03:00
cpuid snapshot: sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1 2026-08-04 15:50:08 +03:00
errors snapshot: sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1 2026-08-04 15:50:08 +03:00
eventfd snapshot: sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1 2026-08-04 15:50:08 +03:00
fd snapshot: sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1 2026-08-04 15:50:08 +03:00
fdchannel snapshot: sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1 2026-08-04 15:50:08 +03:00
fdnotifier snapshot: sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1 2026-08-04 15:50:08 +03:00
flipcall snapshot: sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1 2026-08-04 15:50:08 +03:00
fspath snapshot: sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1 2026-08-04 15:50:08 +03:00
fsutil snapshot: sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1 2026-08-04 15:50:08 +03:00
gohacks snapshot: sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1 2026-08-04 15:50:08 +03:00
goid snapshot: sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1 2026-08-04 15:50:08 +03:00
gomaxprocs snapshot: sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1 2026-08-04 15:50:08 +03:00
hostarch snapshot: sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1 2026-08-04 15:50:08 +03:00
hostsyscall snapshot: sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1 2026-08-04 15:50:08 +03:00
hosttid snapshot: sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1 2026-08-04 15:50:08 +03:00
ilist snapshot: sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1 2026-08-04 15:50:08 +03:00
linewriter snapshot: sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1 2026-08-04 15:50:08 +03:00
log snapshot: sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1 2026-08-04 15:50:08 +03:00
marshal snapshot: sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1 2026-08-04 15:50:08 +03:00
memutil snapshot: sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1 2026-08-04 15:50:08 +03:00
pool snapshot: sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1 2026-08-04 15:50:08 +03:00
rand snapshot: sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1 2026-08-04 15:50:08 +03:00
rawfile snapshot: sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1 2026-08-04 15:50:08 +03:00
refs snapshot: sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1 2026-08-04 15:50:08 +03:00
ringdeque snapshot: sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1 2026-08-04 15:50:08 +03:00
safecopy snapshot: sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1 2026-08-04 15:50:08 +03:00
secio snapshot: sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1 2026-08-04 15:50:08 +03:00
sighandling snapshot: sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1 2026-08-04 15:50:08 +03:00
sleep snapshot: sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1 2026-08-04 15:50:08 +03:00
state snapshot: sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1 2026-08-04 15:50:08 +03:00
sync snapshot: sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1 2026-08-04 15:50:08 +03:00
syncevent snapshot: sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1 2026-08-04 15:50:08 +03:00
syserr snapshot: sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1 2026-08-04 15:50:08 +03:00
tcpip tcp: guard handleConnecting against a zeroed handshake (sing-box-lx SPEC 048) 2026-08-04 15:51:12 +03:00
timing snapshot: sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1 2026-08-04 15:50:08 +03:00
unet snapshot: sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1 2026-08-04 15:50:08 +03:00
waiter snapshot: sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1 2026-08-04 15:50:08 +03:00
xdp snapshot: sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1 2026-08-04 15:50:08 +03:00