From 579be2538c9f493b3fd82760174ca080c52c89d3 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 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/module/zfs/arc.c b/module/zfs/arc.c index 4c967a2ebc92..cc9853a09458 100644 --- a/module/zfs/arc.c +++ b/module/zfs/arc.c @@ -1787,10 +1787,13 @@ arc_hdr_authenticate(arc_buf_hdr_t *hdr, spa_t *spa, uint64_t dsobj) !HDR_COMPRESSION_ENABLED(hdr)) { csize = zio_compress_data(HDR_GET_COMPRESS(hdr), - hdr->b_l1hdr.b_pabd, &tmpbuf, lsize, lsize, + hdr->b_l1hdr.b_pabd, &tmpbuf, lsize, MIN(lsize, psize), hdr->b_complevel); + if (csize >= lsize || csize > psize) { + ret = SET_ERROR(EIO); + goto error; + } ASSERT3P(tmpbuf, !=, NULL); - ASSERT3U(csize, <=, psize); abd = abd_get_from_buf(tmpbuf, lsize); abd_take_ownership_of_buf(abd, B_TRUE); abd_zero_off(abd, csize, psize - csize);