fix(libkernel): fail sceKernelStat with EFAULT for a null buffer #5464
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5464"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-13T20:21:11Z.
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
maindacd78525, 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
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T20:32:25Z.
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.
main)core/libs/prx/libkernel/File/src/Open.cppL301-313Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-14T00:51:49Z.
Windows 10 (19045), MinGW-w64 GCC 15.2.0, Release,
-j4: headeb78c6a45of this PR merged ontomaince5c83953(clean merge, 2 files).guest_filesystempasses (0.82 s, ctest).core/libs/prx/libkernel/File/src/Open.cpptaken back tomainand the PR's new test lines kept,guest_filesystemfails ([libc] unhandled exception 'St16invalid_argument', exit code0xc0000409).AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-14T00:52:24Z.
Thanks, @xXPBSXx. That covers Windows, including the failing run without the change. I've added it to the description.
AI-assisted: yes