Patch "erofs: avoid infinite loop in z_erofs_do_read_page() when reading beyond EOF" has been added to the 6.4-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: avoid infinite loop in z_erofs_do_read_page() when reading beyond EOF

to the 6.4-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-avoid-infinite-loop-in-z_erofs_do_read_page-wh.patch
and it can be found in the queue-6.4 subdirectory.

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



commit 179c93cb4147df032e78c950833127e4fe6344e5
Author: Chunhai Guo <guochunhai@xxxxxxxx>
Date:   Mon Jul 10 17:34:10 2023 +0800

    erofs: avoid infinite loop in z_erofs_do_read_page() when reading beyond EOF
    
    [ Upstream commit 8191213a5835b0317c5e4d0d337ae1ae00c75253 ]
    
    z_erofs_do_read_page() may loop infinitely due to the inappropriate
    truncation in the below statement. Since the offset is 64 bits and min_t()
    truncates the result to 32 bits. The solution is to replace unsigned int
    with a 64-bit type, such as erofs_off_t.
        cur = end - min_t(unsigned int, offset + end - map->m_la, end);
    
        - For example:
            - offset = 0x400160000
            - end = 0x370
            - map->m_la = 0x160370
            - offset + end - map->m_la = 0x400000000
            - offset + end - map->m_la = 0x00000000 (truncated as unsigned int)
        - Expected result:
            - cur = 0
        - Actual result:
            - cur = 0x370
    
    Signed-off-by: Chunhai Guo <guochunhai@xxxxxxxx>
    Fixes: 3883a79abd02 ("staging: erofs: introduce VLE decompression support")
    Reviewed-by: Gao Xiang <hsiangkao@xxxxxxxxxxxxxxxxx>
    Reviewed-by: Chao Yu <chao@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20230710093410.44071-1-guochunhai@xxxxxxxx
    Signed-off-by: Gao Xiang <hsiangkao@xxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c
index bedfff5d45faf..997ca4b32e87f 100644
--- a/fs/erofs/zdata.c
+++ b/fs/erofs/zdata.c
@@ -990,7 +990,7 @@ static int z_erofs_do_read_page(struct z_erofs_decompress_frontend *fe,
 	 */
 	tight &= (fe->mode > Z_EROFS_PCLUSTER_FOLLOWED_NOINPLACE);
 
-	cur = end - min_t(unsigned int, offset + end - map->m_la, end);
+	cur = end - min_t(erofs_off_t, offset + end - map->m_la, end);
 	if (!(map->m_flags & EROFS_MAP_MAPPED)) {
 		zero_user_segment(page, cur, end);
 		goto next_part;



[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