Skip to content

Commit 7303cb5

Browse files
jankaratytso
authored andcommitted
ext4: fix checking of directory entry validity for inline directories
ext4_search_dir() and ext4_generic_delete_entry() can be called both for standard director blocks and for inline directories stored inside inode or inline xattr space. For the second case we didn't call ext4_check_dir_entry() with proper constraints that could result in accepting corrupted directory entry as well as false positive filesystem errors like: EXT4-fs error (device dm-0): ext4_search_dir:1395: inode #28320400: block 113246792: comm dockerd: bad entry in directory: directory entry too close to block end - offset=0, inode=28320403, rec_len=32, name_len=8, size=4096 Fix the arguments passed to ext4_check_dir_entry(). Fixes: 109ba77 ("ext4: check for directory entries too close to block end") CC: [email protected] Signed-off-by: Jan Kara <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent 377254b commit 7303cb5

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

fs/ext4/namei.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1396,8 +1396,8 @@ int ext4_search_dir(struct buffer_head *bh, char *search_buf, int buf_size,
13961396
ext4_match(dir, fname, de)) {
13971397
/* found a match - just to be sure, do
13981398
* a full check */
1399-
if (ext4_check_dir_entry(dir, NULL, de, bh, bh->b_data,
1400-
bh->b_size, offset))
1399+
if (ext4_check_dir_entry(dir, NULL, de, bh, search_buf,
1400+
buf_size, offset))
14011401
return -1;
14021402
*res_dir = de;
14031403
return 1;
@@ -2482,7 +2482,7 @@ int ext4_generic_delete_entry(handle_t *handle,
24822482
de = (struct ext4_dir_entry_2 *)entry_buf;
24832483
while (i < buf_size - csum_size) {
24842484
if (ext4_check_dir_entry(dir, NULL, de, bh,
2485-
bh->b_data, bh->b_size, i))
2485+
entry_buf, buf_size, i))
24862486
return -EFSCORRUPTED;
24872487
if (de == de_del) {
24882488
if (pde)

0 commit comments

Comments
 (0)