Skip to content

fix(libkernel): check operation mode output buffers - #18814

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
THEMANnt:fix/libkernel-operation-mode-output
Nov 12, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
THEMANnt:fix/libkernel-operation-mode-output

Conversation

@THEMANnt

Copy link
Copy Markdown
Contributor

What

Write the mode and submode with the checked guest copy. An inaccessible destination uses the same invalid_argument error path as a null output, instead of causing a native access violation. Valid outputs are still written in order.

Tested

Windows x64, WinLibs GCC 15.2, Release. guest_operation_mode passed three consecutive runs with both bad-output cases. The unpatched source produced a native access violation with the regression test in place. Conventions passed against upstream main. The overlap scan flagged #15095 on the same file, whose Process.cpp hunk only changes the guest environment.

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

@JJenkx

JJenkx commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Windows check of head da41fa6c37, merged onto main c65eb46214 (e6eee158f4, clean merge).

Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release. The hosted Windows check does not run these tests on pull requests.

  • guest_operation_mode passes in 3 of 3 runs, none skipped.

AI-assisted: yes.

@github-actions

github-actions Bot commented Nov 12, 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 17908 core/libs/prx/libkernel/System/src/Process.cpp

@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 da41fa6c37:

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: guest_operation_mode_tests built cleanly.
  • CTest (guest_operation_mode):
    1/1 Test #4562: guest_operation_mode .............   Passed    0.01 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libkernel/System/src/Process.cpp reverted to main and the new tests kept, the suite fails:
    1/1 Test #4562: guest_operation_mode .............***Exception: SegFault  0.14 sec
    0% tests passed, 1 tests failed out of 1
    
    Restoring the change makes it pass again.
  • Code reading:
    • core/libs/prx/libkernel/System/src/Process.cpp: Verified sceKernelGetOperationMode validates mode and submode against nullptr first, preserving the existing std::invalid_argument exception path before any guest copies are attempted.
    • core/libs/prx/libkernel/System/src/Process.cpp: Verified GuestCopyOut_nid_no_patch is invoked for both mode and submode with correct sizes (sizeof(int) = 4 bytes), safely catching unmapped or read-only guest addresses without native host crashes.
    • core/libs/prx/libkernel/System/src/Process.cpp: Verified copy ordering (mode = 2, then submode = 0) is preserved and unwritable destinations throw std::invalid_argument("sceKernelGetOperationMode: output is not writable").
    • core/libs/prx/libkernel/System/src/Process.cpp: Verified cross-platform integer sizing consistency (int is 32-bit on both LP64 Linux and LLP64 Windows) and confirmed zero comments were introduced, adhering strictly to AGENTS.md.
    • core/libs/tests/GuestOperationMode.cpp: Verified test additions rigorously exercise inaccessible destination addresses for both mode and submode parameters alongside existing null and valid buffer assertions.
  • Note: the AI-assisted checkbox can stay.

Looks Good To Me

@oneandonlydean
oneandonlydean merged commit 665a829 into boykopovar:main Nov 12, 2026
14 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.

4 participants