Repository navigation
feat(libkernel_sys): add chroot that keeps the guest root - #5191
Conversation
Porpoise (PPSA99764) imports chroot (AKknh8Cx-V8) from libkernel_sys.prx, not libkernel.prx, one reference. Predicted stop once pathconf, the pthread_attr calls and ftrylockfile ahead of it are covered (not a run): FAIL: unresolved ELF import AKknh8Cx-V8 from libkernel_sys.prx The NID is computed with tools/nid_names.py and matches aerolib. Follows FreeBSD 11.4 sys/kern/vfs_syscalls.c sys_chroot and change_dir (8c639945a44588f6cfdddfb057bb5aad88735da0) for a root caller up to the lookup: EFAULT for a null path, ENOENT for an empty or missing one, ENOTDIR for a file or a path through a file. A directory that is found throws with the path named: the resolver's root is fixed and the mount aliases (/app0, /savedata0) are host paths that do not move with it, so it cannot be re-based, and a real chroot is not modelled. Nothing shows that Porpoise calls it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Porpoise (PPSA99764) stops on its weak chroot import (boykopovar#3632, boykopovar#4497). Run 5 on main c2565f0, and again on a copy of that runtime: FAIL: unresolved ELF import AKknh8Cx-V8 from libkernel_sys.prx Its only call is in put_root_back (src/porpoise_jailbreak.cpp, elripalda/Porpoise-Dolphin-Emulator-for-PS5 2ed1ab5a06995aa1): after a jailbreak daemon has made the console's root its root and /app0 is gone, it calls fchdir on the descriptor of "/" it opened at start, then chroot("."), and checks the result. So it only ever puts back the root it started in, and it does not use paths under any other root. On top of the lookup errors of the previous commit, chroot now follows FreeBSD 11.4 sys_chroot and pwd_chroot (8c639945, vfs_syscalls.c and kern_descrip.c) for that case: a directory that is the guest root ("/", "/..", "." after fchdir to "/") succeeds without a change, since fd_rdir would be set to the vnode it already is. The guest is taken never to have changed its root, so with chroot_allow_open_directories 1 an open directory does not give EPERM. ENAMETOOLONG is added as in pathconf, and a ".." through a file reports ENOTDIR instead of escaping as a filesystem_error. Any other directory still throws: the resolver's root and mount aliases are fixed, and no title is known that needs a real new root. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Checked on main merged with the PR: |
|
Linux validation on the exact PR head: GCC 12.2, Release, |
|
Checked on main merged with the PR: |
|
Linux run: Ubuntu in WSL2, GCC 15.2.0, Ninja Release, |
What
Carries @screamm's two
chrootcommits fromscreamm:feat/libkernel-sys-chroot(059d98cf,15f673ee, author kept), which they offered in #3632 for anyone eligible to carry.Porpoise (PPSA99764, catalog release) imports
chroot(AKknh8Cx-V8) fromlibkernel_sys.prx. On Windows, currentmainrefuses to load it:chrootfollows FreeBSD 11.4sys_chroot/change_dirup to the lookup:EFAULTfor a null path,ENOENTfor an empty or missing one, andENOTDIRfor a file or a path through a file.put_root_back(Porpoisesrc/porpoise_jailbreak.cpp). It callsfchdiron the/it opened at start, thenchroot("."). So a directory that is already the guest root succeeds without a change, as FreeBSD'spwd_chrootwould leavefd_rdirwhere it is. Any other directory still throws, because the resolver's root and mount aliases are fixed.libkernel_sysdebt entry.Tested
main3faa9cb40with fix(libSceVideoOut): return RESOURCE_BUSY when a bus is opened twice #4863 (its next stop isVideoOut: port already open). Before, it does not load. After, it loads and runs for the whole 60 s run with no exception. On Linux the weak import already resolves; the same title stops there on the VideoOut open that fix(libSceVideoOut): return RESOURCE_BUSY when a bus is opened twice #4863 fixes.guest_kernel_sys(from the commits) andguest_filesystempass on Windows;python tools/check_conventions.py --base origin/mainpasses. The commits apply to currentmainwithout changes.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