Skip to content

Commit

Permalink
Initialize all fields in zfs_log_xvattr()
Browse files Browse the repository at this point in the history
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 <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Mark Johnston <markj@FreeBSD.org>
Closes openzfs#12383
  • Loading branch information
markjdb authored and aerusso committed Jul 28, 2021
1 parent f6d53b3 commit 82d9667
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion module/zfs/zfs_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
*attrs = 0;
crtime = attrs + 1;
bzero(crtime, 2 * sizeof (uint64_t));
scanstamp = (caddr_t)(crtime + 2);
*attrs = 0;
bzero(scanstamp, AV_SCANSTAMP_SZ);
if (XVA_ISSET_REQ(xvap, XAT_READONLY))
*attrs |= (xoap->xoa_readonly == 0) ? 0 :
XAT0_READONLY;
Expand Down

0 comments on commit 82d9667

Please sign in to comment.