diff options
author | Tao Ma <boyu.mt@taobao.com> | 2011-10-17 10:13:46 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2011-10-17 10:13:46 -0400 |
commit | f472e02669073e4f1a388142bafa0f806fae841c (patch) | |
tree | 766f26be99c1ffa5d3f0c93e233a60cc52e74094 /fs/ext4/extents.c | |
parent | d44651d0f922b7aaeddd9fc04f2f5700a65983dd (diff) |
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 <boyu.mt@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/extents.c')
-rw-r--r-- | fs/ext4/extents.c | 5 |
1 files changed, 5 insertions, 0 deletions
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, | |||
779 | ix = curp->p_idx; | 779 | ix = curp->p_idx; |
780 | } | 780 | } |
781 | 781 | ||
782 | if (unlikely(ix > EXT_MAX_INDEX(curp->p_hdr))) { | ||
783 | EXT4_ERROR_INODE(inode, "ix > EXT_MAX_INDEX!"); | ||
784 | return -EIO; | ||
785 | } | ||
786 | |||
782 | ix->ei_block = cpu_to_le32(logical); | 787 | ix->ei_block = cpu_to_le32(logical); |
783 | ext4_idx_store_pblock(ix, ptr); | 788 | ext4_idx_store_pblock(ix, ptr); |
784 | le16_add_cpu(&curp->p_hdr->eh_entries, 1); | 789 | le16_add_cpu(&curp->p_hdr->eh_entries, 1); |