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 <behlendorf1@llnl.gov>
Signed-off-by: Tom Caputi <tcaputi@datto.com>
Closes #7474
This commit is contained in:
Tom Caputi
2018-05-02 18:36:20 -04:00
committed by Brian Behlendorf
parent 9464b9591e
commit be9a5c355c
15 changed files with 221 additions and 116 deletions
+31 -1
View File
@@ -123,7 +123,7 @@ freq_triggered(uint32_t frequency)
* Returns true if the given record matches the I/O in progress.
*/
static boolean_t
zio_match_handler(zbookmark_phys_t *zb, uint64_t type,
zio_match_handler(const zbookmark_phys_t *zb, uint64_t type,
zinject_record_t *record, int error)
{
/*
@@ -178,6 +178,36 @@ zio_handle_panic_injection(spa_t *spa, char *tag, uint64_t type)
rw_exit(&inject_lock);
}
/*
* Inject a decryption failure. Decryption failures can occur in
* both the ARC and the ZIO layers.
*/
int
zio_handle_decrypt_injection(spa_t *spa, const zbookmark_phys_t *zb,
uint64_t type, int error)
{
int ret = 0;
inject_handler_t *handler;
rw_enter(&inject_lock, RW_READER);
for (handler = list_head(&inject_handlers); handler != NULL;
handler = list_next(&inject_handlers, handler)) {
if (spa != handler->zi_spa ||
handler->zi_record.zi_cmd != ZINJECT_DECRYPT_FAULT)
continue;
if (zio_match_handler(zb, type, &handler->zi_record, error)) {
ret = error;
break;
}
}
rw_exit(&inject_lock);
return (ret);
}
/*
* Determine if the I/O in question should return failure. Returns the errno
* to be returned to the caller.