git: 21ccba43f511 - stable/13 - ptrace: Clear TDB_BORN during PT_DETACH.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 06 Sep 2023 21:56:44 UTC
The branch stable/13 has been updated by jhb:
URL: https://cgit.FreeBSD.org/src/commit/?id=21ccba43f511cc4089899619b5a85e6d83a200dc
commit 21ccba43f511cc4089899619b5a85e6d83a200dc
Author: John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2023-06-07 19:26:57 +0000
Commit: John Baldwin <jhb@FreeBSD.org>
CommitDate: 2023-09-06 21:56:09 +0000
ptrace: Clear TDB_BORN during PT_DETACH.
If a debugger detaches from a process that has a new thread that has
not yet executed, the new thread will raise a SIGTRAP signal to report
it's thread birth event even after the detach. With the debugger
detached, this results in a SIGTRAP sent to the process and typically
a core dump. Fix this by clearing TDB_BORN from any new threads
during detach.
Bump __FreeBSD_version for debuggers to notice when the fix is
present.
Reported by: GDB's testsuite
Reviewed by: kib, markj (previous version)
Differential Revision: https://reviews.freebsd.org/D39856
(cherry picked from commit 653738e895ba022be1179a95a85089e7bc66dbbe)
---
sys/kern/kern_fork.c | 2 +-
sys/kern/sys_process.c | 2 +-
sys/sys/param.h | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c
index 157eba2b3fbc..e3148763b460 100644
--- a/sys/kern/kern_fork.c
+++ b/sys/kern/kern_fork.c
@@ -1195,7 +1195,7 @@ fork_return(struct thread *td, struct trapframe *frame)
td->td_dbgflags &= ~TDB_STOPATFORK;
}
PROC_UNLOCK(p);
- } else if (p->p_flag & P_TRACED || td->td_dbgflags & TDB_BORN) {
+ } else if (p->p_flag & P_TRACED) {
/*
* This is the start of a new thread in a traced
* process. Report a system call exit event.
diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c
index 6f53f1ae43b4..2eaeabb6a5f9 100644
--- a/sys/kern/sys_process.c
+++ b/sys/kern/sys_process.c
@@ -1288,7 +1288,7 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data)
SIGSTOP);
}
td3->td_dbgflags &= ~(TDB_XSIG | TDB_FSTP |
- TDB_SUSPEND);
+ TDB_SUSPEND | TDB_BORN);
}
if ((p->p_flag2 & P2_PTRACE_FSTP) != 0) {
diff --git a/sys/sys/param.h b/sys/sys/param.h
index 376d1aaa2187..ba64cfa4b5df 100644
--- a/sys/sys/param.h
+++ b/sys/sys/param.h
@@ -59,7 +59,7 @@
* in the range 5 to 9.
*/
#undef __FreeBSD_version
-#define __FreeBSD_version 1302507 /* Master, propagated to newvers */
+#define __FreeBSD_version 1302508 /* Master, propagated to newvers */
/*
* __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,