]> git.proxmox.com Git - mirror_zfs.git/commitdiff
arc_hdr_authenticate: make explicit error
authorGeorge Melikov <mail@gmelikov.ru>
Mon, 3 Jun 2024 17:40:25 +0000 (20:40 +0300)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Fri, 20 Sep 2024 00:25:02 +0000 (17:25 -0700)
On compression we could be more explicit here for cases
where we can not recompress the data.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Co-authored-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: George Melikov <mail@gmelikov.ru>
Closes #9416

module/zfs/arc.c

index c222fd4287ec8d8c738e61db0c4652d0a4801fe4..de64e7a5bd98c5fdf43ac69191e795eb0a4e822c 100644 (file)
@@ -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;
        }