linux: Add additional ptracestop only if the debugger is Linux

In 6e66030c4c, 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:		6e66030c4c
Reported By:	kib
Reviewed By:	kib
Sponsored By:	EPSRC
Differential Revision:	https://reviews.freebsd.org/D32726
This commit is contained in:
Edward Tomasz Napierala 2021-10-30 09:53:55 +01:00
parent 20f8331aca
commit 8bbc0600cc

View 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;
}