From 9b3d7f7e4192712e607193df9a7ae596009b44f1 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. Co-authored-by: Alexander Motin Signed-off-by: George Melikov --- 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 eab618e3470d..cf7cfa1f8828 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; }