git: 10893331d133 - releng/15.2 - ptrace: Call ptrace_check_allowed() from the compat32 layer
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 17 Nov 2026 17:10:04 UTC
The branch releng/15.2 has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=10893331d1335d2b038d15218b6fcb6c175972d9
commit 10893331d1335d2b038d15218b6fcb6c175972d9
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2026-11-15 16:35:36 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2026-11-17 17:09:10 +0000
ptrace: Call ptrace_check_allowed() from the compat32 layer
Otherwise the checks there aren't applied to freebsd32 ptrace calls.
Approved by: re (cperciva)
Fixes: 7006cb7bd22d ("pdptrace(2): allow debugging in capability mode")
Reviewed by: kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D61597
(cherry picked from commit 44ae34814f689bf640c03b7f26f4f540a5f92d54)
(cherry picked from commit c1b0ea1f72d7c7ad21c969191d1bb85aac08d18f)
---
sys/compat/freebsd32/freebsd32_misc.c | 5 ++++-
sys/kern/sys_process.c | 2 +-
sys/sys/ptrace.h | 2 ++
3 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/sys/compat/freebsd32/freebsd32_misc.c b/sys/compat/freebsd32/freebsd32_misc.c
index b6a097cd495e..b3debca0e351 100644
--- a/sys/compat/freebsd32/freebsd32_misc.c
+++ b/sys/compat/freebsd32/freebsd32_misc.c
@@ -1050,7 +1050,10 @@ freebsd32_ptrace_useraction(struct thread *td, int req, bool pd_mode, pid_t pid,
void *addr;
int data, error, i;
- error = 0;
+ error = ptrace_check_allowed(td, req, pd_mode, pid);
+ if (error != 0)
+ return (error);
+
addr = &r;
data = udata;
diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c
index 56c5eebc8a85..c659622a68c3 100644
--- a/sys/kern/sys_process.c
+++ b/sys/kern/sys_process.c
@@ -675,7 +675,7 @@ ptrace_vm_entry(struct thread *td, struct proc *p, struct ptrace_vm_entry *pve)
return (error);
}
-static int
+int
ptrace_check_allowed(struct thread *td, int req, bool pd_mode, pid_t pid)
{
if (!allow_ptrace)
diff --git a/sys/sys/ptrace.h b/sys/sys/ptrace.h
index aeabd1961c21..3acdf64c7bc7 100644
--- a/sys/sys/ptrace.h
+++ b/sys/sys/ptrace.h
@@ -292,6 +292,8 @@ int proc_write_dbregs32(struct thread *_td, struct dbreg32 *_dbreg32);
#endif
void ptrace_unsuspend(struct proc *p);
+int ptrace_check_allowed(struct thread *td, int req, bool pd_mode,
+ pid_t pid);
int ptrace_action(struct thread *td, int req, bool pd_mode, pid_t pid,
int pfd, lwpid_t lwpid, void *addr, int data);