Skip to content

fix(libkernel): fail scePthreadAttr calls with EFAULT on an unusable pointer - #15550

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
Gruzzberry:fix/sce-pthread-attr-efault
Nov 7, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
Gruzzberry:fix/sce-pthread-attr-efault

Conversation

@Gruzzberry

@Gruzzberry Gruzzberry commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

What

scePthreadAttrInit, Destroy, Setdetachstate, Getdetachstate, Setguardsize, Getguardsize, Setinheritsched, Getinheritsched, Setschedparam, Getschedparam, Setschedpolicy, Getschedpolicy, Getstackaddr, Setstacksize, Getstacksize and Setsolosched read the attribute pointer, the attribute handle stored in guest memory, the scheduling parameter and the output pointers with plain dereferences. A pointer like 0x10 or one on an unreadable page crashed the host.

Every guest pointer in these calls now goes through GuestCopyIn_nid_no_patch / GuestCopyOut_nid_no_patch, and an unusable one fails with SCE_KERNEL_ERROR_EFAULT. The answers measured on a PS5 (firmware 13.60) stay: a null attribute pointer or handle gives EINVAL, a null output pointer gives EINVAL, a null scheduling parameter gives EOPNOTSUPP, and scePthreadAttrInit(NULL) still throws. The new EFAULT is checked after the attribute and before the value checks. Init frees its allocation if the copy-out fails and Destroy clears the guest slot before freeing. scePthreadAttrSetstackaddr, scePthreadAttrGetsolosched and the other scePthreadAttr calls are not touched (the first two are named by #9156 and #14798).

This is a host-safety fix. FreeBSD dereferences these pointers and faults the process; no console behaviour is claimed, and the debt entry says the same.

Tested

Windows 11 (10.0.26200), WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release, -DBUILD_TESTING=ON, on current main.

  • guest_pthread_attr_errors: new checks for the 0x10 and unreadable-page attribute pointers on every call, and for 0x10 and unreadable output pointers and scheduling parameter (a null output keeps EINVAL). On main the test crashes with a segmentation fault; on this branch it passes, three runs out of three.
  • Full suite: 3918 tests on current main (4f41f4c). Windows Defender quarantined relinker.exe part-way through the run (a false positive on this machine: its detection log names core/relinker/relinker.exe and a trace-imports output file), so about 95 relinker script tests failed. After relinking, all of them pass alone, three times out of three, except windows_trace_imports, whose output file Defender removes again. The other failures left are vulkan_validation_gate_reports and check_compile_test_windows_gcc_response_text_mode_is_not_reinterpreted (the Windows Python in this environment), agc_driver_store_over_untracked (also fails here on unrelated branches cut from the same main commit), and GPU agc_driver_* timeouts and failures (for example agc_driver_native_depth_clears and agc_driver_job_manager_compute_capacity) that pass in some alone-runs of the same binaries and fail in others on this loaded machine; skipped tests are GPU ones.
  • python tools/check_conventions.py --base upstream/main: passes.
  • Not tested: Linux and macOS, a console, a title run.

Overlaps

Checklist

  • Based on current main; no other open PR implements the same function
  • 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); no silent stubs added
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source: none added
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

AI-assisted (Claude Code).

🤖 Generated with Claude Code

…pointer

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 7, 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 5021 docs/dev/debt/libkernel.md
PR 6149 docs/dev/debt/libkernel.md
PR 6936 docs/dev/debt/libkernel.md
PR 7088 docs/dev/debt/libkernel.md
PR 7105 docs/dev/debt/libkernel.md
PR 7121 docs/dev/debt/libkernel.md
PR 7135 docs/dev/debt/libkernel.md
PR 7149 docs/dev/debt/libkernel.md
PR 7447 docs/dev/debt/libkernel.md
PR 7464 docs/dev/debt/libkernel.md
PR 7804 docs/dev/debt/libkernel.md
PR 8497 docs/dev/debt/libkernel.md
PR 9156 docs/dev/debt/libkernel.md
PR 9199 docs/dev/debt/libkernel.md
PR 9293 docs/dev/debt/libkernel.md
PR 9297 docs/dev/debt/libkernel.md
PR 9302 docs/dev/debt/libkernel.md
PR 9389 docs/dev/debt/libkernel.md
PR 9557 docs/dev/debt/libkernel.md
PR 9566 docs/dev/debt/libkernel.md
PR 9938 core/libs/prx/libkernel/Pthread/src/Attr.cpp
docs/dev/debt/libkernel.md
PR 10442 docs/dev/debt/libkernel.md
PR 11661 docs/dev/debt/libkernel.md
PR 11689 docs/dev/debt/libkernel.md
PR 11698 docs/dev/debt/libkernel.md
PR 11896 docs/dev/debt/libkernel.md
PR 11939 docs/dev/debt/libkernel.md
PR 12170 docs/dev/debt/libkernel.md
PR 12682 docs/dev/debt/libkernel.md
PR 12688 docs/dev/debt/libkernel.md
PR 12700 docs/dev/debt/libkernel.md
PR 12965 docs/dev/debt/libkernel.md
PR 12970 docs/dev/debt/libkernel.md
PR 13560 docs/dev/debt/libkernel.md
PR 13582 docs/dev/debt/libkernel.md
PR 13587 docs/dev/debt/libkernel.md
PR 14043 docs/dev/debt/libkernel.md
PR 14128 docs/dev/debt/libkernel.md
PR 14212 docs/dev/debt/libkernel.md
PR 14497 docs/dev/debt/libkernel.md
PR 15785 docs/dev/debt/libkernel.md
PR 15803 docs/dev/debt/libkernel.md
PR 15804 docs/dev/debt/libkernel.md
PR 15807 docs/dev/debt/libkernel.md
PR 16198 docs/dev/debt/libkernel.md
PR 16215 docs/dev/debt/libkernel.md

@adriadam10 adriadam10 self-assigned this Nov 7, 2026
@adriadam10
adriadam10 merged commit db1f710 into boykopovar:main Nov 7, 2026
14 of 16 checks passed
@adriadam10

Copy link
Copy Markdown
Collaborator

Checked every scePthreadAttr* call in the diff: order of the EINVAL/EFAULT/value checks, the Init leak on a failed copy-out, Destroy clearing the slot first, and the new test, which pins 0x10 and a PROT_NONE/PAGE_NOACCESS page on each call and would segfault on main. Conventions and the Windows job are green; merged.

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.

2 participants