Patch "ext4: check if directory block is within i_size" has been added to the 5.18-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

    ext4: check if directory block is within i_size

to the 5.18-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:
     ext4-check-if-directory-block-is-within-i_size.patch
and it can be found in the queue-5.18 subdirectory.

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



commit 6770bf434d6a397d0ac1762555133b5cf6e7a3e8
Author: Lukas Czerner <lczerner@xxxxxxxxxx>
Date:   Mon Jul 4 16:27:20 2022 +0200

    ext4: check if directory block is within i_size
    
    [ Upstream commit 65f8ea4cd57dbd46ea13b41dc8bac03176b04233 ]
    
    Currently ext4 directory handling code implicitly assumes that the
    directory blocks are always within the i_size. In fact ext4_append()
    will attempt to allocate next directory block based solely on i_size and
    the i_size is then appropriately increased after a successful
    allocation.
    
    However, for this to work it requires i_size to be correct. If, for any
    reason, the directory inode i_size is corrupted in a way that the
    directory tree refers to a valid directory block past i_size, we could
    end up corrupting parts of the directory tree structure by overwriting
    already used directory blocks when modifying the directory.
    
    Fix it by catching the corruption early in __ext4_read_dirblock().
    
    Addresses Red-Hat-Bugzilla: #2070205
    CVE: CVE-2022-1184
    Signed-off-by: Lukas Czerner <lczerner@xxxxxxxxxx>
    Cc: stable@xxxxxxxxxxxxxxx
    Reviewed-by: Andreas Dilger <adilger@xxxxxxxxx>
    Link: https://lore.kernel.org/r/20220704142721.157985-1-lczerner@xxxxxxxxxx
    Signed-off-by: Theodore Ts'o <tytso@xxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index 4f0420b1ff3e..2bc3e4b27204 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -110,6 +110,13 @@ static struct buffer_head *__ext4_read_dirblock(struct inode *inode,
 	struct ext4_dir_entry *dirent;
 	int is_dx_block = 0;
 
+	if (block >= inode->i_size) {
+		ext4_error_inode(inode, func, line, block,
+		       "Attempting to read directory block (%u) that is past i_size (%llu)",
+		       block, inode->i_size);
+		return ERR_PTR(-EFSCORRUPTED);
+	}
+
 	if (ext4_simulate_fail(inode->i_sb, EXT4_SIM_DIRBLOCK_EIO))
 		bh = ERR_PTR(-EIO);
 	else



[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