fix(libSceNet): reject nonpositive socket buffers #9544
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9544"
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 Queuse on 2026-10-22T01:12:22Z.
What
Reject nonpositive
SO_SNDBUFandSO_RCVBUFvalues withEINVALbefore changing the host socket or cached guest size. Previously zero/negative sizes reached the host, producing host-specific success or errors. This follows FreeBSD 11.4 sosetopt; PS5 validation and host buffer-limit differences remain in debt.Tested
Windows 11 x86-64, WinLibs GCC 15.2.0 UCRT, Release.
guest_net_buffer_validationfails on unchanged main and passes here. IPv4/IPv6 TCP/UDP tests reject zero, negative values and INT_MIN through both sceNet and kernel setters, verify guest and native buffer sizes stay unchanged, and check later valid sets, invalid pointers/lengths and descriptor precedence. The three new focused network tests pass together (3/3). Conventions and test-registration audit pass. No Linux, PS5 or title run.Maintenance validation (2026-10-22): merged main
b7d1d47a5fintof555d351c8. Conventions and whitespace checks pass. The focused target builds on Windows x86-64, MSYS2 UCRT64 GCC 16.2.0, Ninja, Release. Runtime validation is blocked: the host lacks required AVX2, FMA, BMI1/BMI2, LZCNT and MOVBE. Both guest_net_boolean_readback and the unchanged guest_sce_net fixture abort in the unchanged main startup guard before assertions. A collaborator needs to run the Build workflow for the refreshed head on a compatible runner. Earlier runtime results remain tied to their stated revisions. Overlap: #6879 only adds a system header to libSceNet, and #7201 changes macOS resolver handling; neither changes these socket options. The current #8362 head merges cleanly with #9544 and #9542 after its author moved the debt entry. Order with #6044 and #5836 is awaiting author confirmation; no agreement is assumed. Retain #9523 before #9542 and #9525 before #9543.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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T01:16:00Z.
Review: APPROVED
Reviewed the full diff against current main. The nonpositive guard runs after descriptor, level, pointer/length and option validation, before calling native setsockopt or updating the guest cached size; the test covers IPv4/IPv6, stream/datagram, sceNet and kernel paths, native/cached state preservation and valid follow-up calls. The overlap scanner found no current open-PR overlap. Hosted eligibility, conventions, intake, labels and report checks pass; product build jobs were skipped by path policy. Windows results and the focused 3/3 tests are reported by the author; I did not run a local build. Approved.
Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-22T04:33:56Z.
Review: COMMENTED
Linux run, since the description lists only Windows 11. On Linux the host accepts every nonpositive size, so the failure on
mainis a silent buffer change rather than an error.Machine: Linux x86_64, i7-8700, Ubuntu 26.04 (kernel 7.0.0-38), GCC 15.2, Release,
BUILD_TESTING=ON. Head4e7559ae9merged--no-commitontomainab347d144(clean).guest_net_buffer_validationpasses, 3 of 3 runs. The other 20 libSceNet tests (guest_sce_net,net_dontwait_*,net_blocking_send,net_epoll_lifetime) pass with it.Red→green: dropping only the new
value < 1line fromsceNetSetsockoptand keeping the test aborts at line 58 (sceNetSetsockopt(..., invalid) == 0x80410116): the call returns 0 instead ofEINVAL.Why it returns 0 on Linux: the host
setsockopt(SO_SNDBUF/SO_RCVBUF)never rejects a size. Measured on the same box with plain host sockets (IPv4 TCP/UDP, IPv6 TCP), after setting 32768 (read back as 65536):setsockoptSO_SNDBUFread backSO_RCVBUFread backINT_MINLinux takes the
intas unsigned and clamps it towmem_max/rmem_max(4 MiB here, doubled), so without this PR a guest that passes -1 on Linux gets the largest host buffer, and 0 gets the smallest. ThenativeBuffer() == originalNativechecks in the test cover exactly that case, so the test guards it on Linux too.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-22T11:33:18Z.
I compared this against open #8362 on the exact shared debt file. The implementations/tests touch different functionality, but both branches add their debt entry at the same insertion point in
docs/dev/debt/libSceNet.md; a pairwise three-way merge currently conflicts in that file. Please coordinate the merge order with #8362’s author and record the agreed order in the overlap note /Depends onif one PR must land first. The individual PR merges cleanly with currentmain, but its sync check is 1 ahead / 119 behind, so please also refresh it onto currentmainbefore merge.Imported from boykopovar/AnyPS5. Originally posted by Queuse on 2026-10-22T15:26:36Z.
@MarcZX10 I rechecked the updated #8362 head against this branch after merging current main (
b7d1d47a5). The pairwise three-way merge is clean, including the debt file. @MarrasFederico's moved entry removes the insertion conflict, so neither PR needs to wait for the other. Thanks for sorting that out.