fix(libkernel): fail sendto to port 0 from an unbound IPv4 datagram socket with EADDRNOTAVAIL #8499
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8499"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-20T13:57:16Z.
What
udp_outputhands the destination toin_pcbconnect_setupunless the socket is bound to a specific address and port and the destination is neitherINADDR_ANYnorINADDR_BROADCAST(in_pcbconnect_setupfails port 0 withEADDRNOTAVAIL).sendto, andsendmsgthrough it, sent such a datagram to the host. For anAF_INETdatagram socket that is not connected they now fail with 49 in those cases; a socket bound to a specific address and port can still send to port 0, as FreeBSD allows. This closes thesendto/sendmsgpart of the known gap in theconnectTechnical debt entry (#6884).AF_INET6is unchanged.Fixes #8498
Overlap:
git merge-treeagainst #7475 (sendto on a connected socket, open) has one conflict inUdp.cpp; against #7090, #8392, #8448, #8463, #8474, #8483, #8492, #7511, #7850, #7490 and #8312 it is clean. Whichever lands second rebases.pr_overlapwas not run.Tested
Windows 10 (19045), MinGW-w64 GCC 15.2.0, Release, on upstream/main
d0eb3b64c9+ this commit:guest_udp: the new case aborts without the change toUdp.cppand passes with it. It checks port 0 from an unbound socket (49, nothing queued), a datagram to the real port, port 0 from a socket bound to 127.0.0.1 (sent) and destination 0.0.0.0 port 0 from that socket (49).guest_datagram_recv,guest_sce_net,guest_socket_error,guest_socket_address_length,guest_pollandguest_tcppass.python tools/check_conventions.py --base upstream/main: passes.sendmsgdirectly,AF_INET6.Checklist
main; no other open PR implements the same functions (#7475 changessendtofor a connected socket).mdfiles or images added to the repositoryAI-assisted (Claude Code).
🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-20T14:26:21Z.
Thanks, the rule matches
udp_outputandin_pcbconnect_setup. One problem on Linux: the new test expects a socket bound to 127.0.0.1 to send to port 0 successfully, and that send goes to the host. Linux'sudp_sendmsgrejects destination port 0 withEINVAL(bound or not; checked on a 7.2 kernel and in an Ubuntu 24.04 container), soguest_udpwill fail on the Linux CI job. Could you either answer that case without the host on Linux (FreeBSD sends the datagram, and nothing receives on port 0, so returning the length matches what the guest sees), or keepEINVALon Linux, note it in the technical debt entry, and make that check platform-specific?Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-20T14:59:44Z.
Thanks, you're right: Linux's udp_sendmsg refuses port 0 with EINVAL. The send that FreeBSD accepts (socket bound to a specific address and port, destination not INADDR_ANY/INADDR_BROADCAST) is now answered in Udp.cpp without the host in
0bb7b02e9f: nothing can receive on port 0, so it returns the length on every platform. The Technical debt entry says so; guest_udp now also checks that nothing is queued afterwards. Re-tested on Windows 10 (guest_udp, guest_sce_net, guest_socket_address_length pass); I could not run Linux here, so the Linux CI is the check.AI-assisted (Claude Code).