Repository navigation
fix(libkernel): fail scePthreadGetname and pthread_getname_np with EFAULT on an unwritable buffer - #15571
Conversation
a048016 to
19f33b3
Compare
|
Rebased onto |
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
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.
|
|
Hi @Gruzzberry, Main moved and the branch conflicted in |
|
Windows check of head Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release. The hosted Windows check does not run these tests on pull requests.
AI-assisted: yes. |
3bd7e73 to
e7f72d0
Compare
…AULT on an unwritable buffer Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
e7f72d0 to
45e75a7
Compare
What
scePthreadGetnameandpthread_getname_npwrote the thread name and its terminator to the guest buffer with a rawmemcpy, so a non-null buffer that is not writable, such as 0x10, aPROT_NONEpage, a read-only page or one that runs out before the terminator, faulted the host.scePthreadGetnamenow builds the name (at most 31 characters and the terminator) in a local buffer, releases the thread's name lock, and writes it withGuestCopyOut_nid_no_patch, returningSCE_KERNEL_ERROR_EFAULTwhen the write fails;pthread_getname_npreturns 14.The order of the checks is unchanged:
scePthreadGetnamegivesEINVALfor a null thread or buffer andESRCHfor an unknown handle before it touches the buffer, andpthread_getname_npstill givesESRCHfor a null or joined thread andEFAULTfor a null buffer (the existing measured behaviour), with the buffer untouched in those cases. A valid buffer receives the same bytes as before.This is a host-safety fix, not console behaviour:
EFAULTfor a non-null bad buffer was not measured on a console, and FreeBSD 11.4's libthr has nopthread_get_name_npto take the order from. The entry is indocs/dev/debt/libkernel.md.Tested
Windows 11 (10.0.26200), WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release,
-DBUILD_TESTING=ON, on currentmain(rebased after the full suite onto 130 newer commits, one of which adds 6 lines elsewhere inPthread/src/Thread.cpp;guest_pthread_getnamewas rerun 3 times out of 3 on the rebased head).guest_pthread_getname: newCheckUnusableBufferscovers a buffer at 0x10, on aPROT_NONEpage, on a read-only page, and one byte short of the 5 byteskeptneeds before an unreadable page (EFAULTfrom both functions, also for a joined thread throughscePthreadGetname); the earlier checks winning over a bad buffer (ESRCHfor a null thread, a joined thread and an unknown handle;EINVALfor a null thread withscePthreadGetname); a buffer that ends exactly at the unreadable page (written, nothing before it disturbed); and a null buffer (EINVAL). Onmainthe test crashes; with this change it passes, three runs out of three. The existing name, joined-thread and null-buffer cases still pass.scePthreadRenamebranch (fix(libkernel): fail pthread_rename_np and scePthreadRename with EFAULT on an unreadable name #15567). 95 are the relinker and ELF tool tests that main gained recently, whose Python driver cannot start therelinkerexecutable, which is not in this build tree;vulkan_validation_gate_reportsandcheck_compile_test_windows_gcc_response_text_mode_is_not_reinterpretedfail because of the WindowsApps Python on this machine;agc_driver_store_over_untrackedandagc_driver_direct_write_completionare GPU tests that also fail with the thread code reverted tomain. Nothing thread related fails.python tools/check_conventions.py --base upstream/main: passes.Overlaps
tools/pr_overlap.pyreports no conflicting file or export. It lists #3986, #4563, #8592, #12130 and #12642 as sharingThread.cppwithout comparing them, because those PRs conflict withmainthemselves; none of their diffs changesscePthreadGetname(#12130 and #12642 only call it in new tests with a valid buffer, which still works). My own #15567 changesscePthreadRenamein the same file, a different function, and appends its own entry todocs/dev/debt/libkernel.md; the two entries are adjacent lines. #15567 was opened first, so it goes first and this PR rebases.Checklist
main; no other open PR implements the same functionNotImplemented_nid_no_patch); no silent stubs added.mdfiles or images added to the repositorydocs/dev/debt/libkernel.md)AI-assisted (Claude Code).
🤖 Generated with Claude Code