git: 8f320c2bc473 - main - getpgrp(2), getsid(2): allow to call on zombies
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 23 Jul 2026 23:51:12 UTC
The branch main has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=8f320c2bc473a775ea9a55d17fa61f729e593867
commit 8f320c2bc473a775ea9a55d17fa61f729e593867
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-07-22 09:36:17 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-07-23 23:50:13 +0000
getpgrp(2), getsid(2): allow to call on zombies
Also be more protective in getsid().
Reported by: arrowd
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differrential revision: https://reviews.freebsd.org/D58393
---
sys/kern/kern_prot.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c
index a223a7720844..5aa7fcf7c653 100644
--- a/sys/kern/kern_prot.c
+++ b/sys/kern/kern_prot.c
@@ -196,7 +196,7 @@ sys_getpgid(struct thread *td, struct getpgid_args *uap)
p = td->td_proc;
PROC_LOCK(p);
} else {
- p = pfind(uap->pid);
+ p = pfind_any(uap->pid);
if (p == NULL)
return (ESRCH);
error = p_cansee(td, p);
@@ -231,11 +231,12 @@ kern_getsid(struct thread *td, pid_t pid)
struct proc *p;
int error;
+ error = 0;
if (pid == 0) {
p = td->td_proc;
PROC_LOCK(p);
} else {
- p = pfind(pid);
+ p = pfind_any(pid);
if (p == NULL)
return (ESRCH);
error = p_cansee(td, p);
@@ -244,9 +245,12 @@ kern_getsid(struct thread *td, pid_t pid)
return (error);
}
}
- td->td_retval[0] = p->p_session->s_sid;
+ if (p->p_session != NULL)
+ td->td_retval[0] = p->p_session->s_sid;
+ else
+ error = EINVAL;
PROC_UNLOCK(p);
- return (0);
+ return (error);
}
#ifndef _SYS_SYSPROTO_H_