ext4: Fix different block exchange issue in EXT4_IOC_MOVE_EXT
authorAkira Fujita <a-fujita@rs.jp.nec.com>
Wed, 16 Sep 2009 18:25:39 +0000 (14:25 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 16 Sep 2009 18:25:39 +0000 (14:25 -0400)
commitc40ce3c9ea97425a12d7e44031a98fe50add6fc1
tree2150e1dbbcbf42c8293a887976a648fceaf8da73
parent347fa6f1c7cb5df2b38d3c9167cfe242ce0cd1da
ext4: Fix different block exchange issue in EXT4_IOC_MOVE_EXT

If logical block offset of original file which is passed to
EXT4_IOC_MOVE_EXT is different from donor file's,
a calculation error occurs in ext4_calc_swap_extents(),
therefore wrong block is exchanged between original file and donor file.
As a result, we hit ext4_error() in check_block_validity().
To detect the logical offset difference in EXT4_IOC_MOVE_EXT,
add checks to mext_calc_swap_extents() and handle it as error,
since data exchange must be done between the same blocks in EXT4_IOC_MOVE_EXT.

Reported-by: Peng Tao <bergwolf@gmail.com>
Signed-off-by: Akira Fujita <a-fujita@rs.jp.nec.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
fs/ext4/move_extent.c