git: 973698a330c3 - main - clock_gettime: Add capability mode check
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 13 Nov 2026 15:00:59 UTC
The branch main has been updated by emaste:
URL: https://cgit.FreeBSD.org/src/commit/?id=973698a330c3c956359a99933b02e11e1f609526
commit 973698a330c3c956359a99933b02e11e1f609526
Author: Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2026-11-12 15:52:18 +0000
Commit: Ed Maste <emaste@FreeBSD.org>
CommitDate: 2026-11-13 14:59:41 +0000
clock_gettime: Add capability mode check
clock_gettime is permitted in capability mode, and it calls get_cputime
if clock_id is negative. get_cputime did not check the target pid in
capability mode.
Reported by: llm-postcr
Reviewed by: markj, Osvaldo Janeri Filho <ojanerif@amd.com>
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D61469
---
sys/kern/kern_time.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c
index 0e637299ae53..18ee05942d1a 100644
--- a/sys/kern/kern_time.c
+++ b/sys/kern/kern_time.c
@@ -35,6 +35,7 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/limits.h>
+#include <sys/capsicum.h>
#include <sys/clock.h>
#include <sys/lock.h>
#include <sys/mutex.h>
@@ -302,6 +303,8 @@ get_cputime(struct thread *td, clockid_t clock_id, struct timespec *ats)
PROC_UNLOCK(td2->td_proc);
} else {
pid = clock_id & CPUCLOCK_ID_MASK;
+ if (IN_CAPABILITY_MODE(td) && pid != td->td_proc->p_pid)
+ return (ECAPMODE);
error = pget(pid, PGET_CANSEE, &p2);
if (error != 0)
return (EINVAL);