fix(libSceNet): return EFAULT from sceNetSendmsg and sceNetSendto for unreadable guest memory #11472
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11472"
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 ycbuzi on 2026-10-26T15:46:11Z.
What
sceNetSendmsgread the guest'sNetMsghdr, its iovec table and each payload directly, andsceNetSendtoread the destination address the same way. When any of those crossed into unreadable guest memory, the host process crashed with0xc0000005instead of the call failing withEFAULT, as reported with a reproduction in #11467 by @lgqdaxia.sceNetSendmsgsnapshots the header withGuestSocketReadGuest_nid_no_patch, then copies the iovec table (once the header'siov_lengthis in range) and each nonempty payload the same way. Any failed read returnsNET_EFAULTand sends nothing. The checks keepmain's order and results (EMSGSIZEfor an out-of-rangeiov_length,EFAULTfor a null table or base with a length). This matches FreeBSD'ssys_sendmsg, whichcopyins the header, thencopyiniovs the table, and fails withEFAULTwhen either copy or the payload'suiomovefaults.sceNetSendtocopies the destination address (up tosizeof(sockaddr_storage)bytes) the same way before parsing it, and returnsNET_EFAULTif it isn't readable, like FreeBSD'sgetsockaddrcopyin.sceNetSendmsgpasses itsnamethrough here, so this also covers @lgqdaxia's review point aboutmsg->name.sceNetSendtoalready failed cleanly withEFAULTfrom the hostsend, so it's unchanged. Other direct address reads (sceNetBind,sceNetConnect) aren't part of this.New
guest_net_sendmsg_fault_{payload,iovec,header,name}(core/libs/tests/GuestNetSendmsgFaults.cpp, built on the fixture in #11467). Each case maps three guest pages and makes one unreadable withsceKernelMprotect:payload: an iovec whose 16 bytes cross into the unreadable page;sceNetSendtowith the same range as the control.iovec: an iovec table that crosses into it.header: aNetMsghdrthat crosses into it.name: a destination address in it, throughsceNetSendmsgandsceNetSendto.Each case requires
0x8041010ewith errno 14, then sends a marker datagram and requires it to be the first one received, so nothing was sent by the failed call. A readablesceNetSendmsgbefore and after must still send 8 bytes.Tested
Windows 11 Home 10.0.26200, WinLibs GCC 15.2.0 r7 (MinGW-w64 UCRT), Release, on
mainc4669c9ca2.guest_net_buffer_validationand the 11net_dontwait_*tests pass, 3 of 3 (ctest --repeat until-fail:3).guest_net*andnet_*tests (58 entries) pass 2 of 2, exceptguest_netctl_apandguest_netctl_ap_dialog, whose executable I didn't build.main'slibSceNet/Export.cppand this PR's test, each of the four cases fails on its own withFATAL: unhandled exception 0xc0000005(payloadexits0xc0000409after the handler,iovec,headerandnameasSegFault).tools/check_conventions.py --base origin/mainpasses. It merges cleanly with #11037, the open PR that also touchessceNetSendto/sceNetSendmsg.main48c160c58b(head6e97111223): the four new tests pass 3 of 3, and the 56guest_net*andnet_*entries (without the twoguest_netctl_apones) pass 2 of 2.mainf5fefb982c(head38c3845149, 0 behind): the four new tests pass 3 of 3, all 61guest_net*andnet_*entries pass 2 of 2 (now including the twoguest_netctl_apones), andtools/check_conventions.py --base origin/mainpasses.main420b6a064e(head5f29795a8c, a clean merge;mainhas since moved 8 commits, none inlibSceNet): the four new tests pass 3 of 3, all 61guest_net*andnet_*entries pass 2 of 2, andtools/check_conventions.py --base origin/mainpasses.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T15:48:58Z.
Review: CHANGES_REQUESTED
The implementation and focused test cases address the reported unreadable-header, iovec, payload, and destination-address faults. I reviewed the exact head
5780180b94bbagainst livemainda89f18ea7c1; the merge preview is clean, conventions andgit diff --checkpass, and I found no additional code defect in the changed paths.I’m requesting one policy update before approval: this branch is still based on
c4669c9ca207, while CONTRIBUTING.md requires branches to stay up to date withmain. Please rebase or merge the currentmain. The hosted build/test jobs were skipped by path policy; I did not independently run the Windows test suite. The PR reports the new fault cases passing on Windows, with related network tests also passing.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T15:55:50Z.
Review: APPROVED
Re-reviewed exact head
5fee6793af3eafter the requested sync. The merge base is currentmainda89f18ea7c1; the sync changes only unrelated paths, leaving this PR's production and test files unchanged. The author reports the four new fault tests passing 3/3 and 56 related network tests 2/2 on this head. Conventions andgit diff --checkpass, and the merge previews against currentmainand overlapping #11037 are clean. I did not independently run the Windows suite; product jobs are skipped by path policy. The previous branch-freshness request is resolved. Approved.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T17:02:17Z.
Review: CHANGES_REQUESTED
The implementation covers the issue's unreadable payload case and also validates the header, iovec table and destination address. The author reports the four boundary tests and related network tests passing on Windows; current conventions and diff checks pass, and the merge preview against live main is clean. However, the branch is 144 commits behind current main (merge base
5bdda3661), so it fails the repository's current-main sync check. Please rebase onto current main and rerun the focused checks. I found no additional code defect in the changed paths.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T17:23:43Z.
Review: APPROVED
The requested sync is resolved: exact head
6e9711122350is 3 commits ahead and 0 behind currentupstream/main(48c160c58b58), with a clean merge. The author reports the four new fault-boundary tests passing 3/3 and 56 related network tests passing 2/2 on this head. I did not independently rerun the Windows suite. Current conventions, eligibility, labels, and report checks pass; product and relinker jobs are skipped by path policy. My earlier review found no code defect in the changed paths, so I approve this synchronized head.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T18:57:11Z.
Review: APPROVED
Reviewed head
6e97111223506513a54cd808eb9de456df50dd99. The guest-controlled header and iovec table are copied before inspection, each payload is copied throughGuestSocketReadGuest_nid_no_patch, and the destination address is copied before parsing. The four boundary cases assertNET_EFAULT/errno 14 and verify no datagram was sent; the readable send path is checked before and after the fault cases.The hosted eligibility, conventions, labels and report checks pass; the Linux and Windows product jobs were skipped by path policy. I did not rerun the Windows tests locally; the PR reports 3/3 runs of each new test on Windows after syncing to current
main, plus 2/2 of the 56 related network tests. AI-assisted: yes.Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-27T01:22:17Z.
Review: COMMENTED
First run on Linux, since the PR lists Linux as not tested and the product jobs were skipped by path policy.
Exact head
6e97111223506513a54cd808eb9de456df50dd99, merged onmaincb45ae2dd. Linux x86_64 (bare metal, not WSL), i7-8700, Ubuntu 26.04, kernel 7.0, GCC 15.2, glibc 2.43, CMake 4.2.3, Ninja, Release,BUILD_TESTING=ON, full build.guest_net_sendmsg_fault_*tests pass, 3 of 3 runs.guest_net*|guest_sce_net*tests pass, including bothguest_netctl_apones andguest_net_buffer_validation.mainwithout the PR: 1361/1361.core/libs/prx/libSceNet/Export.cppreverted tomain(new tests kept), all four (payload,iovec,header,name) crash with SIGSEGV. So the unreadable header, iovec table, payload and destination address also crash on Linux, and each test catches its case there.Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-27T09:41:04Z.
Review: CHANGES_REQUESTED
Follow-up on the current repository state: this PR is still based on
mainat48c160c58b, while the current upstream tip is801d5b9bc1(1,275 commits ahead). Bothcore/libs/prx/libSceNet/Export.cppand itsCMakeLists.txtchanged onmainsince that base, so the submitted change and test registration need to be rebased and rechecked against the current files before merge. The current PR remains mergeable, and I found no new defect in the send-side copy logic on the submitted head; this request is for the required current-main integration and retest. The reported Linux full-build evidence is useful: the exact submitted head passed the four fault cases 3/3, with a baseline control crashing all four. Please rerun the relevant focused tests and overlap/conventions checks on the rebased head.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T07:56:02Z.
Review: CHANGES_REQUESTED
Re-review — changes requested
The latest author report resolves the previous test request on the submitted head: four fault tests passed 3/3 and the related Windows network suite passed 2/2. My earlier source review found no defect in the guest-copy and
EFAULThandling.Current-main integration
The reviewed head is
38c384514945ec400fad63bfcf1ab63d78c94418, based onf5fefb982c53672bda23767304f97aac2eec5207. Currentmainis4c7d275bef89d309313d16bc2bc05d37a1b50be2. The current merge preview is clean, butmainhas since changed 145 lines incore/libs/prx/libSceNet/Export.cpp, which this PR also changes. CONTRIBUTING requires keeping the branch up to date withmain.Please integrate current
mainand rerun the fourguest_net_sendmsg_fault_*tests on the updated head. The existing independent Linux run is useful but predates the latest branch sync; please rerun the four tests on Linux as well so the current integrated copy path is covered on both platforms.Checks
git diff --check: passed against currentmain.tools/check_conventions.py: passed against currentmain.I found no new code defect; this request is for the required current-main integration and focused retest.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T21:27:33Z.
Review: CHANGES_REQUESTED
Re-checked — new head, changes requested
The Windows rerun covers head
5f29795a8c231f504c971aa7296acec256e4da71, but the available Linux fault-test run is on earlier head6e97111223506513a54cd808eb9de456df50dd99, before thelibSceNetsource changes merged into this head.What I ran
Compared exact PR head
5f29795a8c231f504c971aa7296acec256e4da71against livemain1a4d8fd28bafe20792aa9f99bd6e09ab53c43687on Linux x86-64 using Git and GitHub CLI. The merge preview is clean andgit diff --checkpasses. I also ran the repository convention check. I did not build or run tests locally.Results
main952fd6a238cc1ca9ae3f461b4ee3edbb20b3c72egit diff --checkcheck_conventions.py5f29795a8c6e97111223. TheExport.cppand CMake files differ between that head and5f29795a8c, so it does not verify the exact submitted integrationlibSceNetsource or CMake paths changed onmainafter the branch's420b6a064emerge; the live-main merge preview is cleanUnedited local output
git diff --checkproduced no output and exited successfully. The path comparison found no matchinglibSceNetpaths.Findings
Blocking
libSceNet/Export.cppand CMake changes relative to Linux-tested head6e97111223; the current-head Windows run does not exercise Linux guest-memory protection behavior. Please runguest_net_sendmsg_fault_{payload,iovec,header,name}on exact head5f29795a8c231f504c971aa7296acec256e4da71(and keep the existing baseline negative control), or obtain an exact-head Linux report from another tester. The existing Linux report remains useful for the earlier implementation.Non-blocking
Sources
1a4d8fd28bafe20792aa9f99bd6e09ab53c436875f29795a8c231f504c971aa7296acec256e4da716e97111223506513a54cd808eb9de456df50dd99Not verified
I did not build or run the Linux tests locally, verify the author's Windows logs independently, or test on macOS or console hardware. Linux product CI is skipped for this PR.
To get this to a good state
Run the four focused fault tests on exact head
5f29795a8c231f504c971aa7296acec256e4da71on Linux, include validation of the existing baseline control, and update the Tested section. I will recheck the exact new head and rerun the available non-build checks.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T09:28:23Z.
Review: APPROVED
Reviewed — looks good
The previously blocking Linux evidence gap is resolved: the four fault tests and the negative control were reported on exact head
5f29795a8c231f504c971aa7296acec256e4da71.What I ran
Reviewed exact head
5f29795a8c231f504c971aa7296acec256e4da71. GitHub reports PR base420b6a064eadaa7c5e50b080c7fad59c41150b4b; currentmainwasbd9039ca20905c71c0eb77a4a0f5194f0ef98838. The merge preview against currentmainwas clean. Environment: Linux x86_64, Python 3.11.2, Git 2.39.5; I did not build locally.Results
main.main.guest_net_sendmsg_fault_*tests passed 3/3 on the exact PR head, the 39-entry network test family passed, and revertingExport.cppmade all four fault tests crash.Selected unedited command output
Conventions:
Merge preview:
Negative control
EFAULTwithout sending a datagram.Export.cpptomainwhile retaining the tests.SIGSEGVon exact head; not independently run here.Findings
Blocking
None found. The requested Linux run is on the exact submitted head, and the current-main merge preview is clean.
Non-blocking
The current
maincontains later changes in the same module, limited here to inventory exports and IPv6 constants. I found no overlap with the reviewed send-side copy logic, so I am not asking for a rebase solely to update the branch.Sources
Not verified
I did not independently build or run tests. The Linux and Windows test results are reports from other contributors; macOS and console behavior were not verified. Linux product CI is skipped for this PR.