git: 70d08c69f4d0 - main - p1003_1b: Add capability mode checks
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 11 Nov 2026 15:13:50 UTC
The branch main has been updated by emaste:
URL: https://cgit.FreeBSD.org/src/commit/?id=70d08c69f4d0cb3e53347f2dd8dd06007c5d635a
commit 70d08c69f4d0cb3e53347f2dd8dd06007c5d635a
Author: Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2026-05-29 20:57:49 +0000
Commit: Ed Maste <emaste@FreeBSD.org>
CommitDate: 2026-11-11 15:13:24 +0000
p1003_1b: Add capability mode checks
The sched_* syscalls can operate either on the calling process (by
setting pid = 0) or by specifying a pid. They are allowed in capability
mode, but previously were not scoped to only operating on the calling
process.
Reviewed by: olce
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D57346
---
sys/kern/p1003_1b.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/sys/kern/p1003_1b.c b/sys/kern/p1003_1b.c
index 96730f22596c..2f382aa52821 100644
--- a/sys/kern/p1003_1b.c
+++ b/sys/kern/p1003_1b.c
@@ -40,6 +40,7 @@
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/capsicum.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/module.h>
@@ -130,6 +131,8 @@ user_sched_setparam(struct thread *td, pid_t pid,
targettd = td;
PROC_LOCK(targetp);
} else {
+ if (IN_CAPABILITY_MODE(td) && pid != td->td_proc->p_pid)
+ return (ECAPMODE);
targetp = pfind(pid);
if (targetp == NULL)
return (ESRCH);
@@ -177,6 +180,8 @@ user_sched_getparam(struct thread *td, pid_t pid, struct sched_param *param)
targettd = td;
PROC_LOCK(targetp);
} else {
+ if (IN_CAPABILITY_MODE(td) && pid != td->td_proc->p_pid)
+ return (ECAPMODE);
targetp = pfind(pid);
if (targetp == NULL) {
return (ESRCH);
@@ -231,6 +236,8 @@ user_sched_setscheduler(struct thread *td, pid_t pid, int policy,
targettd = td;
PROC_LOCK(targetp);
} else {
+ if (IN_CAPABILITY_MODE(td) && pid != td->td_proc->p_pid)
+ return (ECAPMODE);
targetp = pfind(pid);
if (targetp == NULL)
return (ESRCH);
@@ -276,6 +283,8 @@ sys_sched_getscheduler(struct thread *td, struct sched_getscheduler_args *uap)
targettd = td;
PROC_LOCK(targetp);
} else {
+ if (IN_CAPABILITY_MODE(td) && uap->pid != td->td_proc->p_pid)
+ return (ECAPMODE);
targetp = pfind(uap->pid);
if (targetp == NULL)
return (ESRCH);
@@ -369,6 +378,8 @@ kern_sched_rr_get_interval(struct thread *td, pid_t pid,
targetp = td->td_proc;
PROC_LOCK(targetp);
} else {
+ if (IN_CAPABILITY_MODE(td) && pid != td->td_proc->p_pid)
+ return (ECAPMODE);
targetp = pfind(pid);
if (targetp == NULL)
return (ESRCH);