Repository navigation
fix(libSceNet): reject nonpositive socket buffers - #9544
Conversation
MarcZX10
left a comment
There was a problem hiding this comment.
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.
|
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.
|
jotitadev
left a comment
There was a problem hiding this comment.
Linux run, since the description lists only Windows 11. On Linux the host accepts every nonpositive size, so the failure on main is 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. Head 4e7559ae9 merged --no-commit onto main ab347d144 (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):value setsockoptSO_SNDBUFread backSO_RCVBUFread back0 ok 4608 2304 -1, -4096, INT_MINok 8388608 8388608 Linux 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.
|
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 |
|
@MarcZX10 I rechecked the updated #8362 head against this branch after merging current main ( |
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)