From 9b865405c4f8bbf56f2ad171c37bdb691af4377b Mon Sep 17 00:00:00 2001 From: guenther Date: Thu, 9 Feb 2023 08:00:31 +0000 Subject: [PATCH] Delay setting the timestamp in the ktrace header until we've grabbed the vnode, to eliminate misordering of ktrace records. problem noted by jrick@ ok deraadt@ --- sys/kern/kern_ktrace.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/kern/kern_ktrace.c b/sys/kern/kern_ktrace.c index 6ede5569311..8f304925d43 100644 --- a/sys/kern/kern_ktrace.c +++ b/sys/kern/kern_ktrace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_ktrace.c,v 1.109 2022/12/05 23:18:37 deraadt Exp $ */ +/* $OpenBSD: kern_ktrace.c,v 1.110 2023/02/09 08:00:31 guenther Exp $ */ /* $NetBSD: kern_ktrace.c,v 1.23 1996/02/09 18:59:36 christos Exp $ */ /* @@ -128,7 +128,6 @@ ktrinitheaderraw(struct ktr_header *kth, uint type, pid_t pid, pid_t tid) { memset(kth, 0, sizeof(struct ktr_header)); kth->ktr_type = type; - nanotime(&kth->ktr_time); kth->ktr_pid = pid; kth->ktr_tid = tid; } @@ -635,6 +634,8 @@ ktrwriteraw(struct proc *curp, struct vnode *vp, struct ucred *cred, struct process *pr; int error; + nanotime(&kth->ktr_time); + KERNEL_ASSERT_LOCKED(); auio.uio_iov = &aiov[0]; -- 2.20.1