fix(libSceHttp2): copy status output through guest memory #25663

Merged
malekaifa merged 1 commit from upstream-pr/25663 into main 2026-11-24 17:54:01 +00:00
malekaifa commented 2026-11-22 13:55:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by malekaifa on 2026-11-22T13:55:22Z.


What

sceHttp2GetStatusCode passed its guest output pointer directly into the transport, so a non-null inaccessible guest address could fault while publishing an otherwise valid status. Receive the transport status into a host local first, then publish it with the existing errno-preserving Http2Guest::Store helper. Existing invalid-id, null-pointer, transport-state and transport-error behavior is otherwise unchanged.

Tested

Windows, MSYS2 UCRT64 GCC 16.2.0, Release, BUILD_TESTING=ON.

  • Negative control with only the new regression assertion on main 24836104d0f845d52f858c5f043aac1641e2846e: guest_http2_guest_pointers access-violated on a write to guest address 0x10 and CTest exited 8.
  • After the fix, guest_http2_guest_pointer_tests built and guest_http2_guest_pointers passed 1/1.
  • After rebasing onto main c9bf4612bc60fe940d28f3208e879fd76cc0c054, guest_http2_guest_pointers, guest_http2, and all four guest_http2_offline_* tests passed 6/6.
  • python tools/check_conventions.py --base origin/main passed; git diff --check origin/main...HEAD passed.
  • python tools/pr_overlap.py --branch prime-f/http2-status-guest-output-20261122 --jobs 16 checked all 2,384 open PRs and reported No overlap with open pull requests.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5439654861 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25663). Originally posted by [malekaifa](https://github.com/malekaifa) on 2026-11-22T13:55:22Z. --- ### What `sceHttp2GetStatusCode` passed its guest output pointer directly into the transport, so a non-null inaccessible guest address could fault while publishing an otherwise valid status. Receive the transport status into a host local first, then publish it with the existing errno-preserving `Http2Guest::Store` helper. Existing invalid-id, null-pointer, transport-state and transport-error behavior is otherwise unchanged. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Windows, MSYS2 UCRT64 GCC 16.2.0, Release, `BUILD_TESTING=ON`. - Negative control with only the new regression assertion on main `24836104d0f845d52f858c5f043aac1641e2846e`: `guest_http2_guest_pointers` access-violated on a write to guest address `0x10` and CTest exited 8. - After the fix, `guest_http2_guest_pointer_tests` built and `guest_http2_guest_pointers` passed 1/1. - After rebasing onto main `c9bf4612bc60fe940d28f3208e879fd76cc0c054`, `guest_http2_guest_pointers`, `guest_http2`, and all four `guest_http2_offline_*` tests passed 6/6. - `python tools/check_conventions.py --base origin/main` passed; `git diff --check origin/main...HEAD` passed. - `python tools/pr_overlap.py --branch prime-f/http2-status-guest-output-20261122 --jobs 16` checked all 2,384 open PRs and reported `No overlap with open pull requests.` ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) and the licence notice of code adapted from upstream (see AGENTS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
copilot-pull-request-reviewer[bot] commented 2026-11-22 13:55:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-22T13:55:37Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6012589581 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25663#pullrequestreview-6012589581). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-11-22T13:55:37Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
PrivacyOnion commented 2026-11-22 13:59:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-22T13:59:04Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 36c8f92b34:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_http2_guest_pointer_tests built cleanly.
  • CTest (guest_http2_guest_pointers):
    1/1 Test #4047: guest_http2_guest_pointers .......   Passed    0.02 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceHttp2/Export.cpp reverted to main and the new tests kept, the suite fails:
    1/1 Test #4047: guest_http2_guest_pointers .......***Exception: SegFault  0.26 sec
    0% tests passed, 1 tests failed out of 1
    
    Restoring the change makes it pass again.
  • Code reading:
    • Verified sceHttp2GetStatusCode in core/libs/prx/libSceHttp2/Export.cpp:270-278 handles nullptr status_code by delegating to request->Status(status_code) to preserve the existing transport status return behavior.
    • Verified guest pointer copyout using Http2Guest::Store(status_code, status) returning ERROR_NULL_POINTER (0x817B1225) on inaccessible guest addresses without crashing.
    • Verified return codes on missing/invalid handle returning ERROR_INVALID_ID (0x817B1100) first before interacting with request or pointers.
    • Verified test regression coverage in core/libs/tests/GuestHttp2GuestPointers.cpp:65 checking RequireErrno(sceHttp2GetStatusCode(request, static_cast<int*>(unmapped)), nullPointer).
    • Verified compliance with AGENTS.md: no illegal comments, no fake stubs, no special-cased game IDs, builds and tests clean.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6012601838 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25663#pullrequestreview-6012601838). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-22T13:59:04Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `36c8f92b34`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_http2_guest_pointer_tests` built cleanly. - **CTest** (`guest_http2_guest_pointers`): ``` 1/1 Test #4047: guest_http2_guest_pointers ....... Passed 0.02 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceHttp2/Export.cpp` reverted to `main` and the new tests kept, the suite fails: ``` 1/1 Test #4047: guest_http2_guest_pointers .......***Exception: SegFault 0.26 sec 0% tests passed, 1 tests failed out of 1 ``` Restoring the change makes it pass again. - **Code reading**: - Verified `sceHttp2GetStatusCode` in core/libs/prx/libSceHttp2/Export.cpp:270-278 handles nullptr `status_code` by delegating to `request->Status(status_code)` to preserve the existing transport status return behavior. - Verified guest pointer copyout using `Http2Guest::Store(status_code, status)` returning `ERROR_NULL_POINTER` (0x817B1225) on inaccessible guest addresses without crashing. - Verified return codes on missing/invalid handle returning `ERROR_INVALID_ID` (0x817B1100) first before interacting with `request` or pointers. - Verified test regression coverage in core/libs/tests/GuestHttp2GuestPointers.cpp:65 checking `RequireErrno(sceHttp2GetStatusCode(request, static_cast<int*>(unmapped)), nullPointer)`. - Verified compliance with AGENTS.md: no illegal comments, no fake stubs, no special-cased game IDs, builds and tests clean. Looks Good To Me
throny commented 2026-11-22 14:04:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by throny on 2026-11-22T14:04:51Z.

Review: APPROVED


Review: ✅ correct; three sibling exports still write through guest pointers

Basis: code read · head 36c8f92b34

Checked

  • On main, Request::Status writes *status straight through the guest pointer (Transport.cpp:1314, :1318), so an unmapped or read-only non-null pointer faults the host. Copying through Http2Guest::Store matches the sibling exports (Export.cpp:432, 596, 604, 611, 614). ERROR_INVALID_ID is still checked first, and a null output still reaches Status unchanged.
  • The new line in GuestHttp2GuestPointers.cpp faults on main; existing callers in GuestHttp2.cpp / GuestHttp2Transport.cpp use valid pointers.

Findings

  1. Same bug class, not covered here: Request::ContentLength (*kind, *length, Transport.cpp:1328-1329), Request::Headers and Request::TrailingHeaders (*header, *size, :1343-1348) still write straight through guest pointers for sceHttp2GetResponseContentLength and the two header exports. A follow-up would close them.
  2. 0x817B1225 for an unwritable output follows this file's convention; the only console-backed instance in docs/dev/debt/libSceHttp2.md is sceHttp2GetCookieBox's null case, so for this export it's inferred. Worth a word in the description.

Suggested action: merge.

AI-assisted review (Claude Code) · head 36c8f92b34 · base main 337a948bf1

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6012623642 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25663#pullrequestreview-6012623642). Originally posted by [throny](https://github.com/throny) on 2026-11-22T14:04:51Z. **Review:** APPROVED --- ### Review: ✅ correct; three sibling exports still write through guest pointers **Basis:** code read · head `36c8f92b34` **Checked** - On `main`, `Request::Status` writes `*status` straight through the guest pointer (`Transport.cpp:1314`, `:1318`), so an unmapped or read-only non-null pointer faults the host. Copying through `Http2Guest::Store` matches the sibling exports (`Export.cpp:432`, `596`, `604`, `611`, `614`). `ERROR_INVALID_ID` is still checked first, and a null output still reaches `Status` unchanged. - The new line in `GuestHttp2GuestPointers.cpp` faults on `main`; existing callers in `GuestHttp2.cpp` / `GuestHttp2Transport.cpp` use valid pointers. **Findings** 1. Same bug class, not covered here: `Request::ContentLength` (`*kind`, `*length`, `Transport.cpp:1328-1329`), `Request::Headers` and `Request::TrailingHeaders` (`*header`, `*size`, `:1343-1348`) still write straight through guest pointers for `sceHttp2GetResponseContentLength` and the two header exports. A follow-up would close them. 2. `0x817B1225` for an unwritable output follows this file's convention; the only console-backed instance in `docs/dev/debt/libSceHttp2.md` is `sceHttp2GetCookieBox`'s null case, so for this export it's inferred. Worth a word in the description. **Suggested action:** merge. <sub>AI-assisted review (Claude Code) · head `36c8f92b34` · base `main` `337a948bf1`</sub>
MarcZX10 commented 2026-11-22 14:18:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T14:18:43Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; it stages the status in host memory and uses the guest-memory helper to publish it, with a regression assertion for an unmapped destination.

What I ran

Reviewed head 36c8f92b3466a8f22d7135e729a36ec4e0cbee89. I read description.md, commits.md, manifest.json, diff.patch, and both changed files plus the targeted GuestAccess.hpp, Transport.cpp, and Transport.hpp context. All files listed under reviewed in files.json were read. I did not run commands or tests; the described Windows test results are author-reported.

Results

Check Result Note
Code review passed Both changed files read
Tests not run Results in description are author-reported
Other changed files not applicable None excluded

Findings

Blocking

None.

Non-blocking

None.

Not verified

I did not run the build, tests, convention check, diff check, or PR overlap check. The review bundle listed two changed files and included both; no excluded files were reported.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6012688583 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25663#pullrequestreview-6012688583). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-22T14:18:43Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; it stages the status in host memory and uses the guest-memory helper to publish it, with a regression assertion for an unmapped destination. ## What I ran Reviewed head `36c8f92b3466a8f22d7135e729a36ec4e0cbee89`. I read `description.md`, `commits.md`, `manifest.json`, `diff.patch`, and both changed files plus the targeted `GuestAccess.hpp`, `Transport.cpp`, and `Transport.hpp` context. All files listed under `reviewed` in `files.json` were read. I did not run commands or tests; the described Windows test results are author-reported. ## Results | Check | Result | Note | |---|---|---| | Code review | passed | Both changed files read | | Tests | not run | Results in description are author-reported | | Other changed files | not applicable | None excluded | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified I did not run the build, tests, convention check, diff check, or PR overlap check. The review bundle listed two changed files and included both; no excluded files were reported. ## To get this to a good state Nothing is required.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!25663
No description provided.