From c8f8d00c2422bf7eca71b7b41e9d586ca25c4b8a Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Wed, 2 Sep 2026 01:14:58 +0300 Subject: [PATCH] ptrace(2): allow ptrace(PT_TRACE_ME) in cap mode Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D59317 --- sys/kern/sys_process.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c index 5c8f32773412..9b4f8dffddda 100644 --- a/sys/kern/sys_process.c +++ b/sys/kern/sys_process.c @@ -720,6 +720,8 @@ ptrace_check_allowed(struct thread *td, int req, bool pd_mode, pid_t pid) return (ECAPMODE); if (pd_mode) return (0); + if (req == PT_TRACE_ME) + return (0); if (req == PT_GET_CHILDREN && pid == td->td_proc->p_pid) return (0); if (req == PT_CLEARSTEP && pid == td->td_tid)