Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 16 Sep 2025 02:50:23 GMT
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 594982a69714 - stable/14 - kern_thr_exit(): clear kASTs in advance
Message-ID:  <202509160250.58G2oN97009036@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=594982a69714150ccf8616ffbce65fecab70ec03

commit 594982a69714150ccf8616ffbce65fecab70ec03
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2025-09-08 03:43:09 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2025-09-16 02:44:24 +0000

    kern_thr_exit(): clear kASTs in advance
    
    PR:     289204
    
    (cherry picked from commit f51d7d5139a76d225c9f537bd948525ababdef0c)
---
 sys/kern/kern_thr.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/sys/kern/kern_thr.c b/sys/kern/kern_thr.c
index 8ad885b42ebe..1b5f0b1a33ad 100644
--- a/sys/kern/kern_thr.c
+++ b/sys/kern/kern_thr.c
@@ -339,6 +339,17 @@ kern_thr_exit(struct thread *td)
 
 	p = td->td_proc;
 
+	/*
+	 * Clear kernel ASTs in advance of selecting the last exiting
+	 * thread and acquiring schedulers locks.  It is fine to
+	 * clear the ASTs here even if we are not going to exit after
+	 * all.  On the other hand, leaving them pending could trigger
+	 * execution in subsystems in a context where they are not
+	 * prepared to handle top kernel actions, even in execution of
+	 * an unrelated thread.
+	 */
+	ast_kclear(td);
+
 	/*
 	 * If all of the threads in a process call this routine to
 	 * exit (e.g. all threads call pthread_exit()), exactly one



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202509160250.58G2oN97009036>