aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/move_extent.c
diff options
context:
space:
mode:
authorAkira Fujita <a-fujita@rs.jp.nec.com>2010-03-04 00:34:58 -0500
committerTheodore Ts'o <tytso@mit.edu>2010-03-04 00:34:58 -0500
commit7247c0caa23d94a1cb6b307edba9dc45fb0798d4 (patch)
tree435dd65425ea98ce4e10396f27c7a2f02dde15c8 /fs/ext4/move_extent.c
parent5fd5249aa36fad98c9fd5edced352939e54f9324 (diff)
ext4: Fix the NULL reference in double_down_write_data_sem()
If EXT4_IOC_MOVE_EXT ioctl is called with NULL donor_fd, fget() in ext4_ioctl() gets inappropriate file structure for donor; so we need to do this check earlier, before calling double_down_write_data_sem(). Signed-off-by: Akira Fujita <a-fujita@rs.jp.nec.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/move_extent.c')
-rw-r--r--fs/ext4/move_extent.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c
index 9eca1c0ec546..7e99f4e72bf5 100644
--- a/fs/ext4/move_extent.c
+++ b/fs/ext4/move_extent.c
@@ -953,14 +953,6 @@ mext_check_arguments(struct inode *orig_inode,
953 unsigned int blkbits = orig_inode->i_blkbits; 953 unsigned int blkbits = orig_inode->i_blkbits;
954 unsigned int blocksize = 1 << blkbits; 954 unsigned int blocksize = 1 << blkbits;
955 955
956 /* Regular file check */
957 if (!S_ISREG(orig_inode->i_mode) || !S_ISREG(donor_inode->i_mode)) {
958 ext4_debug("ext4 move extent: The argument files should be "
959 "regular file [ino:orig %lu, donor %lu]\n",
960 orig_inode->i_ino, donor_inode->i_ino);
961 return -EINVAL;
962 }
963
964 if (donor_inode->i_mode & (S_ISUID|S_ISGID)) { 956 if (donor_inode->i_mode & (S_ISUID|S_ISGID)) {
965 ext4_debug("ext4 move extent: suid or sgid is set" 957 ext4_debug("ext4 move extent: suid or sgid is set"
966 " to donor file [ino:orig %lu, donor %lu]\n", 958 " to donor file [ino:orig %lu, donor %lu]\n",
@@ -1208,6 +1200,14 @@ ext4_move_extents(struct file *o_filp, struct file *d_filp,
1208 return -EINVAL; 1200 return -EINVAL;
1209 } 1201 }
1210 1202
1203 /* Regular file check */
1204 if (!S_ISREG(orig_inode->i_mode) || !S_ISREG(donor_inode->i_mode)) {
1205 ext4_debug("ext4 move extent: The argument files should be "
1206 "regular file [ino:orig %lu, donor %lu]\n",
1207 orig_inode->i_ino, donor_inode->i_ino);
1208 return -EINVAL;
1209 }
1210
1211 /* Protect orig and donor inodes against a truncate */ 1211 /* Protect orig and donor inodes against a truncate */
1212 ret1 = mext_inode_double_lock(orig_inode, donor_inode); 1212 ret1 = mext_inode_double_lock(orig_inode, donor_inode);
1213 if (ret1 < 0) 1213 if (ret1 < 0)