From 9cc982101495bc02675208c946ffc2af3a38c2fa Mon Sep 17 00:00:00 2001 From: Mark Johnston Date: Fri, 16 Jul 2021 09:27:11 -0400 Subject: [PATCH] Initialize all fields in zfs_log_xvattr() When logging TX_SETATTR, we could otherwise fail to initialize part of the corresponding ZIL record depending on which fields are present in the xvattr. Initialize the creation time and the AV scan timestamp to zero so that uninitialized bytes are not written to the ZIL. This was found using KMSAN. Reviewed-by: Brian Behlendorf Reviewed-by: Alexander Motin Signed-off-by: Mark Johnston Closes #12383 --- module/zfs/zfs_log.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/module/zfs/zfs_log.c b/module/zfs/zfs_log.c index 30d5c4821a..c2f4821039 100644 --- a/module/zfs/zfs_log.c +++ b/module/zfs/zfs_log.c @@ -126,9 +126,11 @@ zfs_log_xvattr(lr_attr_t *lrattr, xvattr_t *xvap) /* Now pack the attributes up in a single uint64_t */ attrs = (uint64_t *)bitmap; - crtime = attrs + 1; - scanstamp = (caddr_t)(crtime + 2); *attrs = 0; + crtime = attrs + 1; + bzero(crtime, 2 * sizeof (uint64_t)); + scanstamp = (caddr_t)(crtime + 2); + bzero(scanstamp, AV_SCANSTAMP_SZ); if (XVA_ISSET_REQ(xvap, XAT_READONLY)) *attrs |= (xoap->xoa_readonly == 0) ? 0 : XAT0_READONLY;