fix(libkernel): return EISCONN from sendto with an address on a connected datagram socket #7475

Closed
Bonjourcestmatt wants to merge 2 commits from upstream-pr/7475 into main
Bonjourcestmatt commented 2026-10-18 08:52:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Bonjourcestmatt on 2026-10-18T08:52:34Z.


What

sendto (and sendmsg with a name) with a destination address on an already connected datagram socket now fails with EISCONN (56). FreeBSD 11.4 udp_output() does if (inp->inp_faddr.s_addr != INADDR_ANY) { error = EISCONN; goto release; } when a destination is supplied (read in sys/netinet/udp_usrreq.c, release/11.4.0). Linux and Winsock accept such a send, so the guest socket now checks getpeername first. GuestUdp.cpp pinned the old behaviour in two places (sendto and sendmsg with an address on the connected sender); they now send without an address, and a new check pins the EISCONN result.

Overlap: open PRs #7201 and #7332 (macOS port) touch the same file and #7332 adds a similar EISCONN test expectation, because macOS already returns EISCONN natively; this change is the Linux/Windows side and does not conflict with the macOS host path, though the test lines may need a trivial merge.

Tested

  • Windows 11, WinLibs GCC 15.2.0 UCRT, Release: guest_udp_tests and all 27 udp/socket ctest tests pass; the full non-GPU suite passes (755 of 755, skipped ones included); python tools/check_conventions.py --base origin/main passes.
  • I did not run the new check against main without the fix; it follows from the host accepting the send. The two old sendto/sendmsg lines in the test did fail with the fix, which shows the new check is active.
  • Not run: Linux and macOS, no console. Only the FreeBSD source was used as reference.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw; no silent stubs added
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4907732632 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7475). Originally posted by [Bonjourcestmatt](https://github.com/Bonjourcestmatt) on 2026-10-18T08:52:34Z. --- ### What `sendto` (and `sendmsg` with a name) with a destination address on an already connected datagram socket now fails with `EISCONN` (56). FreeBSD 11.4 `udp_output()` does `if (inp->inp_faddr.s_addr != INADDR_ANY) { error = EISCONN; goto release; }` when a destination is supplied (read in `sys/netinet/udp_usrreq.c`, release/11.4.0). Linux and Winsock accept such a send, so the guest socket now checks `getpeername` first. `GuestUdp.cpp` pinned the old behaviour in two places (`sendto` and `sendmsg` with an address on the connected sender); they now send without an address, and a new check pins the `EISCONN` result. Overlap: open PRs #7201 and #7332 (macOS port) touch the same file and #7332 adds a similar `EISCONN` test expectation, because macOS already returns `EISCONN` natively; this change is the Linux/Windows side and does not conflict with the macOS host path, though the test lines may need a trivial merge. ### Tested - Windows 11, WinLibs GCC 15.2.0 UCRT, Release: `guest_udp_tests` and all 27 udp/socket ctest tests pass; the full non-GPU suite passes (755 of 755, skipped ones included); `python tools/check_conventions.py --base origin/main` passes. - I did not run the new check against `main` without the fix; it follows from the host accepting the send. The two old `sendto`/`sendmsg` lines in the test did fail with the fix, which shows the new check is active. - Not run: Linux and macOS, no console. Only the FreeBSD source was used as reference. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw; no silent stubs added - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
jotitadev commented 2026-10-18 10:09:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-18T10:09:43Z.

Review: COMMENTED


Linux run, and the check against main that the description leaves open.

Machine: Linux x86_64, i7-8700, Ubuntu 26.04, GCC 15.2, Release, BUILD_TESTING=ON, full build.
Head 90c26b2e3 merged onto main 9caecfd2d (clean merge).

  • guest_udp passes, as do the other socket/network tests (ctest -R "udp|socket|^guest_sce_net$", 16 tests). On Linux getpeername() succeeds on the connected datagram socket, so sendto with an address returns -1 with errno 56, and send / sendmsg without one still deliver.
  • GuestUdp.cpp only, on main: guest_udp aborts at the new sendto(...) == -1 && errno == 56 line (I numbered the Require calls to find it), since the host accepts the send. So the new check fails without the fix.
  • Non-GPU suite (ctest -E "^agc|gpu|vulkan|video_out"): 712/712, same as main.

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5562495517 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7475#pullrequestreview-5562495517). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-18T10:09:43Z. **Review:** COMMENTED --- Linux run, and the check against `main` that the description leaves open. Machine: Linux x86_64, i7-8700, Ubuntu 26.04, GCC 15.2, Release, `BUILD_TESTING=ON`, full build. Head `90c26b2e3` merged onto `main` `9caecfd2d` (clean merge). - `guest_udp` passes, as do the other socket/network tests (`ctest -R "udp|socket|^guest_sce_net$"`, 16 tests). On Linux `getpeername()` succeeds on the connected datagram socket, so `sendto` with an address returns -1 with errno 56, and `send` / `sendmsg` without one still deliver. - `GuestUdp.cpp` only, on `main`: `guest_udp` aborts at the new `sendto(...) == -1 && errno == 56` line (I numbered the `Require` calls to find it), since the host accepts the send. So the new check fails without the fix. - Non-GPU suite (`ctest -E "^agc|gpu|vulkan|video_out"`): 712/712, same as `main`. Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
ycarogabriel-lgtm commented 2026-10-19 00:13:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ycarogabriel-lgtm on 2026-10-19T00:13:33Z.


Ran this on macOS, since it was not run there: Apple M1, macOS 26.6.2 (25G83), x86-64 build under Rosetta 2, AppleClang 21. Merged into the macOS host branch of #7332 (57bccfbfc, main at d71853cf2) together with #7121, #7475, #7490, #7507 and #7612; Release build.

  • guest_udp passes on macOS with this branch's version of the test.
  • XNU already returns EISCONN for sendto with an address on a connected UDP socket. That is why #7332 sends its addressed datagrams from a second, unconnected socket on macOS only.
  • With this change every host behaves the same, so that macOS-only workaround is no longer needed. The only conflict with #7332 is in GuestUdp.cpp, as you expected, and it resolves to your version of the file.

AI-assisted: yes (Claude Code). I ran the build and tests on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6256922781 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7475#issuecomment-6256922781). Originally posted by [ycarogabriel-lgtm](https://github.com/ycarogabriel-lgtm) on 2026-10-19T00:13:33Z. --- Ran this on macOS, since it was not run there: Apple M1, macOS 26.6.2 (25G83), x86-64 build under Rosetta 2, AppleClang 21. Merged into the macOS host branch of #7332 (`57bccfbfc`, `main` at `d71853cf2`) together with #7121, #7475, #7490, #7507 and #7612; `Release` build. - `guest_udp` passes on macOS with this branch's version of the test. - XNU already returns `EISCONN` for `sendto` with an address on a connected UDP socket. That is why #7332 sends its addressed datagrams from a second, unconnected socket on macOS only. - With this change every host behaves the same, so that macOS-only workaround is no longer needed. The only conflict with #7332 is in `GuestUdp.cpp`, as you expected, and it resolves to your version of the file. AI-assisted: yes (Claude Code). I ran the build and tests on my machine.
xXPBSXx commented 2026-10-21 02:49:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-21T02:49:20Z.


Independent Windows run of this PR (data only).

Environment: Windows 10 Pro 10.0.19045, Ryzen 7 5800X3D, WinLibs GCC 15.2.0 r7 (MinGW-w64 UCRT), Release, BUILD_TESTING=ON. Merge-tree of the PR head against main is clean. I built only guest_udp_tests; ctest -N -R guest_udp lists exactly one test.

Results (3 runs each):

  • PR head: guest_udp passes 3/3.
  • Baseline: I kept the PR's test and replaced only core/libs/prx/libkernel/Socket/src/Udp.cpp with the version from the PR's merge base (e5c2b3c325), then rebuilt. The test fails 3/3 (exit 0xc0000409, a failed Require). I restored the PR's file afterwards.

Not run: other platforms, the other tests in the same family, the full repository CTest, and any title or console run.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6306774726 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7475#issuecomment-6306774726). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-21T02:49:20Z. --- Independent Windows run of this PR (data only). **Environment:** Windows 10 Pro 10.0.19045, Ryzen 7 5800X3D, WinLibs GCC 15.2.0 r7 (MinGW-w64 UCRT), Release, BUILD_TESTING=ON. Merge-tree of the PR head against `main` is clean. I built only `guest_udp_tests`; `ctest -N -R guest_udp` lists exactly one test. **Results (3 runs each):** - PR head: `guest_udp` passes 3/3. - Baseline: I kept the PR's test and replaced only `core/libs/prx/libkernel/Socket/src/Udp.cpp` with the version from the PR's merge base (`e5c2b3c325`), then rebuilt. The test fails 3/3 (exit 0xc0000409, a failed Require). I restored the PR's file afterwards. **Not run:** other platforms, the other tests in the same family, the full repository CTest, and any title or console run. AI-assisted (Claude Code).

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!7475
No description provided.