git: 8bbc0600cc21 - main - linux: Add additional ptracestop only if the debugger is Linux
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 30 Oct 2021 09:12:59 UTC
The branch main has been updated by trasz:
URL: https://cgit.FreeBSD.org/src/commit/?id=8bbc0600cc21bbfdc3b8e67199eec4220952b7e3
commit 8bbc0600cc21bbfdc3b8e67199eec4220952b7e3
Author: Edward Tomasz Napierala <trasz@FreeBSD.org>
AuthorDate: 2021-10-30 08:53:55 +0000
Commit: Edward Tomasz Napierala <trasz@FreeBSD.org>
CommitDate: 2021-10-30 08:54:17 +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
---
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 fab67a68b0a3..dacd82f4c466 100644
--- a/sys/kern/subr_syscall.c
+++ b/sys/kern/subr_syscall.c
@@ -260,9 +260,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;
}