git: 93f78e8fb89a - main - getpgid,getsid: Add capability mode checks

From: Ed Maste <emaste_at_FreeBSD.org>
Date: Thu, 12 Nov 2026 15:15:30 UTC
The branch main has been updated by emaste:

URL: https://cgit.FreeBSD.org/src/commit/?id=93f78e8fb89a54b6f2c37437a5b912203369daef

commit 93f78e8fb89a54b6f2c37437a5b912203369daef
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2026-06-01 17:13:07 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2026-11-12 15:15:20 +0000

    getpgid,getsid: Add capability mode checks
    
    Reviewed by:    markj
    Sponsored by:   The FreeBSD Foundation
    Differential Revision: https://reviews.freebsd.org/D57385
---
 sys/kern/kern_prot.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c
index 8f4dc4f5ebdf..d47dc8bfaa57 100644
--- a/sys/kern/kern_prot.c
+++ b/sys/kern/kern_prot.c
@@ -195,6 +195,8 @@ sys_getpgid(struct thread *td, struct getpgid_args *uap)
 		p = td->td_proc;
 		PROC_LOCK(p);
 	} else {
+		if (IN_CAPABILITY_MODE(td) && uap->pid != td->td_proc->p_pid)
+			return (ECAPMODE);
 		p = pfind_any(uap->pid);
 		if (p == NULL)
 			return (ESRCH);
@@ -235,6 +237,8 @@ kern_getsid(struct thread *td, pid_t pid)
 		p = td->td_proc;
 		PROC_LOCK(p);
 	} else {
+		if (IN_CAPABILITY_MODE(td) && pid != td->td_proc->p_pid)
+			return (ECAPMODE);
 		p = pfind_any(pid);
 		if (p == NULL)
 			return (ESRCH);