fix(libcurl): read curl_formget nodes through checked guest copies #27587

Open
Ducengarth wants to merge 1 commit from upstream-pr/27587 into main
Ducengarth commented 2026-11-26 18:49:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Ducengarth on 2026-11-26T18:49:30Z.


What

curl_formget read each guest curl_httppost node by dereferencing guest memory, so a node pointer the guest cannot read crashed the process. HostFormFromGuest now copies each node through GuestCopyIn_nid_no_patch and throws through NotImplementedAt_nid_no_patch when the copy fails, as curl_formadd does for its unreadable guest pointers. The curl_formget debt entry, which is still in the pending fragment feat-libcurl-formget.md, now describes the checked copy.

Tested

Ubuntu 24.04 (WSL2), guest_curl_SlistMime_tests passes. Its new checks give curl_formget an unreadable next link and an unreadable first node, and both now throw instead of crashing.

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

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Form serialization now reports an error when it encounters an unreadable form entry, including entries reached while following linked form data. This prevents the operation from continuing with invalid data and makes failures more consistent.
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5515531392 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27587). Originally posted by [Ducengarth](https://github.com/Ducengarth) on 2026-11-26T18:49:30Z. --- ### What `curl_formget` read each guest `curl_httppost` node by dereferencing guest memory, so a node pointer the guest cannot read crashed the process. `HostFormFromGuest` now copies each node through `GuestCopyIn_nid_no_patch` and throws through `NotImplementedAt_nid_no_patch` when the copy fails, as `curl_formadd` does for its unreadable guest pointers. The `curl_formget` debt entry, which is still in the pending fragment `feat-libcurl-formget.md`, now describes the checked copy. ### Tested Ubuntu 24.04 (WSL2), `guest_curl_SlistMime_tests` passes. Its new checks give `curl_formget` an unreadable `next` link and an unreadable first node, and both now throw instead of crashing. ### 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 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit - **Bug Fixes** - Form serialization now reports an error when it encounters an unreadable form entry, including entries reached while following linked form data. This prevents the operation from continuing with invalid data and makes failures more consistent. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
MarcZX10 commented 2026-11-26 19:06:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-26T19:06:12Z.

Review: APPROVED


Reviewed — looks good

The change safely copies each form node from guest memory before reading its fields; the two added unreadable-pointer cases verify that failure throws.

What I ran

Reviewed head bcb4e977e1fa527fd44b82be09dd524c5beee293 against the prepared diff. No tests or builds were run; the test result in the PR description is author-reported.

Results

Check Result Note
Diff and changed code passed Read all three changed files
Build and tests not run Author reports the guest curl test passes

Findings

Blocking

None.

Non-blocking

None.

Not verified

No build or tests were run. Reviewed all files listed as changed in the manifest: core/libs/prx/libcurl/Export.cpp, core/libs/prx/libcurl/tests/CurlSlistMime.cpp, and docs/dev/debt/changes/feat-libcurl-formget.md. No files were excluded by the provided manifest; files.json was not available in the review bundle. No console behavior was verified.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6079314379 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27587#pullrequestreview-6079314379). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-26T19:06:12Z. **Review:** APPROVED --- # Reviewed — looks good The change safely copies each form node from guest memory before reading its fields; the two added unreadable-pointer cases verify that failure throws. ## What I ran Reviewed head `bcb4e977e1fa527fd44b82be09dd524c5beee293` against the prepared diff. No tests or builds were run; the test result in the PR description is author-reported. ## Results | Check | Result | Note | |---|---|---| | Diff and changed code | passed | Read all three changed files | | Build and tests | not run | Author reports the guest curl test passes | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified No build or tests were run. Reviewed all files listed as changed in the manifest: `core/libs/prx/libcurl/Export.cpp`, `core/libs/prx/libcurl/tests/CurlSlistMime.cpp`, and `docs/dev/debt/changes/feat-libcurl-formget.md`. No files were excluded by the provided manifest; `files.json` was not available in the review bundle. No console behavior was verified. ## To get this to a good state Nothing is required.
Plyxen commented 2026-11-27 03:11:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-11-27T03:11:21Z.

Review: APPROVED


Checked head bcb4e977e1. I applied it to main ad7582bad4 together with #27588 and #27585, which touch different files. On Windows 11 with WinLibs GCC 15.2 (Release), tools/check_conventions.py --head on each head and tools/debt_fold.py --check passed, the build succeeded, and all 4,930 CPU tests passed (I left out the GPU tests).

guest_curl_slistmime passed. With main's libcurl/Export.cpp and the new checks, it fails.

HostFormFromGuest now copies each guest curl_httppost node through GuestCopyIn_nid_no_patch before reading it, so a bad more or next pointer, or a bad first node, throws through NotImplementedAt_nid_no_patch instead of being read directly. The host node still borrows the guest's string and buffer pointers, as before, and the debt fragment says so.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6082969406 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27587#pullrequestreview-6082969406). Originally posted by [Plyxen](https://github.com/Plyxen) on 2026-11-27T03:11:21Z. **Review:** APPROVED --- Checked head `bcb4e977e1`. I applied it to `main` `ad7582bad4` together with #27588 and #27585, which touch different files. On Windows 11 with WinLibs GCC 15.2 (Release), `tools/check_conventions.py --head` on each head and `tools/debt_fold.py --check` passed, the build succeeded, and all 4,930 CPU tests passed (I left out the GPU tests). `guest_curl_slistmime` passed. With `main`'s `libcurl/Export.cpp` and the new checks, it fails. `HostFormFromGuest` now copies each guest `curl_httppost` node through `GuestCopyIn_nid_no_patch` before reading it, so a bad `more` or `next` pointer, or a bad first node, throws through `NotImplementedAt_nid_no_patch` instead of being read directly. The host node still borrows the guest's string and buffer pointers, as before, and the debt fragment says so. AI-assisted: yes (Claude Code)
MertCtn commented 2026-12-02 11:44:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MertCtn on 2026-12-02T11:44:25Z.

Review: COMMENTED


Verified the Windows side of this one: guest_curl_slistmime passes on LLP64.

  • Windows 11, MSYS2 UCRT64 GCC 16.2.0, Ninja, Release, at bcb4e977e1: guest_curl_slistmime Passed, including the two new unreadable-node checks (bad next link and bad first node both throw instead of crashing).
  • check_conventions.py scoped to this PR (--base its merge-base) passes.

One consistency suggestion, non-blocking: the new GuestCopyIn_nid_no_patch copy in HostFormFromGuest does not preserve errno, while the neighboring GuestText::Fill and the curl_formfree path both save/restore it around the same call. A failed (or even successful) curl_formget can therefore clobber the guest errno where the old direct-deref path never touched it. Worth the same two-line save/restore for consistency.

Also note: debt_fold.py --check fails at this head on the unrelated feat-libwebrtc-rnn-vad.md fragment (predates this PR's base), so I could not validate feat-libcurl-formget.md with the tool — checked by hand instead: single ## add Functional entry, well-formed link, under the length limit.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6150073371 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27587#pullrequestreview-6150073371). Originally posted by [MertCtn](https://github.com/MertCtn) on 2026-12-02T11:44:25Z. **Review:** COMMENTED --- Verified the Windows side of this one: `guest_curl_slistmime` passes on LLP64. - Windows 11, MSYS2 UCRT64 GCC 16.2.0, Ninja, Release, at `bcb4e977e1`: `guest_curl_slistmime` **Passed**, including the two new unreadable-node checks (bad `next` link and bad first node both throw instead of crashing). - `check_conventions.py` scoped to this PR (`--base` its merge-base) passes. One consistency suggestion, non-blocking: the new `GuestCopyIn_nid_no_patch` copy in `HostFormFromGuest` does not preserve `errno`, while the neighboring `GuestText::Fill` and the `curl_formfree` path both save/restore it around the same call. A failed (or even successful) `curl_formget` can therefore clobber the guest `errno` where the old direct-deref path never touched it. Worth the same two-line save/restore for consistency. Also note: `debt_fold.py --check` fails at this head on the unrelated `feat-libwebrtc-rnn-vad.md` fragment (predates this PR's base), so I could not validate `feat-libcurl-formget.md` with the tool — checked by hand instead: single `## add Functional` entry, well-formed link, under the length limit.
ligmaSec commented 2026-12-03 15:01:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T15:01:57Z.

Review: COMMENTED


Built and ran guest_curl_slistmime on Linux with this head integrated. It passed. I traced curl_formget from the checked form-node read through the callback and checked that a failed read follows the existing guest error path.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6172363467 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27587#pullrequestreview-6172363467). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-12-03T15:01:57Z. **Review:** COMMENTED --- Built and ran `guest_curl_slistmime` on Linux with this head integrated. It passed. I traced `curl_formget` from the checked form-node read through the callback and checked that a failed read follows the existing guest error path. AI-assisted: yes.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/27587:upstream-pr/27587'
git switch 'upstream-pr/27587'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/27587'
git switch 'upstream-pr/27587'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/27587'
git switch 'upstream-pr/27587'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/27587'
git switch 'main'
git merge --squash 'upstream-pr/27587'
git switch 'main'
git merge --ff-only 'upstream-pr/27587'
git switch 'main'
git merge 'upstream-pr/27587'
git push origin 'main'
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!27587
No description provided.