Commit 881ceebe authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Nathan Scott

[XFS] Fix r/o check in xfs_ioc_space, fix checks on xfs_swapext validity.

SGI Modid: xfs-linux:xfs-kern:169135a
parent 83ea3f02
...@@ -850,6 +850,9 @@ xfs_ioctl( ...@@ -850,6 +850,9 @@ xfs_ioctl(
case XFS_IOC_ERROR_INJECTION: { case XFS_IOC_ERROR_INJECTION: {
xfs_error_injection_t in; xfs_error_injection_t in;
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
if (copy_from_user(&in, (char *)arg, sizeof(in))) if (copy_from_user(&in, (char *)arg, sizeof(in)))
return -XFS_ERROR(EFAULT); return -XFS_ERROR(EFAULT);
...@@ -858,6 +861,9 @@ xfs_ioctl( ...@@ -858,6 +861,9 @@ xfs_ioctl(
} }
case XFS_IOC_ERROR_CLEARALL: case XFS_IOC_ERROR_CLEARALL:
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
error = xfs_errortag_clearall(mp); error = xfs_errortag_clearall(mp);
return -error; return -error;
...@@ -882,7 +888,7 @@ xfs_ioc_space( ...@@ -882,7 +888,7 @@ xfs_ioc_space(
if (vp->v_inode.i_flags & (S_IMMUTABLE|S_APPEND)) if (vp->v_inode.i_flags & (S_IMMUTABLE|S_APPEND))
return -XFS_ERROR(EPERM); return -XFS_ERROR(EPERM);
if (filp->f_flags & O_RDONLY) if (!(filp->f_flags & FMODE_WRITE))
return -XFS_ERROR(EBADF); return -XFS_ERROR(EBADF);
if (vp->v_type != VREG) if (vp->v_type != VREG)
......
...@@ -119,6 +119,11 @@ xfs_swapext( ...@@ -119,6 +119,11 @@ xfs_swapext(
tip = XFS_BHVTOI(tbdp); tip = XFS_BHVTOI(tbdp);
} }
if (ip->i_mount != tip->i_mount) {
error = XFS_ERROR(EINVAL);
goto error0;
}
if (ip->i_ino == tip->i_ino) { if (ip->i_ino == tip->i_ino) {
error = XFS_ERROR(EINVAL); error = XFS_ERROR(EINVAL);
goto error0; goto error0;
...@@ -147,20 +152,17 @@ xfs_swapext( ...@@ -147,20 +152,17 @@ xfs_swapext(
xfs_lock_inodes(ips, 2, 0, lock_flags); xfs_lock_inodes(ips, 2, 0, lock_flags);
/* Check permissions */ /* Check permissions */
if ((error = _MAC_XFS_IACCESS(ip, MACWRITE, NULL))) { error = xfs_iaccess(ip, S_IWUSR, NULL);
goto error0; if (error)
}
if ((error = _MAC_XFS_IACCESS(tip, MACWRITE, NULL))) {
goto error0; goto error0;
}
if ((current_fsuid(cred) != ip->i_d.di_uid) && error = xfs_iaccess(tip, S_IWUSR, NULL);
(error = xfs_iaccess(ip, S_IWUSR, NULL)) && if (error)
!capable_cred(NULL, CAP_FOWNER)) {
goto error0; goto error0;
}
if ((current_fsuid(cred) != tip->i_d.di_uid) && /* Verify that both files have the same format */
(error = xfs_iaccess(tip, S_IWUSR, NULL)) && if ((ip->i_d.di_mode & S_IFMT) != (tip->i_d.di_mode & S_IFMT)) {
!capable_cred(NULL, CAP_FOWNER)) { error = XFS_ERROR(EINVAL);
goto error0; goto error0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment