feat(libkernel_sys): implement kldload argument and privilege checks #11216
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11216"
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 Gruzzberry on 2026-10-25T21:58:26Z.
What
kldloadwas a throwing stub in libkernel_sys. FreeBSD 11.4'ssys_kldloadcopies the name in withcopyinstr(MAXPATHLEN), thenkern_kldloadcheckssecurelevel_gtandpriv_check(td, PRIV_KLD_LOAD)before any search or open. A title runs jailed and not as root, andprison_priv_checkgrants a jail noPRIV_KLD_LOAD, so every name that was copied in givesEPERM. Here the name is copied withCopyGuestPath_nid_no_patch: a null or unreadable pointer givesEFAULTand 1024 bytes or moreENAMETOOLONG, both before the privilege check, as in FreeBSD. Nothing is looked up or read afterwards, so a missing, an existing, a directory and a non-ELF name all giveEPERM. The new debt entry records that this follows the jailed-caller model, taken fromprison_priv_checkand not measured on a console.Tested
Windows 11 (10.0.26200), WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release,
-DBUILD_TESTING=ON, on currentmain(rebased).guest_kernel_sys: new checks for a null name and the unreadable address0x10, plus the unreadable-page fixture (EFAULT), a name of 1024 bytes (ENAMETOOLONG), and the empty name (copied in successfully, ascopyinstraccepts it), a bare module name, a missing path, an existing file, a directory and a path through a file (allEPERM). With the stub onmainthe test aborts atkldload_nid_postfix not implemented; with this change it passes, three runs out of three.mainbaseline; only the known environment failures (pr_overlap_encoding,agc_host_import_cut_lifetime,agc_driver_depth_plane_partial_store).python tools/check_conventions.py --base upstream/main: passes.kldloadreaches the file lookup is unverified.Overlaps
statfs/symlinkat) removes neighbouring stubs inExport.Discovery.cppandinclude/Api.hppand adds code atExport.cppL534-535: proposed on it that it goes first and this PR rebases.libkernel_sys.mdL41: proposed on each that it goes first and this PR rebases.getfsstat) and #11034 (swapon), both mine, touch the same debt line and the same test region: they were opened first, so they go first and this PR rebases.Checklist
main; no other open PR implements the same functionNotImplemented_nid_no_patch); no silent stubs added.mdfiles or images added to the repositoryAI-assisted (Claude Code).
🤖 Generated with Claude Code