git: 42f1054ef12d - main - ast: do not dereference NULL td_proc in CTR statement
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 14 Jul 2025 22:03:51 UTC
The branch main has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=42f1054ef12d10f3ba46770b985a320b0ceb9f2f
commit 42f1054ef12d10f3ba46770b985a320b0ceb9f2f
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2025-07-14 21:54:34 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2025-07-14 22:03:28 +0000
ast: do not dereference NULL td_proc in CTR statement
If ast is called to clean up thread, as in ast_kclear(), td_proc is
NULL. Guard against derefencing it in the trace.
Reported by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
---
sys/kern/subr_trap.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/sys/kern/subr_trap.c b/sys/kern/subr_trap.c
index 18388ae5f232..bac7d0080c71 100644
--- a/sys/kern/subr_trap.c
+++ b/sys/kern/subr_trap.c
@@ -338,8 +338,9 @@ ast_handler(struct thread *td, struct trapframe *framep, bool dtor)
td->td_ast = 0;
}
- CTR3(KTR_SYSC, "ast: thread %p (pid %d, %s)", td, td->td_proc->p_pid,
- td->td_proc->p_comm);
+ CTR3(KTR_SYSC, "ast: thread %p (pid %d, %s)", td,
+ td->td_proc == NULL ? -1 : td->td_proc->p_pid,
+ td->td_proc == NULL ? "" : td->td_proc->p_comm);
KASSERT(framep == NULL || TRAPF_USERMODE(framep),
("ast in kernel mode"));