aboutsummaryrefslogtreecommitdiffstats
path: root/module/zfs/zio.c
diff options
context:
space:
mode:
authorTom Caputi <[email protected]>2018-05-02 18:36:20 -0400
committerBrian Behlendorf <[email protected]>2018-05-02 15:36:20 -0700
commitbe9a5c355c819ac0f2aca1f8c30dc75164e10322 (patch)
treede57c7d931764c3abfc94422c14311b12f83c5e3 /module/zfs/zio.c
parent9464b9591ea5cd61a4d6ef8e29c4597b48d16a77 (diff)
Add support for decryption faults in zinject
This patch adds the ability for zinject to trigger decryption and authentication faults in the ZIO and ARC layers. This functionality is exposed via the new "decrypt" error type, which may be provided for "data" object types. This patch also refactors some of the core encryption / decryption functions so that they have consistent prototypes, handle errors consistently, and do not have unused arguments. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Tom Caputi <[email protected]> Closes #7474
Diffstat (limited to 'module/zfs/zio.c')
-rw-r--r--module/zfs/zio.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/module/zfs/zio.c b/module/zfs/zio.c
index b585368be..6822505f1 100644
--- a/module/zfs/zio.c
+++ b/module/zfs/zio.c
@@ -449,6 +449,10 @@ zio_decrypt(zio_t *zio, abd_t *data, uint64_t size)
}
abd_copy(data, zio->io_abd, size);
+ if (zio_injection_enabled && ot != DMU_OT_DNODE && ret == 0) {
+ ret = zio_handle_decrypt_injection(spa,
+ &zio->io_bookmark, ot, ECKSUM);
+ }
if (ret != 0)
goto error;
@@ -468,6 +472,10 @@ zio_decrypt(zio_t *zio, abd_t *data, uint64_t size)
zio_crypt_decode_mac_bp(bp, mac);
ret = spa_do_crypt_mac_abd(B_FALSE, spa, dsobj,
zio->io_abd, size, mac);
+ if (zio_injection_enabled && ret == 0) {
+ ret = zio_handle_decrypt_injection(spa,
+ &zio->io_bookmark, ot, ECKSUM);
+ }
}
abd_copy(data, zio->io_abd, size);
@@ -487,8 +495,9 @@ zio_decrypt(zio_t *zio, abd_t *data, uint64_t size)
zio_crypt_decode_mac_bp(bp, mac);
}
- ret = spa_do_crypt_abd(B_FALSE, spa, dsobj, bp, bp->blk_birth,
- size, data, zio->io_abd, iv, mac, salt, &no_crypt);
+ ret = spa_do_crypt_abd(B_FALSE, spa, &zio->io_bookmark, BP_GET_TYPE(bp),
+ BP_GET_DEDUP(bp), BP_SHOULD_BYTESWAP(bp), salt, iv, mac, size, data,
+ zio->io_abd, &no_crypt);
if (no_crypt)
abd_copy(data, zio->io_abd, size);
@@ -499,7 +508,7 @@ zio_decrypt(zio_t *zio, abd_t *data, uint64_t size)
error:
/* assert that the key was found unless this was speculative */
- ASSERT(ret != ENOENT || (zio->io_flags & ZIO_FLAG_SPECULATIVE));
+ ASSERT(ret != EACCES || (zio->io_flags & ZIO_FLAG_SPECULATIVE));
/*
* If there was a decryption / authentication error return EIO as
@@ -508,6 +517,7 @@ error:
if (ret == ECKSUM) {
zio->io_error = SET_ERROR(EIO);
if ((zio->io_flags & ZIO_FLAG_SPECULATIVE) == 0) {
+ spa_log_error(spa, &zio->io_bookmark);
zfs_ereport_post(FM_EREPORT_ZFS_AUTHENTICATION,
spa, NULL, &zio->io_bookmark, zio, 0, 0);
}
@@ -3906,8 +3916,9 @@ zio_encrypt(zio_t *zio)
}
/* Perform the encryption. This should not fail */
- VERIFY0(spa_do_crypt_abd(B_TRUE, spa, dsobj, bp, zio->io_txg,
- psize, zio->io_abd, eabd, iv, mac, salt, &no_crypt));
+ VERIFY0(spa_do_crypt_abd(B_TRUE, spa, &zio->io_bookmark,
+ BP_GET_TYPE(bp), BP_GET_DEDUP(bp), BP_SHOULD_BYTESWAP(bp),
+ salt, iv, mac, psize, zio->io_abd, eabd, &no_crypt));
/* encode encryption metadata into the bp */
if (ot == DMU_OT_INTENT_LOG) {