Patch "erofs: fix wrong primary bvec selection on deduplicated extents" has been added to the 6.1-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    erofs: fix wrong primary bvec selection on deduplicated extents

to the 6.1-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     erofs-fix-wrong-primary-bvec-selection-on-deduplicat.patch
and it can be found in the queue-6.1 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit b54e9bdfd5f9f3e58da198b9c3fa6ec295dada52
Author: Gao Xiang <xiang@xxxxxxxxxx>
Date:   Wed Jul 19 14:54:59 2023 +0800

    erofs: fix wrong primary bvec selection on deduplicated extents
    
    [ Upstream commit 94c43de73521d8ed7ebcfc6191d9dace1cbf7caa ]
    
    When handling deduplicated compressed data, there can be multiple
    decompressed extents pointing to the same compressed data in one shot.
    
    In such cases, the bvecs which belong to the longest extent will be
    selected as the primary bvecs for real decompressors to decode and the
    other duplicated bvecs will be directly copied from the primary bvecs.
    
    Previously, only relative offsets of the longest extent were checked to
    decompress the primary bvecs.  On rare occasions, it can be incorrect
    if there are several extents with the same start relative offset.
    As a result, some short bvecs could be selected for decompression and
    then cause data corruption.
    
    For example, as Shijie Sun reported off-list, considering the following
    extents of a file:
     117:   903345..  915250 |   11905 :     385024..    389120 |    4096
    ...
     119:   919729..  930323 |   10594 :     385024..    389120 |    4096
    ...
     124:   968881..  980786 |   11905 :     385024..    389120 |    4096
    
    The start relative offset is the same: 2225, but extent 119 (919729..
    930323) is shorter than the others.
    
    Let's restrict the bvec length in addition to the start offset if bvecs
    are not full.
    
    Reported-by: Shijie Sun <sunshijie@xxxxxxxxxx>
    Fixes: 5c2a64252c5d ("erofs: introduce partial-referenced pclusters")
    Tested-by Shijie Sun <sunshijie@xxxxxxxxxx>
    Reviewed-by: Yue Hu <huyue2@xxxxxxxxxxx>
    Reviewed-by: Chao Yu <chao@xxxxxxxxxx>
    Signed-off-by: Gao Xiang <hsiangkao@xxxxxxxxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20230719065459.60083-1-hsiangkao@xxxxxxxxxxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c
index 533e612b6a486..361f3c29897e8 100644
--- a/fs/erofs/zdata.c
+++ b/fs/erofs/zdata.c
@@ -989,10 +989,11 @@ static void z_erofs_do_decompressed_bvec(struct z_erofs_decompress_backend *be,
 					 struct z_erofs_bvec *bvec)
 {
 	struct z_erofs_bvec_item *item;
+	unsigned int pgnr;
 
-	if (!((bvec->offset + be->pcl->pageofs_out) & ~PAGE_MASK)) {
-		unsigned int pgnr;
-
+	if (!((bvec->offset + be->pcl->pageofs_out) & ~PAGE_MASK) &&
+	    (bvec->end == PAGE_SIZE ||
+	     bvec->offset + bvec->end == be->pcl->length)) {
 		pgnr = (bvec->offset + be->pcl->pageofs_out) >> PAGE_SHIFT;
 		DBG_BUGON(pgnr >= be->nr_pages);
 		if (!be->decompressed_pages[pgnr]) {



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux