Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F173249785
D59951.id187548.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D59951.id187548.diff
View Options
diff --git a/sys/contrib/openzfs/module/zfs/zfs_log.c b/sys/contrib/openzfs/module/zfs/zfs_log.c
--- a/sys/contrib/openzfs/module/zfs/zfs_log.c
+++ b/sys/contrib/openzfs/module/zfs/zfs_log.c
@@ -349,10 +349,16 @@
} else {
lr->lr_gid = fuidp->z_fuid_group;
}
- (void) sa_lookup(zp->z_sa_hdl, SA_ZPL_GEN(ZTOZSB(zp)), &lr->lr_gen,
- sizeof (uint64_t));
- (void) sa_lookup(zp->z_sa_hdl, SA_ZPL_CRTIME(ZTOZSB(zp)),
- lr->lr_crtime, sizeof (uint64_t) * 2);
+ /*
+ * The whole record is written to the ZIL, so leave nothing
+ * uninitialized if a lookup fails.
+ */
+ if (sa_lookup(zp->z_sa_hdl, SA_ZPL_GEN(ZTOZSB(zp)), &lr->lr_gen,
+ sizeof (uint64_t)) != 0)
+ lr->lr_gen = 0;
+ if (sa_lookup(zp->z_sa_hdl, SA_ZPL_CRTIME(ZTOZSB(zp)),
+ lr->lr_crtime, sizeof (uint64_t) * 2) != 0)
+ lr->lr_crtime[0] = lr->lr_crtime[1] = 0;
if (sa_lookup(zp->z_sa_hdl, SA_ZPL_RDEV(ZTOZSB(zp)), &lr->lr_rdev,
sizeof (lr->lr_rdev)) != 0)
@@ -478,10 +484,18 @@
lr->lr_uid = KUID_TO_SUID(ZTOUID(zp));
lr->lr_gid = KGID_TO_SGID(ZTOGID(zp));
lr->lr_mode = zp->z_mode;
- (void) sa_lookup(zp->z_sa_hdl, SA_ZPL_GEN(ZTOZSB(zp)), &lr->lr_gen,
- sizeof (uint64_t));
- (void) sa_lookup(zp->z_sa_hdl, SA_ZPL_CRTIME(ZTOZSB(zp)),
- lr->lr_crtime, sizeof (uint64_t) * 2);
+ /*
+ * The whole record is written to the ZIL, so leave nothing
+ * uninitialized: symlinks have no rdev, and a failed lookup
+ * must not leave garbage behind either.
+ */
+ lr->lr_rdev = 0;
+ if (sa_lookup(zp->z_sa_hdl, SA_ZPL_GEN(ZTOZSB(zp)), &lr->lr_gen,
+ sizeof (uint64_t)) != 0)
+ lr->lr_gen = 0;
+ if (sa_lookup(zp->z_sa_hdl, SA_ZPL_CRTIME(ZTOZSB(zp)),
+ lr->lr_crtime, sizeof (uint64_t) * 2) != 0)
+ lr->lr_crtime[0] = lr->lr_crtime[1] = 0;
memcpy(&lrc->lr_data[0], name, namesize);
memcpy(&lrc->lr_data[namesize], link, linksize);
@@ -568,10 +582,16 @@
*/
lr->lr_wfoid = wzp->z_id;
LR_FOID_SET_SLOTS(lr->lr_wfoid, wzp->z_dnodesize >> DNODE_SHIFT);
- (void) sa_lookup(wzp->z_sa_hdl, SA_ZPL_GEN(ZTOZSB(wzp)), &lr->lr_wgen,
- sizeof (uint64_t));
- (void) sa_lookup(wzp->z_sa_hdl, SA_ZPL_CRTIME(ZTOZSB(wzp)),
- lr->lr_wcrtime, sizeof (uint64_t) * 2);
+ /*
+ * The whole record is written to the ZIL, so leave nothing
+ * uninitialized if a lookup fails.
+ */
+ if (sa_lookup(wzp->z_sa_hdl, SA_ZPL_GEN(ZTOZSB(wzp)), &lr->lr_wgen,
+ sizeof (uint64_t)) != 0)
+ lr->lr_wgen = 0;
+ if (sa_lookup(wzp->z_sa_hdl, SA_ZPL_CRTIME(ZTOZSB(wzp)),
+ lr->lr_wcrtime, sizeof (uint64_t) * 2) != 0)
+ lr->lr_wcrtime[0] = lr->lr_wcrtime[1] = 0;
lr->lr_wmode = wzp->z_mode;
lr->lr_wuid = (uint64_t)KUID_TO_SUID(ZTOUID(wzp));
lr->lr_wgid = (uint64_t)KGID_TO_SGID(ZTOGID(wzp));
@@ -582,8 +602,9 @@
* platform independent makdev()) we need to copy the one created
* during the rename operation.
*/
- (void) sa_lookup(wzp->z_sa_hdl, SA_ZPL_RDEV(ZTOZSB(wzp)), &lr->lr_wrdev,
- sizeof (lr->lr_wrdev));
+ if (sa_lookup(wzp->z_sa_hdl, SA_ZPL_RDEV(ZTOZSB(wzp)), &lr->lr_wrdev,
+ sizeof (lr->lr_wrdev)) != 0)
+ lr->lr_wrdev = 0;
memcpy(&lr->lr_data[0], sname, snamesize);
memcpy(&lr->lr_data[snamesize], dname, dnamesize);
@@ -860,6 +881,11 @@
uint8_t *start = &lr->lr_data[0];
memcpy(start, vsecp->vsa_aclentp, aclbytes);
+ /*
+ * The record is padded out to an 8 byte boundary and written
+ * to the ZIL, so the padding must not be left uninitialized.
+ */
+ memset(start + aclbytes, 0, ZIL_ACE_LENGTH(aclbytes) - aclbytes);
start = &lr->lr_data[ZIL_ACE_LENGTH(aclbytes)];
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Sep 25, 5:04 PM (19 h, 23 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
39560876
Default Alt Text
D59951.id187548.diff (3 KB)
Attached To
Mode
D59951: zfs: avoid disclosing uninitialized data in various zil functions
Attached
Detach File
Event Timeline
Log In to Comment