Skip to content

Commit

Permalink
Also check if user accounting is enabled
Browse files Browse the repository at this point in the history
Signed-off-by: George Amanakis <[email protected]>
  • Loading branch information
gamanakis committed Dec 8, 2020
1 parent 5ca6120 commit 493e4c6
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions module/zfs/dsl_crypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -2674,7 +2674,7 @@ spa_do_crypt_objset_mac_abd(boolean_t generate, spa_t *spa, uint64_t dsobj,
objset_phys_t *osp = buf;
uint8_t portable_mac[ZIO_OBJSET_MAC_LEN];
uint8_t local_mac[ZIO_OBJSET_MAC_LEN];
uint64_t intval;
uint64_t intflags, inttype;

/* look up the key from the spa's keystore */
ret = spa_keystore_lookup_key(spa, dsobj, FTAG, &dck);
Expand All @@ -2697,15 +2697,31 @@ spa_do_crypt_objset_mac_abd(boolean_t generate, spa_t *spa, uint64_t dsobj,
return (0);
}

intval = osp->os_flags;
if (byteswap)
intval = BSWAP_64(intval);
intflags = osp->os_flags;
inttype = osp->os_type;
if (byteswap) {
intflags = BSWAP_64(intflags);
inttype = BSWAP_64(inttype);
}

/*
* Do not compare the local_mac if user accounting is not enabled or
* complete.
*/
if ((spa_feature_is_enabled(spa, SPA_FEATURE_USEROBJ_ACCOUNTING) &&
spa_version(spa) >= SPA_VERSION_USERSPACE &&
osp->os_userused_dnode.dn_type != DMU_OT_NONE &&
inttype != 0 &&
(intflags & OBJSET_FLAG_USEROBJACCOUNTING_COMPLETE) != 0 &&
(intflags & OBJSET_FLAG_USERACCOUNTING_COMPLETE) != 0)) {
if (bcmp(local_mac, osp->os_local_mac,
ZIO_OBJSET_MAC_LEN) != 0) {
abd_return_buf(abd, buf, datalen);
return (SET_ERROR(ECKSUM));
}
}

/* Do not compare the local_mac if user accounting is not complete */
if (bcmp(portable_mac, osp->os_portable_mac, ZIO_OBJSET_MAC_LEN) != 0 ||
((intval & OBJSET_FLAG_USERACCOUNTING_COMPLETE) != 0 &&
(intval & OBJSET_FLAG_USEROBJACCOUNTING_COMPLETE) != 0 &&
bcmp(local_mac, osp->os_local_mac, ZIO_OBJSET_MAC_LEN) != 0)) {
if (bcmp(portable_mac, osp->os_portable_mac, ZIO_OBJSET_MAC_LEN) != 0) {
abd_return_buf(abd, buf, datalen);
return (SET_ERROR(ECKSUM));
}
Expand Down

0 comments on commit 493e4c6

Please sign in to comment.