feat(libSceHttp2): create WebSocket requests and answer them as a PS5 does before they connect #11470
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11470"
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 frankea on 2026-10-26T15:34:54Z.
What
Onimusha (PPSA27836) imports
sceHttp2WebSocketCreateRequest,sceHttp2WebSocketSetPingInterval,sceHttp2WebSocketSetPingTimeout,sceHttp2WebSocketSendTextMessageAsync,sceHttp2WebSocketSendDataMessageAsyncandsceHttp2WebSocketCloseAsync, and all six threw. They now answer as a PS5 does for a WebSocket request that has not connected, the only state this offline library has:sceHttp2WebSocketCreateRequestchecks its arguments, zeroes the receive buffer, checks the template and the URL, and returns a request id from the same registry assceHttp2CreateRequestWithURL, sosceHttp2DeleteRequestand template deletion handle it. Like that function onmain, the request takes the template's SSL context, capacity, version and settings, with method GET and the URL. The URL goes throughsceHttpUriParse, so libSceHttp2 now links libSceHttp; the scheme must be ws or wss.sceHttp2WebSocketSetPingIntervalandsceHttp2WebSocketSetPingTimeoutcheck their values and drop them (listed under Silent stubs).sceHttp2WebSocketCloseAsyncreturn 0x817B1065 (not connected) for a WebSocket request and 0x817B1100 for any other id. Before the id is looked up, a setoption, a null text or data, and a close reason without a status return 0x817B11FE.sceHttp2SendRequestAsyncthrows for every valid request onmain(its "asynchronous requests" debt entry), WebSocket requests included. On the PS5 the handshake fails offline like any other request, but the library also calls the request's error callback with the request id, from its own thread (measured below); the WebSocket debt entry records that.Measurement: PS5 on firmware 13.40, inside Gran Turismo 7 (PPSA01317), on 2026-10-26. A payload attached to the game with ptrace, created its own libnet pool, SSL context, Http2 context and template, called the game's
libSceHttp2exports, and deleted everything afterwards. Connections went to a closed port on a LAN host and to an unresolvable.invalidname.Second run on 2026-10-30, same console and harness, Gran Turismo 7 01.700.000: the three calls went to ids 0x7777 and -1, a plain request, and a WebSocket request that had not connected (the payload created both requests and deleted them afterwards). Each call ran three times on each id. All 144 calls returned the values below, and none returned the stack check's 0x817b1076.
The callback check used libc
srandas the error callback: after the wait, the game's nextrand()matched the firstrand()aftersrand(request id)and not the one after the seed set before the call.Read from
libSceHttp2.sprx(13.40, decrypted from the game's process; not shared) and not measured: null data and close callbacks are refused like the other two; the template is checked before the URL and a ping value before the request id; the sends do not check their flags, data size or async option before the connection check; the scheme comparison ignores case. The debt entry lists all but the first. The module tests a null text or data in the same branch as theoptioncheck (text0x27e80, data0x281e0, lookup0x4e90), so the order between those two cannot be observed. BunnyFl's read and native run of the 13.42 module found the same null text/data order that the second run measured.Tested
Windows 11 (build 26200), MinGW GCC (WinLibs 15.2) Release build with
BUILD_TESTING=ON, each test run three times (ctest --repeat until-fail:3).324c6ddfeonly changes the WebSocket debt entry, which now lists the null text/data order as measured. The code is that ofda8fbc6c4.da8fbc6c4,main9f748f4d8merged, no conflicts): the 13 ctest entries of the libSceHttp2, libSceHttp and libSceHttpCache test executables (ctest -R ^guest_http) pass 13/13, each run three times, and so doesmain9f748f4d8. Control, this head with the two send functions' old checks:guest_http2aborts on a failedRequire, and the other 12 pass. Control,main9f748f4d8with only this PR'sGuestHttp2.cpp:guest_http2aborts withsceHttp2WebSocketCreateRequest not implemented, and the other 12 pass.mainbb04a4f1e(headc1b635f8e). The merge takesmain's transport, request fields and asynchronous-request throws. It drops this PR's checks thatsceHttp2SendRequestAsyncthrows on a WebSocket request and completes on a plain one, since that is a valid path that is not implemented.guest_http2_teardown_tests, which buildsExport.cppitself, now links libSceHttp for the URL parse. The 13 ctest entries of the libSceHttp2 and libSceHttp test executables pass 13/13, each run three times, and so doesmainbb04a4f1e.mainca6e29e83(head7231c2a2d; no conflicts): the five ctest entries below pass 5/5, and so doesmainca6e29e83.guest_http2_testsgains a WebSocket section: every argument check, with the receive buffer untouched or zeroed as on the console; bogus template and null URL; http and empty URLs;ws:/bad, wss and upper-caseWSaccepted; both ping ranges; ids 0, -1, 0x7777, a plain request, the template and the context; the value checked before the id; a null text or data refused before the id, for every one of those ids and for a WebSocket request that has not connected; sends and closes before connecting; deletion directly and through its template. One existing line, which expectedsceHttp2WebSocketSetPingInterval(0, 1000000)to throw, now checks that a plain POST request gets 0x817B1100.guest_http2,guest_http,guest_http_response_header,guest_http_options,guest_memory_pool_stats):mainbf77a9e9c; the pushed commit differs from it only in the debt text): 5/5.mainbf77a9e9cwith only this PR'sGuestHttp2.cpp:guest_http2fails (sceHttp2WebSocketCreateRequest not implemented), the other four pass.mainbf77a9e9c: 5/5.tools/check_conventions.py --base origin/mainpasses.Overlap
No open PR implements these six functions. #9598, #10167, #10534, #10536 and #11145, which changed libSceHttp2 next to this branch, are in
mainnow, and this branch merges it.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-26T15:45:35Z.
Review: CHANGES_REQUESTED
I reviewed the WebSocket request and pre-connect behavior on exact head
3d7e2d2dcb43d0d1dd4a9a6833ad6a31b36dec2c. I found no concrete implementation defect in the request-handle ownership, URI scheme check, ping range validation, or pre-connect return paths. The PR reports a focused Windows suite repeated three times and a control run that fails only the new WebSocket case before the change. I did not independently run the Windows suite; hosted Linux/Windows product jobs are skipped.Before approval, please sync this branch to current
main(b0f1183ca12b) as required byCONTRIBUTING.md. The current branch is based onbf77a9e9cba4; the intervening commits do not touch the changed HTTP2 implementation/test/debt paths, and the merge-tree preview is clean. Current-main conventions andgit diff --checkpass.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T07:56:44Z.
Review: CHANGES_REQUESTED
Re-review — changes requested
Two items remain before this PR is ready.
Findings
[P2] Do not pin a valid, unimplemented handshake to a throw
In
GuestHttp2.cpp, the WebSocket request test expectssceHttp2SendRequestAsync(request, nullptr, 0, nullptr, &tag)to throw. This is a valid WebSocket request exercising the unimplemented handshake path. The production limitation and debt entry can remain, but the test should not require an unsupported path to throw. Please remove that assertion, as the reviewer requested, while retaining the supported pre-connect behavior tests.[P2] Integrate current main and rerun the focused tests
The exact head
7231c2a2d66b95fda621ee713c3f4e661182213fis based onca6e29e8363e3d10e9e6482bede3d19d6b9f0e6e. Currentmainis4c7d275bef89d309313d16bc2bc05d37a1b50be2; the merge preview conflicts inlibSceHttp2/CMakeLists.txt,Export.cpp,GuestHttp2.cpp, anddocs/dev/debt/libSceHttp2.md. Please integrate currentmain, resolve those conflicts, and rerun the five focused CTest entries on the updated base and change.Checks
git diff --check: clean.tools/check_conventions.py: passed against currentmain.ca6e29emerge.I did not run a local build or CTest.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T19:08:52Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The updated head merges cleanly and its focused build succeeds, but the implementation returns a measured “not connected” result for malformed send/close arguments whose PS5 validation behavior is not established in the report.
What I ran
Reviewed head
c1b635f8e49ffe98564f8a8b9c7b44b896f4bd5bagainst currentmainbb04a4f1ea0175e9e4f149f0359a764d62ff3296;git merge-tree --write-treeproducedc23e17d0b831298250c1bffdd0535f9c158be798without conflicts. Environment: Debian 12 x86_64, GCC 12.2.0, CMake 3.25.1; test binaries that require PS5 CPU features were run under QEMU TCG 7.2.22 (-cpu max).Results
c23e17d0b831298250c1bffdd0535f9c158be798.git diff --checkguest_http_testsguest_http_tests --uri-localeguest_http2_testsguest_http2_cookie_testsguest_http2_options_testsguest_http2_teardown_testsguest_http2CTestUnedited command output
Conventions:
Diff check: exit 0, no output.
Build command, final incremental build output:
QEMU test commands, in order:
Native CTest:
Negative control replaced this PR's
core/libs/prx/libSceHttp2/Export.cppwith currentmain's version, rebuiltguest_http2_tests, and ran it under QEMU. It aborted at the expected unimplemented WebSocket export with exit 134. I restored the exact PR file, rebuilt, and reran the test successfully.Negative control
Export.cppwithupstream/mainExport.cpp, then rebuiltguest_http2_tests.sceHttp2WebSocketCreateRequest not implemented(exit 134). Restored the PR source and the test passed.Findings
Blocking
Unverified argument validation in send/close calls. The PR tests valid text/data sends and close calls before connection, plus selected
optionand status/reason cases. The implementation ignorestext,data,dataSize,flags, andasyncOption, then returnsERROR_NOT_CONNECTEDfor any live WebSocket handle. The report does not establish how the PS5 handles null message pointers, invalid sizes/flags, or async options before the pre-connect result is returned. The repository requires unknown general behavior to throw and be recorded as debt. Please verify the validation order from the 13.40 module or a console measurement and add focused tests, or keep unverified input cases on the unimplemented/debt path.Non-blocking
main; the hosted Windows job is green. The hosted Linux and specialized jobs are skipped.Sources
c1b635f8e49ffe98564f8a8b9c7b44b896f4bd5bc1b635f8e49ffe98564f8a8b9c7b44b896f4bd5bbb04a4f1ea0175e9e4f149f0359a764d62ff3296bb04a4f1ea0175e9e4f149f0359a764d62ff3296Not verified
To get this to a good state
Please add evidence and tests for the argument-validation cases above, or preserve them as unimplemented behavior with a debt entry. I’ll rerun the same convention, diff, build, and focused HTTP/HTTP2 commands on the updated head.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-30T01:24:24Z.
Review: CHANGES_REQUESTED
Re-checked — new evidence, changes requested
The firmware-module report identifies a concrete validation-order mismatch in the two asynchronous send calls at head
c1b635f8e49ffe98564f8a8b9c7b44b896f4bd5b.Finding
For firmware 13.42, the author reports that null
textordatareturns0x817b11febefore request-ID lookup, including with IDs 1,0x7777, and -1; valid arguments with ID 1 reach the later0x817b1100request-type error. In the reviewed head,sceHttp2WebSocketSendTextMessageAsyncandsceHttp2WebSocketSendDataMessageAsyncignore those pointers and return based onIsWebSocket, so they do not preserve the measured null-argument precedence. Please reject nulltext/datawithERROR_INVALID_VALUEbeforeIsWebSocketand add regression cases that pin the error precedence. The relevant implementation is pinned to this head; the reported firmware-module evidence is from a native x86-64 run with imports stubbed, not a console run.Not verified
I did not independently reproduce the firmware-module result or rerun local tests for this follow-up. The latest hosted Windows job passes; Linux and specialized jobs are skipped for this PR.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-01T02:39:14Z.
Review: DISMISSED
Re-checked — new head, changes requested
The null
text/datavalidation was added, but unsupporteddataSize,flags, and async-option combinations still returnERROR_NOT_CONNECTEDwithout evidence that firmware validates them that way.What I ran
Reviewed head
324c6ddfe2e7439334de792f31110652e2f3bd2eagainst PR base9f748f4d8e36ce3714f3b95f3386316e110a9b22; the merge preview against currentmaincf79276fee2f042feb6a7c71d0d6a27e9cfe2592is clean. Environment: Debian Linux x86-64, Python 3.11.2; no local build or tests.Results
Findings
Blocking
Unmeasured validation before the pre-connect result. In
sceHttp2WebSocketSendDataMessageAsync,dataSize,flags, andasyncOptionare ignored;sceHttp2WebSocketSendTextMessageAsyncignoresflagsandasyncOption;sceHttp2WebSocketCloseAsyncalso ignoresflagsandasyncOption. For a live WebSocket handle, these calls returnERROR_NOT_CONNECTEDeven for combinations whose firmware validation order is not established in the report. The tests cover null message pointers,option, and selected status/reason cases, but do not pin these remaining inputs. Please add firmware/console evidence and tests for their precedence, or preserve the unverified input cases on the unimplemented/debt path.Non-blocking
The declared #14236 ordering is documented; no source overlap issue was found on this head.
Sources
Not verified
I did not independently reproduce the firmware measurements or run a local build/CTest. Linux and specialized hosted jobs were skipped.
To get this to a good state
Establish and test the validation order for
dataSize,flags, and async options, or leave those unmeasured combinations unimplemented with debt notes. I’ll rerun the same no-build checks and review the updated head.