From 6cb3f9a36d47a0e1ecf9617072c8196d302ee622 Mon Sep 17 00:00:00 2001 From: Patrick Farrell Date: Mon, 18 Dec 2023 23:19:44 -0500 Subject: [PATCH] EX-7601 osc: add check to decompress_request 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 Change-Id: Ib1bf19bf39701b72f0f5a61b2aaff2f2fdad1897 Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/53502 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Artem Blagodarenko Reviewed-by: Andreas Dilger --- lustre/osc/osc_compress.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lustre/osc/osc_compress.c b/lustre/osc/osc_compress.c index 79c557f..bae9309 100644 --- a/lustre/osc/osc_compress.c +++ b/lustre/osc/osc_compress.c @@ -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); -- 1.8.3.1