diff options
author | Rich Ercolani <214141+rincebrain@users.noreply.github.com> | 2021-12-03 16:13:21 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-03 13:13:21 -0800 |
commit | df42e20ac68ed642c42d1b131391bf46452dadb0 (patch) | |
tree | 361ffc60f28046fea5a80386623b6dd0156a4156 | |
parent | ddc026f59ba38ae6a33fa7b6874eaa8105ad7df3 (diff) |
Corrected a case where we could read uninited ABD memory
For my sins, I started running valgrind over ztest to try and fix
that pesky intermittent "zloop dies with malloc errors" problem.
This one seemed exciting enough to merit cutting a PR for before
the rest get polished.
Suggested-by: Paul Dagnelie <pcd@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rich Ercolani <rincebrain@gmail.com>
Closes #12214
-rw-r--r-- | module/zfs/arc.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/module/zfs/arc.c b/module/zfs/arc.c index 79e2d4381..5f086ea9f 100644 --- a/module/zfs/arc.c +++ b/module/zfs/arc.c @@ -5682,17 +5682,20 @@ arc_read_done(zio_t *zio) zio_crypt_decode_params_bp(bp, hdr->b_crypt_hdr.b_salt, hdr->b_crypt_hdr.b_iv); - if (BP_GET_TYPE(bp) == DMU_OT_INTENT_LOG) { - void *tmpbuf; - - tmpbuf = abd_borrow_buf_copy(zio->io_abd, - sizeof (zil_chain_t)); - zio_crypt_decode_mac_zil(tmpbuf, - hdr->b_crypt_hdr.b_mac); - abd_return_buf(zio->io_abd, tmpbuf, - sizeof (zil_chain_t)); - } else { - zio_crypt_decode_mac_bp(bp, hdr->b_crypt_hdr.b_mac); + if (zio->io_error == 0) { + if (BP_GET_TYPE(bp) == DMU_OT_INTENT_LOG) { + void *tmpbuf; + + tmpbuf = abd_borrow_buf_copy(zio->io_abd, + sizeof (zil_chain_t)); + zio_crypt_decode_mac_zil(tmpbuf, + hdr->b_crypt_hdr.b_mac); + abd_return_buf(zio->io_abd, tmpbuf, + sizeof (zil_chain_t)); + } else { + zio_crypt_decode_mac_bp(bp, + hdr->b_crypt_hdr.b_mac); + } } } |