Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

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
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -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);