Repository navigation
fix(libkernel): fail sceKernelStat with EFAULT for a null buffer - #5464
Merged
oneandonlydean merged 1 commit intoOct 14, 2026
Merged
Conversation
Crimson Desert (PPSA25286) calls sceKernelStat with a null buffer at start-up, and main throws "sceKernelStat: sb is null", which ends the title in its first second. FreeBSD 11.4 looks the path up first and only then copies the result out, so a null buffer gets EFAULT for a path that exists and the lookup error for one that does not (sys/kern/vfs_syscalls.c, sys_stat): error = kern_statat(td, 0, AT_FDCWD, uap->path, UIO_USERSPACE, &sb, NULL); if (error == 0) error = copyout(&sb, uap->ub, sizeof (sb)); sceKernelStat now does the same: the lookup and its errors are as before, and a null buffer returns SCE_KERNEL_ERROR_EFAULT where the status would be copied. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
11 tasks done
11 tasks done
Contributor
|
Windows 10 (19045), MinGW-w64 GCC 15.2.0, Release,
AI-assisted (Claude Code). |
Contributor
Author
|
Thanks, @xXPBSXx. That covers Windows, including the failing run without the change. I've added it to the description. AI-assisted: yes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Crimson Desert (PPSA25286) calls
sceKernelStatwith a null buffer at start-up. Onmainthat throws and ends the title in its first second:FreeBSD 11.4 looks the path up first and only then copies the result out (
sys_stat,sys/kern/vfs_syscalls.c):So a null buffer gets
EFAULTfor a path that exists, and the lookup's own error for one that does not.sceKernelStatnow does the same: the lookup and its errors are unchanged, and a null buffer returnsSCE_KERNEL_ERROR_EFAULTwhere the status would be copied.statalready returnsEFAULTfor a null buffer before it callssceKernelStat, so it is unaffected.guest_filesystemgains two checks:sceKernelStatwith a null buffer gets0x80020002for a missing path and0x8002000Efor..#4938 also rewrites the end of
sceKernelStat(one host query instead of several) and keeps the null-buffer throw. The two do not depend on each other, and whichever lands second needs a small rebase.Tested
Ubuntu 24.04, GCC 13.3 (CI's compiler), Release with CI's configure flags, on
maindacd785, RTX 4070 Ti (NVIDIA 580.142):main'sOpen.cppand the new checks,guest_filesystemthrowssceKernelStat: sb is null; with the change it passes 20/20.guest_*tests pass in two runs.--to-inteland run on Linux:mainit stops at 0 s with the lines above.sceHttp2SendRequestAsync not implemented, a separate gap.tools/check_conventions.py --base upstream/mainpasses.eb78c6a45) merged ontomaince5c83953.guest_filesystempasses; withmain'sOpen.cppand the new checks it fails with an unhandledstd::invalid_argument(0xc0000409).Not checked on a console.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code