Skip to content

fix(libkernel): match write throttling status failure - #26453

Merged
oneandonlydean merged 2 commits into
boykopovar:mainfrom
malekaifa:prime-b/write-throttling-status-20261123
Dec 3, 2026
Merged

oneandonlydean merged 2 commits into
boykopovar:mainfrom
malekaifa:prime-b/write-throttling-status-20261123

Conversation

@malekaifa

@malekaifa malekaifa commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

What

sceKernelWriteThrottlingStatus now follows the PS5 payload-process result already recorded in libkernel debt instead of fabricating a successful unlimited status.

For a valid 32-byte output, firmware 11.60 returned SCE_KERNEL_ERROR_ESRCH (0x80020003) and left the buffer untouched. This change returns that result after a non-mutating guest writeability check. A null output keeps the measured EINVAL result, and an unmapped non-null output keeps the existing EFAULT host-safety fallback.

The focused filesystem regression now requires ESRCH and verifies all four sentinel qwords remain unchanged. The debt fragment records the measured payload behavior, the unmeasured title/fault boundary, and that PPSA17221 chooses the same highest write-budget tier on call failure as it did from the previous fabricated UINT32_MAX success.

The branch-overlap helper failed closed because older PRs touch the broad Stdio.cpp / GuestFilesystem.cpp files. I manually compared every reported branch: #6936, #7121, #7447, #9293, #9297, #9302, #9371, #12682, #12688, #12700, #12965 and #15037. None implements the measured sceKernelWriteThrottlingStatus behavior; their copies retain either the older direct-write success or the current guarded fabricated success.

Tested

Machine vm, Windows 11 CI VM, WinLibs MinGW-w64 GCC 15.2.0, Ninja, Release, BUILD_TESTING=ON, exact tree published as head 1c800fb0253a7ccdbb50e5f484a21eca1ce261ea:

  • configured from upstream main f4c9a67f581bc9d4e50f5aa97fd7765e10f4d593;
  • built guest_filesystem_tests cleanly;
  • ctest --test-dir build -R '^guest_filesystem$' --output-on-failure --repeat until-fail:3: 3/3 passed;
  • negative control: restored only Stdio.cpp from the exact base while keeping the new test, rebuilt, and guest_filesystem aborted at the new throttling assertion (line 853, exit 0xc0000409);
  • restored the branch implementation, rebuilt, and the focused test passed 3/3 again;
  • tools/debt_fold.py --check: passed;
  • tools/check_conventions.py --base origin/main --head HEAD: passed;
  • git diff --check: passed.

The GitHub-published commit has the same three blob SHAs as the locally built/tested commit.

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

Summary by CodeRabbit

  • Bug Fixes
    • Write-throttling status requests now return an error for valid buffers and leave their contents unchanged, instead of reporting success with placeholder values. Invalid or unwritable buffers also return an error.
  • Documentation
    • Added notes on observed behavior and remaining uncertainties around status values and untested cases.

Copilot AI balanced review requested due to automatic review settings November 23, 2026 23:25

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 PrivacyOnion left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 1c800fb025:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_filesystem_tests built cleanly.
  • CTest (guest_filesystem):
    1/1 Test #5934: guest_filesystem .................   Passed    0.64 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libkernel/File/src/Stdio.cpp reverted to main and the new tests kept, the suite fails:
    1/1 Test #5934: guest_filesystem .................Subprocess aborted***Exception:   0.65 sec
    0% tests passed, 1 tests failed out of 1
    
    Restoring the change makes it pass again.
  • Code reading:
    • Verified sceKernelWriteThrottlingStatus pointer validation: checks nullptr first returning SceErrorFromErrno(GUEST_EINVAL) (0x80020016), then calls GuestWritable_nid_no_patch(status, 4 * sizeof(*status)) returning SceErrorFromErrno(GUEST_EFAULT) (0x8002000e) on unmapped addresses like 0x10.
    • Verified non-mutating behavior matches real PS5 payload process measurement: on valid 32-byte status buffer, returns SCE_KERNEL_ERROR_ESRCH (0x80020003) without modifying caller memory.
    • Verified AGENTS.md compliance: no comments added to Stdio.cpp, proper debt fragment added in docs/dev/debt/changes/fix-libkernel-write-throttling-status.md documenting measured payload behaviour and known gaps.
    • Verified cross-platform 64-bit portability (LP64 vs LLP64): status is std::uint64_t* and size is 4 * sizeof(*status) (32 bytes), matching buffer expectations without type narrowing or platform-dependent width issues.
    • Verified test coverage in GuestFilesystem.cpp: tests valid non-mutated buffer preserving sentinels with ESRCH, nullptr with EINVAL, and unmapped address with EFAULT.

