The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=6bb3f208617b58a54e2204eb31bae3f9a86117a7
commit 6bb3f208617b58a54e2204eb31bae3f9a86117a7 Author: Konstantin Belousov <[email protected]> AuthorDate: 2026-01-20 15:01:08 +0000 Commit: Konstantin Belousov <[email protected]> CommitDate: 2026-01-20 19:44:54 +0000 ktrace: do not enqueue request if the process' ktrioparams are freed The p_ktrioparms are freed on termination of tracing. Any ktr requests added to the queue after that would hang there and leak on the struct proc recycling, or trigger an assert in the process destructor for debug builds. Reported and tested by: pho Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D54804 --- sys/kern/kern_ktrace.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sys/kern/kern_ktrace.c b/sys/kern/kern_ktrace.c index 15a8a4ab4fa4..b58e69a3f38e 100644 --- a/sys/kern/kern_ktrace.c +++ b/sys/kern/kern_ktrace.c @@ -373,11 +373,17 @@ ktr_getrequest(int type) static void ktr_enqueuerequest(struct thread *td, struct ktr_request *req) { + bool sched_ast; mtx_lock(&ktrace_mtx); - STAILQ_INSERT_TAIL(&td->td_proc->p_ktr, req, ktr_list); + sched_ast = td->td_proc->p_ktrioparms != NULL; + if (sched_ast) + STAILQ_INSERT_TAIL(&td->td_proc->p_ktr, req, ktr_list); + else + ktr_freerequest_locked(req); mtx_unlock(&ktrace_mtx); - ast_sched(td, TDA_KTRACE); + if (sched_ast) + ast_sched(td, TDA_KTRACE); } /*
