SelectTarget, CancelTarget, AbortSendData, GetMembers and
__NetMatchingCallbacks looked up peers and changed their state unlocked,
while the input thread can free them (DEATH, BYE, CANCEL, timeouts).
GetMembers locked only the context lookup. SelectTarget and CancelTarget
queue input messages, which became safe under peerlock with the previous
change.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Delete held peerlock while Stop joined the matching threads, which take
peerlock in their loops and while sending BYE, so deleting a running
context could hang (sceNetAdhocMatchingTerm and emulator shutdown go
through here).
Since the context is now still linked while its threads wind down, they
send BYE and clear the peer list as on an explicit Stop, instead of
skipping that when it was the only context.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The input thread held inputlock while sending, and the send functions take
peerlock, the reverse of the emulator thread's peerlock -> inputlock (via
send*Message). The event thread held eventlock while queueing callbacks,
which takes adhocEvtMtx, closing a cycle with the input thread
(peerlock -> eventlock in spawnLocalEvent) and __NetMatchingCallbacks
(adhocEvtMtx -> peerlock).
Detach messages under the lock and handle them after unlocking. The order
is unchanged: the event thread still pops one message at a time, and the
input thread still sends the whole stack as a batch, with anything linked
meanwhile left for the next pass (rather than overwritten, as a message
linked from within a send was before). The two copies of the input send
chain become sendInputMessages().
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The sibling/child loop didn't check requestedpeers, so a game passing a
buffer smaller than the member count got it overflowed. Also validate the
guest range before writing.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
An established parent could send repeated BIRTH packets that added
duplicate siblings beyond the matching context peer limit. The growing
list consumed memory and made peer lookups increasingly costly.
Serialize peer-list validation and insertion, ignore existing members,
and enforce maxpeers before allocating a sibling.
Matching packet handlers added untrusted payload lengths to fixed header
sizes before comparing them with the datagram length. Large values could
overflow and permit out-of-bounds reads. Compare against the remaining
packet size instead, and reject negative ACCEPT sibling counts.
With WLAN on and no server reachable, sceNetAdhocctlInit keeps its thread
waiting for the login. The load dropped the request, and the wait ended in
BUSY, which Init can't retry. Splinter Cell then ran its failure path with
a deleted event flag. Also stop freeing matching event buffers into the
restored allocator, and take the event lock when clearing.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>