git: fe56ee28349c - stable/15 - ptrace(2): allow ptrace(PT_TRACE_ME) in cap mode

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Sat, 05 Sep 2026 00:35:33 UTC
The branch stable/15 has been updated by kib:

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

commit fe56ee28349cbc8e35c898864077aa844a155e61
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-09-01 22:14:58 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-09-05 00:33:43 +0000

    ptrace(2): allow ptrace(PT_TRACE_ME) in cap mode
    
    (cherry picked from commit c8f8d00c2422bf7eca71b7b41e9d586ca25c4b8a)
---
 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 af8a7dafaf3e..56c5eebc8a85 100644
--- a/sys/kern/sys_process.c
+++ b/sys/kern/sys_process.c
@@ -686,6 +686,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)