From 171f0832c5b15f2f66d2fe59967348a42814b0c1 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Tue, 28 Nov 2023 17:42:49 +0200 Subject: [PATCH] EVFILT_TIMER: intialize stop timer list in type-stable proc init, instead of fork Since kqueue timer may exist after the process that created it exited (same scenario with rfork(2) as in PR 275286), make the tailq p_kqtim_stop accessed by filt_timerdetach() type-stable. Noted and reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D42777 --- sys/kern/kern_fork.c | 1 - sys/kern/kern_proc.c | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index 7b9aa4cd61d1..c7b2b1195841 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -622,7 +622,6 @@ do_fork(struct thread *td, struct fork_req *fr, struct proc *p2, struct thread * LIST_INIT(&p2->p_orphans); callout_init_mtx(&p2->p_itcallout, &p2->p_mtx, 0); - TAILQ_INIT(&p2->p_kqtim_stop); /* * This begins the section where we must prevent the parent diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c index 2c115202636e..8a396e208ff6 100644 --- a/sys/kern/kern_proc.c +++ b/sys/kern/kern_proc.c @@ -275,6 +275,7 @@ proc_init(void *mem, int size, int flags) EVENTHANDLER_DIRECT_INVOKE(process_init, p); p->p_stats = pstats_alloc(); p->p_pgrp = NULL; + TAILQ_INIT(&p->p_kqtim_stop); return (0); }