feat(libkernel_sys): implement _execve export #14275
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/14275"
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 bipinkrish on 2026-11-01T06:04:21Z.
What
_execve(NID-3nj+K1elI0) inlibkernel_systhrew throughNotImplemented_nid_no_patch. It now follows FreeBSD 11.4'sexec_copyin_argsandexec_check_permissionsargument ladder up to the point of activation:argvisEFAULTbefore the pathname is read; the pathname is copied in page-sized pieces throughGuestCopyIn_nid_no_patchand refuses pastPATH_MAX1024 withENAMETOOLONG.argventry and, when not null, everyenvpentry is read through checked guest reads; an unreadable entry or string isEFAULT. Lengths are charged to one sharedARG_MAXstringspace of 262144 bytes counting each terminating NUL, so an entry that no longer fits turns the call intoE2BIG.ENOENT; FreeBSD would instead execute the file open on descriptor 0 (args->fdis never set forexec_copyin_args), which stays unmodelled.ENOTDIR.exec_check_permissionsorder: no execute bits or a non-regular file isEACCES(the mode-bit gate is POSIX-only), a zero-size file isENOEXEC, refusal throughExecutePermissionisEACCES, and a file the host cannot reopen for reading isEACCES, matching FreeBSD'sVOP_OPEN(vp, FREAD)at kern_exec.c L1677.ELFmagic, the PS4SELFmagic4F 15 3D 1Dor the PS5SELFmagic54 14 F5 EE(both measured) throws, naming the path, since replacing the running relinked image is not modelled. A#!script throws, since script interpreters are not modelled. Every other format isENOEXEC.Unmodelled FreeBSD paths:
MNT_NOEXEC,ETXTBSYfor a vnode open for writing,#!interpreter-name parsing and redirection, the Windows mode-bit gate and resolver search-permission checks. The console's own acceptance of plainELFimages is unverified.The declaration takes the FreeBSD parameter list
const char* path, char* const* argv, char* const* envp, and the debt entry moves_execvefrom the NID table of pending exports to an implementation bullet._execvpe(ScfDTOqLOMw) stays a pending placeholder for a follow-up PR.Tested
Linux, a local build with the new
guest_kernel_sys_execvetest: theEFAULTladder (nullargv, unreadableargvandenvpentries, unreadable strings, checked before the pathname), a 1023-byte path resolving toENOENTwhile a 1024-byte path isENAMETOOLONG, a missing path and a directory (ENOENTandEACCES), a zero-size file isENOEXEC, a mode-0644 file isEACCES(#ifndef _WIN32), 128 argument strings of 2048 bytes charge the sharedARG_MAXstringspace intoE2BIG, andELF, PS4 and PS5SELFimages and a#!script throw with their exact messages.ctest -R 'guest_kernel_sys': 27/27 passed. No GPU or console testing (n/a).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)Pull request closed