Looks Good To Me

@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 7121 core/libs/prx/libkernel/File/src/Stdio.cpp
PR 9302 core/libs/prx/libkernel/File/src/Stdio.cpp
PR 12682 core/libs/prx/libkernel/File/src/Stdio.cpp
PR 12688 core/libs/prx/libkernel/File/src/Stdio.cpp
PR 12700 core/libs/prx/libkernel/File/src/Stdio.cpp
PR 12965 core/libs/prx/libkernel/File/src/Stdio.cpp
PR 15037 core/libs/prx/libkernel/File/src/Stdio.cpp
core/libs/tests/GuestFilesystem.cpp
PR 18190 core/libs/prx/libkernel/File/src/Stdio.cpp

@catminou4 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Built libkernel and ran guest_filesystem_tests on Linux (x86-64, GCC 11): passes.

Control — reverted Stdio.cpp to origin/main, kept the updated test: the test aborts. On main, sceKernelWriteThrottlingStatus returns 0 and writes fabricated values (UINT32_MAX, 0, 0, 0), which is exactly the "made-up success" the repo conventions forbid; the updated test requires the measured ESRCH (0x80020003) return and an untouched buffer.

This is a console-measured fix (PS5 firmware 11.60): a valid 32-byte status buffer returns ESRCH and leaves the four qwords alone, a null pointer returns EINVAL, and the buffer is only probed with a non-mutating GuestWritable check. The debt fragment is exemplary — it records the exact measured return codes, explains why PPSA17221 still selects the same highest write-budget tier on the failure path, and is honest that the hardware meaning of the status qwords and title-process behavior are unknown. Correct, mergeable fix.

@malekaifa

Copy link
Copy Markdown
Contributor Author

Overlap follow-up on machine main: the bot's newly listed #25495 (fix(libc): fail fopen of an empty name with ENOENT, head 34d9faf7a12dfb96d2fd14c0ea306025b826a774) is not a same-behavior implementation. Its GuestFilesystem.cpp still contains the old sceKernelWriteThrottlingStatus success assertions (return 0, UINT32_MAX,0,0,0) unchanged; #25495's actual change is fopen("") handling in FileAndHeap.cpp plus its test coverage. So the shared GuestFilesystem.cpp path is mechanical overlap only. Together with the previously documented manual checks for the other fail-closed branches, no reported open PR implements this PR's measured ESRCH + untouched-buffer behavior. Head 1c800fb0253a7ccdbb50e5f484a21eca1ce261ea stays unchanged. AI-assisted: yes

@malekaifa

Copy link
Copy Markdown
Contributor Author

Maintainer-ready evidence for exact head 1c800fb0253a7ccdbb50e5f484a21eca1ce261ea: GitHub reports CLEAN; all 14 checks are terminal (7 successful, 7 intentionally skipped, zero failures). Hosted Windows job 138106782544 built the actual changed-library targets and passed guest_filesystem and patched_libraries (2/2). PrivacyOnion approved the exact head with a Linux Release build and failing negative control; catminou4 independently reproduced the regression and passing fix on Linux/GCC 11. The previous overlap follow-up remains applicable. The physical-console evidence is limited to the recorded payload-process measurement; title-process behavior is not independently verified. No code or branch change is needed from the known reviews. AI-assisted: yes.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — looks good

The change matches the reported firmware 11.60 payload result for a valid 32-byte status buffer; the changed implementation and regression assertions are consistent with that behavior.

What I ran

