diff options
author | Kent Ross <[email protected]> | 2024-01-09 09:13:52 -0800 |
---|---|---|
committer | GitHub <[email protected]> | 2024-01-09 09:13:52 -0800 |
commit | 7ecaa0758005a56fa579c87a84a2a25ccd61033e (patch) | |
tree | 6202eaceaee2a0ff167c8c576c0121287c7a741e /cmd | |
parent | bd3f90c0c1db570aeebda52c3413662863f9129e (diff) |
make zdb_decompress_block check decompression reliably
This function decompresses to two buffers and then compares them to
check whether the (opaque) decompression process filled the whole
buffer. Previously it began with lbuf uninitialized and lbuf2 filled
with pseudorandom data. This neither guarantees that any bytes not
written by the compressor would be different, nor seems incredibly
sound otherwise!
After these changes, instead of filling one buffer with generated
pseudorandom data we overwrite each buffer with completely different
data. This should remove the possibility of low-probability failures,
as well as make the process simpler and cheaper.
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Rich Ercolani <[email protected]>
Signed-off-by: Kent Ross <[email protected]>
Closes #15733
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/zdb/zdb.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c index 777032bf8..cd934b2ae 100644 --- a/cmd/zdb/zdb.c +++ b/cmd/zdb/zdb.c @@ -8533,11 +8533,14 @@ zdb_decompress_block(abd_t *pabd, void *buf, void *lbuf, uint64_t lsize, } /* - * We randomize lbuf2, and decompress to both - * lbuf and lbuf2. This way, we will know if - * decompression fill exactly to lsize. + * We set lbuf to all zeros and lbuf2 to all + * ones, then decompress to both buffers and + * compare their contents. This way we can + * know if decompression filled exactly to + * lsize or if it left some bytes unwritten. */ - VERIFY0(random_get_pseudo_bytes(lbuf2, lsize)); + memset(lbuf, 0x00, lsize); + memset(lbuf2, 0xff, lsize); if (zio_decompress_data(*cfuncp, pabd, lbuf, psize, lsize, NULL) == 0 && |