aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/ext4/ioctl.c27
-rw-r--r--fs/inode.c13
-rw-r--r--fs/xfs/xfs_ioctl.c15
3 files changed, 13 insertions, 42 deletions
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index 1974cb755d09..566dfac28b3f 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -697,30 +697,6 @@ group_add_out:
697 return err; 697 return err;
698} 698}
699 699
700static int ext4_ioctl_check_project(struct inode *inode, struct fsxattr *fa)
701{
702 /*
703 * Project Quota ID state is only allowed to change from within the init
704 * namespace. Enforce that restriction only if we are trying to change
705 * the quota ID state. Everything else is allowed in user namespaces.
706 */
707 if (current_user_ns() == &init_user_ns)
708 return 0;
709
710 if (__kprojid_val(EXT4_I(inode)->i_projid) != fa->fsx_projid)
711 return -EINVAL;
712
713 if (ext4_test_inode_flag(inode, EXT4_INODE_PROJINHERIT)) {
714 if (!(fa->fsx_xflags & FS_XFLAG_PROJINHERIT))
715 return -EINVAL;
716 } else {
717 if (fa->fsx_xflags & FS_XFLAG_PROJINHERIT)
718 return -EINVAL;
719 }
720
721 return 0;
722}
723
724static void ext4_fill_fsxattr(struct inode *inode, struct fsxattr *fa) 700static void ext4_fill_fsxattr(struct inode *inode, struct fsxattr *fa)
725{ 701{
726 struct ext4_inode_info *ei = EXT4_I(inode); 702 struct ext4_inode_info *ei = EXT4_I(inode);
@@ -1133,9 +1109,6 @@ resizefs_out:
1133 1109
1134 inode_lock(inode); 1110 inode_lock(inode);
1135 ext4_fill_fsxattr(inode, &old_fa); 1111 ext4_fill_fsxattr(inode, &old_fa);
1136 err = ext4_ioctl_check_project(inode, &fa);
1137 if (err)
1138 goto out;
1139 err = vfs_ioc_fssetxattr_check(inode, &old_fa, &fa); 1112 err = vfs_ioc_fssetxattr_check(inode, &old_fa, &fa);
1140 if (err) 1113 if (err)
1141 goto out; 1114 goto out;
diff --git a/fs/inode.c b/fs/inode.c
index ba2bafa22885..30b720cffd9c 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -2214,6 +2214,19 @@ int vfs_ioc_fssetxattr_check(struct inode *inode, const struct fsxattr *old_fa,
2214 !capable(CAP_LINUX_IMMUTABLE)) 2214 !capable(CAP_LINUX_IMMUTABLE))
2215 return -EPERM; 2215 return -EPERM;
2216 2216
2217 /*
2218 * Project Quota ID state is only allowed to change from within the init
2219 * namespace. Enforce that restriction only if we are trying to change
2220 * the quota ID state. Everything else is allowed in user namespaces.
2221 */
2222 if (current_user_ns() != &init_user_ns) {
2223 if (old_fa->fsx_projid != fa->fsx_projid)
2224 return -EINVAL;
2225 if ((old_fa->fsx_xflags ^ fa->fsx_xflags) &
2226 FS_XFLAG_PROJINHERIT)
2227 return -EINVAL;
2228 }
2229
2217 return 0; 2230 return 0;
2218} 2231}
2219EXPORT_SYMBOL(vfs_ioc_fssetxattr_check); 2232EXPORT_SYMBOL(vfs_ioc_fssetxattr_check);
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index 458a7043b4d2..f494c01342c6 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -1298,21 +1298,6 @@ xfs_ioctl_setattr_check_projid(
1298 if (fa->fsx_projid > (uint16_t)-1 && 1298 if (fa->fsx_projid > (uint16_t)-1 &&
1299 !xfs_sb_version_hasprojid32bit(&ip->i_mount->m_sb)) 1299 !xfs_sb_version_hasprojid32bit(&ip->i_mount->m_sb))
1300 return -EINVAL; 1300 return -EINVAL;
1301
1302 /*
1303 * Project Quota ID state is only allowed to change from within the init
1304 * namespace. Enforce that restriction only if we are trying to change
1305 * the quota ID state. Everything else is allowed in user namespaces.
1306 */
1307 if (current_user_ns() == &init_user_ns)
1308 return 0;
1309
1310 if (xfs_get_projid(ip) != fa->fsx_projid)
1311 return -EINVAL;
1312 if ((fa->fsx_xflags & FS_XFLAG_PROJINHERIT) !=
1313 (ip->i_d.di_flags & XFS_DIFLAG_PROJINHERIT))
1314 return -EINVAL;
1315
1316 return 0; 1301 return 0;
1317} 1302}
1318 1303