DragonFlyBSD Kernel Audit
DF-2944 / fix.diff
← back to finding ↓ download raw
--- a/sys/kern/kern_acct.c
+++ b/sys/kern/kern_acct.c
@@ -202,6 +202,14 @@ acct_process(struct proc *p)
 	int error;
 	struct vnode *vp;
 
+	/*
+	 * Zero the whole record.  struct acct contains alignment padding
+	 * (2 bytes before ac_btime and 7 bytes of tail padding on 64-bit
+	 * platforms) that no field assignment covers; without this the
+	 * vn_rdwr() below writes 9 bytes of uninitialized kernel stack
+	 * into the accounting file on every process exit (DF-2944).
+	 */
+	bzero(&acct, sizeof(acct));
+
 	/*
 	 * If accounting isn't enabled, don't bother.  Lock acct_lock
 	 * make sure.