Commit a5d3f789 authored by Jan Kara's avatar Jan Kara Committed by Greg Kroah-Hartman

ext4: fix checking of directory entry validity for inline directories

commit 7303cb5b upstream.

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: 109ba779 ("ext4: check for directory entries too close to block end")
CC: stable@vger.kernel.org
Signed-off-by: default avatarJan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20200731162135.8080-1-jack@suse.czSigned-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent c666936d
...@@ -1309,8 +1309,8 @@ int ext4_search_dir(struct buffer_head *bh, char *search_buf, int buf_size, ...@@ -1309,8 +1309,8 @@ int ext4_search_dir(struct buffer_head *bh, char *search_buf, int buf_size,
ext4_match(fname, de)) { ext4_match(fname, de)) {
/* found a match - just to be sure, do /* found a match - just to be sure, do
* a full check */ * a full check */
if (ext4_check_dir_entry(dir, NULL, de, bh, bh->b_data, if (ext4_check_dir_entry(dir, NULL, de, bh, search_buf,
bh->b_size, offset)) buf_size, offset))
return -1; return -1;
*res_dir = de; *res_dir = de;
return 1; return 1;
...@@ -2344,7 +2344,7 @@ int ext4_generic_delete_entry(handle_t *handle, ...@@ -2344,7 +2344,7 @@ int ext4_generic_delete_entry(handle_t *handle,
de = (struct ext4_dir_entry_2 *)entry_buf; de = (struct ext4_dir_entry_2 *)entry_buf;
while (i < buf_size - csum_size) { while (i < buf_size - csum_size) {
if (ext4_check_dir_entry(dir, NULL, de, bh, if (ext4_check_dir_entry(dir, NULL, de, bh,
bh->b_data, bh->b_size, i)) entry_buf, buf_size, i))
return -EFSCORRUPTED; return -EFSCORRUPTED;
if (de == de_del) { if (de == de_del) {
if (pde) if (pde)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment