fix(libSceHttp2): copy response metadata through guest memory #25731

Merged
malekaifa merged 2 commits from upstream-pr/25731 into main 2026-11-25 01:59:25 +00:00
malekaifa commented 2026-11-22 15:55:05 +00:00 (Migrated from github.com)

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


What

Route the remaining response-metadata output pairs in the HTTP/2 transport through guest-safe writes:

  • sceHttp2GetResponseContentLength (kind, content_length)
  • sceHttp2GetAllResponseHeaders (header, header_size)
  • sceHttp2GetAllTrailingHeaders (header, header_size)

The transport preserves the existing request/network/readiness/null ordering, preflights both non-null output objects as writable before publishing either value, and then stores them through Http2Guest::Store. An inaccessible guest output now returns the existing HTTP/2 null-pointer error 0x817B1225 instead of faulting the host, without partially changing the other output.

This is the sibling follow-up identified during review of #25663; it intentionally changes Transport.cpp and GuestHttp2Transport.cpp, so it does not overlap that PR's Export.cpp / guest-pointer test files.

Tested

Windows 11, UCRT MinGW GCC 16.2, Release, BUILD_TESTING=ON:

  • cmake --build C:/b/http2-metadata-guest-output-20261122 --target guest_http2_transport_tests --parallel 4 — passed
  • ctest --test-dir C:/b/http2-metadata-guest-output-20261122 -R '^guest_http2_transport$' --output-on-failure — 1/1 passed
  • negative control: restored only core/libs/prx/libSceHttp2/Transport.cpp to upstream while retaining the new assertions; guest_http2_transport crashed with access violation 0xc0000005, writing address 0x10; restoring the fix and rebuilding returned to 1/1 passing
  • after rebasing to current main (23b87724628c54f0f5ba28619d02856f3f762c25), rebuilt the target and reran the focused CTest — 1/1 passed
  • git diff --check HEAD^ HEAD — clean
  • python -I tools/check_conventions.py --base HEAD^ --head HEAD — passed

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; no stubs added
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source: none added
  • 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:5440680386 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25731). Originally posted by [malekaifa](https://github.com/malekaifa) on 2026-11-22T15:55:05Z. --- ### What Route the remaining response-metadata output pairs in the HTTP/2 transport through guest-safe writes: - `sceHttp2GetResponseContentLength` (`kind`, `content_length`) - `sceHttp2GetAllResponseHeaders` (`header`, `header_size`) - `sceHttp2GetAllTrailingHeaders` (`header`, `header_size`) The transport preserves the existing request/network/readiness/null ordering, preflights both non-null output objects as writable before publishing either value, and then stores them through `Http2Guest::Store`. An inaccessible guest output now returns the existing HTTP/2 null-pointer error `0x817B1225` instead of faulting the host, without partially changing the other output. This is the sibling follow-up identified during review of #25663; it intentionally changes `Transport.cpp` and `GuestHttp2Transport.cpp`, so it does not overlap that PR's `Export.cpp` / guest-pointer test files. ### Tested Windows 11, UCRT MinGW GCC 16.2, Release, `BUILD_TESTING=ON`: - `cmake --build C:/b/http2-metadata-guest-output-20261122 --target guest_http2_transport_tests --parallel 4` — passed - `ctest --test-dir C:/b/http2-metadata-guest-output-20261122 -R '^guest_http2_transport$' --output-on-failure` — 1/1 passed - negative control: restored only `core/libs/prx/libSceHttp2/Transport.cpp` to upstream while retaining the new assertions; `guest_http2_transport` crashed with access violation `0xc0000005`, writing address `0x10`; restoring the fix and rebuilding returned to 1/1 passing - after rebasing to current `main` (`23b87724628c54f0f5ba28619d02856f3f762c25`), rebuilt the target and reran the focused CTest — 1/1 passed - `git diff --check HEAD^ HEAD` — clean - `python -I tools/check_conventions.py --base HEAD^ --head HEAD` — passed ### Checklist - [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 and the licence notice of code adapted from upstream (see AGENTS.md) - [x] Unimplemented paths throw; no stubs added - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source: none added - [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 15:55:13 +00:00 (Migrated from github.com)

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

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:6013138774 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25731#pullrequestreview-6013138774). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-11-22T15:55:13Z. **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 15:58:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-22T15:58:47Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 52043d2aaf:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_http2_transport_tests built cleanly.
  • CTest (guest_http2_gzip_members, guest_http2_gzip_headers, guest_http2_transport, guest_http2_early_response, guest_http2_system_roots, guest_http2_http1_gzip, guest_http2_http1, guest_http2_http1_cookies, guest_http2_strip_gzip_headers, guest_http2_gzip_content_length, guest_http2_gzip_default, guest_http2_ssl_callbacks, guest_http2_redirects, guest_http2_auth_status):
    4/14 Test #4059: guest_http2_system_roots ..........   Passed    0.19 sec
    5/14 Test #4060: guest_http2_http1_gzip ............   Passed    6.85 sec
    6/14 Test #4057: guest_http2_transport .............   Passed   13.88 sec
    7/14 Test #4062: guest_http2_http1_cookies .........   Passed    0.58 sec
    8/14 Test #4063: guest_http2_strip_gzip_headers ....   Passed    3.63 sec
    9/14 Test #4064: guest_http2_gzip_content_length ...   Passed    3.59 sec
    10/14 Test #4065: guest_http2_gzip_default ..........   Passed    0.56 sec
    11/14 Test #4066: guest_http2_ssl_callbacks .........   Passed    2.12 sec
    12/14 Test #4061: guest_http2_http1 .................   Passed   13.92 sec
    13/14 Test #4069: guest_http2_auth_status ...........   Passed    3.07 sec
    14/14 Test #4067: guest_http2_redirects .............   Passed   12.12 sec
    100% tests passed, 0 tests failed out of 14
    
  • Negative control: with core/libs/prx/libSceHttp2/Transport.cpp reverted to main and the new tests kept, the suite fails:
    8/14 Test #4069: guest_http2_auth_status ...........   Passed    3.11 sec
    9/14 Test #4066: guest_http2_ssl_callbacks .........   Passed    2.18 sec
    10/14 Test #4056: guest_http2_gzip_headers ..........   Passed    0.93 sec
    11/14 Test #4058: guest_http2_early_response ........   Passed    0.76 sec
    12/14 Test #4062: guest_http2_http1_cookies .........   Passed    0.62 sec
    13/14 Test #4059: guest_http2_system_roots ..........***Exception: SegFault  0.49 sec
    14/14 Test #4065: guest_http2_gzip_default ..........   Passed    0.60 sec
    86% tests passed, 2 tests failed out of 14
    
    Restoring the change makes it pass again.
  • Code reading:
    • Verified sceHttp2GetResponseContentLength, sceHttp2GetAllResponseHeaders, and sceHttp2GetAllTrailingHeaders in core/libs/prx/libSceHttp2/Transport.cpp maintain state, networkResult, and null checks before preflighting memory with GuestWritable_nid_no_patch.
    • Verified atomic publication behavior: both output locations are validated via GuestWritable_nid_no_patch before Http2Guest::Store is called, preventing partial writes if either guest pointer is unmapped/inaccessible.
    • Verified error code correctness: inaccessible guest output returns 0x817B1225 (NullPointer) matching libSceHttp2 specification and conventions.
    • Verified LP64 vs LLP64 portability: std::size_t, std::uint64_t, int, and pointer types are matched accurately with Http2Guest::Store template deduction.
    • Verified unit tests in core/libs/tests/GuestHttp2Transport.cpp thoroughly test unmapped guest pointers (0x10) for both parameters across content length, response headers, and trailing headers while verifying preserved values.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6013154596 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25731#pullrequestreview-6013154596). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-22T15:58:47Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `52043d2aaf`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_http2_transport_tests` built cleanly. - **CTest** (`guest_http2_gzip_members`, `guest_http2_gzip_headers`, `guest_http2_transport`, `guest_http2_early_response`, `guest_http2_system_roots`, `guest_http2_http1_gzip`, `guest_http2_http1`, `guest_http2_http1_cookies`, `guest_http2_strip_gzip_headers`, `guest_http2_gzip_content_length`, `guest_http2_gzip_default`, `guest_http2_ssl_callbacks`, `guest_http2_redirects`, `guest_http2_auth_status`): ``` 4/14 Test #4059: guest_http2_system_roots .......... Passed 0.19 sec 5/14 Test #4060: guest_http2_http1_gzip ............ Passed 6.85 sec 6/14 Test #4057: guest_http2_transport ............. Passed 13.88 sec 7/14 Test #4062: guest_http2_http1_cookies ......... Passed 0.58 sec 8/14 Test #4063: guest_http2_strip_gzip_headers .... Passed 3.63 sec 9/14 Test #4064: guest_http2_gzip_content_length ... Passed 3.59 sec 10/14 Test #4065: guest_http2_gzip_default .......... Passed 0.56 sec 11/14 Test #4066: guest_http2_ssl_callbacks ......... Passed 2.12 sec 12/14 Test #4061: guest_http2_http1 ................. Passed 13.92 sec 13/14 Test #4069: guest_http2_auth_status ........... Passed 3.07 sec 14/14 Test #4067: guest_http2_redirects ............. Passed 12.12 sec 100% tests passed, 0 tests failed out of 14 ``` - **Negative control**: with `core/libs/prx/libSceHttp2/Transport.cpp` reverted to `main` and the new tests kept, the suite fails: ``` 8/14 Test #4069: guest_http2_auth_status ........... Passed 3.11 sec 9/14 Test #4066: guest_http2_ssl_callbacks ......... Passed 2.18 sec 10/14 Test #4056: guest_http2_gzip_headers .......... Passed 0.93 sec 11/14 Test #4058: guest_http2_early_response ........ Passed 0.76 sec 12/14 Test #4062: guest_http2_http1_cookies ......... Passed 0.62 sec 13/14 Test #4059: guest_http2_system_roots ..........***Exception: SegFault 0.49 sec 14/14 Test #4065: guest_http2_gzip_default .......... Passed 0.60 sec 86% tests passed, 2 tests failed out of 14 ``` Restoring the change makes it pass again. - **Code reading**: - Verified sceHttp2GetResponseContentLength, sceHttp2GetAllResponseHeaders, and sceHttp2GetAllTrailingHeaders in core/libs/prx/libSceHttp2/Transport.cpp maintain state, networkResult, and null checks before preflighting memory with GuestWritable_nid_no_patch. - Verified atomic publication behavior: both output locations are validated via GuestWritable_nid_no_patch before Http2Guest::Store is called, preventing partial writes if either guest pointer is unmapped/inaccessible. - Verified error code correctness: inaccessible guest output returns 0x817B1225 (NullPointer) matching libSceHttp2 specification and conventions. - Verified LP64 vs LLP64 portability: std::size_t, std::uint64_t, int, and pointer types are matched accurately with Http2Guest::Store template deduction. - Verified unit tests in core/libs/tests/GuestHttp2Transport.cpp thoroughly test unmapped guest pointers (0x10) for both parameters across content length, response headers, and trailing headers while verifying preserved values. Looks Good To Me
MarcZX10 commented 2026-11-22 16:20:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T16:20:45Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the checks reported by the author support the guest-safe output handling, and I found no verified blocking defect in the changed code.

What I ran

Reviewed head 52043d2aaf12baf24347ddc4de44467ac31bb3b3 against the prepared diff. No commands or tests were run.

Read core/libs/prx/libSceHttp2/Transport.cpp, core/libs/tests/GuestHttp2Transport.cpp, and the related GuestAccess.hpp, General.cpp, and Export.cpp ranges. Both changed files listed as reviewed in the manifest were read. No changed files were excluded.

Results

Check Result Note
Changed code review passed Output writes and readiness ordering inspected
Build and focused tests not run Results in the description are author reported
Negative control not run Author reports a crash with the prior implementation

Findings

Blocking

None.

Non-blocking

None.

Not verified

I did not run the build, focused CTest, negative control, diff check, or conventions check. The reported Windows 11 build and test results were not independently confirmed. I reviewed only the changed files and the related ranges listed above; no other repository files were reviewed.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6013237489 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25731#pullrequestreview-6013237489). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-22T16:20:45Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the checks reported by the author support the guest-safe output handling, and I found no verified blocking defect in the changed code. ## What I ran Reviewed head `52043d2aaf12baf24347ddc4de44467ac31bb3b3` against the prepared diff. No commands or tests were run. Read `core/libs/prx/libSceHttp2/Transport.cpp`, `core/libs/tests/GuestHttp2Transport.cpp`, and the related `GuestAccess.hpp`, `General.cpp`, and `Export.cpp` ranges. Both changed files listed as reviewed in the manifest were read. No changed files were excluded. ## Results | Check | Result | Note | |---|---|---| | Changed code review | passed | Output writes and readiness ordering inspected | | Build and focused tests | not run | Results in the description are author reported | | Negative control | not run | Author reports a crash with the prior implementation | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified I did not run the build, focused CTest, negative control, diff check, or conventions check. The reported Windows 11 build and test results were not independently confirmed. I reviewed only the changed files and the related ranges listed above; no other repository files were reviewed. ## To get this to a good state Nothing is required.
throny commented 2026-11-22 17:13:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by throny on 2026-11-22T17:13:53Z.

Review: APPROVED


Review: ✅ correct, I'd merge it

Basis: code read

Checked

  • On main, the content-length, headers and trailing-headers getters in Transport.cpp write *kind, *length, *header and *size through raw guest pointers, so an unmapped pointer faults the host.
  • Each getter now checks that both outputs are writable before storing either through Http2Guest::Store, and also checks the store results. Failure returns 0x817B1225, the ERROR_NULL_POINTER the Export.cpp getters use. Null still throws via Require, and values and ordering for valid inputs are unchanged.
  • The new assertions use an unmapped 0x10 for each output, check the other output is untouched, and fault on main.

Findings
none. Request::Status (Transport.cpp:1315-1321, sceHttp2GetStatusCode) still writes *status raw. Check that #25663 covers it.

Suggested action: merge

AI-assisted review (Claude Code) · head 52043d2aaf · base main 23b8772462

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6013450551 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25731#pullrequestreview-6013450551). Originally posted by [throny](https://github.com/throny) on 2026-11-22T17:13:53Z. **Review:** APPROVED --- ### Review: ✅ correct, I'd merge it **Basis:** code read **Checked** - On main, the content-length, headers and trailing-headers getters in `Transport.cpp` write `*kind`, `*length`, `*header` and `*size` through raw guest pointers, so an unmapped pointer faults the host. - Each getter now checks that both outputs are writable before storing either through `Http2Guest::Store`, and also checks the store results. Failure returns `0x817B1225`, the `ERROR_NULL_POINTER` the `Export.cpp` getters use. Null still throws via `Require`, and values and ordering for valid inputs are unchanged. - The new assertions use an unmapped `0x10` for each output, check the other output is untouched, and fault on main. **Findings** none. `Request::Status` (`Transport.cpp:1315-1321`, `sceHttp2GetStatusCode`) still writes `*status` raw. Check that #25663 covers it. **Suggested action:** merge <sub>AI-assisted review (Claude Code) · head `52043d2aaf` · base `main` `23b8772462`</sub>
MarcZX10 commented 2026-11-24 23:12:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-24T23:12:58Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the points below are optional.

What I ran

Reviewed head a845b7de185e586b6b597750c6fda92e224a2eb9. I read description.md, commits.md, manifest.json, diff.patch, the changed Transport.cpp and GuestHttp2Transport.cpp ranges, GuestAccess.hpp, and searched the HTTP/2 exports and guest-write call sites. No commands or tests were run.

Results

Check Result Note
Changed code review passed Both outputs are preflighted and guest-stored.
Build and focused tests not run Reported as passed by the author; not independently confirmed.
Negative control not run Author reports a crash with the upstream implementation.

Findings

Blocking

None.

Non-blocking

None.

Not verified

The repository reader did not expose the prepared review/files/ snapshots or files.json; I reviewed the changed code at the pinned head through the reader. I did not verify host build/test results, negative-control behavior, the full test file, or excluded files from files.json.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6048897157 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25731#pullrequestreview-6048897157). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-24T23:12:58Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the points below are optional. ## What I ran Reviewed head `a845b7de185e586b6b597750c6fda92e224a2eb9`. I read `description.md`, `commits.md`, `manifest.json`, `diff.patch`, the changed `Transport.cpp` and `GuestHttp2Transport.cpp` ranges, `GuestAccess.hpp`, and searched the HTTP/2 exports and guest-write call sites. No commands or tests were run. ## Results | Check | Result | Note | |---|---|---| | Changed code review | passed | Both outputs are preflighted and guest-stored. | | Build and focused tests | not run | Reported as passed by the author; not independently confirmed. | | Negative control | not run | Author reports a crash with the upstream implementation. | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified The repository reader did not expose the prepared `review/files/` snapshots or `files.json`; I reviewed the changed code at the pinned head through the reader. I did not verify host build/test results, negative-control behavior, the full test file, or excluded files from `files.json`. ## 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!25731
No description provided.