From f472e02669073e4f1a388142bafa0f806fae841c Mon Sep 17 00:00:00 2001 From: Tao Ma Date: Mon, 17 Oct 2011 10:13:46 -0400 Subject: 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: Tao Ma Signed-off-by: "Theodore Ts'o" --- fs/ext4/extents.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'fs/ext4') diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index f473ddf0bd94..5c4861210d4c 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -779,6 +779,11 @@ static int ext4_ext_insert_index(handle_t *handle, struct inode *inode, 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); ext4_idx_store_pblock(ix, ptr); le16_add_cpu(&curp->p_hdr->eh_entries, 1); -- cgit v1.2.3