Skip to content

Commit

Permalink
Silence some complaints from valgrind
Browse files Browse the repository at this point in the history
Without this, valgrind is effectively useless in many cases, as
it floods with messages about zio writes trying to read uninited
buffers, and about the old LZ4 compressor doing the same.

It'd be nice to fix the logic that involves doing that if possible,
but for now, this at least reduces it to a small handful of messages
beyond whatever new code you're introducing.

Signed-off-by: Rich Ercolani <rincebrain@gmail.com>
  • Loading branch information
rincebrain committed Mar 14, 2022
1 parent 1282274 commit a40df00
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
8 changes: 4 additions & 4 deletions module/zfs/dsl_crypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1193,10 +1193,10 @@ dsl_crypto_key_sync(dsl_crypto_key_t *dck, dmu_tx_t *tx)
{
zio_crypt_key_t *key = &dck->dck_key;
dsl_wrapping_key_t *wkey = dck->dck_wkey;
uint8_t keydata[MASTER_KEY_MAX_LEN];
uint8_t hmac_keydata[SHA512_HMAC_KEYLEN];
uint8_t iv[WRAPPING_IV_LEN];
uint8_t mac[WRAPPING_MAC_LEN];
uint8_t keydata[MASTER_KEY_MAX_LEN] = {0};
uint8_t hmac_keydata[SHA512_HMAC_KEYLEN] = {0};
uint8_t iv[WRAPPING_IV_LEN] = {0};
uint8_t mac[WRAPPING_MAC_LEN] = {0};

ASSERT(dmu_tx_is_syncing(tx));
ASSERT3U(key->zk_crypt, <, ZIO_CRYPT_FUNCTIONS);
Expand Down
9 changes: 9 additions & 0 deletions module/zfs/zio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1706,6 +1706,15 @@ zio_write_compress(zio_t *zio)
if (compress != ZIO_COMPRESS_OFF &&
!(zio->io_flags & ZIO_FLAG_RAW_COMPRESS)) {
void *cbuf = zio_buf_alloc(lsize);
/*
* Both the crypto code and LZ4 code have bad habits of reading
* uninited bytes sometimes.
*
* So to stop valgrind screaming to the point of uselessness,
* zero them all.
*/
memset(cbuf, 0, lsize);

psize = zio_compress_data(compress, zio->io_abd, cbuf, lsize,
zp->zp_complevel);
if (psize == 0 || psize >= lsize) {
Expand Down

0 comments on commit a40df00

Please sign in to comment.