git: 44ae34814f68 - main - 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:02:10 UTC
The branch main has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=44ae34814f689bf640c03b7f26f4f540a5f92d54
commit 44ae34814f689bf640c03b7f26f4f540a5f92d54
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2026-11-15 16:35:36 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2026-11-17 16:57:02 +0000
ptrace: Call ptrace_check_allowed() from the compat32 layer
Otherwise the checks there aren't applied to freebsd32 ptrace calls.
Fixes: 7006cb7bd22d ("pdptrace(2): allow debugging in capability mode")
Reviewed by: kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D61597
---
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 a6604fffad34..37a29878dfb3 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 9b4f8dffddda..aa89779c4d42 100644
--- a/sys/kern/sys_process.c
+++ b/sys/kern/sys_process.c
@@ -709,7 +709,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 d6e071285eac..265db2697433 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);