Commit ae437ce
CKI Backport Bot
ext4: make sure the first directory block is not a hole
JIRA: https://issues.redhat.com/browse/RHEL-54975
CVE: CVE-2024-42304
commit f9ca515
Author: Baokun Li <libaokun1@huawei.com>
Date: Tue Jul 2 21:23:49 2024 +0800
ext4: make sure the first directory block is not a hole
The syzbot constructs a directory that has no dirblock but is non-inline,
i.e. the first directory block is a hole. And no errors are reported when
creating files in this directory in the following flow.
ext4_mknod
...
ext4_add_entry
// Read block 0
ext4_read_dirblock(dir, block, DIRENT)
bh = ext4_bread(NULL, inode, block, 0)
if (!bh && (type == INDEX || type == DIRENT_HTREE))
// The first directory block is a hole
// But type == DIRENT, so no error is reported.
After that, we get a directory block without '.' and '..' but with a valid
dentry. This may cause some code that relies on dot or dotdot (such as
make_indexed_dir()) to crash.
Therefore when ext4_read_dirblock() finds that the first directory block
is a hole report that the filesystem is corrupted and return an error to
avoid loading corrupted data from disk causing something bad.
Reported-by: syzbot+ae688d469e36fb5138d0@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=ae688d469e36fb5138d0
Fixes: 4e19d6b ("ext4: allow directory holes")
Cc: stable@kernel.org
Signed-off-by: Baokun Li <libaokun1@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Link: https://patch.msgid.link/20240702132349.2600605-3-libaokun@huaweicloud.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: CKI Backport Bot <cki-ci-bot+cki-gitlab-backport-bot@redhat.com>1 parent 8825a45 commit ae437ce
1 file changed
+6
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
155 | | - | |
| 155 | + | |
| 156 | + | |
156 | 157 | | |
157 | | - | |
158 | | - | |
| 158 | + | |
| 159 | + | |
159 | 160 | | |
160 | 161 | | |
161 | 162 | | |
| |||
3085 | 3086 | | |
3086 | 3087 | | |
3087 | 3088 | | |
3088 | | - | |
3089 | | - | |
3090 | | - | |
3091 | | - | |
| 3089 | + | |
3092 | 3090 | | |
3093 | 3091 | | |
3094 | 3092 | | |
| |||
3532 | 3530 | | |
3533 | 3531 | | |
3534 | 3532 | | |
3535 | | - | |
3536 | | - | |
3537 | | - | |
3538 | | - | |
| 3533 | + | |
3539 | 3534 | | |
3540 | 3535 | | |
3541 | 3536 | | |
| |||
0 commit comments