History

xfs: support idmapped mounts

Enable idmapped mounts for xfs. This basically just means passing down the user_namespace argument from the VFS methods down to where it is passed to the relevant helpers. Note that full-filesystem bulkstat is not supported from inside idmapped mounts as it is an administrative operation that acts on the whole file system. The limitation is not applied to the bulkstat single operation that just operates on a single inode.

Christoph Hellwig committed 5 years ago

Commit f736d931 parent 14f3db514 files · +110 −65Browse files

Unified · Split

14 files
  1. fs/xfs/xfs_acl.c +1 −2
  2. fs/xfs/xfs_file.c +3 −1
  3. fs/xfs/xfs_inode.c +18 −8
  4. fs/xfs/xfs_inode.h +10 −6
  5. fs/xfs/xfs_ioctl.c +21 −14
  6. fs/xfs/xfs_ioctl32.c +4 −2
  7. fs/xfs/xfs_iops.c +28 −21
  8. fs/xfs/xfs_iops.h +2 −1
  9. fs/xfs/xfs_itable.c +13 −4
  10. fs/xfs/xfs_itable.h +1 −0
  11. fs/xfs/xfs_qm.c +2 −1
  12. fs/xfs/xfs_super.c +1 −1
  13. fs/xfs/xfs_symlink.c +3 −2
  14. fs/xfs/xfs_symlink.h +3 −2
