Skip to contentSkip to conversation

ext4 defrag executables

PATCH New Andreas Rid 1 participant 1 message Aug 29, 2010 ext4 file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ext4 defrag executables

hi,

since ioctl EXT4_IOC_MOVE_EXT checks the original file descriptor for write access it's no longer possible to defrag executable files which are currently in use. This is because you can only open() those files readonly. This patch solves it without adding a security hole.
What do you think about it?

Andreas

fs/ext4/ioctl.c +2 -2
index 352cb35..ae45380 100644
@@ -242,8 +242,8 @@ setversion_out:
 		struct file *donor_filp;
 		int err;
 
-		if (!(filp->f_mode & FMODE_READ) ||
-		    !(filp->f_mode & FMODE_WRITE))
+		if (generic_permission(filp->f_dentry->d_inode,
+			MAY_READ | MAY_WRITE, NULL))
 			return -EBADF;
 
 		if (copy_from_user(&me,