]> xenbits.xensource.com Git - people/royger/freebsd.git/commitdiff
linux: Add additional ptracestop only if the debugger is Linux
authorEdward Tomasz Napierala <trasz@FreeBSD.org>
Sat, 30 Oct 2021 08:53:55 +0000 (09:53 +0100)
committerEdward Tomasz Napierala <trasz@FreeBSD.org>
Sat, 30 Oct 2021 08:54:17 +0000 (09:54 +0100)
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

index fab67a68b0a3eabaadbde2e2fa8a970d6e782522..dacd82f4c46686c8a7ca303408b2fbe9b1c39d1e 100644 (file)
@@ -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;
                }