mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 18:40:43 +03:00
ZIL: Assert record sizes in different places
This should make sure we have log written without overflows. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Alexander Motin <mav@FreeBSD.org> Sponsored by: iXsystems, Inc. Closes #15517
This commit is contained in:
@@ -1251,7 +1251,7 @@ zio_crypt_init_uios_zil(boolean_t encrypt, uint8_t *plainbuf,
|
||||
iovec_t *dst_iovecs;
|
||||
zil_chain_t *zilc;
|
||||
lr_t *lr;
|
||||
uint64_t txtype, lr_len;
|
||||
uint64_t txtype, lr_len, nused;
|
||||
uint_t crypt_len, nr_iovecs, vec;
|
||||
uint_t aad_len = 0, total_len = 0;
|
||||
|
||||
@@ -1268,7 +1268,10 @@ zio_crypt_init_uios_zil(boolean_t encrypt, uint8_t *plainbuf,
|
||||
zilc = (zil_chain_t *)src;
|
||||
slrp = src + sizeof (zil_chain_t);
|
||||
aadp = aadbuf;
|
||||
blkend = src + ((byteswap) ? BSWAP_64(zilc->zc_nused) : zilc->zc_nused);
|
||||
nused = ((byteswap) ? BSWAP_64(zilc->zc_nused) : zilc->zc_nused);
|
||||
ASSERT3U(nused, >=, sizeof (zil_chain_t));
|
||||
ASSERT3U(nused, <=, datalen);
|
||||
blkend = src + nused;
|
||||
|
||||
/*
|
||||
* Calculate the number of encrypted iovecs we will need.
|
||||
@@ -1287,6 +1290,8 @@ zio_crypt_init_uios_zil(boolean_t encrypt, uint8_t *plainbuf,
|
||||
txtype = lr->lrc_txtype;
|
||||
lr_len = lr->lrc_reclen;
|
||||
}
|
||||
ASSERT3U(lr_len, >=, sizeof (lr_t));
|
||||
ASSERT3U(lr_len, <=, blkend - slrp);
|
||||
|
||||
nr_iovecs++;
|
||||
if (txtype == TX_WRITE && lr_len != sizeof (lr_write_t))
|
||||
|
||||
@@ -1405,7 +1405,7 @@ zio_crypt_init_uios_zil(boolean_t encrypt, uint8_t *plainbuf,
|
||||
boolean_t *no_crypt)
|
||||
{
|
||||
int ret;
|
||||
uint64_t txtype, lr_len;
|
||||
uint64_t txtype, lr_len, nused;
|
||||
uint_t nr_src, nr_dst, crypt_len;
|
||||
uint_t aad_len = 0, nr_iovecs = 0, total_len = 0;
|
||||
iovec_t *src_iovecs = NULL, *dst_iovecs = NULL;
|
||||
@@ -1432,7 +1432,10 @@ zio_crypt_init_uios_zil(boolean_t encrypt, uint8_t *plainbuf,
|
||||
zilc = (zil_chain_t *)src;
|
||||
slrp = src + sizeof (zil_chain_t);
|
||||
aadp = aadbuf;
|
||||
blkend = src + ((byteswap) ? BSWAP_64(zilc->zc_nused) : zilc->zc_nused);
|
||||
nused = ((byteswap) ? BSWAP_64(zilc->zc_nused) : zilc->zc_nused);
|
||||
ASSERT3U(nused, >=, sizeof (zil_chain_t));
|
||||
ASSERT3U(nused, <=, datalen);
|
||||
blkend = src + nused;
|
||||
|
||||
/* calculate the number of encrypted iovecs we will need */
|
||||
for (; slrp < blkend; slrp += lr_len) {
|
||||
@@ -1445,6 +1448,8 @@ zio_crypt_init_uios_zil(boolean_t encrypt, uint8_t *plainbuf,
|
||||
txtype = BSWAP_64(lr->lrc_txtype);
|
||||
lr_len = BSWAP_64(lr->lrc_reclen);
|
||||
}
|
||||
ASSERT3U(lr_len, >=, sizeof (lr_t));
|
||||
ASSERT3U(lr_len, <=, blkend - slrp);
|
||||
|
||||
nr_iovecs++;
|
||||
if (txtype == TX_WRITE && lr_len != sizeof (lr_write_t))
|
||||
|
||||
Reference in New Issue
Block a user