fix(libSceNpUniversalDataSystem): copy guest pointers safely in context and event exports #21557

Open
Gruzzberry wants to merge 1 commit from upstream-pr/21557 into main
Gruzzberry commented 2026-11-16 11:44:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Gruzzberry on 2026-11-16T11:44:01Z.


What

sceNpUniversalDataSystemCreateContext, CreateEvent, EventEstimateSize and EventToString wrote through guest pointers directly. They now go through GuestPtr, GuestWritable and CopyGuestString, and return SCE_NP_UNIVERSAL_DATA_SYSTEM_ERROR_INVALID_ARGUMENT for an unreadable name or an unwritable output. CreateContext no longer registers a context whose id could not be written back. The property array and object setters are not touched.

Tested

Not built or run (no host compiler in this environment). tools/check_conventions.py --base upstream/main passes. The guest pointer audit no longer lists the changed outputs.

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

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5336356599 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21557). Originally posted by [Gruzzberry](https://github.com/Gruzzberry) on 2026-11-16T11:44:01Z. --- ### What sceNpUniversalDataSystemCreateContext, CreateEvent, EventEstimateSize and EventToString wrote through guest pointers directly. They now go through GuestPtr, GuestWritable and CopyGuestString, and return SCE_NP_UNIVERSAL_DATA_SYSTEM_ERROR_INVALID_ARGUMENT for an unreadable name or an unwritable output. CreateContext no longer registers a context whose id could not be written back. The property array and object setters are not touched. ### Tested Not built or run (no host compiler in this environment). `tools/check_conventions.py --base upstream/main` passes. The guest pointer audit no longer lists the changed outputs. ### 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)
MarcZX10 commented 2026-11-25 09:41:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T09:41:02Z.

Review: COMMENTED


Reviewed — no blocking findings

Nothing blocks this change; the author-reported convention check was not run by me, and the change could not be built or tested here.

What I ran

Reviewed head 77a27ef295c257fc1e41ab769535b15d582a0c6b using the prepared diff and pinned repository reader. No build or test commands were available.

Results

Check Result Note
Changed source review passed Both changed files read in full
Build and tests not run No execution environment available
Convention check not run Reported by the author only

Findings

Blocking

None.

Non-blocking

None.

Not verified

The build, tests, and convention check were not run by me. The author reports that tools/check_conventions.py --base upstream/main passes; I did not verify that report. I read Context.cpp, Event.cpp, and GuestPtr.hpp; no changed files were excluded from the review.

To get this to a good state

Nothing is required. Optional: add coverage for unreadable event names and unwritable output pointers.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6055147552 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21557#pullrequestreview-6055147552). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-25T09:41:02Z. **Review:** COMMENTED --- # Reviewed — no blocking findings Nothing blocks this change; the author-reported convention check was not run by me, and the change could not be built or tested here. ## What I ran Reviewed head `77a27ef295c257fc1e41ab769535b15d582a0c6b` using the prepared diff and pinned repository reader. No build or test commands were available. ## Results | Check | Result | Note | |---|---|---| | Changed source review | passed | Both changed files read in full | | Build and tests | not run | No execution environment available | | Convention check | not run | Reported by the author only | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified The build, tests, and convention check were not run by me. The author reports that `tools/check_conventions.py --base upstream/main` passes; I did not verify that report. I read `Context.cpp`, `Event.cpp`, and `GuestPtr.hpp`; no changed files were excluded from the review. ## To get this to a good state Nothing is required. Optional: add coverage for unreadable event names and unwritable output pointers.
ligmaSec commented 2026-12-03 15:43:51 +00:00 (Migrated from github.com)

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

Review: COMMENTED


This head conflicts in the UDS context and event implementations. Main already uses a checked copy for the context ID and explicitly preserves errno. The branch also delays advancing table.next until the copy succeeds. That distinction can be kept as a small change around the existing checked write.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6173135424 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21557#pullrequestreview-6173135424). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-12-03T15:43:51Z. **Review:** COMMENTED --- This head conflicts in the UDS context and event implementations. Main already uses a checked copy for the context ID and explicitly preserves errno. The branch also delays advancing `table.next` until the copy succeeds. That distinction can be kept as a small change around the existing checked write. 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/21557:upstream-pr/21557'
git switch 'upstream-pr/21557'

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