fix(libSceNet): accept every sceNetMemoryAllocate flag as measured on a PS5 #9076
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9076"
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 orezraey on 2026-10-21T11:51:22Z.
What
On
main,sceNetMemoryAllocatetakes anint32_tsize and throws for flag 4 (the pool reserve bypass), since AnyPS5 has no network pool. In a payload process on a PS5 (firmware 13.60):sceNetMemoryAllocatecasemainbefore this PRstd::runtime_errorINT64_MIN(flags 0 or 2)sceNetErrnoLocunchangedFlag 4 only lets an allocation dip into the pool's reserve. AnyPS5 allocates from the guest heap and enforces no pool or reserve, so a flag 4 allocation succeeds exactly as one without it does, which is what the console shows away from the reserve. The probe's sizes do not tell an
int32_tsize from anint64_tone (INT64_MINhas a zero low half), so this PR keepsmain'sint32_t.The same probe measured the other small utilities whose debt entries said "unverified on hardware". They already matched:
sceNetGetIfNamegives the 10 names for indexes 0 to 9 and an empty string with errno 22 past them, with a 32-bit index.sceNetGetRandomwrites exactly 4 bytes and fails with 22 for a null output.sceNetGetSystemTimegives microseconds equal tosceKernelGetProcessTimeand ignores a null output.sceNetMemoryFree(NULL)does nothing.sceNetUsleeptakes a signed 32-bit count and fails with 22 when it is negative.sceNetEtherNtostr's results and errors.On every failure the console returns
0x80410100 | errnoand setssceNetErrnoLoc, and a successful call leaves it unchanged; AnyPS5'sfail()already does this. Results were the same before and aftersceNetInit(which returned 0).Debt:
mainalready removed thesceNetGetIfNameandsceNetGetSystemTimeentries and rewrotesceNetGetRandom's. This PR:main'ssceNetMemoryAllocate and sceNetMemoryFreeentry with the measured cases, the0xddbytes a non-zero-filled block holds on the console, what happens when the pool runs out, and why flag 4 no longer throws;sceNetUsleep: the[LIBNET] usleep <n>line the console prints for a negative count, and what an interrupted sleep returns.Tests:
guest_sce_netchecks:sceNetGetRandom;sceNetGetRandom;sceNetUsleep(INT32_MIN).Related: open PR #8204 implements
sceNetEtherStrton, which this PR does not touch. The same probe measured it, and the console does not validate its input; see the log.How the console was measured
libSceNet.sprxwas loaded withdlopen, and every function was taken from it withdlsym.~or 0x5a, andsceNetErrnoLocis preset to 90 before each call.sceKernelGetProcessTime.Console output (excerpt, copied unchanged)
Tested
Windows 11, WinLibs GCC 15.2.0, Release:
guest_sce_netpasses, also after the merge ofmaininda0ed3b5c3. Not tested on Linux or with a title.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 xXPBSXx on 2026-10-21T13:43:56Z.
Linux data point for
c5df2f4ce0: WSL2 Ubuntu 24.04 (virtualised kernel, not bare-metal Linux), GCC 13.3.0, Release,BUILD_TESTING=ON, PR head alone (not merged ontomain) (its merge-base is47fa6eecf).ctest -R '^guest_sce_net$'passes 3 of 3.core/libs/prx/libSceNet/Export.cpp; the PR's tests kept): fails (Subprocess aborted).Not tested: macOS, Windows, a title run.
AI-assisted (Claude Code).