pdopenpid(2): allow in capability mode with restrictions

The pdopenpid() syscall is allowed to open processes which are either
direct children of the caller, or are debuggees already attached to the
calling process. This is reasonable because we could have controlled the
child on fork anyway.

The procdesc-less debuggee can legitimately appear due to ptrace
FOLLOW-FORK mode.

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58989
This commit is contained in:
Konstantin Belousov committed 2026-08-28 14:55:11 +03:00
1 parent 7006cb7bd2
commit 73c92a978c
2 files changed
+7 -1

No files matched your search

+6
View File
@@ -665,6 +665,12 @@ pdopenpid1(struct thread *td, pid_t pid, struct procdesc **pdf, struct file *fp)
PROC_UNLOCK(p); PROC_UNLOCK(p);
return (EBUSY); return (EBUSY);
} }
error = p_canopen(td, p);
if (error != 0) {
PROC_UNLOCK(p);
return (error);
}
pd = p->p_procdesc; pd = p->p_procdesc;
if (pd != NULL) { if (pd != NULL) {
MPASS((p->p_zombieref & PZOMBIEREF_PROCDESC) != 0); MPASS((p->p_zombieref & PZOMBIEREF_PROCDESC) != 0);
+1 -1
View File
@@ -3429,7 +3429,7 @@
int flags int flags
); );
} }
603 AUE_PDOPENPID STD { 603 AUE_PDOPENPID STD|CAPENABLED {
int pdopenpid( int pdopenpid(
pid_t pid, pid_t pid,
int flags int flags