fix(libSceRudp): check the context status arguments first and initialization before the id pointer #13849

Closed
zaryabzip wants to merge 0 commits from upstream-pr/13849 into main
zaryabzip commented 2026-10-31 09:26:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by zaryabzip on 2026-10-31T09:26:52Z.


What

Two libSceRudp answers now follow the firmware readings on #13682.

sceRudpGetContextStatus(int ctxId, void* status, uint32_t size)

  • After the initialization check, a negative id, a null status or a size outside 1 to 0x30 returns 0x80770004, before the id is looked up.
  • An unknown id then returns 0x80770003.
  • On success it writes the first size bytes of a 0x30-byte block. The block is zero except for 0xFFFFFFFF at bytes 4-7, which is what the 13.42 run read for an idle context.

On main it accepted any size, returned 0 for a null pointer, checked the id first, and wrote zeros. Every context answers with the idle block here. The run didn't read a bound or listening context, and the new debt entry says so.

sceRudpCreateContext: before initialization, a null id pointer returns 0x80770001, as in the 13.42 run. main checked the pointer first and returned 0x80770004.

No function changes count.

GuestRudpContextLifecycle.cpp changes to match:

  • It used a 64-byte buffer and expected 64 zero bytes and success for a null pointer. It now checks the refusals with an unknown id and with a live one.
  • It checks the 0x30-byte block, a 6-byte partial read, and that bytes past size stay untouched.
  • It adds sceRudpCreateContext(handler, NULL, NULL) before init.

Overlap: this doesn't depend on my other Rudp PRs (#13718, #13799, #13814). git merge-tree merges it cleanly with each of them, with #11042 and #13844, and with every other open pull request that merges with main.

Tested

Windows 11 (WinLibs MinGW-w64 GCC 15.2.0 UCRT r7, CMake 4.3.1, Ninja 1.13.2) and Ubuntu 24.04 on WSL2 (GCC 13.3.0, CMake 3.28.3, Ninja 1.11.1), both with the head 553f1a82d2 merged into main 1b91748340.

  • No warnings in Export.cpp or GuestRudpContextLifecycle.cpp.
  • ctest -R "guest_rudp|rudp_poll": 6 of 6 pass on WSL2 and 7 of 7 on Windows (plus rudp_poll_wait_exception). guest_rudp_context_lifecycle passes 3 of 3 on --repeat until-fail:3.
  • Baseline: on that main with only the test change, guest_rudp_context_lifecycle builds and then aborts at sceRudpCreateContext(Handler, nullptr, nullptr) == notInitialized (line 127) on both hosts (Windows exit 0xc0000409, Linux SIGABRT).
  • tools/check_conventions.py passes.

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
  • 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 (Claude Code)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5096310727 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13849). Originally posted by [zaryabzip](https://github.com/zaryabzip) on 2026-10-31T09:26:52Z. --- ### What Two libSceRudp answers now follow the firmware readings on #13682. **`sceRudpGetContextStatus(int ctxId, void* status, uint32_t size)`** - After the initialization check, a negative id, a null `status` or a `size` outside 1 to 0x30 returns `0x80770004`, before the id is looked up. - Source: @ntamas94's [reading of firmware 10.71's module](https://github.com/boykopovar/AnyPS5/issues/13682#issuecomment-6541579780), a PS4 one, read statically. - @BunnyFl's [13.42 run](https://github.com/boykopovar/AnyPS5/issues/13682#issuecomment-6537745577) gives the same size range and null refusal. - An unknown id then returns `0x80770003`. - On success it writes the first `size` bytes of a 0x30-byte block. The block is zero except for `0xFFFFFFFF` at bytes 4-7, which is what the 13.42 run read for an idle context. On `main` it accepted any size, returned 0 for a null pointer, checked the id first, and wrote zeros. Every context answers with the idle block here. The run didn't read a bound or listening context, and the new debt entry says so. **`sceRudpCreateContext`**: before initialization, a null id pointer returns `0x80770001`, as in the 13.42 run. `main` checked the pointer first and returned `0x80770004`. No function changes count. `GuestRudpContextLifecycle.cpp` changes to match: - It used a 64-byte buffer and expected 64 zero bytes and success for a null pointer. It now checks the refusals with an unknown id and with a live one. - It checks the 0x30-byte block, a 6-byte partial read, and that bytes past `size` stay untouched. - It adds `sceRudpCreateContext(handler, NULL, NULL)` before init. Overlap: this doesn't depend on my other Rudp PRs (#13718, #13799, #13814). `git merge-tree` merges it cleanly with each of them, with #11042 and #13844, and with every other open pull request that merges with `main`. ### 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 11 (WinLibs MinGW-w64 GCC 15.2.0 UCRT r7, CMake 4.3.1, Ninja 1.13.2) and Ubuntu 24.04 on WSL2 (GCC 13.3.0, CMake 3.28.3, Ninja 1.11.1), both with the head 553f1a82d2 merged into `main` 1b91748340. - No warnings in `Export.cpp` or `GuestRudpContextLifecycle.cpp`. - `ctest -R "guest_rudp|rudp_poll"`: 6 of 6 pass on WSL2 and 7 of 7 on Windows (plus `rudp_poll_wait_exception`). `guest_rudp_context_lifecycle` passes 3 of 3 on `--repeat until-fail:3`. - Baseline: on that `main` with only the test change, `guest_rudp_context_lifecycle` builds and then aborts at `sceRudpCreateContext(Handler, nullptr, nullptr) == notInitialized` (line 127) on both hosts (Windows exit 0xc0000409, Linux SIGABRT). - `tools/check_conventions.py` passes. ### 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) - [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: <!-- #PR, or none --> none - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> n/a - [x] AI-assisted: <!-- yes / no --> yes (Claude Code)

Pull request closed

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!13849
No description provided.