Whamcloud - gitweb
EX-7601 osc: add check to decompress_request
authorPatrick Farrell <pfarrell@whamcloud.com>
Tue, 19 Dec 2023 04:19:44 +0000 (23:19 -0500)
committerAndreas Dilger <adilger@whamcloud.com>
Sat, 6 Jan 2024 08:20:29 +0000 (08:20 +0000)
decompress_request should check to see if there's room in
the RPC for the decompressed data, since this can occur if
there's a bug or data corruption, and otherwise we will
go past the end of the RPC during decompression.

Test-Parameters: trivial
Signed-off-by: Patrick Farrell <pfarrell@whamcloud.com>
Change-Id: Ib1bf19bf39701b72f0f5a61b2aaff2f2fdad1897
Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/53502
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Artem Blagodarenko <ablagodarenko@ddn.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/osc/osc_compress.c

index 79c557f..bae9309 100644 (file)
@@ -403,9 +403,9 @@ int decompress_request(struct osc_brw_async_args *aa, int page_count)
                /* must be enough pages left in the RPC to hold the compressed
                 * data, if not, the data from disk is probably corrupt
                 */
-               if (compressed_pages > page_count - 1) {
-                       CERROR("compressed pages from disk %d don't match pages in rpc %d\n",
-                              compressed_pages, page_count - 1);
+               if (compressed_pages > page_count - i) {
+                       CERROR("compressed pages from disk %d don't match pages in rpc %d (at %d of %d pages)\n",
+                              compressed_pages, page_count - 1 - i, i, page_count);
                        GOTO(out, rc = -EUCLEAN);
                }
 
@@ -439,6 +439,14 @@ int decompress_request(struct osc_brw_async_args *aa, int page_count)
                CDEBUG(D_SEC, "Decompressed size %u, pages %d\n", dst_size,
                       decompressed_pages);
 
+               /* must be enough pages left in the RPC to hold the decompressed
+                * data, if not, the data from disk is probably corrupt
+                */
+               if (decompressed_pages > page_count - i) {
+                       CERROR("decompressed pages from disk %d don't match pages in rpc %d (at %d of %d pages)\n",
+                              decompressed_pages, page_count - 1 - i, i, page_count);
+                       GOTO(out, rc = -EUCLEAN);
+               }
                unmerge_chunk(pga, NULL, i, decompressed_pages, dst, dst_size,
                              0);