Delay setting the timestamp in the ktrace header until we've grabbed
authorguenther <guenther@openbsd.org>
Thu, 9 Feb 2023 08:00:31 +0000 (08:00 +0000)
committerguenther <guenther@openbsd.org>
Thu, 9 Feb 2023 08:00:31 +0000 (08:00 +0000)
the vnode, to eliminate misordering of ktrace records.

problem noted by jrick@
ok deraadt@

sys/kern/kern_ktrace.c

index 6ede556..8f30492 100644 (file)
@@ -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];