git: 18ea9571f7a4 - stable/15 - getpgrp(2), getsid(2): allow to call on zombies

Konstantin Belousov <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.src
Message-ID <6a66a691.30e9a.54c025e9__41246.9279531919$1785112590$gmane$org@gitrepo.freebsd.org>
The branch stable/15 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=18ea9571f7a423059b7f34903ebb0201afed660a

commit 18ea9571f7a423059b7f34903ebb0201afed660a
Author:     Konstantin Belousov <[email protected]>
AuthorDate: 2026-07-22 09:36:17 +0000
Commit:     Konstantin Belousov <[email protected]>
CommitDate: 2026-07-27 00:28:43 +0000

    getpgrp(2), getsid(2): allow to call on zombies
    
    (cherry picked from commit 8f320c2bc473a775ea9a55d17fa61f729e593867)
---
 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_
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.