Reviewed head 1c800fb0253a7ccdbb50e5f484a21eca1ce261ea using the prepared diff and the pinned repository reader. No commands or tests were run during this review.

Results

Check Result Note
Changed code review passed Implementation and regression assertions read
Test execution not run Only author-reported results are available

Findings

Blocking

None.

Non-blocking

None.

Not verified

The PR description reports a Windows 11 CI VM build, focused test repetitions, a negative control, and convention and debt checks; I did not run or independently verify those checks. I read all three changed files listed in the manifest. No files were excluded.

To get this to a good state

Nothing is required.

@malekaifa

Copy link
Copy Markdown
Contributor Author

Fresh current-main integration check on machine main: I replayed the existing one-commit PR patch onto current main dc956738fdccad9a63fb323f60cc5fab4f34aaf1 in the detached scratch checkout. The resulting delta remains exactly the three PR paths.

I manually checked the shared-path changes since the PR's old base. Current main changes Stdio.cpp for verbatim path lookup, sceKernelRdup, stat/open/mkfifo and related file-call wrappers; it does not change sceKernelWriteThrottlingStatus. Its GuestFilesystem.cpp additions exercise stat/open behavior, not write-throttling status. Current main still has the old fabricated-success implementation and the 0, UINT32_MAX, 0, 0 assertions; this PR still changes that behavior to the measured ESRCH result with an untouched caller buffer. The shared paths are mechanical overlap, not a competing implementation.

Windows 11 / MSYS2 UCRT64 GCC 16.2 / Ninja / Release on the current-main preview: guest_filesystem_tests built; guest_filesystem passed 1/1; check_conventions.py, debt_fold.py --check, and git diff --check all passed.

This is an integration-preview validation, not a new PR head. I left the published branch unchanged: exact head 1c800fb0253a7ccdbb50e5f484a21eca1ce261ea already has terminal green applicable CI, two approvals, and GitHub reports it mergeable. No rebase or content change is required.

@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Changes: Write throttling status

Layer / File(s) Summary
Function behavior and validation
core/libs/prx/libkernel/File/src/Stdio.cpp, core/libs/tests/GuestFilesystem.cpp, docs/dev/debt/changes/fix-libkernel-write-throttling-status.md
The function checks buffer writability and returns GUEST_EFAULT or SCE_KERNEL_ERROR_ESRCH without writing status values. The test expects the error and verifies the input remains unchanged. The documentation records measured results and unknowns.

Suggested reviewers: deveshb-1

Change: Bug fix

Merge Risk: Minimal · up to f5b75

This change makes sceKernelWriteThrottlingStatus return the error measured on firmware 11.60 and leave the caller's buffer untouched. It has a small blast radius, and the test and documentation match the new behavior. No merge-blocking risk was identified.

Security architecture risk: Minimal · up to f5b75

The existing call now returns an error without writing to caller memory. Callers that relied on the old success result will see a behavior change, but the change does not introduce a new entrypoint or expand memory access.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The changed security-relevant behavior is confined to a guest-supplied pointer in the emulator process: the return code reflects host writeability of the requested span, but the handler no longer reads or writes the pointed-to bytes.

Trust Boundaries and Controls

  • observed — The helper checks host mapping permissions across the requested span, not guest ownership. Unlike the former copy-out path, it does not open a guest-arena host-write guard. Its result classifies the call; it is not authorization for a later write.
Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 11b10ff9-afc6-48ea-9844-d7e6055ebcc1
Commits

Reviewing files that changed from the base of the PR and between 1bc9275 and f5b7511.

Files selected for processing: 3

  • core/libs/prx/libkernel/File/src/Stdio.cpp
  • core/libs/tests/GuestFilesystem.cpp
  • docs/dev/debt/changes/fix-libkernel-write-throttling-status.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@ligmaSec ligmaSec left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The GuestFilesystem fixture coverage passed on Linux with the exact implementation from this head. The fixture checks the write-throttling failure code and verifies that the output buffer remains intact.

AI-assisted: yes.

@oneandonlydean
oneandonlydean merged commit 7b8dc9b into boykopovar:main Dec 3, 2026
14 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants