Skip to content

fix(libSceVoiceQoS): guard local endpoint attribute guest inputs - #20378

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
hyvvs:fix/voiceqos-copy-in-local-attributes-w33
Nov 15, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
hyvvs:fix/voiceqos-copy-in-local-attributes-w33

Conversation

@hyvvs

@hyvvs hyvvs commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

What

sceVoiceQoSSetLocalEndpointAttribute read caller-controlled values through raw float* and uint8_t* dereferences. A non-null but unmapped guest pointer, such as address 0x10, crashed the host before libSceVoice was called. The four supported selectors now use the existing GuestCopyIn_nid_no_patch mechanism to copy their four-byte volume or one-byte mute value into a local scalar before forwarding it. Copy failures return the existing SCE_VOICE_ERROR_LIBVOICEQOS_ARGUMENT_INVALID (0x804E0902) without changing a voice port, and the caller's errno is preserved. Size, local endpoint, selector, and initialization checks retain their precedence; valid values still update the correct input/output voice port.

The guest regression now calls all four selectors with an unreadable 0x10 input, checks the return and errno, and reads back each previously set value to confirm a rejected input does not change it. The technical-debt fragment documents that the console result for an unreadable non-null value is unmeasured; the existing error is a host-safety fallback.

Overlap: python tools/pr_overlap.py --names sceVoiceQoSSetLocalEndpointAttribute examined 1,526 open PRs and found no competing implementation. The full branch scan examined 1,527 open PRs and failed closed on one stale, conflicting PR, #8656, whose Export.cpp and GuestVoiceQoS.cpp are also modified. I inspected its patch: it changes connection-attribute storage, sceVoiceQoSSetConnectionAttribute, the two remote/connection attribute getters, and their tests. It includes sceVoiceQoSSetLocalEndpointAttribute only as unchanged hunk context, and does not add checked guest input handling or unreadable-value tests. The subject matter is independent, though the shared files could need a future rebase.

Tested

  • WSL Ubuntu 24.04, GCC 13.3: a focused standalone regression compiles the actual core/libs/prx/libSceVoiceQoS/Export.cpp with -std=c++20 -O0 -g -fno-omit-frame-pointer -ffunction-sections -fdata-sections -fsanitize=address,undefined -Wl,--gc-sections. Its test-only Linux guest-copy helper uses process_vm_readv, the same OS mechanism used by the library; controlled libSceVoice volume/mute callbacks record calls. On untouched main (905768a7, identical Export.cpp/GuestVoiceQoS.cpp to the rebased parent), the test aborts at the first invalid input: ASan SEGV reading 0x10 in Export.cpp:236, exit 134. With this patch, all four invalid-pointer selectors and the four valid-value checks pass under ASan and UBSan, exit 0. The harness is outside this PR.
  • Windows WinLibs GCC: g++ -std=c++20 -fsyntax-only -I core/libs passes for core/libs/prx/libSceVoiceQoS/Export.cpp and core/libs/tests/GuestVoiceQoS.cpp separately. git diff --check passes.
  • python tools/check_conventions.py --base upstream/main: all checks pass. The branch uses the latest upstream main; the fork's origin/main is older and produces unrelated errors if selected as the comparison base.
  • The added debt fragment passes python tools/debt_fold.py --root <isolated-copy-of-VoiceQoS-debt-and-fragment> --check. The global python tools/debt_fold.py --check fails on preexisting docs/dev/debt/changes/feat-icu-ulist.md, where [Older callable exports] matches two libSceIcu entries, unrelated to this PR.
  • Full Linux BUILD_TESTING=ON configuration was attempted but could not complete: 3rdparty/SDL2 is an uninitialized submodule in this worktree, and the host lacks some SDL Linux development dependencies. The registered guest_voice_qos CTests and title-level execution were therefore not run.

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

@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 12b92f3dbb:

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: guest_voice_qos_tests built cleanly.
  • CTest (guest_voice_qos, guest_voice_qos_app_type_0x10000000):
    1/2 Test #4705: guest_voice_qos_app_type_0x10000000 ...   Passed    0.03 sec
    2/2 Test #4704: guest_voice_qos .......................   Passed    0.02 sec
    100% tests passed, 0 tests failed out of 2
    
  • Negative control: with core/libs/prx/libSceVoiceQoS/Export.cpp reverted to main and the new tests kept, the suite fails:
    1/2 Test #4704: guest_voice_qos .......................***Exception: SegFault  0.52 sec
    2/2 Test #4705: guest_voice_qos_app_type_0x10000000 ...***Exception: SegFault  0.60 sec
    0% tests passed, 2 tests failed out of 2
    
    Restoring the change makes it pass again.
  • Code reading:
    • core/libs/prx/libSceVoiceQoS/Export.cpp: verified CopyIn safely copies caller values into local stack variables via GuestCopyIn_nid_no_patch and preserves errno, preventing host crashes on unmapped or invalid guest addresses such as 0x10.
    • core/libs/prx/libSceVoiceQoS/Export.cpp: confirmed sceVoiceQoSSetLocalEndpointAttribute rigorously validates guest inputs (!value, localId != 0, attributeId < 0 || attributeId > 3, uncreated local endpoint, and size != 4 for selectors 0/2 or size != 1 for selectors 1/3) and returns SCE_VOICE_ERROR_LIBVOICEQOS_ARGUMENT_INVALID (0x804E0902) before any forwarding.
    • core/libs/prx/libSceVoiceQoS/Export.cpp: checked selector dispatch logic, confirming that attributeId values 0 and 2 forward volume floats to sceVoiceSetVolume on inPort and outPort respectively, while attributeId values 1 and 3 forward mute flags to sceVoiceSetMuteFlag on inPort and outPort respectively.
    • core/libs/prx/libSceVoiceQoS/Export.cpp: verified concurrency safety and lifecycle checks, ensuring Locked holds qos.mutex and checks initialization state (returning SCE_VOICE_ERROR_LIBVOICEQOS_NOT_INIT) across endpoint resolution, copy-in, and voice port manipulation without leaking locks or introducing races.
    • core/libs/tests/GuestVoiceQoS.cpp: verified regression coverage for invalid pointer 0x10 across selectors 0, 1, 2, and 3, confirming that SCE_VOICE_ERROR_LIBVOICEQOS_ARGUMENT_INVALID is returned, errno preservation is asserted (Require(errno == 71)), and readbacks prove existing volume and mute states remain unaffected.
    • docs/dev/debt/changes/fix-voiceqos-copy-in-local-attributes-w33.md: confirmed strict compliance with AGENTS.md, including zero added code comments, Conventional Commits PR title formatting, and accurate technical debt fragment logging for unmeasured console behavior on unreadable pointers.

Looks Good To Me

@oneandonlydean
oneandonlydean merged commit 5430765 into boykopovar:main Nov 15, 2026
14 checks passed
@github-actions

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 8656 core/libs/prx/libSceVoiceQoS/Export.cpp
core/libs/tests/GuestVoiceQoS.cpp

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.

3 participants