git: d3f0d2c0eef6 - stable/13 - linux: Add additional ptracestop only if the debugger is Linux
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 21 Feb 2022 14:55:06 UTC
The branch stable/13 has been updated by trasz:
URL: https://cgit.FreeBSD.org/src/commit/?id=d3f0d2c0eef6ef2092cd66db02aace57eb3c6a4d
commit d3f0d2c0eef6ef2092cd66db02aace57eb3c6a4d
Author: Edward Tomasz Napierala <trasz@FreeBSD.org>
AuthorDate: 2021-10-30 08:53:55 +0000
Commit: Edward Tomasz Napierala <trasz@FreeBSD.org>
CommitDate: 2022-02-21 14:31:22 +0000
linux: Add additional ptracestop only if the debugger is Linux
In 6e66030c4c0, additional ptracestop was added in order
to implement PTRACE_EVENT_EXEC. Make it only apply to cases
where the debugger is a Linux processes; native FreeBSD
debuggers can trace Linux processes too, but they don't
expect that additonal ptracestop.
Fixes: 6e66030c4c0
Reported By: kib
Reviewed By: kib
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D32726
(cherry picked from commit 8bbc0600cc21bbfdc3b8e67199eec4220952b7e3)
---
sys/kern/subr_syscall.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/sys/kern/subr_syscall.c b/sys/kern/subr_syscall.c
index dee81ba0fa48..8507c5393c01 100644
--- a/sys/kern/subr_syscall.c
+++ b/sys/kern/subr_syscall.c
@@ -261,9 +261,15 @@ syscallret(struct thread *td)
* the exec event now and then clear TDB_EXEC so that
* the next stop is reported as a syscall exit by
* linux_ptrace_status().
+ *
+ * We are accessing p->p_pptr without any additional
+ * locks here: it cannot change while p is kept locked;
+ * while the debugger could in theory change its ABI
+ * while tracing another process, the outcome of such
+ * a race wouln't be deterministic anyway.
*/
- if ((td->td_dbgflags & TDB_EXEC) != 0 &&
- SV_PROC_ABI(td->td_proc) == SV_ABI_LINUX) {
+ if (traced && (td->td_dbgflags & TDB_EXEC) != 0 &&
+ SV_PROC_ABI(p->p_pptr) == SV_ABI_LINUX) {
ptracestop(td, SIGTRAP, NULL);
td->td_dbgflags &= ~TDB_EXEC;
}