summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToomas Soome <tsoome@me.com>2019-09-18 12:33:38 +0300
committerToomas Soome <tsoome@me.com>2019-09-23 21:45:34 +0300
commit29de914fcef174393d74135cd19f6920fac954bc (patch)
treedfcdec7d955b0e2333a8561ba63bf15cea192d02
parent20f5f9633a7f7a00734c4c03c7c12016e6935b05 (diff)
downloadillumos-joyent-29de914fcef174393d74135cd19f6920fac954bc.tar.gz
11709 zfs: zio_checksum_table may be accessed past array end
Reviewed by: Andrew Stormont <andyjstormont@gmail.com> Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com> Approved by: Dan McDonald <danmcd@joyent.com>
-rw-r--r--usr/src/uts/common/fs/zfs/zio_checksum.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/usr/src/uts/common/fs/zfs/zio_checksum.c b/usr/src/uts/common/fs/zfs/zio_checksum.c
index d5aa9303b8..85d7e7f4ff 100644
--- a/usr/src/uts/common/fs/zfs/zio_checksum.c
+++ b/usr/src/uts/common/fs/zfs/zio_checksum.c
@@ -316,13 +316,15 @@ zio_checksum_compute(zio_t *zio, enum zio_checksum checksum,
static const uint64_t zec_magic = ZEC_MAGIC;
blkptr_t *bp = zio->io_bp;
uint64_t offset = zio->io_offset;
- zio_checksum_info_t *ci = &zio_checksum_table[checksum];
+ zio_checksum_info_t *ci;
zio_cksum_t cksum, saved;
spa_t *spa = zio->io_spa;
- boolean_t insecure = (ci->ci_flags & ZCHECKSUM_FLAG_DEDUP) == 0;
+ boolean_t insecure;
ASSERT((uint_t)checksum < ZIO_CHECKSUM_FUNCTIONS);
+ ci = &zio_checksum_table[checksum];
ASSERT(ci->ci_func[0] != NULL);
+ insecure = (ci->ci_flags & ZCHECKSUM_FLAG_DEDUP) == 0;
zio_checksum_template_init(checksum, spa);
@@ -386,12 +388,17 @@ zio_checksum_error_impl(spa_t *spa, const blkptr_t *bp,
enum zio_checksum checksum, abd_t *abd, uint64_t size,
uint64_t offset, zio_bad_cksum_t *info)
{
- zio_checksum_info_t *ci = &zio_checksum_table[checksum];
+ zio_checksum_info_t *ci;
zio_cksum_t actual_cksum, expected_cksum;
zio_eck_t eck;
int byteswap;
- if (checksum >= ZIO_CHECKSUM_FUNCTIONS || ci->ci_func[0] == NULL)
+ if (checksum >= ZIO_CHECKSUM_FUNCTIONS)
+ return (SET_ERROR(EINVAL));
+
+ ci = &zio_checksum_table[checksum];
+
+ if (ci->ci_func[0] == NULL)
return (SET_ERROR(EINVAL));
zio_checksum_template_init(checksum, spa);