Repository navigation
fix(libkernel): fail rtprio_thread, sched_setscheduler and setpriority with the jail privilege errors - #13896
Conversation
MarcZX10
left a comment
There was a problem hiding this comment.
Tests run and reviewed — approval deferred
The source changes match the cited FreeBSD jail checks, but the exact-current-base Windows run did not execute guest_rtprio_thread.
What I ran
Reviewed head 59bda82d4daa7e9b5bef421b2fa5d5c9702ff1f0 against PR base cbed91529193c47194bef11811906c7cb6054af1; the merge preview against current main b8f0a6b2025605b78eb70646bda79f458a577c82 was clean. Environment: Debian 12, Linux x86_64, Python 3.11.2; no local compiler or build was used.
python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 13896
git diff --check b8f0a6b2025605b78eb70646bda79f458a577c82...59bda82d4daa7e9b5bef421b2fa5d5c9702ff1f0
python3 tools/check_conventions.py --base b8f0a6b2025605b78eb70646bda79f458a577c82 --head 59bda82d4daa7e9b5bef421b2fa5d5c9702ff1f0
gh run view 41198173496 -R boykopovar/AnyPS5 --job 124528697285 --log | grep -E 'guest_rtprio_thread|guest_sched_priority|guest_kernel_sys|Test #[0-9]+|[0-9]+/[0-9]+ Test|100% tests passed|tests failed|Test project'I also inspected the exact-head implementations and assertions, the current-main test registrations, and the precheck's current-main merge preview.
Results
| Check | Result |
|---|---|
| Diff check and conventions | Passed against current main. |
| Current-main merge preview | Clean against b8f0a6b2025605b78eb70646bda79f458a577c82; no declared dependencies. |
| Source review | The setpriority and sched_setscheduler error ordering matches the cited FreeBSD flow; the real-time and idle rtprio_thread classes return EPERM. I found no separate source defect. |
| Hosted Windows | Passed. It built guest_rtprio_thread_tests, but CTest ran guest_kernel_sys and guest_sched_priority, not guest_rtprio_thread. |
| Other hosted checks | Eligibility, conventions, library portability, intake, labels and report passed; Linux and specialized jobs were skipped. |
| Author-provided tests | The PR reports all three tests passing 3/3, but the cited test base 049619c202f00698b6d559817577726fbeb1ca4d is 63 commits behind the PR base. I did not independently rerun those tests. |
| Precheck helper scripts | Diff, conventions and mergeability passed. Its ABI and test-quality helper invocations could not run because those helper files are absent from the isolated PR checkout; I manually verified the current-main CMake test registrations. |
Unedited relevant check output
All conventions checks passed.
windows Build and run changed guest core/libs tests 2026-10-31T11:56:50.5849589Z [2/8] Building CXX object core/libs/prx/libkernel/CMakeFiles/guest_sched_priority_tests.dir/__/__/tests/GuestSchedPriority.cpp.obj
windows Build and run changed guest core/libs tests 2026-10-31T11:56:50.7268866Z [3/8] Linking CXX executable tests\guest_sched_priority_tests.exe
windows Build and run changed guest core/libs tests 2026-10-31T11:56:50.7300857Z [4/8] Building CXX object core/libs/prx/libkernel/CMakeFiles/guest_rtprio_thread_tests.dir/__/__/tests/GuestRtprioThread.cpp.obj
windows Build and run changed guest core/libs tests 2026-10-31T11:56:50.8518021Z [5/8] Linking CXX executable tests\guest_rtprio_thread_tests.exe
windows Build and run changed guest core/libs tests 2026-10-31T11:56:59.2810169Z Test project D:/a/AnyPS5/AnyPS5/build
windows Build and run changed guest core/libs tests 2026-10-31T11:56:59.3832758Z Start 439: guest_kernel_sys
windows Build and run changed guest core/libs tests 2026-10-31T11:56:59.3904560Z Start 2805: guest_sched_priority
windows Build and run changed guest core/libs tests 2026-10-31T11:56:59.4208619Z 1/3 Test #2805: guest_sched_priority ................................................. Passed 0.03 sec
windows Build and run changed guest core/libs tests 2026-10-31T11:56:59.5524887Z 2/3 Test #439: guest_kernel_sys ..................................................... Passed 0.17 sec
windows Build and run changed guest core/libs tests 2026-10-31T11:57:01.0992896Z 100% tests passed, 0 tests failed out of 3
/usr/bin/python3: can't open file '/tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13896-59bda82d4daa/head-59bda82d4daa-6235b747/tools/pr_abi_audit.py': [Errno 2] No such file or directory
/usr/bin/python3: can't open file '/tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13896-59bda82d4daa/head-59bda82d4daa-6235b747/tools/pr_test_quality.py': [Errno 2] No such file or directory
Findings
Blocking
No source-level defect identified. Approval is deferred because the exact-current-base CI run does not execute the changed rtprio_thread test, and the reported local run used a substantially older main.
Non-blocking
The current-main CMake tree registers guest_rtprio_thread; the hosted job built its executable but its selected CTest run omitted it. The review would be complete with that focused test run on the current merge of this head and main.
Sources
- FreeBSD 11.4
sys_rtprio_threadprivilege and conversion order. - FreeBSD 11.4
sched_setschedulercopy and target lookup. - Reviewed implementation at this PR head.
- Current-main registration for
guest_rtprio_thread.
Not verified
I did not build or run C++ tests locally, independently reproduce the author’s Windows results, run Linux/macOS tests, or test a PS5. The exact-head Windows CI run did not execute guest_rtprio_thread.
To get this to a good state
Run guest_rtprio_thread on the exact PR head merged with current main and add the tested head/base and result to the PR. I will re-check the updated evidence and head.
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
|
@Gruzzberry Reviewed at
|
…y with the jail privilege errors A title is jailed (agreed on boykopovar#11216). FreeBSD 11.4 prison_priv_check denies PRIV_SCHED_RTPRIO, PRIV_SCHED_SET and PRIV_SCHED_SETPRIORITY to a jailed caller. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…etpriority debt entries Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
59bda82 to
97ff67b
Compare
|
Checked the three jail privilege paths against FreeBSD 11.4 ( Added a commit with both debt changes @oneandonlydean asked for: the measured text in the |
What
A title runs as a jailed uid 0 (the credential model agreed on #11216). FreeBSD 11.4's
prison_priv_checkgrants a jailed caller onlyPRIV_SCHED_DIFFCREDandPRIV_SCHED_CPUSETof the scheduler privileges and sends every other one to itsdefault:branch, which returnsEPERM.maindid the privileged work anyway. Three calls change, each at the position ofpriv_checkinkern_resource.candp1003_1b.c:rtprio_threadwithRTP_SETof a real-time (2), FIFO (10) or idle (4) class fails withEPERM(PRIV_SCHED_RTPRIO; idle needs it too becauseunprivileged_idpriois 0). It comes after the thread lookup (ESRCH) and the copy-in (EFAULT) and beforertp_to_pri, so a priority above 31 also givesEPERM. Before, these threw as not implemented.setprioritywith a negative nice fails withEACCES(donice:PRIV_SCHED_SETPRIORITY, the nice value of the process is 0), after thewhich(EINVAL) andwho(ESRCH) checks and forPRIO_PROCESS,PRIO_PGRPandPRIO_USER. A nice of 0 or more behaves as before.sched_setschedulercopies the parameter in first (EFAULT, now also for an unreadable non-null pointer), then finds the pid (ESRCHunless 0 or the guest's own), then fails every policy and priority withEPERM(PRIV_SCHED_SETis checked inkern_sched_setschedulerbefore the policy is looked at, so a bad policy no longer givesEINVAL). The call no longer records anything throughscePthreadSetschedparamand the own-pid case no longer throws.Not changed:
rtpriois not modelled onmain;sched_setparam,getpriority,cpusetand thescePthread*calls are untouched. The debt entries for the three calls say what a payload process outside a jail answered (rtprio_threadtype 2 gaveEINVAL;setpriorityaccepted -25 and -5) and that the jail result is 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(049619c).guest_rtprio_thread:RTP_SETof types 2, 4, 10 and 12 with priorities 0, 15, 31, 32 and 999, on the calling thread and on another thread, givesEPERMand leaves the request alone; an unreadable pointer still givesEFAULTand an unknown threadESRCHfirst.guest_sched_priority: negative nice (-1, -5, -20, -25, -99) givesEACCESfor the threewhichvalues,getprioritystays 0, an unknown pid with a negative nice still givesESRCH, a badwhichEINVAL, nice 0 and 5 return 0.guest_kernel_sys:sched_setschedulergivesEFAULTfor a null and for a0x10parameter (also with an unknown pid),ESRCHfor an unknown pid, andEPERMfor pid 0 and the guest's own pid with policies -1, 0, 1, 2, 3, 4 and 7 at priorities 700 and 300, leaving the thread's policy and priority as they were.mainall three tests fail; with this change they pass, three runs out of three.vulkan_validation_gate_reportsandcheck_compile_test_windows_gcc_response_text_mode_is_not_reinterpreted(the WindowsApps python in this environment) andannotate_module, a timeout under load that passes alone; nothing else differs from the lastmainresult.python tools/check_conventions.py --base upstream/main: passes.Overlaps
tools/pr_overlap.pyfailed closed and listed 50 pull requests it could not compare; I read the diffs of those that touchProcess.cpp,Thread.cpporExport.Discovery.cpp. None changesrtprio_thread,setpriorityorsched_setscheduler. The only neighbour is #9713, which adds a debt line two lines below thesched_setschedulerentry indocs/dev/debt/libkernel_sys.md; the hunks do not touch.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