Commit f472e026 authored by Tao Ma's avatar Tao Ma Committed by Theodore Ts'o

ext4: avoid stamping on other memories in ext4_ext_insert_index()

Add a sanity check to make sure ix hasn't gone beyond the valid bounds
of the extent block.
Signed-off-by: default avatarTao Ma <boyu.mt@taobao.com>
Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
parent d44651d0
...@@ -779,6 +779,11 @@ static int ext4_ext_insert_index(handle_t *handle, struct inode *inode, ...@@ -779,6 +779,11 @@ static int ext4_ext_insert_index(handle_t *handle, struct inode *inode,
ix = curp->p_idx; ix = curp->p_idx;
} }
if (unlikely(ix > EXT_MAX_INDEX(curp->p_hdr))) {
EXT4_ERROR_INODE(inode, "ix > EXT_MAX_INDEX!");
return -EIO;
}
ix->ei_block = cpu_to_le32(logical); ix->ei_block = cpu_to_le32(logical);
ext4_idx_store_pblock(ix, ptr); ext4_idx_store_pblock(ix, ptr);
le16_add_cpu(&curp->p_hdr->eh_entries, 1); le16_add_cpu(&curp->p_hdr->eh_entries, 1);
......
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