Skip to contentSkip to conversation

remove permission check from xfs_change_file_space

PATCH New Christoph Hellwig 1 participant 1 message Dec 21, 2007 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 remove permission check from xfs_change_file_space

Both callers of xfs_change_file_space alreaedy do the file->f_mode & FMODE_WRITE check to ensure we have a file descriptor that has been opened for write mode, so there is no need to re-check that with xfs_iaccess. Especially as the later might wrongly deny it for corner cases like file descriptor passing through unix domain sockets.

fs/xfs/xfs_vnodeops.c +0 -12
Index: linux-2.6-xfs/fs/xfs/xfs_vnodeops.c
===================================================================
@@ -4311,21 +4311,9 @@ xfs_change_file_space(
 
 	xfs_itrace_entry(ip);
 
-	/*
-	 * must be a regular file and have write permission
-	 */
 	if (!S_ISREG(ip->i_d.di_mode))
 		return XFS_ERROR(EINVAL);
 
-	xfs_ilock(ip, XFS_ILOCK_SHARED);
-
-	if ((error = xfs_iaccess(ip, S_IWUSR, credp))) {
-		xfs_iunlock(ip, XFS_ILOCK_SHARED);
-		return error;
-	}
-
-	xfs_iunlock(ip, XFS_ILOCK_SHARED);
-
 	switch (bf->l_whence) {
 	case 0: /*SEEK_SET*/
 		break;