fs/xfs/xfs_acl.c+1−2
@@ -253,8 +253,7 @@ xfs_set_acl(struct user_namespace *mnt_userns, struct inode *inode, · 252 unmodified lines
253253 return error;
254254
255255 if (type == ACL_TYPE_ACCESS) {
256− error = posix_acl_update_mode(&init_user_ns, inode, &mode,
257− &acl);
256+ error = posix_acl_update_mode(mnt_userns, inode, &mode, &acl);
258257 if (error)
259258 return error;
260259 set_mode = true;
fs/xfs/xfs_file.c+3−1
@@ -29,6 +29,7 @@ · 28 unmodified lines
2929 #include <linux/backing-dev.h>
3030 #include <linux/mman.h>
3131 #include <linux/fadvise.h>
32+#include <linux/mount.h>
3233
3334 static const struct vm_operations_struct xfs_file_vm_ops;
3435
@@ -994,7 +995,8 @@ xfs_file_fallocate( · 959 unmodified lines
994995
995996 iattr.ia_valid = ATTR_SIZE;
996997 iattr.ia_size = new_size;
997− error = xfs_vn_setattr_size(file_dentry(file), &iattr);
998+ error = xfs_vn_setattr_size(file_mnt_user_ns(file),
999+ file_dentry(file), &iattr);
9981000 if (error)
9991001 goto out_unlock;
10001002 }
fs/xfs/xfs_inode.c+18−8
@@ -766,6 +766,7 @@ xfs_inode_inherit_flags2( · 765 unmodified lines
766766 */
767767 static int
768768 xfs_init_new_inode(
769+ struct user_namespace *mnt_userns,
769770 struct xfs_trans *tp,
770771 struct xfs_inode *pip,
771772 xfs_ino_t ino,
@@ -806,7 +807,7 @@ xfs_init_new_inode( · 34 unmodified lines
806807 inode = VFS_I(ip);
807808 inode->i_mode = mode;
808809 set_nlink(inode, nlink);
809− inode->i_uid = current_fsuid();
810+ inode->i_uid = fsuid_into_mnt(mnt_userns);
810811 inode->i_rdev = rdev;
811812 ip->i_d.di_projid = prid;
812813
@@ -815,7 +816,7 @@ xfs_init_new_inode( · 2 unmodified lines
815816 if ((VFS_I(pip)->i_mode & S_ISGID) && S_ISDIR(mode))
816817 inode->i_mode |= S_ISGID;
817818 } else {
818− inode->i_gid = current_fsgid();
819+ inode->i_gid = fsgid_into_mnt(mnt_userns);
819820 }
820821
821822 /*
@@ -824,7 +825,8 @@ xfs_init_new_inode( · 2 unmodified lines
824825 * (and only if the irix_sgid_inherit compatibility variable is set).
825826 */
826827 if (irix_sgid_inherit &&
827− (inode->i_mode & S_ISGID) && !in_group_p(inode->i_gid))
828+ (inode->i_mode & S_ISGID) &&
829+ !in_group_p(i_gid_into_mnt(mnt_userns, inode)))
828830 inode->i_mode &= ~S_ISGID;
829831
830832 ip->i_d.di_size = 0;
@@ -901,6 +903,7 @@ xfs_init_new_inode( · 70 unmodified lines
901903 */
902904 int
903905 xfs_dir_ialloc(
906+ struct user_namespace *mnt_userns,
904907 struct xfs_trans **tpp,
905908 struct xfs_inode *dp,
906909 umode_t mode,
@@ -933,7 +936,8 @@ xfs_dir_ialloc( · 26 unmodified lines
933936 return error;
934937 ASSERT(ino != NULLFSINO);
935938
936− return xfs_init_new_inode(*tpp, dp, ino, mode, nlink, rdev, prid, ipp);
939+ return xfs_init_new_inode(mnt_userns, *tpp, dp, ino, mode, nlink, rdev,
940+ prid, ipp);
937941 }
938942
939943 /*
@@ -973,6 +977,7 @@ xfs_bumplink( · 33 unmodified lines
973977
974978 int
975979 xfs_create(
980+ struct user_namespace *mnt_userns,
976981 xfs_inode_t *dp,
977982 struct xfs_name *name,
978983 umode_t mode,
@@ -1047,7 +1052,8 @@ xfs_create( · 68 unmodified lines
10471052 * entry pointing to them, but a directory also the "." entry
10481053 * pointing to itself.
10491054 */
1050− error = xfs_dir_ialloc(&tp, dp, mode, is_dir ? 2 : 1, rdev, prid, &ip);
1055+ error = xfs_dir_ialloc(mnt_userns, &tp, dp, mode, is_dir ? 2 : 1, rdev,
1056+ prid, &ip);
10511057 if (error)
10521058 goto out_trans_cancel;
10531059
@@ -1128,6 +1134,7 @@ xfs_create( · 74 unmodified lines
11281134
11291135 int
11301136 xfs_create_tmpfile(
1137+ struct user_namespace *mnt_userns,
11311138 struct xfs_inode *dp,
11321139 umode_t mode,
11331140 struct xfs_inode **ipp)
@@ -1169,7 +1176,7 @@ xfs_create_tmpfile( · 35 unmodified lines
11691176 if (error)
11701177 goto out_trans_cancel;
11711178
1172− error = xfs_dir_ialloc(&tp, dp, mode, 0, 0, prid, &ip);
1179+ error = xfs_dir_ialloc(mnt_userns, &tp, dp, mode, 0, 0, prid, &ip);
11731180 if (error)
11741181 goto out_trans_cancel;
11751182
@@ -2977,13 +2984,15 @@ out_trans_abort: · 1801 unmodified lines
29772984 */
29782985 static int
29792986 xfs_rename_alloc_whiteout(
2987+ struct user_namespace *mnt_userns,
29802988 struct xfs_inode *dp,
29812989 struct xfs_inode **wip)
29822990 {
29832991 struct xfs_inode *tmpfile;
29842992 int error;
29852993
2986− error = xfs_create_tmpfile(dp, S_IFCHR | WHITEOUT_MODE, &tmpfile);
2994+ error = xfs_create_tmpfile(mnt_userns, dp, S_IFCHR | WHITEOUT_MODE,
2995+ &tmpfile);
29872996 if (error)
29882997 return error;
29892998
@@ -3005,6 +3014,7 @@ xfs_rename_alloc_whiteout( · 15 unmodified lines
30053014 */
30063015 int
30073016 xfs_rename(
3017+ struct user_namespace *mnt_userns,
30083018 struct xfs_inode *src_dp,
30093019 struct xfs_name *src_name,
30103020 struct xfs_inode *src_ip,
@@ -3036,7 +3046,7 @@ xfs_rename( · 25 unmodified lines
30363046 */
30373047 if (flags & RENAME_WHITEOUT) {
30383048 ASSERT(!(flags & (RENAME_NOREPLACE | RENAME_EXCHANGE)));
3039− error = xfs_rename_alloc_whiteout(target_dp, &wip);
3049+ error = xfs_rename_alloc_whiteout(mnt_userns, target_dp, &wip);
30403050 if (error)
30413051 return error;
30423052
fs/xfs/xfs_inode.h+10−6
@@ -369,15 +369,18 @@ int xfs_release(struct xfs_inode *ip); · 368 unmodified lines
369369 void xfs_inactive(struct xfs_inode *ip);
370370 int xfs_lookup(struct xfs_inode *dp, struct xfs_name *name,
371371 struct xfs_inode **ipp, struct xfs_name *ci_name);
372−int xfs_create(struct xfs_inode *dp, struct xfs_name *name,
372+int xfs_create(struct user_namespace *mnt_userns,
373+ struct xfs_inode *dp, struct xfs_name *name,
373374 umode_t mode, dev_t rdev, struct xfs_inode **ipp);
374−int xfs_create_tmpfile(struct xfs_inode *dp, umode_t mode,
375+int xfs_create_tmpfile(struct user_namespace *mnt_userns,
376+ struct xfs_inode *dp, umode_t mode,
375377 struct xfs_inode **ipp);
376378 int xfs_remove(struct xfs_inode *dp, struct xfs_name *name,
377379 struct xfs_inode *ip);
378380 int xfs_link(struct xfs_inode *tdp, struct xfs_inode *sip,
379381 struct xfs_name *target_name);
380−int xfs_rename(struct xfs_inode *src_dp, struct xfs_name *src_name,
382+int xfs_rename(struct user_namespace *mnt_userns,
383+ struct xfs_inode *src_dp, struct xfs_name *src_name,
381384 struct xfs_inode *src_ip, struct xfs_inode *target_dp,
382385 struct xfs_name *target_name,
383386 struct xfs_inode *target_ip, unsigned int flags);
@@ -407,9 +410,10 @@ void xfs_lock_two_inodes(struct xfs_inode *ip0, uint ip0_mode, · 23 unmodified lines
407410 xfs_extlen_t xfs_get_extsz_hint(struct xfs_inode *ip);
408411 xfs_extlen_t xfs_get_cowextsz_hint(struct xfs_inode *ip);
409412
410−int xfs_dir_ialloc(struct xfs_trans **tpp, struct xfs_inode *dp, umode_t mode,
411− xfs_nlink_t nlink, dev_t dev, prid_t prid,
412− struct xfs_inode **ipp);
413+int xfs_dir_ialloc(struct user_namespace *mnt_userns,
414+ struct xfs_trans **tpp, struct xfs_inode *dp,
415+ umode_t mode, xfs_nlink_t nlink, dev_t dev,
416+ prid_t prid, struct xfs_inode **ipp);
413417
414418 static inline int
415419 xfs_itruncate_extents(
fs/xfs/xfs_ioctl.c+21−14
@@ -693,7 +693,8 @@ xfs_ioc_space( · 692 unmodified lines
693693
694694 iattr.ia_valid = ATTR_SIZE;
695695 iattr.ia_size = bf->l_start;
696− error = xfs_vn_setattr_size(file_dentry(filp), &iattr);
696+ error = xfs_vn_setattr_size(file_mnt_user_ns(filp), file_dentry(filp),
697+ &iattr);
697698 if (error)
698699 goto out_unlock;
699700
@@ -734,13 +735,15 @@ xfs_fsinumbers_fmt( · 34 unmodified lines
734735
735736 STATIC int
736737 xfs_ioc_fsbulkstat(
737− xfs_mount_t *mp,
738+ struct file *file,
738739 unsigned int cmd,
739740 void __user *arg)
740741 {
742+ struct xfs_mount *mp = XFS_I(file_inode(file))->i_mount;
741743 struct xfs_fsop_bulkreq bulkreq;
742744 struct xfs_ibulk breq = {
743745 .mp = mp,
746+ .mnt_userns = file_mnt_user_ns(file),
744747 .ocount = 0,
745748 };
746749 xfs_ino_t lastino;
@@ -908,13 +911,15 @@ xfs_bulk_ireq_teardown( · 161 unmodified lines
908911 /* Handle the v5 bulkstat ioctl. */
909912 STATIC int
910913 xfs_ioc_bulkstat(
911− struct xfs_mount *mp,
914+ struct file *file,
912915 unsigned int cmd,
913916 struct xfs_bulkstat_req __user *arg)
914917 {
918+ struct xfs_mount *mp = XFS_I(file_inode(file))->i_mount;
915919 struct xfs_bulk_ireq hdr;
916920 struct xfs_ibulk breq = {
917921 .mp = mp,
922+ .mnt_userns = file_mnt_user_ns(file),
918923 };
919924 int error;
920925
@@ -1275,8 +1280,9 @@ xfs_ioctl_setattr_prepare_dax( · 354 unmodified lines
12751280 */
12761281 static struct xfs_trans *
12771282 xfs_ioctl_setattr_get_trans(
1278− struct xfs_inode *ip)
1283+ struct file *file)
12791284 {
1285+ struct xfs_inode *ip = XFS_I(file_inode(file));
12801286 struct xfs_mount *mp = ip->i_mount;
12811287 struct xfs_trans *tp;
12821288 int error = -EROFS;
@@ -1300,7 +1306,7 @@ xfs_ioctl_setattr_get_trans( · 17 unmodified lines
13001306 * The user ID of the calling process must be equal to the file owner
13011307 * ID, except in cases where the CAP_FSETID capability is applicable.
13021308 */
1303− if (!inode_owner_or_capable(&init_user_ns, VFS_I(ip))) {
1309+ if (!inode_owner_or_capable(file_mnt_user_ns(file), VFS_I(ip))) {
13041310 error = -EPERM;
13051311 goto out_cancel;
13061312 }
@@ -1428,9 +1434,11 @@ xfs_ioctl_setattr_check_projid( · 121 unmodified lines
14281434
14291435 STATIC int
14301436 xfs_ioctl_setattr(
1431− xfs_inode_t *ip,
1437+ struct file *file,
14321438 struct fsxattr *fa)
14331439 {
1440+ struct user_namespace *mnt_userns = file_mnt_user_ns(file);
1441+ struct xfs_inode *ip = XFS_I(file_inode(file));
14341442 struct fsxattr old_fa;
14351443 struct xfs_mount *mp = ip->i_mount;
14361444 struct xfs_trans *tp;
@@ -1462,7 +1470,7 @@ xfs_ioctl_setattr( · 25 unmodified lines
14621470
14631471 xfs_ioctl_setattr_prepare_dax(ip, fa);
14641472
1465− tp = xfs_ioctl_setattr_get_trans(ip);
1473+ tp = xfs_ioctl_setattr_get_trans(file);
14661474 if (IS_ERR(tp)) {
14671475 code = PTR_ERR(tp);
14681476 goto error_free_dquots;
@@ -1502,7 +1510,7 @@ xfs_ioctl_setattr( · 33 unmodified lines
15021510 */
15031511
15041512 if ((VFS_I(ip)->i_mode & (S_ISUID|S_ISGID)) &&
1505− !capable_wrt_inode_uidgid(&init_user_ns, VFS_I(ip), CAP_FSETID))
1513+ !capable_wrt_inode_uidgid(mnt_userns, VFS_I(ip), CAP_FSETID))
15061514 VFS_I(ip)->i_mode &= ~(S_ISUID|S_ISGID);
15071515
15081516 /* Change the ownerships and register project quota modifications */
@@ -1549,7 +1557,6 @@ error_free_dquots: · 40 unmodified lines
15491557
15501558 STATIC int
15511559 xfs_ioc_fssetxattr(
1552− xfs_inode_t *ip,
15531560 struct file *filp,
15541561 void __user *arg)
15551562 {
@@ -1562,7 +1569,7 @@ xfs_ioc_fssetxattr( · 6 unmodified lines
15621569 error = mnt_want_write_file(filp);
15631570 if (error)
15641571 return error;
1565− error = xfs_ioctl_setattr(ip, &fa);
1572+ error = xfs_ioctl_setattr(filp, &fa);
15661573 mnt_drop_write_file(filp);
15671574 return error;
15681575 }
@@ -1608,7 +1615,7 @@ xfs_ioc_setxflags( · 39 unmodified lines
16081615
16091616 xfs_ioctl_setattr_prepare_dax(ip, &fa);
16101617
1611− tp = xfs_ioctl_setattr_get_trans(ip);
1618+ tp = xfs_ioctl_setattr_get_trans(filp);
16121619 if (IS_ERR(tp)) {
16131620 error = PTR_ERR(tp);
16141621 goto out_drop_write;
@@ -2119,10 +2126,10 @@ xfs_file_ioctl( · 504 unmodified lines
21192126 case XFS_IOC_FSBULKSTAT_SINGLE:
21202127 case XFS_IOC_FSBULKSTAT:
21212128 case XFS_IOC_FSINUMBERS:
2122− return xfs_ioc_fsbulkstat(mp, cmd, arg);
2129+ return xfs_ioc_fsbulkstat(filp, cmd, arg);
21232130
21242131 case XFS_IOC_BULKSTAT:
2125− return xfs_ioc_bulkstat(mp, cmd, arg);
2132+ return xfs_ioc_bulkstat(filp, cmd, arg);
21262133 case XFS_IOC_INUMBERS:
21272134 return xfs_ioc_inumbers(mp, cmd, arg);
21282135
@@ -2144,7 +2151,7 @@ xfs_file_ioctl( · 15 unmodified lines
21442151 case XFS_IOC_FSGETXATTRA:
21452152 return xfs_ioc_fsgetxattr(ip, 1, arg);
21462153 case XFS_IOC_FSSETXATTR:
2147− return xfs_ioc_fssetxattr(ip, filp, arg);
2154+ return xfs_ioc_fssetxattr(filp, arg);
21482155 case XFS_IOC_GETXFLAGS:
21492156 return xfs_ioc_getxflags(ip, arg);
21502157 case XFS_IOC_SETXFLAGS:
fs/xfs/xfs_ioctl32.c+4−2
@@ -209,14 +209,16 @@ xfs_fsbulkstat_one_fmt_compat( · 208 unmodified lines
209209 /* copied from xfs_ioctl.c */
210210 STATIC int
211211 xfs_compat_ioc_fsbulkstat(
212− xfs_mount_t *mp,
212+ struct file *file,
213213 unsigned int cmd,
214214 struct compat_xfs_fsop_bulkreq __user *p32)
215215 {
216+ struct xfs_mount *mp = XFS_I(file_inode(file))->i_mount;
216217 u32 addr;
217218 struct xfs_fsop_bulkreq bulkreq;
218219 struct xfs_ibulk breq = {
219220 .mp = mp,
221+ .mnt_userns = file_mnt_user_ns(file),
220222 .ocount = 0,
221223 };
222224 xfs_ino_t lastino;
@@ -507,7 +509,7 @@ xfs_file_compat_ioctl( · 284 unmodified lines
507509 case XFS_IOC_FSBULKSTAT_32:
508510 case XFS_IOC_FSBULKSTAT_SINGLE_32:
509511 case XFS_IOC_FSINUMBERS_32:
510− return xfs_compat_ioc_fsbulkstat(mp, cmd, arg);
512+ return xfs_compat_ioc_fsbulkstat(filp, cmd, arg);
511513 case XFS_IOC_FD_TO_HANDLE_32:
512514 case XFS_IOC_PATH_TO_HANDLE_32:
513515 case XFS_IOC_PATH_TO_FSHANDLE_32: {
fs/xfs/xfs_iops.c+28−21
@@ -128,6 +128,7 @@ xfs_cleanup_inode( · 127 unmodified lines
128128
129129 STATIC int
130130 xfs_generic_create(
131+ struct user_namespace *mnt_userns,
131132 struct inode *dir,
132133 struct dentry *dentry,
133134 umode_t mode,
@@ -161,9 +162,10 @@ xfs_generic_create( · 27 unmodified lines
161162 goto out_free_acl;
162163
163164 if (!tmpfile) {
164− error = xfs_create(XFS_I(dir), &name, mode, rdev, &ip);
165+ error = xfs_create(mnt_userns, XFS_I(dir), &name, mode, rdev,
166+ &ip);
165167 } else {
166− error = xfs_create_tmpfile(XFS_I(dir), mode, &ip);
168+ error = xfs_create_tmpfile(mnt_userns, XFS_I(dir), mode, &ip);
167169 }
168170 if (unlikely(error))
169171 goto out_free_acl;
@@ -226,7 +228,7 @@ xfs_vn_mknod( · 56 unmodified lines
226228 umode_t mode,
227229 dev_t rdev)
228230 {
229− return xfs_generic_create(dir, dentry, mode, rdev, false);
231+ return xfs_generic_create(mnt_userns, dir, dentry, mode, rdev, false);
230232 }
231233
232234 STATIC int
@@ -237,7 +239,7 @@ xfs_vn_create( · 4 unmodified lines
237239 umode_t mode,
238240 bool flags)
239241 {
240− return xfs_generic_create(dir, dentry, mode, 0, false);
242+ return xfs_generic_create(mnt_userns, dir, dentry, mode, 0, false);
241243 }
242244
243245 STATIC int
@@ -247,7 +249,8 @@ xfs_vn_mkdir( · 3 unmodified lines
247249 struct dentry *dentry,
248250 umode_t mode)
249251 {
250− return xfs_generic_create(dir, dentry, mode | S_IFDIR, 0, false);
252+ return xfs_generic_create(mnt_userns, dir, dentry, mode | S_IFDIR, 0,
253+ false);
251254 }
252255
253256 STATIC struct dentry *
@@ -381,7 +384,7 @@ xfs_vn_symlink( · 127 unmodified lines
381384 if (unlikely(error))
382385 goto out;
383386
384− error = xfs_symlink(XFS_I(dir), &name, symname, mode, &cip);
387+ error = xfs_symlink(mnt_userns, XFS_I(dir), &name, symname, mode, &cip);
385388 if (unlikely(error))
386389 goto out;
387390
@@ -436,8 +439,8 @@ xfs_vn_rename( · 48 unmodified lines
436439 if (unlikely(error))
437440 return error;
438441
439− return xfs_rename(XFS_I(odir), &oname, XFS_I(d_inode(odentry)),
440− XFS_I(ndir), &nname,
442+ return xfs_rename(mnt_userns, XFS_I(odir), &oname,
443+ XFS_I(d_inode(odentry)), XFS_I(ndir), &nname,
441444 new_inode ? XFS_I(new_inode) : NULL, flags);
442445 }
443446
@@ -553,8 +556,8 @@ xfs_vn_getattr( · 109 unmodified lines
553556 stat->dev = inode->i_sb->s_dev;
554557 stat->mode = inode->i_mode;
555558 stat->nlink = inode->i_nlink;
556− stat->uid = inode->i_uid;
557− stat->gid = inode->i_gid;
559+ stat->uid = i_uid_into_mnt(mnt_userns, inode);
560+ stat->gid = i_gid_into_mnt(mnt_userns, inode);
558561 stat->ino = ip->i_ino;
559562 stat->atime = inode->i_atime;
560563 stat->mtime = inode->i_mtime;
@@ -632,8 +635,9 @@ xfs_setattr_time( · 71 unmodified lines
632635
633636 static int
634637 xfs_vn_change_ok(
635− struct dentry *dentry,
636− struct iattr *iattr)
638+ struct user_namespace *mnt_userns,
639+ struct dentry *dentry,
640+ struct iattr *iattr)
637641 {
638642 struct xfs_mount *mp = XFS_I(d_inode(dentry))->i_mount;
639643
@@ -643,7 +647,7 @@ xfs_vn_change_ok( · 3 unmodified lines
643647 if (XFS_FORCED_SHUTDOWN(mp))
644648 return -EIO;
645649
646− return setattr_prepare(&init_user_ns, dentry, iattr);
650+ return setattr_prepare(mnt_userns, dentry, iattr);
647651 }
648652
649653 /*
@@ -654,6 +658,7 @@ xfs_vn_change_ok( · 4 unmodified lines
654658 */
655659 static int
656660 xfs_setattr_nonsize(
661+ struct user_namespace *mnt_userns,
657662 struct xfs_inode *ip,
658663 struct iattr *iattr)
659664 {
@@ -813,7 +818,7 @@ xfs_setattr_nonsize( · 153 unmodified lines
813818 * Posix ACL code seems to care about this issue either.
814819 */
815820 if (mask & ATTR_MODE) {
816− error = posix_acl_chmod(&init_user_ns, inode, inode->i_mode);
821+ error = posix_acl_chmod(mnt_userns, inode, inode->i_mode);
817822 if (error)
818823 return error;
819824 }
@@ -837,6 +842,7 @@ out_dqrele: · 17 unmodified lines
837842 */
838843 STATIC int
839844 xfs_setattr_size(
845+ struct user_namespace *mnt_userns,
840846 struct xfs_inode *ip,
841847 struct iattr *iattr)
842848 {
@@ -868,7 +874,7 @@ xfs_setattr_size( · 25 unmodified lines
868874 * Use the regular setattr path to update the timestamps.
869875 */
870876 iattr->ia_valid &= ~ATTR_SIZE;
871− return xfs_setattr_nonsize(ip, iattr);
877+ return xfs_setattr_nonsize(mnt_userns, ip, iattr);
872878 }
873879
874880 /*
@@ -1037,6 +1043,7 @@ out_trans_cancel: · 162 unmodified lines
10371043
10381044 int
10391045 xfs_vn_setattr_size(
1046+ struct user_namespace *mnt_userns,
10401047 struct dentry *dentry,
10411048 struct iattr *iattr)
10421049 {
@@ -1045,10 +1052,10 @@ xfs_vn_setattr_size( · 2 unmodified lines
10451052
10461053 trace_xfs_setattr(ip);
10471054
1048− error = xfs_vn_change_ok(dentry, iattr);
1055+ error = xfs_vn_change_ok(mnt_userns, dentry, iattr);
10491056 if (error)
10501057 return error;
1051− return xfs_setattr_size(ip, iattr);
1058+ return xfs_setattr_size(mnt_userns, ip, iattr);
10521059 }
10531060
10541061 STATIC int
@@ -1073,14 +1080,14 @@ xfs_vn_setattr( · 18 unmodified lines
10731080 return error;
10741081 }
10751082
1076− error = xfs_vn_setattr_size(dentry, iattr);
1083+ error = xfs_vn_setattr_size(mnt_userns, dentry, iattr);
10771084 xfs_iunlock(ip, XFS_MMAPLOCK_EXCL);
10781085 } else {
10791086 trace_xfs_setattr(ip);
10801087
1081− error = xfs_vn_change_ok(dentry, iattr);
1088+ error = xfs_vn_change_ok(mnt_userns, dentry, iattr);
10821089 if (!error)
1083− error = xfs_setattr_nonsize(ip, iattr);
1090+ error = xfs_setattr_nonsize(mnt_userns, ip, iattr);
10841091 }
10851092
10861093 return error;
@@ -1156,7 +1163,7 @@ xfs_vn_tmpfile( · 69 unmodified lines
11561163 struct dentry *dentry,
11571164 umode_t mode)
11581165 {
1159− return xfs_generic_create(dir, dentry, mode, 0, true);
1166+ return xfs_generic_create(mnt_userns, dir, dentry, mode, 0, true);
11601167 }
11611168
11621169 static const struct inode_operations xfs_inode_operations = {
fs/xfs/xfs_iops.h+2−1
@@ -14,6 +14,7 @@ extern const struct file_operations xfs_dir_file_operations; · 13 unmodified lines
1414 extern ssize_t xfs_vn_listxattr(struct dentry *, char *data, size_t size);
1515
1616 extern void xfs_setattr_time(struct xfs_inode *ip, struct iattr *iattr);
17−extern int xfs_vn_setattr_size(struct dentry *dentry, struct iattr *vap);
17+int xfs_vn_setattr_size(struct user_namespace *mnt_userns,
18+ struct dentry *dentry, struct iattr *vap);
1819
1920 #endif /* __XFS_IOPS_H__ */
fs/xfs/xfs_itable.c+13−4
@@ -54,10 +54,12 @@ struct xfs_bstat_chunk { · 53 unmodified lines
5454 STATIC int
5555 xfs_bulkstat_one_int(
5656 struct xfs_mount *mp,
57+ struct user_namespace *mnt_userns,
5758 struct xfs_trans *tp,
5859 xfs_ino_t ino,
5960 struct xfs_bstat_chunk *bc)
6061 {
62+ struct user_namespace *sb_userns = mp->m_super->s_user_ns;
6163 struct xfs_icdinode *dic; /* dinode core info pointer */
6264 struct xfs_inode *ip; /* incore inode pointer */
6365 struct inode *inode;
@@ -86,8 +88,8 @@ xfs_bulkstat_one_int( · 22 unmodified lines
8688 */
8789 buf->bs_projectid = ip->i_d.di_projid;
8890 buf->bs_ino = ino;
89− buf->bs_uid = i_uid_read(inode);
90− buf->bs_gid = i_gid_read(inode);
91+ buf->bs_uid = from_kuid(sb_userns, i_uid_into_mnt(mnt_userns, inode));
92+ buf->bs_gid = from_kgid(sb_userns, i_gid_into_mnt(mnt_userns, inode));
9193 buf->bs_size = dic->di_size;
9294
9395 buf->bs_nlink = inode->i_nlink;
@@ -173,7 +175,8 @@ xfs_bulkstat_one( · 79 unmodified lines
173175 if (!bc.buf)
174176 return -ENOMEM;
175177
176− error = xfs_bulkstat_one_int(breq->mp, NULL, breq->startino, &bc);
178+ error = xfs_bulkstat_one_int(breq->mp, breq->mnt_userns, NULL,
179+ breq->startino, &bc);
177180
178181 kmem_free(bc.buf);
179182
@@ -194,9 +197,10 @@ xfs_bulkstat_iwalk( · 14 unmodified lines
194197 xfs_ino_t ino,
195198 void *data)
196199 {
200+ struct xfs_bstat_chunk *bc = data;
197201 int error;
198202
199− error = xfs_bulkstat_one_int(mp, tp, ino, data);
203+ error = xfs_bulkstat_one_int(mp, bc->breq->mnt_userns, tp, ino, data);
200204 /* bulkstat just skips over missing inodes */
201205 if (error == -ENOENT || error == -EINVAL)
202206 return 0;
@@ -239,6 +243,11 @@ xfs_bulkstat( · 36 unmodified lines
239243 };
240244 int error;
241245
246+ if (breq->mnt_userns != &init_user_ns) {
247+ xfs_warn_ratelimited(breq->mp,
248+ "bulkstat not supported inside of idmapped mounts.");
249+ return -EINVAL;
250+ }
242251 if (xfs_bulkstat_already_done(breq->mp, breq->startino))
243252 return 0;
244253
fs/xfs/xfs_itable.h+1−0
@@ -8,6 +8,7 @@ · 7 unmodified lines
88 /* In-memory representation of a userspace request for batch inode data. */
99 struct xfs_ibulk {
1010 struct xfs_mount *mp;
11+ struct user_namespace *mnt_userns;
1112 void __user *ubuffer; /* user output buffer */
1213 xfs_ino_t startino; /* start with this inode */
1314 unsigned int icount; /* number of elements in ubuffer */
fs/xfs/xfs_qm.c+2−1
@@ -787,7 +787,8 @@ xfs_qm_qino_alloc( · 786 unmodified lines
787787 return error;
788788
789789 if (need_alloc) {
790− error = xfs_dir_ialloc(&tp, NULL, S_IFREG, 1, 0, 0, ipp);
790+ error = xfs_dir_ialloc(&init_user_ns, &tp, NULL, S_IFREG, 1, 0,
791+ 0, ipp);
791792 if (error) {
792793 xfs_trans_cancel(tp);
793794 return error;
fs/xfs/xfs_super.c+1−1
@@ -1912,7 +1912,7 @@ static struct file_system_type xfs_fs_type = { · 1911 unmodified lines
19121912 .init_fs_context = xfs_init_fs_context,
19131913 .parameters = xfs_fs_parameters,
19141914 .kill_sb = kill_block_super,
1915− .fs_flags = FS_REQUIRES_DEV,
1915+ .fs_flags = FS_REQUIRES_DEV | FS_ALLOW_IDMAP,
19161916 };
19171917 MODULE_ALIAS_FS("xfs");
19181918
fs/xfs/xfs_symlink.c+3−2
@@ -134,6 +134,7 @@ xfs_readlink( · 133 unmodified lines
134134
135135 int
136136 xfs_symlink(
137+ struct user_namespace *mnt_userns,
137138 struct xfs_inode *dp,
138139 struct xfs_name *link_name,
139140 const char *target_path,
@@ -223,8 +224,8 @@ xfs_symlink( · 83 unmodified lines
223224 /*
224225 * Allocate an inode for the symlink.
225226 */
226− error = xfs_dir_ialloc(&tp, dp, S_IFLNK | (mode & ~S_IFMT), 1, 0,
227− prid, &ip);
227+ error = xfs_dir_ialloc(mnt_userns, &tp, dp, S_IFLNK | (mode & ~S_IFMT),
228+ 1, 0, prid, &ip);
228229 if (error)
229230 goto out_trans_cancel;
230231
fs/xfs/xfs_symlink.h+3−2
@@ -7,8 +7,9 @@ · 6 unmodified lines
77
88 /* Kernel only symlink definitions */
99
10−int xfs_symlink(struct xfs_inode *dp, struct xfs_name *link_name,
11− const char *target_path, umode_t mode, struct xfs_inode **ipp);
10+int xfs_symlink(struct user_namespace *mnt_userns, struct xfs_inode *dp,
11+ struct xfs_name *link_name, const char *target_path,
12+ umode_t mode, struct xfs_inode **ipp);
1213 int xfs_readlink_bmap_ilocked(struct xfs_inode *ip, char *link);
1314 int xfs_readlink(struct xfs_inode *ip, char *link);
1415 int xfs_inactive_symlink(struct xfs_inode *ip);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t