fix(libSceNet): safely probe guest option and timeout pointers #24646
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/24646"
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 Sheikh-Bilal65 on 2026-11-20T21:45:28Z.
What
Drop
sceNetResolverConnectDestroy(merged via #25747) and keep checked guest copies acrossset_kernel_timeout,sceNetSetsockopt(includingIPV6_V6ONLYandSO_LINGERinputs), andsceNetGetsockopt(including checkedoptlenin/out aroundGuestSocketGetLinger_nid_no_patch), plus inaccessible-pointer tests (0x10,sceKernelMprotect(..., 0)guard page, and page-boundary straddle) across all covered socket options inGuestNetBufferValidation.cpp.Tested
python tools/debt_fold.py --checkpassed on Windows 11.python tools/check_conventions.py --base upstream/mainpassed on Windows 11.g++ -std=c++23 -fsyntax-onlypassed oncore/libs/prx/libSceNet/Export.cppandcore/libs/tests/GuestNetBufferValidation.cpp.ctestexecution deferred to CI (no CMake/Ninja toolchain installed locally).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)Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T00:58:21Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: fix the DHCP option parser to store the matched option’s value pointer, then rerun the focused tests.
What I ran
Reviewed head
cf62261e2ea9037d61b81b09ba528e4c2da8119d. I did not run commands or tests. I read the prepared diff, all three changed files, the DHCP option structure and its existing parser test, plus relevant socket and sync code.files.jsonwas not available in the review bundle.Results
files.jsonunavailableFindings
Blocking
core/libs/prx/libSceNet/InventoryExports.cpp:62: the result field is assigned from&options, which copies the address of the local pointer variable, rather than the matched guest buffer address. This makesoption.valueincorrect. The existingCheckDhcpOptionParsertest asserts it equalsoptions.data() + 5(and similarly checks the first match); this implementation does not satisfy that contract. Copy the pointer value itself to the guest field.Non-blocking
None.
Not verified
files.jsonwas unavailable, so exclusions beyond the supplied manifest could not be checked.To get this to a good state
Fix the DHCP output pointer and rerun
CheckDhcpOptionParserand the relevant build checks on the updated head.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T11:30:29Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: fix the regression in
sceNetGetsockoptfor sockets handled by the postfix path.What I ran
Reviewed head
02b4cd22c9e2dfbe4d8329a38cfb8220bd9d51dausingrepo_read.pyto read the prepared diff, manifest and changed source files. No tests or builds were run.Results
Findings
Blocking
core/libs/prx/libSceNet/Export.cpp:2213: For sockets absent fromg_socks,sceNetGetsockoptdelegates directly togetsockopt_nid_postfixbefore the newoptval/optlenchecks or guest-memory probes. The change therefore leaves this path able to dereference invalid guest pointers, contrary to the PR’s stated goal of safely probing those pointers. Validate and safely handle the guest pointers before delegating, or otherwise make the postfix path safe.Non-blocking
None.
Not verified
No tests, build, or Windows 11 checks were run. The PR author reports convention checks and unit tests on Windows 11; that report was not independently verified.
files.jsonwas not available through the reader. All three files listed in the manifest were read; no other files were reviewed.To get this to a good state
Make the postfix path safely validate and access
optvalandoptlen, then rerun the relevant unit tests and convention checks.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T12:06:04Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: fix the
sceNetGetsockoptbuffer validation so it validates only the bytes the selected implementation may write.What I ran
Reviewed head
c3c68a6888d6d502c59e4c25826ffbab766ee0d4. I read the prepared description, commit summary, manifest, diff, and all three changed files. I did not run tests or build commands. Repository source context was read throughrepo_read.py.Results
Findings
Blocking
core/libs/prx/libSceNet/Export.cpp:2204validatescurrentLenwritable bytes atoptvalbefore determining the option’s actual output size. For a recognized fixed-size option,writeOptlater writes onlymin(currentLen, sizeof(value))bytes (Export.cpp:2220-2222). This rejects otherwise valid calls when the advertised capacity extends beyond the writable guest range even though the actual result fits. Validate the actual write length for each path, or probe only the bytes that will be written.Non-blocking
None.
Not verified
GuestSocketGetLinger,GuestSocketGetUdpLinger, and IPv6 option helpers were not inspected internally.To get this to a good state
Adjust
sceNetGetsockoptto validate only the output range each branch writes, then add or update coverage for a capacity larger than the writable range when the actual returned option fits. Re-run the relevant unit tests and build on the new head.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T12:48:56Z.
Review: COMMENTED
Reviewed — comments
The change improves guest pointer probing in several paths, but
sceNetGetsockoptstill returnsNET_EINVALfor null pointers before its guest memory probes can reportNET_EFAULT.What I ran
Reviewed head
2b5efd14772355f77373ce8f86d02e10176c6f05usingrepo_read.pytargeted reads. No tests or builds were run.Results
Findings
Blocking
None.
Non-blocking
sceNetGetsockoptreturnsNET_EINVALwhenoptvaloroptlenis null, before attempting guest-memory access. The PR description says these pointers are safely probed to avoid guest memory faulting; invalid non-null pointers on some branches do returnNET_EFAULT, but null pointers do not. Consider whether the guest API expects these cases to map toNET_EFAULT. Evidence:core/libs/prx/libSceNet/Export.cpp:2201.Not verified
core/libs/prx/libSceNet/Export.cpp,core/libs/prx/libSceNet/InventoryExports.cpp, anddocs/dev/debt/changes/net-sockopt-sync-probes.md. No changed files were excluded according to the manifest.review/files.jsonwas not available through the reader, so its excluded-file list was not independently checked.To get this to a good state
Nothing is required. The optional point above is feedback for consideration.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T02:31:53Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the review did not find a verified defect in the inspected changes.
What I ran
Reviewed head
e3b87462e192010f397a88b2c89aa12390818bd8. I did not run commands or tests. I readdescription.md,commits.md,manifest.json, anddiff.patch, plus the changed code ranges incore/libs/prx/libSceNet/Export.cppand the complete added debt note. The repository reader was not run as a command; its provided read tools supplied the repository context.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
files.jsonwas unavailable through the reader, so I could not independently confirm its reviewed/excluded lists. The change adds checked guest-memory copies for selected socket-option and resolver paths. Other functions described by the debt note, including sync and DHCP option paths, were not changed in the supplied diff. Their behavior and the author's reported tests were not independently verified.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-27T13:59:19Z.
Review: COMMENTED
Actionable comments posted: 1
a11512f7-4056-496e-b8b7-42c16f7a1c02Reviewing files that changed from the base of the PR and between
84c7002018ande4c258a77d.core/libs/prx/libSceNet/Export.cppcore/libs/tests/GuestNetBufferValidation.cppdocs/dev/debt/changes/net-sockopt-sync-probes.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-27T14:12:02Z.
Review: APPROVED
Reviewed — looks good
The inspected changes safely copy the targeted socket option values and resolver flags, and the added tests cover inaccessible inputs and outputs; runtime checks were deferred to CI.
What I ran
Reviewed head
e4c258a77de103301b9d327c37606806d0fde6bafrom the prepared diff and pinned reader. No commands or tests were run by me.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
No runtime build or
ctestexecution was performed. No performance or physical console behavior was verified. The reader exposed all three files marked included in the manifest;files.jsonwas unavailable through the reader.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-28T10:57:19Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge:
sceNetSetsockoptstill passes guest pointers directly to helpers that read them, so the advertised pointer safety is incomplete.What I ran
Inspected the prepared diff and changed source files at head
b771d84a26d09ea18809a3ea9126c9d681c936da, plus the socket option helper implementations they call. I did not run build or tests.Results
Findings
Blocking
sceNetSetsockoptchanges only the integer and timeout input paths to checked guest copies. The IPv6 option path still passesoptvaltoGuestSocketSetIpv6LevelOption_nid_no_patch(Export.cpp:2184); that helper reads it throughReadValue(SocketOptions.cpp:578). The linger path likewise passesoptvaldirectly (Export.cpp:2242), andGuestSocketSetLinger_nid_no_patchforwards it toSetSocketLevelOption(SocketOptions.cpp:615), which reads the supplied guest value. An inaccessible pointer can therefore still fault in these handled option paths, contrary to this PR's stated goal. Route these inputs through checked guest copies or explicitly scope the change and its tests to the covered option cases.Non-blocking
None.
Not verified
files.jsonwas unavailable in the reader view.To get this to a good state
setsockoptpaths, and add corresponding coverage. Re-run the build and runtime tests on the updated head.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-28T11:23:02Z.
Review: COMMENTED
Reviewed — no blocking findings
The inspected socket-option paths use checked guest copies for the pointer reads and writes covered by this change; runtime build and
ctestwere deferred to CI.What I ran
0cdf386d7080835d0063e1133c30c89c946a318e; base ismain. No merged-preview check was run.Export.cpp.repo_read.pywas unavailable as a runnable command in this environment; targeted source reads used the provided reader.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
ctestwere not verified here.files.jsonwas not available through the provided reader, so the file list could not be independently checked against itsreviewedentries.g_socksdelegate to postfix socket functions; their guest-pointer safety was not reviewed.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T11:28:49Z.
Review: COMMENTED
Built the submitted network code and ran the exact
GuestNetBufferValidationfixture on Linux. It passed, including option and timeout data at the guest page boundary and theEFAULTchecks in both errno fields.AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-03T11:35:09Z.
Review: APPROVED
Reviewed — looks good
The reviewed changes safely copy the covered socket option and timeout pointers at the pinned head, with no verified blocking findings.
What I ran
Reviewed head
aae38d1a803e9c6ace620b42766bc4f5595415a1against basemain. I inspected the prepared diff and changed files, plus targeted socket option helper code throughrepo_read.py. No tests or prechecks were run; the author reports syntax checks and other prechecks, with runtime tests deferred to CI.Results
Negative control
Not run; no new test was executed with the change disabled.
Findings
Blocking
None.
Non-blocking
None.
Sources
Not verified
Runtime tests, CI results, Windows behavior, and physical-console behavior were not verified. All three files listed as reviewed in
files.jsonwere read at their changed sections;files.jsonlists no excluded files.To get this to a good state
Nothing is required.