Skip to content

fix(runtime): guard extreme signed handles - #17953

Merged
oneandonlydean merged 2 commits into
boykopovar:mainfrom
DonRyuzaki:batch10/pad-audio-handle-current
Nov 12, 2026
Merged

oneandonlydean merged 2 commits into
boykopovar:mainfrom
DonRyuzaki:batch10/pad-audio-handle-current

Conversation

@DonRyuzaki

Copy link
Copy Markdown
Contributor

What

Reject out-of-range signed Pad and AudioOut handles before subtracting the handle base. INT_MIN previously caused signed overflow in Pad special-handle, port and user-ID helpers and in AudioOut port lookup. Valid handles and existing error returns are preserved.

Tested

  • Clean head 1f2e495095cf39f45095619705a3870e665d08c3 directly on upstream main 3e089775b9a12e3d2e70ede255363c522dbf3135.
  • Isolated negative controls trapped on the old INT_MIN subtractions with Windows GCC 15.2 signed-overflow sanitizer (0xC000001D). These establish the original undefined arithmetic; they are not full-library tests.
  • Shared full Linux Release integration build on main 3e089775b9a12e3d2e70ede255363c522dbf3135 plus all ten pinned candidate patches completed 3219/3219 incremental Ninja steps, including runtime libraries and relinker. Focused CTest passed 20/20, including guest_pad and audio_out_last_output_time. Earlier full integration build on main 5e04f680ad completed 4369/4369 with 20/20 focused tests. These are integrated-tree results, not an isolated full build of this branch.
  • tools/check_conventions.py --base origin/main and git diff --check origin/main...HEAD passed on this rebased head. C++20 syntax-only compilation passed on Windows before rebase.
  • Overlap review: fix(libScePad): validate negative user IDs and closed special handles in scePadOpen #14124 and test(libScePad): audit handle validation and slot boundary limits #17440 cover other Pad validation and tests; fix(libSceAudioOut): return the closed-port code for a closed handle #16614 changes AudioOut closed-port errors but not this getPort range guard. No matching INT_MIN arithmetic fix found.
  • No console or game test was run for this change.

Checklist

  • Based on current main; checked competing open PRs
  • One topic: extreme signed-handle arithmetic in input/output libraries
  • No new third-party code, notes or images
  • Unimplemented paths remain explicit; no new silent stubs
  • Depends on: none; Fixes: none; Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

Validate handles and user IDs before subtracting their bases. Extreme negative inputs otherwise trigger signed-overflow undefined behavior before the range checks.
Reject extreme invalid handles before subtracting one in getPort. INT_MIN otherwise triggers signed-overflow undefined behavior.
@JJenkx

JJenkx commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Windows check of head 1f2e495095, merged onto main 65a80a5dc7 (4e1e1fd03a, 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.

  • audio_out_last_output_time, guest_pad pass in 3 of 3 runs, none skipped.

AI-assisted: yes.

@github-actions

github-actions Bot commented Nov 10, 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 5038 core/libs/prx/libScePad/Export.cpp
PR 8260 core/libs/prx/libScePad/Export.cpp
core/libs/tests/GuestPad.cpp
PR 14124 core/libs/prx/libScePad/Export.cpp
core/libs/tests/GuestPad.cpp
PR 14634 core/libs/tests/GuestPad.cpp
PR 15905 core/libs/tests/GuestPad.cpp

@Ethan-Hainline

Copy link
Copy Markdown
Contributor

Context from the 2026-11-11 sanitizer nightly (run 42954663888, 15 failures of 4,823): the only new failure against the 11-10 run is guest_audio_out, and it is exactly this arithmetic:

AudioOut.cpp:388:15: runtime error: signed integer overflow: -2147483648 - 1 cannot be represented in type 'int'
    #0 getPort AudioOut.cpp:388
    #1 sceAudioOutGetPortState AudioOut.cpp:618
    #2 TestPortHandleBounds GuestAudioOut.cpp:65

Yesterday's failure set did not include it; it arrived with the port-bounds audit b3fe05b5d0 (as the Linux UBSan comment above also found). The other eight previous failures that are gone today include the pipeline-cache and ngs2 set, so this is the one regression the nightly attributes to current main.

That makes this PR the fix for the nightly's new failure, not just a hardening change.

I also ran guest_audio_out itself on Windows at head 1f2e495095 merged onto main 22cc516f87: passed 3 of 3 runs (3.48 s cold, then 1.29 s twice), WinLibs GCC 16.2.0 UCRT, Release. Release does not trap the overflow, so this is a no-regression check for the new bounds handling; the Linux UBSan run above is the proof that the arithmetic is gone.

AI-assisted.

@gabichuuuuu

Copy link
Copy Markdown
Contributor

Windows check of head 1f2e495095, merged onto main 28237a8567 (clean merge, built together with other open PRs that touch different files).

Setup: Windows 11 x64, WinLibs GCC 15.2.0 (r7), Ninja, Release, BUILD_TESTING=ON, Python 3.15.

  • Tests built from this PR's test files: audio_out_last_output_time, guest_pad.
  • All of them pass in 3 of 3 runs.
  • Negative control: with this PR's code reverted to main (files it adds removed) and rebuilt, the same tests still pass in 2 of 2 runs, so they do not detect the change on this machine.

AI-assisted: yes.

@oneandonlydean
oneandonlydean merged commit 067e36b 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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants