git: 838878fc632e - stable/14 - getpgrp(2), getsid(2): allow to call on zombies

Konstantin Belousov <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.src
Message-ID <6a72d7cc.26586.18f9c830__32120.9322124318$1785911364$gmane$org@gitrepo.freebsd.org>
The branch stable/14 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=838878fc632e8defadd45eef33fafed9bf598e13

commit 838878fc632e8defadd45eef33fafed9bf598e13
Author:     Konstantin Belousov <[email protected]>
AuthorDate: 2026-07-22 09:36:17 +0000
Commit:     Konstantin Belousov <[email protected]>
CommitDate: 2026-08-05 06:22:24 +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 44e7f2174089..320d5271a645 100644
--- a/sys/kern/kern_prot.c
+++ b/sys/kern/kern_prot.c
@@ -197,7 +197,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);
@@ -232,11 +232,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);
@@ -245,9 +246,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.