AnyPS5/core/libs/prx/libkernel
milescoviello b8d71fc7f2 fix(libkernel): dissolve a UDP association on connect to AF_UNSPEC
connect() on a guest datagram socket checked the address family before
doing anything, so an AF_UNSPEC (null) address failed with EAFNOSUPPORT
and left the socket connected: getpeername() still reported the old
peer, send() without an address still went there, and datagrams from
any other sender were dropped by the host.

FreeBSD 11.4 disconnects a connected datagram socket first and only then
rejects the address. sys/kern/uipc_socket.c, soconnectat():

	 * If protocol is connection-based, can only connect once.
	 * Otherwise, if connected, try to disconnect first.  This allows
	 * user to disconnect by connecting to, e.g., a null address.
	 */
	if (so->so_state & (SS_ISCONNECTED|SS_ISCONNECTING) &&
	    ((so->so_proto->pr_flags & PR_CONNREQUIRED) ||
	    (error = sodisconnect(so)))) {

udp_disconnect() (sys/netinet/udp_usrreq.c) clears the peer and resets
only the local address, keeping the local port:

	in_pcbdisconnect(inp);
	inp->inp_laddr.s_addr = INADDR_ANY;

after which in_pcbconnect_setup() (sys/netinet/in_pcb.c) returns
EAFNOSUPPORT for the full-size address, as main already does. connect(2)
documents it: "Datagram sockets may dissolve the association by
connecting to an invalid address, such as a null address."

A connected internet datagram socket given an address whose family byte
is 0 is now disconnected on the host first (AF_UNSPEC on Linux, a zeroed
address on Windows) and the call then fails as before. Linux also drops
an ephemeral local port on that disconnect, so the port is bound again
on the wildcard address, which is what FreeBSD leaves. A host
failure during the disconnect is returned as the call's error. Stream
sockets keep the previous path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 19:33:20 +00:00
..
Aio/src fix(aio): use precise polling sleep 2026-10-11 18:48:18 -04:00
AppMetadata Merge pull request #3971 from arreina/fix/param-json-nesting 2026-10-13 02:33:55 +13:00
Apr fix(libkernel): report the target size of symbolic links on Windows 2026-10-12 13:48:56 +05:30
DirectMemory Merge pull request #4324 from abhinav29102005/feat/libkernel-memory-pool-commit-type 2026-10-12 23:53:02 +13:00
Equeue fix(libkernel): report a level-triggered equeue event once per wait 2026-10-11 11:28:34 +00:00
EventFlag/src feat(runtime): timed waits, sync primitive fixes, heap and RTC fixes, unattended-run switches 2026-09-26 19:00:39 -07:00
File Merge pull request #4536 from orishamir/fix/debugout-host-stderr 2026-10-13 07:31:53 +13:00
Module Merge pull request #4544 from poonasor/feat/libkernel-module-info2 2026-10-13 07:33:08 +13:00
Pthread Merge pull request #4350 from milescoviello/fix/once-reset-on-exit 2026-10-13 04:53:46 +13:00
Semaphore fix(libkernel): report the remaining time from sceKernelWaitSema 2026-10-11 20:09:33 +00:00
Socket fix(libkernel): dissolve a UDP association on connect to AF_UNSPEC 2026-10-12 19:33:20 +00:00
SyncOnAddress/src feat(libkernel): wake each listed address in _umtx_op UMTX_OP_NWAKE_PRIVATE 2026-10-11 17:48:06 +00:00
System Merge pull request #4536 from orishamir/fix/debugout-host-stderr 2026-10-13 07:31:53 +13:00
Time Merge pull request #4466 from babyhuey/feat/libkernel-socid-cpumode 2026-10-13 07:27:28 +13:00
CMakeLists.txt Merge pull request #4516 from Ondra97/codex/file-lock-lifetime 2026-10-13 07:30:48 +13:00
KernelErrors.hpp refactor(kernel): share SCE kernel error codes through KernelErrors.hpp 2026-09-27 13:32:28 +07:00
Unimplemented.cpp feat(libkernel): implement sceKernelGetCpuTemperature 2026-10-12 07:37:44 +02:00