From 035798a8d7456b59c22610889b653faf6334d299 Mon Sep 17 00:00:00 2001 From: George Melikov Date: Mon, 3 Jun 2024 20:40:25 +0300 Subject: [PATCH] arc_hdr_authenticate: make explicit error On compression we could be more explicit here for cases where we can not recompress the data. Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Co-authored-by: Alexander Motin Signed-off-by: George Melikov Closes #9416 --- module/zfs/arc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/module/zfs/arc.c b/module/zfs/arc.c index c222fd4287ec..de64e7a5bd98 100644 --- a/module/zfs/arc.c +++ b/module/zfs/arc.c @@ -1787,9 +1787,13 @@ arc_hdr_authenticate(arc_buf_hdr_t *hdr, spa_t *spa, uint64_t dsobj) !HDR_COMPRESSION_ENABLED(hdr)) { abd = NULL; csize = zio_compress_data(HDR_GET_COMPRESS(hdr), - hdr->b_l1hdr.b_pabd, &abd, lsize, lsize, hdr->b_complevel); + hdr->b_l1hdr.b_pabd, &abd, lsize, MIN(lsize, psize), + hdr->b_complevel); + if (csize >= lsize || csize > psize) { + ret = SET_ERROR(EIO); + return (ret); + } ASSERT3P(abd, !=, NULL); - ASSERT3U(csize, <=, psize); abd_zero_off(abd, csize, psize - csize); free_abd = B_TRUE; }