Skip to content

fix(libkernel): reject overlong POSIX thread names - #2230

Merged
adriadam10 merged 3 commits into
boykopovar:mainfrom
QRMOE:fix/libkernel-pthread-rename-limit
Oct 10, 2026
Merged

adriadam10 merged 3 commits into
boykopovar:mainfrom
QRMOE:fix/libkernel-pthread-rename-limit

Conversation

@QRMOE

@QRMOE QRMOE commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

What

Rejects pthread_rename_np names of 32 bytes or more with guest ENAMETOOLONG (63), before changing the stored or native thread name. Names up to 31 bytes continue to succeed.

This matches the published PS5 firmware 13.60 probe and raw output: 31 bytes succeed; 32 and 40 bytes return 63 and preserve the previous 31-byte name. That measurement was made by the author of #1798, not locally for this PR. This fixes an existing export; no title-unblocking or new-export claim is made.

The dedicated test avoids changing GuestThreadSelf.cpp. Local merges with the inspected heads of #1798, #1739, #1676 and #2184 are clean. Actual library diffs of 522 open PR heads were inspected; no competing rename-length implementation was found. The latest additional PRs were checked before publication.

Tested

Windows 11, WinLibs MinGW-w64 GCC 15.2.0 UCRT/POSIX/SEH, Ninja Release, BUILD_TESTING=ON, ANYPS5_ENABLE_SPIRV_TOOLS=ON; based on main d70b89989473ba1f6ae13e44e079e67f1f8a44b0.

  • Complete project build, including patched libraries, passed.
  • Eight focused runtime tests passed: guest_pthread_rename, guest_thread_self, guest_pthread_attr, guest_kernel_errors, guest_errors, guest_thread_atexit, host_thread_local and guest_thread_callback_abi.
  • guest_pthread_rename checks empty, 1-, 11- and 31-byte names, rejects 32-, 40- and 1024-byte names, verifies the old name survives rejection, checks that a later valid rename succeeds, and checks output guards and errno preservation. It runs on both the adopted main thread and a created guest thread. Final runtime: 0.02 s.
  • The regression fails without the length check (32-byte name returned 0; expected ENAMETOOLONG=63). It also detects three deliberate faults: rejecting 31 bytes, returning EINVAL, and changing the name before reporting the error. The final source was restored and rebuilt afterward.
  • Conventions, whitespace and test registration checks passed.

Linux, a new console run, games and the full CTest suite have not been run. No new dependency, silent stub or code comment is added.

AI-assisted: yes — OpenAI Codex assisted with implementation, testing and this description.

Checklist

  • Based on current main; no competing rename-length implementation found in the inspected open PRs
  • One topic per PR
  • No new code comments
  • No new silent stubs or fallback behavior
  • Reports, logs and screenshots kept outside the repository
  • No new third-party dependencies
  • General behavior, not specific to one title
  • Depends on: none
  • AI-assisted: yes

@github-actions github-actions Bot added libkernel build needs rebase Conflicts with main, rebase needed labels Oct 9, 2026
@oneandonlydean

Copy link
Copy Markdown
Collaborator

This conflicts with main after today's merges; could you rebase? It passed testing and is otherwise ready.

QRMOE added 3 commits October 10, 2026 09:53
AI-assisted: yes. Validated with the final library change on Windows; full build and eight focused runtime tests pass. Expected rename behavior comes from the public firmware 13.60 probe in PR boykopovar#1798.
AI-assisted: yes. Match the firmware 13.60 probe in PR boykopovar#1798: names of 32 bytes or more return guest ENAMETOOLONG=63 and preserve the prior name. The complete final change passed a full Windows build and eight focused runtime tests.
AI-assisted: yes. Final code passed the complete Windows build, eight focused runtime tests and four deliberate-fault checks.
@adriadam10

Copy link
Copy Markdown
Collaborator

Rebased onto current main as @oneandonlydean asked (only conflict: adjacent test registrations in libkernel/CMakeLists.txt, kept both). Rebuilt and ran guest_pthread_rename plus the libkernel/libs tests on Linux: green, and the new test fails without the length check in Thread.cpp; merging on green CI.

@adriadam10
adriadam10 force-pushed the fix/libkernel-pthread-rename-limit branch from 7fe81d3 to b8f04c6 Compare October 10, 2026 07:56
@adriadam10
adriadam10 merged commit d4b5cd6 into boykopovar:main Oct 10, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build libkernel needs rebase Conflicts with main, rebase needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants