git: 5b3e5c6ce3e5 - main - kcmp_pget(): do not accept TIDs

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Tue, 30 Apr 2024 07:07:25 UTC
The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=5b3e5c6ce3e552dae3e84d6bc781bc9f53c22d71

commit 5b3e5c6ce3e552dae3e84d6bc781bc9f53c22d71
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-04-29 21:04:25 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-04-30 07:07:03 +0000

    kcmp_pget(): do not accept TIDs
    
    Otherwise pget() might still look up and hold the current process.
    
    Reported and tested by: pho
    Sponsored by:   The FreeBSD Foundation
    MFC after:      3 days
---
 sys/kern/sys_generic.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sys/kern/sys_generic.c b/sys/kern/sys_generic.c
index cc1126ac4dc4..99b018dee26c 100644
--- a/sys/kern/sys_generic.c
+++ b/sys/kern/sys_generic.c
@@ -2098,7 +2098,8 @@ kcmp_pget(struct thread *td, pid_t pid, struct proc **pp)
 		*pp = td->td_proc;
 		return (0);
 	}
-	error = pget(pid, PGET_CANDEBUG | PGET_NOTWEXIT | PGET_HOLD, pp);
+	error = pget(pid, PGET_NOTID | PGET_CANDEBUG | PGET_NOTWEXIT |
+	    PGET_HOLD, pp);
 	MPASS(*pp != td->td_proc);
 	return (error);
 }