mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-23 02:44:41 +03:00
In #13709, as in #11294 before it, it turns out that63a26454still had the same failure mode as when it was first landed asd1d47691, and fails to unlock certain datasets that formerly worked. Rather than reverting it again, let's add handling to just throw out the accounting metadata that failed to unlock when that happens, as well as a test with a pre-broken pool image to ensure that we never get bitten by this again. Fixes: #13709 Signed-off-by: Rich Ercolani <rincebrain@gmail.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Tony Hutter <hutter2@llnl.gov>
This commit is contained in:
+16
-2
@@ -2671,6 +2671,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];
|
||||
const uint8_t zeroed_mac[ZIO_OBJSET_MAC_LEN] = {0};
|
||||
|
||||
/* look up the key from the spa's keystore */
|
||||
ret = spa_keystore_lookup_key(spa, dsobj, FTAG, &dck);
|
||||
@@ -2696,8 +2697,21 @@ spa_do_crypt_objset_mac_abd(boolean_t generate, spa_t *spa, uint64_t dsobj,
|
||||
if (memcmp(portable_mac, osp->os_portable_mac,
|
||||
ZIO_OBJSET_MAC_LEN) != 0 ||
|
||||
memcmp(local_mac, osp->os_local_mac, ZIO_OBJSET_MAC_LEN) != 0) {
|
||||
abd_return_buf(abd, buf, datalen);
|
||||
return (SET_ERROR(ECKSUM));
|
||||
/*
|
||||
* If the MAC is zeroed out, we failed to decrypt it.
|
||||
* This should only arise, at least on Linux,
|
||||
* if we hit edge case handling for useraccounting, since we
|
||||
* shouldn't get here without bailing out on error earlier
|
||||
* otherwise.
|
||||
*
|
||||
* So if we're in that case, we can just fall through and
|
||||
* special-casing noticing that it's zero will handle it
|
||||
* elsewhere, since we can just regenerate it.
|
||||
*/
|
||||
if (memcmp(local_mac, zeroed_mac, ZIO_OBJSET_MAC_LEN) != 0) {
|
||||
abd_return_buf(abd, buf, datalen);
|
||||
return (SET_ERROR(ECKSUM));
|
||||
}
|
||||
}
|
||||
|
||||
abd_return_buf(abd, buf, datalen);
|
||||
|
||||
Reference in New Issue
Block a user