Patch "Squashfs: sanity check symbolic link size" has been added to the 5.10-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

    Squashfs: sanity check symbolic link size

to the 5.10-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:
     squashfs-sanity-check-symbolic-link-size.patch
and it can be found in the queue-5.10 subdirectory.

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



commit b7769eae32ed03dc420b1a28e501349b6593c38e
Author: Phillip Lougher <phillip@xxxxxxxxxxxxxxx>
Date:   Mon Aug 12 00:28:21 2024 +0100

    Squashfs: sanity check symbolic link size
    
    [ Upstream commit 810ee43d9cd245d138a2733d87a24858a23f577d ]
    
    Syzkiller reports a "KMSAN: uninit-value in pick_link" bug.
    
    This is caused by an uninitialised page, which is ultimately caused
    by a corrupted symbolic link size read from disk.
    
    The reason why the corrupted symlink size causes an uninitialised
    page is due to the following sequence of events:
    
    1. squashfs_read_inode() is called to read the symbolic
       link from disk.  This assigns the corrupted value
       3875536935 to inode->i_size.
    
    2. Later squashfs_symlink_read_folio() is called, which assigns
       this corrupted value to the length variable, which being a
       signed int, overflows producing a negative number.
    
    3. The following loop that fills in the page contents checks that
       the copied bytes is less than length, which being negative means
       the loop is skipped, producing an uninitialised page.
    
    This patch adds a sanity check which checks that the symbolic
    link size is not larger than expected.
    
    --
    
    Signed-off-by: Phillip Lougher <phillip@xxxxxxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20240811232821.13903-1-phillip@xxxxxxxxxxxxxxx
    Reported-by: Lizhi Xu <lizhi.xu@xxxxxxxxxxxxx>
    Reported-by: syzbot+24ac24ff58dc5b0d26b9@xxxxxxxxxxxxxxxxxxxxxxxxx
    Closes: https://lore.kernel.org/all/000000000000a90e8c061e86a76b@xxxxxxxxxx/
    V2: fix spelling mistake.
    Signed-off-by: Christian Brauner <brauner@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/fs/squashfs/inode.c b/fs/squashfs/inode.c
index 24463145b351..f31649080a88 100644
--- a/fs/squashfs/inode.c
+++ b/fs/squashfs/inode.c
@@ -276,8 +276,13 @@ int squashfs_read_inode(struct inode *inode, long long ino)
 		if (err < 0)
 			goto failed_read;
 
-		set_nlink(inode, le32_to_cpu(sqsh_ino->nlink));
 		inode->i_size = le32_to_cpu(sqsh_ino->symlink_size);
+		if (inode->i_size > PAGE_SIZE) {
+			ERROR("Corrupted symlink\n");
+			return -EINVAL;
+		}
+
+		set_nlink(inode, le32_to_cpu(sqsh_ino->nlink));
 		inode->i_op = &squashfs_symlink_inode_ops;
 		inode_nohighmem(inode);
 		inode->i_data.a_ops = &squashfs_symlink_aops;




[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