diff --git a/sys/kern/kern_ktrace.c b/sys/kern/kern_ktrace.c --- a/sys/kern/kern_ktrace.c +++ b/sys/kern/kern_ktrace.c @@ -612,7 +612,14 @@ auio.uio_offset = 0; auio.uio_segflg = UIO_SYSSPACE; auio.uio_rw = UIO_WRITE; - aiov[0].iov_base = (caddr_t)kth; + /* + * ktr_buf holds a kernel address; emit a sanitized copy of the + * header to the trace file so the ktr_buf field does not leak it. + */ + struct ktr_header kth_disk; + kth_disk = *kth; + kth_disk.ktr_buf = NULL; + aiov[0].iov_base = (caddr_t)&kth_disk; aiov[0].iov_len = sizeof(struct ktr_header); auio.uio_resid = sizeof(struct ktr_header); auio.uio_iovcnt = 1;