fix(libSceNet): guard recvmsg guest outputs #5930

Merged
Ondra97 merged 1 commit from upstream-pr/5930 into main 2026-10-18 14:45:15 +00:00
Ondra97 commented 2026-10-14 16:15:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Ondra97 on 2026-10-14T16:15:15Z.


What

sceNetRecvmsg copied received bytes into guest vectors and updated the message header without the host-write guards used by the other socket receive functions. On Windows, tracked mappings of shared direct memory can be armed read-only. The scatter copy and header update can then fault, and a logically read-only output faults instead of returning EFAULT.

Keep the existing GuestArena::HostWrite guards for the message and each nonempty vector through receive and scatter delivery. Refuse a read-only output before consuming the queued data. If a later vector is refused, earlier guards are released automatically.

Extend the existing watched-socket fixture for sceNetRecvmsg over UDP and TCP, using three vectors including an empty one. It checks boundaries, short receives, peek, unchanged errno, error cleanup, read-only vectors and headers, and collection during a blocking receive.

Tested

Windows 11 Pro 10.0.26300, supported WinLibs GCC 15.2.0, Release, based on main e34c47921.

  • The two added UDP/TCP cases both fail with access violations on main. After guarding the vectors, the added read-only message check still faults at its flags field; guarding the message header resolves that too.
  • Full default Windows build passed after rebase. All 19 related CTest cases passed in 2.50 s: the 14 watched-socket cases, four datagram receive cases and guest_sce_net.
  • Conventions and whitespace checks passed. Reviewed shared changes from #5836, #5536, #5141, #4933 and #4924; none implements these receive-message guards. Linux and retail-title execution were not run locally. No performance claim.

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 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
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes, Codex

Full platform runtime CI requires a write-access collaborator to dispatch it under repository policy.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4860866398 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5930). Originally posted by [Ondra97](https://github.com/Ondra97) on 2026-10-14T16:15:15Z. --- ### What `sceNetRecvmsg` copied received bytes into guest vectors and updated the message header without the host-write guards used by the other socket receive functions. On Windows, tracked mappings of shared direct memory can be armed read-only. The scatter copy and header update can then fault, and a logically read-only output faults instead of returning `EFAULT`. Keep the existing `GuestArena::HostWrite` guards for the message and each nonempty vector through receive and scatter delivery. Refuse a read-only output before consuming the queued data. If a later vector is refused, earlier guards are released automatically. Extend the existing watched-socket fixture for `sceNetRecvmsg` over UDP and TCP, using three vectors including an empty one. It checks boundaries, short receives, peek, unchanged errno, error cleanup, read-only vectors and headers, and collection during a blocking receive. ### Tested Windows 11 Pro 10.0.26300, supported WinLibs GCC 15.2.0, Release, based on main `e34c47921`. - The two added UDP/TCP cases both fail with access violations on main. After guarding the vectors, the added read-only message check still faults at its flags field; guarding the message header resolves that too. - Full default Windows build passed after rebase. All 19 related CTest cases passed in 2.50 s: the 14 watched-socket cases, four datagram receive cases and `guest_sce_net`. - Conventions and whitespace checks passed. Reviewed shared changes from #5836, #5536, #5141, #4933 and #4924; none implements these receive-message guards. Linux and retail-title execution were not run locally. No performance claim. ### 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 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] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes, Codex Full platform runtime CI requires a write-access collaborator to dispatch it under repository policy.
github-actions[bot] commented 2026-10-15 12:11:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:11:50Z.


Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 5836 core/libs/prx/libSceNet/CMakeLists.txt
core/libs/prx/libSceNet/Export.cpp
PR 6044 core/libs/prx/libSceNet/CMakeLists.txt
core/libs/tests/GuestSocketHostWrite.cpp
PR 7201 core/libs/prx/libSceNet/Export.cpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6191743384 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5930#issuecomment-6191743384). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-15T12:11:50Z. --- <!-- pr-overlap --> Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 5836](https://www.github.com/boykopovar/AnyPS5/pull/5836) | `core/libs/prx/libSceNet/CMakeLists.txt`<br>`core/libs/prx/libSceNet/Export.cpp` | | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/prx/libSceNet/CMakeLists.txt`<br>`core/libs/tests/GuestSocketHostWrite.cpp` | | [PR 7201](https://www.github.com/boykopovar/AnyPS5/pull/7201) | `core/libs/prx/libSceNet/Export.cpp` |
adriadam10 commented 2026-10-16 18:50:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-16T18:50:10Z.


Checked the diff: the HostWrite guards on the message and each non-empty iovec are opened before the queued data is consumed, after message_length has validated null/iov_length/null bases, and a refused later vector releases the earlier guards. The new sceNetRecvmsg cases extend the existing watched-socket fixture. Linux build and the scoped ctest (libs + libSceNet, 37 tests) are green; the new cases are Windows-only, so they will run in the Windows job. Merging once that is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6222472116 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5930#issuecomment-6222472116). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-16T18:50:10Z. --- Checked the diff: the `HostWrite` guards on the message and each non-empty iovec are opened before the queued data is consumed, after `message_length` has validated null/`iov_length`/null bases, and a refused later vector releases the earlier guards. The new `sceNetRecvmsg` cases extend the existing watched-socket fixture. Linux build and the scoped ctest (libs + libSceNet, 37 tests) are green; the new cases are Windows-only, so they will run in the Windows job. Merging once that is green.
adriadam10 commented 2026-10-16 20:29:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-16T20:29:37Z.


Re-checked against current main: the HostWrite guards on the message and each non-empty iovec are opened before the queued data is consumed, after message_length has validated null/iov_length/null bases, and a refused later vector releases the earlier guards. The new sceNetRecvmsg cases extend the existing watched-socket fixture. Linux build and the scoped ctest (libs + libSceNet, 39 tests) are green; the new cases are Windows-only, so they will run in the Windows job. Merging once that is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6224111422 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5930#issuecomment-6224111422). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-16T20:29:37Z. --- Re-checked against current `main`: the `HostWrite` guards on the message and each non-empty iovec are opened before the queued data is consumed, after `message_length` has validated null/`iov_length`/null bases, and a refused later vector releases the earlier guards. The new `sceNetRecvmsg` cases extend the existing watched-socket fixture. Linux build and the scoped ctest (libs + libSceNet, 39 tests) are green; the new cases are Windows-only, so they will run in the Windows job. Merging once that is green.
adriadam10 commented 2026-10-16 23:28:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-16T23:28:51Z.


Re-checked against current main (after #5928): the HostWrite guards on the message and each non-empty iovec are opened before the queued data is consumed, after message_length has validated the vectors, and a refused later vector releases the earlier guards. The new sceNetRecvmsg cases extend the existing watched-socket fixture. Linux build and ctest are green for libSceNet (guest_sce_net); the new cases are Windows-only, so they will run in the Windows job. Merging once that is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6226607966 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5930#issuecomment-6226607966). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-16T23:28:51Z. --- Re-checked against current `main` (after #5928): the `HostWrite` guards on the message and each non-empty iovec are opened before the queued data is consumed, after `message_length` has validated the vectors, and a refused later vector releases the earlier guards. The new `sceNetRecvmsg` cases extend the existing watched-socket fixture. Linux build and ctest are green for libSceNet (`guest_sce_net`); the new cases are Windows-only, so they will run in the Windows job. Merging once that is green.
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!5930
No description provided.