Repository navigation
syscall: signalling or rescheduling another process needs PR_CAP_ADMIN - #20425
Conversation
|
|
Please include full test logs. |
|
Full log of the flat run,
|
d5a5132 to
5a035e5
Compare
casaroli
left a comment
There was a problem hiding this comment.
This one is clean, and the placement is right: the checks are in the public functions and the nx variants stay open, so the kernel can still signal and reschedule on its own account.
#20417 is merged now, so this can rebase to its own two commits and come out of draft. Please also add the Assisted-by trailer.
Test: I rebased on master (c7cba68) and ran qemu-armv8a:knsh with CONFIG_SCHED_CAPABILITIES and a program that drops PR_CAP_ADMIN and then acts on pid 1: kill(1, SIGUSR1) and sched_setparam(1) return EPERM, and kill(1, 0) and kill(getpid(), 0) still return 0. On master the same calls return 0; pid 1 there is the hpwork kernel thread. ostest exits 0 on knsh and nsh.
A note for the docs: a program that keeps PR_CAP_ADMIN (the default) can still signal and reprioritise kernel threads; only a program that drops it is stopped. That is the stated model, but one line in the docs would make it clear.
kill, tgkill, sigqueue, sched_setparam, sched_setscheduler, sched_setaffinity, the pthread set calls, pthread_cancel and PR_SET_NAME_EXT acted on any thread in the system. They now need PR_CAP_ADMIN when the target is outside the caller's process, in every build. Signal 0 stays open. Kernel callers use the nx variants and stay unchecked. Signed-off-by: Royyan Zahir <[email protected]>
lm3s6965-ek:qemu-flat fills its 256 KB of flash to the last few hundred bytes, and the capability checks overflow it by 200. Signed-off-by: Royyan Zahir <[email protected]>
Note: Please adhere to Contributing Guidelines.
Summary
#20417 is merged. Rebased onto
39ebce866c; this PR now contains only the cross-process checks and the lm3s6965-ek:qemu-flat size adjustment.Any process could signal, reschedule, cancel or rename any thread in the system. A process with no capabilities could still kill or starve the ones that hold them.
kill,tgkill,sigqueue,sched_setparam,sched_setscheduler,sched_setaffinity,pthread_setschedparam,pthread_setschedprio,pthread_setaffinity_np,pthread_cancelandPR_SET_NAME_EXTnow needPR_CAP_ADMINwhen the target is outside the caller's process. Signal 0 stays open. The check sits in each public function, so it holds in every build. Unlike the spawn and mount checks in #20417 it stays out of thenxvariants: the kernel signals and reschedules other processes on its own account through them.Impact
Every build with
CONFIG_SCHED_CAPABILITIES. Acting on another process needsPR_CAP_ADMIN; nothing changes until a process drops it. A process retainsPR_CAP_ADMINby default and can still signal or reprioritise kernel threads while it holds that capability.Testing
Rebase validation, 2026-10-24
Ubuntu 26.04.1, x86_64, GCC 15.2.0. NuttX
0eaf9bca49, appsb89cb41.sim:ostest,CONFIG_SCHED_CAPABILITIES=y,CONFIG_TESTING_OSTEST_LOOPS=1.Build completed without compiler warnings. OSTest completed with exit status 0; the runtime log contains hrtimer latency warnings above 10 ms. This is simulator regression coverage, not a fresh hardware or kernel-build test.
tools/checkpatch.sh -m -g upstream/master..HEADpasses.git range-diffconfirms both patches are unchanged by the rebase.Earlier validation, before this rebase
Host: Ubuntu 24.04, x86_64. Builds and QEMU runs in
ghcr.io/apache/nuttx/apache-nuttx-ci-linux(QEMU 6.2, Arm GNU GCC 13.2, xPack RISC-V GCC 14.3). Hardware: i.MX93 (Cortex-A55), PX4 kernel build.qemu-armv8a:nsh, flat, with the newostestcasecaps_test: PASSED;ostestpassesqemu-armv8a:knshostestpasses;hellorv-virt:knsh64hello;osteststops afterStarted user_main at PID=6, as master doesqemu-armv8a:nsh_smpqemu-intel64:knsh_romfs,rv-virt:knetnsh64andsim:nshA process that dropped every capability, aimed at its parent, on the i.MX93:
kill(parent, SIGUSR2)EPERMkill(parent, 0)sched_setparam(parent)EPERMsched_setparam(own pid)qemu-armv8a:nsh, flat, with the newostestcase: the caps part and the endqemu-armv8a:knsh:hello, thenostestrv-virt:knsh64:hello, thenostest; identical to master'si.MX93, PX4 kernel build, an earlier revision of this series:
tests isolationtools/checkpatch.sh -c -u -m -gclean.