feat(libkernel_sys): implement _execve and _execvpe exports #14299
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/14299"
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-01T07:22:43Z.
What
Implement
_execveand_execvpewith checked guest argument copying, FreeBSD-style validation andPATHsearch. Recognized ELF/SELF candidates now call libkernel's existingexecvereplacement path with copied argument and environment vectors, so they can launch a converted executable._execvperetains FreeBSD 11.4's per-candidate errno handling andENOEXECretry through/bin/sh. Its name read is bounded to 1024 bytes; oversized names end with the search'sENOENT. The search uses guestPATH, independently of the replacement's explicit environment. SeeexecvPeand kernelexec_copyin_args/exec_check_permissions.Review fixes make the shared helper private, use
NotImplemented_nid_no_patchfor unsupported script and null-path execution, remove exact exception-message assertions, and add process-replacement fixtures for both exports. Keeping the FreeBSD candidate loop avoids changing libkernel's existing first-matchexecvpsearch behavior.The debt entries now state remaining gaps first and inherit converted-target restrictions from libkernel. Corrected the pending inventory to 323 exports: 163 named and 160 unresolved. Console behavior is unverified. Land after #14257, then reconcile its independently updated inventory counts when rebasing; #14304 follows this PR.
A null pathname in
_execveremains unsupported: FreeBSD 11.4'sdo_execveselects descriptor-based execution there, which this implementation does not model. Equivalence to libkernelexecve's separately measured null-pathEBADFis unverified._execvpechecks a null search name before candidate execution and returnsEFAULTas a checked-read fallback.Both exports inherit libkernel's environment merge: host
environentries survive unlessenvpoverrides their names. The supplied environment does not completely replace the inherited one; this limitation is explicit in the debt entry.Tested
maine67cc81869: built both errno test executables,guest_exec_host, andrelinker.ctest --test-dir build -R '^(guest_kernel_sys_exec(ve|vpe)|exec_arguments|exec_sys_(ve|vpe)_arguments)$' --output-on-failure: 5/5 passed outside the syscall-restricted sandbox. The two new process fixtures verify actual image replacement, arguments, explicit environment, working directory, PID behavior and absence of exit-handler execution. The errno tests cover invalid guest reads, path and argument limits, access errors, default/guest/emptyPATH, and shell fallback. Search fixtures now use a unique temporary directory.399bb8f19a; the subsequent null-path and environment clarification changes documentation only.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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-01T09:03:00Z.
Review: COMMENTED
Reviewed — no blocking findings
The two new tests pass on hosted Windows at this head and the errno ladders match the PR body in source reading; the open points below are non-blocking, the main one being that the existing libkernel
execvealready replaces the process for ELF images.What I ran
Exact head reviewed:
a37dcc1320fb22da78e9afe2744334cb0dac66aa(commitscf77fa4bcc,_execve, anda37dcc1320,_execvpe). PR base3e29acc3805f15e19a0c8f55eedb0c93e92f2f90. Merge preview against currentmainc674f8c14da93df7a6b37657117ca3f58357477f: clean (git merge-tree --write-tree, exit 0, no conflicts).Environment: Debian host, git 2.39.5, system Python 3. No build, no compile, no local test run. The checks were run from the trusted checkout
/marc/AnyPS5/toolsagainst the PR's git objects; the PR's own tools and tests were not executed.The
pr_precheck.pywrapper was not run for this head, for the same reason as the review of #14096: its isolated checkout would execute PR-head tooling and tests.Results
git diff --checkover the PR rangepr_abi_audit.py, by hand)passed, 325 symbols, 0 findings; lexical onlypr_test_quality.py)possible-unregistered-cpp-testfindings, false positives: the CMake path is relative (tests/...); registration is explicit atcore/libs/CMakeLists.txtL505-L519Buildrun 41284550676, job 124783770803guest_kernel_sys_execveandguest_kernel_sys_execvpePassed; 2581 of 2581 tests passedUnedited hosted log lines (Windows job)
Findings
Blocking: none.
Non-blocking:
execve. In libkernel,execve,execvandexecvpalready replace the process for ELF images throughExecProgram, which callsfexecveon Linux (Process.cpp L842-L892 atmain). The new_execveand_execvperefuse the same images with "program activation is not modelled" (AdditionalExports.cpp L295 at the head). The PR body lists this as a follow-up, but the head has no such commit. Either route the libkernel_sys exports through the same activation, or say in the debt bullet why they refuse whatexecveperforms.std::runtime_error, notNotImplemented_nid_no_patch, soNotImplementedCalls_nid_no_patchdoes not count them (General.cpp L1020-L1023 atmain). The PR checklist says unimplemented paths throw throughNotImplemented_nid_no_patch. Use it, or note the deviation in the debt bullet._execvpereads the name with no length cap; the loop ends only at a NUL or an unreadable page (AdditionalExports.cpp L326-L338 at the head)._execvecaps its path at 1024 bytes. A cap would bound host allocation for hostile names.execve, exact-message asserts in the tests, and the debt bullet length) are not yet in the head. The_execvedebt bullet is exactly 1000 characters, which is not over thedebt-lengthwarning threshold intools/check_conventions.py.Sources
ExecProgramandexecveat upstreammainmainNot verified
#ifndef _WIN32EACCES cases and the Linux permission path) rest on the author's report of a local Linux build andctest -R 'guest_kernel_sys'(28/28); not run here._execvpemapsENAMETOOLONGfor a slash-containing name longer than 1024 bytes toENOENTwas not checked against FreeBSD.AdditionalExports.cpp, its header and the libkernel_sys debt file, was not resolved here. The PR's merge preview against currentmainis clean.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-01T11:58:11Z.
Review: COMMENTED
Re-checked — new head, earlier points addressed in source
The four non-blocking points in my review at
a37dcc1320are addressed at399bb8f19ain source, and I found no new blocking issue; approval waits for the hosted Windows run at this head, which is still queued.What I ran
Exact head
399bb8f19a88a90515b9b77cc9ecf6cb56b7c3a8; PR basee67cc818696fd6e6c58ac80adc6550c54aed68e8, unchanged at completion. Delta read:a37dcc1320..399bb8f19a, limited to the PR's own commits (664b12ae45,d42bf12baf,399bb8f19a). The merge commits frommainin that range were not treated as PR changes. Environment: Linux, Python 3.11; no compiler and no build. Commands:The precheck's ABI and test-quality helpers were missing from the isolated head tree, so I ran both by hand from
/marc/AnyPS5/tools.Results
possible-unregistered-cpp-testfindings, one per changed test file; false positives of the same kind as before, since CMake uses relative pathswindowsqueued at 11:57 UTC; no hosted test result yetFindings
Blocking: none.
Non-blocking, status of the earlier points:
execve: addressed. The ELF, PS4 SELF and PS5 SELF branch ofGuestExecve_nid_no_patchnow callsexecve_nid_postfixwith checked argument and environment copies, instead of refusing (AdditionalExports.cpp,GuestExecve_nid_no_patch, at this head).NotImplemented_nid_no_patch: addressed for the exec path. The script and null-path refusals now useNotImplemented_nid_no_patch(__func__)._execvpe: addressed. The name read stops atGuestCandidateMax(1024 bytes), and a name that fills the cap returns ENOENT._execvedebt bullet is about 820 characters.Sources
GuestExecve_nid_no_patchand_execvpeat the reviewed headNot verified
399bb8f19ahas not finished; no CTest result exists yet for this head.To get this to a good state
Nothing further is needed from the author for the source points above. The approval waits for the hosted Windows run at
399bb8f19a.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-01T12:00:35Z.
Review: COMMENTED
Re-checked — new head, two non-blocking points
This adds two points to the review at
399bb8f19a(5727927314) that it does not cover, and I found no blocking issue.What I ran
Exact head
399bb8f19a88a90515b9b77cc9ecf6cb56b7c3a8, basee67cc818696fd6e6c58ac80adc6550c54aed68e8. Source read ofcore/libs/prx/libkernel_sys/AdditionalExports.cppandcore/libs/prx/libkernel/System/src/Process.cppat this head. No build, no compile, no local test run. The precheck and helper results are the same as in 5727927314 and are not repeated here.Findings
Blocking: none.
Non-blocking:
_execve(NULL, argv, envp)now throws throughNotImplemented_nid_no_patch(AdditionalExports.cppL268), after the argument and environment copies. The libkernelexecvedebt entry records a null path asEBADF(measured) (docs/dev/debt/libkernel.mdL240), and the same kernel'sExecProgramreturnserrnoBadFile(9) for a null file (Process.cppL845). Null is therefore not clearly unsupported here. Either returnEBADFinGuestExecve_nid_no_patch, or say in the_execvedebt bullet (docs/dev/debt/libkernel_sys.mdL352) why it differs fromexecve._execvpe(NULL, ...)returnsEFAULTat the same head, so the two new exports also differ from each other.ExecProgramkeeps hostenvironentries thatenvpdoes not name (Process.cppL876-L888). The libkernel debt entry documents this forexecve, butexecve(2)replaces the environment._execveinherits the difference, and its debt bullet says only that it inherits libkernel limitations. Naming this one there would make it explicit.Sources
GuestExecve_nid_no_patchnull-path check at399bb8f19aExecProgramat399bb8f19aexecveat399bb8f19aTo get this to a good state
A decision on the null-path answer (item 1), and naming the environment merge in the
_execvedebt bullet (item 2). Approval still waits for the hosted Windows run at this head.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-01T12:10:46Z.
Review: COMMENTED
Re-checked — new head, both points addressed in the debt entry
The two non-blocking points in the 12:00 review at
399bb8f19aare answered in the_execvedebt bullet atf9474c5040, and no code change is needed for them.What I ran
Exact head
f9474c5040(the only new commit isf9474c5040, which changesdocs/dev/debt/libkernel_sys.mdby one line). PR basee67cc818696fd6e6c58ac80adc6550c54aed68e8. No build, no compile and no test run. Source read of the code the bullet describes, at this head:GuestExecve_nid_no_patch, the null-path check, AdditionalExports.cpp L268 (if (path == nullptr) NotImplemented_nid_no_patch(__func__);).ExecProgram, the environment merge, Process.cpp L872-L891: hostenvironentries are kept unless the guestenvpnames them.Findings
Blocking: none.
Non-blocking, status of the two points:
_execveshares libkernelexecve's measuredEBADFis unverified. That is the explanation the point asked for; returningEBADFis not required._execvemerges hostenvironwithenvpname overrides instead of replacing the environment, which matches the code above.Not verified
f9474c5040was not complete when I checked it.To get this to a good state
Nothing further is needed for these two points.