Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fs: port ->getattr() to pass mnt_idmap

Convert to struct mnt_idmap.

Last cycle we merged the necessary infrastructure in
256c8aed2b42 ("fs: introduce dedicated idmap type for mounts").
This is just the conversion to struct mnt_idmap.

Currently we still pass around the plain namespace that was attached to a
mount. This is in general pretty convenient but it makes it easy to
conflate namespaces that are relevant on the filesystem with namespaces
that are relevent on the mount level. Especially for non-vfs developers
without detailed knowledge in this area this can be a potential source for
bugs.

Once the conversion to struct mnt_idmap is done all helpers down to the
really low-level helpers will take a struct mnt_idmap argument instead of
two namespace arguments. This way it becomes impossible to conflate the two
eliminating the possibility of any bugs. All of the vfs and all filesystems
only operate on struct mnt_idmap.

Acked-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org>

+152 -148
+1 -1
Documentation/filesystems/locking.rst
··· 72 72 int (*permission) (struct inode *, int, unsigned int); 73 73 struct posix_acl * (*get_inode_acl)(struct inode *, int, bool); 74 74 int (*setattr) (struct mnt_idmap *, struct dentry *, struct iattr *); 75 - int (*getattr) (const struct path *, struct kstat *, u32, unsigned int); 75 + int (*getattr) (struct mnt_idmap *, const struct path *, struct kstat *, u32, unsigned int); 76 76 ssize_t (*listxattr) (struct dentry *, char *, size_t); 77 77 int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start, u64 len); 78 78 void (*update_time)(struct inode *, struct timespec *, int);
+1 -1
Documentation/filesystems/vfs.rst
··· 437 437 int (*permission) (struct user_namespace *, struct inode *, int); 438 438 struct posix_acl * (*get_inode_acl)(struct inode *, int, bool); 439 439 int (*setattr) (struct mnt_idmap *, struct dentry *, struct iattr *); 440 - int (*getattr) (struct user_namespace *, const struct path *, struct kstat *, u32, unsigned int); 440 + int (*getattr) (struct mnt_idmap *, const struct path *, struct kstat *, u32, unsigned int); 441 441 ssize_t (*listxattr) (struct dentry *, char *, size_t); 442 442 void (*update_time)(struct inode *, struct timespec *, int); 443 443 int (*atomic_open)(struct inode *, struct dentry *, struct file *,
+4 -4
fs/9p/vfs_inode.c
··· 1018 1018 1019 1019 /** 1020 1020 * v9fs_vfs_getattr - retrieve file metadata 1021 - * @mnt_userns: The user namespace of the mount 1021 + * @idmap: idmap of the mount 1022 1022 * @path: Object to query 1023 1023 * @stat: metadata structure to populate 1024 1024 * @request_mask: Mask of STATX_xxx flags indicating the caller's interests ··· 1027 1027 */ 1028 1028 1029 1029 static int 1030 - v9fs_vfs_getattr(struct user_namespace *mnt_userns, const struct path *path, 1030 + v9fs_vfs_getattr(struct mnt_idmap *idmap, const struct path *path, 1031 1031 struct kstat *stat, u32 request_mask, unsigned int flags) 1032 1032 { 1033 1033 struct dentry *dentry = path->dentry; ··· 1038 1038 p9_debug(P9_DEBUG_VFS, "dentry: %p\n", dentry); 1039 1039 v9ses = v9fs_dentry2v9ses(dentry); 1040 1040 if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) { 1041 - generic_fillattr(&init_user_ns, d_inode(dentry), stat); 1041 + generic_fillattr(&nop_mnt_idmap, d_inode(dentry), stat); 1042 1042 return 0; 1043 1043 } 1044 1044 fid = v9fs_fid_lookup(dentry); ··· 1051 1051 return PTR_ERR(st); 1052 1052 1053 1053 v9fs_stat2inode(st, d_inode(dentry), dentry->d_sb, 0); 1054 - generic_fillattr(&init_user_ns, d_inode(dentry), stat); 1054 + generic_fillattr(&nop_mnt_idmap, d_inode(dentry), stat); 1055 1055 1056 1056 p9stat_free(st); 1057 1057 kfree(st);
+3 -3
fs/9p/vfs_inode_dotl.c
··· 450 450 } 451 451 452 452 static int 453 - v9fs_vfs_getattr_dotl(struct user_namespace *mnt_userns, 453 + v9fs_vfs_getattr_dotl(struct mnt_idmap *idmap, 454 454 const struct path *path, struct kstat *stat, 455 455 u32 request_mask, unsigned int flags) 456 456 { ··· 462 462 p9_debug(P9_DEBUG_VFS, "dentry: %p\n", dentry); 463 463 v9ses = v9fs_dentry2v9ses(dentry); 464 464 if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) { 465 - generic_fillattr(&init_user_ns, d_inode(dentry), stat); 465 + generic_fillattr(&nop_mnt_idmap, d_inode(dentry), stat); 466 466 return 0; 467 467 } 468 468 fid = v9fs_fid_lookup(dentry); ··· 479 479 return PTR_ERR(st); 480 480 481 481 v9fs_stat2inode_dotl(st, d_inode(dentry), 0); 482 - generic_fillattr(&init_user_ns, d_inode(dentry), stat); 482 + generic_fillattr(&nop_mnt_idmap, d_inode(dentry), stat); 483 483 /* Change block size to what the server returned */ 484 484 stat->blksize = st->st_blksize; 485 485
+2 -2
fs/afs/inode.c
··· 737 737 /* 738 738 * read the attributes of an inode 739 739 */ 740 - int afs_getattr(struct user_namespace *mnt_userns, const struct path *path, 740 + int afs_getattr(struct mnt_idmap *idmap, const struct path *path, 741 741 struct kstat *stat, u32 request_mask, unsigned int query_flags) 742 742 { 743 743 struct inode *inode = d_inode(path->dentry); ··· 761 761 762 762 do { 763 763 read_seqbegin_or_lock(&vnode->cb_lock, &seq); 764 - generic_fillattr(&init_user_ns, inode, stat); 764 + generic_fillattr(&nop_mnt_idmap, inode, stat); 765 765 if (test_bit(AFS_VNODE_SILLY_DELETED, &vnode->flags) && 766 766 stat->nlink > 0) 767 767 stat->nlink -= 1;
+1 -1
fs/afs/internal.h
··· 1170 1170 extern struct inode *afs_root_iget(struct super_block *, struct key *); 1171 1171 extern bool afs_check_validity(struct afs_vnode *); 1172 1172 extern int afs_validate(struct afs_vnode *, struct key *); 1173 - extern int afs_getattr(struct user_namespace *mnt_userns, const struct path *, 1173 + extern int afs_getattr(struct mnt_idmap *idmap, const struct path *, 1174 1174 struct kstat *, u32, unsigned int); 1175 1175 extern int afs_setattr(struct mnt_idmap *idmap, struct dentry *, struct iattr *); 1176 1176 extern void afs_evict_inode(struct inode *);
+1 -1
fs/bad_inode.c
··· 95 95 return -EIO; 96 96 } 97 97 98 - static int bad_inode_getattr(struct user_namespace *mnt_userns, 98 + static int bad_inode_getattr(struct mnt_idmap *idmap, 99 99 const struct path *path, struct kstat *stat, 100 100 u32 request_mask, unsigned int query_flags) 101 101 {
+2 -2
fs/btrfs/inode.c
··· 9005 9005 return -ENOMEM; 9006 9006 } 9007 9007 9008 - static int btrfs_getattr(struct user_namespace *mnt_userns, 9008 + static int btrfs_getattr(struct mnt_idmap *idmap, 9009 9009 const struct path *path, struct kstat *stat, 9010 9010 u32 request_mask, unsigned int flags) 9011 9011 { ··· 9035 9035 STATX_ATTR_IMMUTABLE | 9036 9036 STATX_ATTR_NODUMP); 9037 9037 9038 - generic_fillattr(mnt_userns, inode, stat); 9038 + generic_fillattr(idmap, inode, stat); 9039 9039 stat->dev = BTRFS_I(inode)->root->anon_dev; 9040 9040 9041 9041 spin_lock(&BTRFS_I(inode)->lock);
+2 -2
fs/ceph/inode.c
··· 2445 2445 * Get all the attributes. If we have sufficient caps for the requested attrs, 2446 2446 * then we can avoid talking to the MDS at all. 2447 2447 */ 2448 - int ceph_getattr(struct user_namespace *mnt_userns, const struct path *path, 2448 + int ceph_getattr(struct mnt_idmap *idmap, const struct path *path, 2449 2449 struct kstat *stat, u32 request_mask, unsigned int flags) 2450 2450 { 2451 2451 struct inode *inode = d_inode(path->dentry); ··· 2466 2466 return err; 2467 2467 } 2468 2468 2469 - generic_fillattr(&init_user_ns, inode, stat); 2469 + generic_fillattr(&nop_mnt_idmap, inode, stat); 2470 2470 stat->ino = ceph_present_inode(inode); 2471 2471 2472 2472 /*
+1 -1
fs/ceph/super.h
··· 1045 1045 extern int __ceph_setattr(struct inode *inode, struct iattr *attr); 1046 1046 extern int ceph_setattr(struct mnt_idmap *idmap, 1047 1047 struct dentry *dentry, struct iattr *attr); 1048 - extern int ceph_getattr(struct user_namespace *mnt_userns, 1048 + extern int ceph_getattr(struct mnt_idmap *idmap, 1049 1049 const struct path *path, struct kstat *stat, 1050 1050 u32 request_mask, unsigned int flags); 1051 1051 void ceph_inode_shutdown(struct inode *inode);
+1 -1
fs/cifs/cifsfs.h
··· 72 72 extern int cifs_invalidate_mapping(struct inode *inode); 73 73 extern int cifs_revalidate_mapping(struct inode *inode); 74 74 extern int cifs_zap_mapping(struct inode *inode); 75 - extern int cifs_getattr(struct user_namespace *, const struct path *, 75 + extern int cifs_getattr(struct mnt_idmap *, const struct path *, 76 76 struct kstat *, u32, unsigned int); 77 77 extern int cifs_setattr(struct mnt_idmap *, struct dentry *, 78 78 struct iattr *);
+2 -2
fs/cifs/inode.c
··· 2496 2496 return cifs_revalidate_mapping(inode); 2497 2497 } 2498 2498 2499 - int cifs_getattr(struct user_namespace *mnt_userns, const struct path *path, 2499 + int cifs_getattr(struct mnt_idmap *idmap, const struct path *path, 2500 2500 struct kstat *stat, u32 request_mask, unsigned int flags) 2501 2501 { 2502 2502 struct dentry *dentry = path->dentry; ··· 2537 2537 return rc; 2538 2538 } 2539 2539 2540 - generic_fillattr(&init_user_ns, inode, stat); 2540 + generic_fillattr(&nop_mnt_idmap, inode, stat); 2541 2541 stat->blksize = cifs_sb->ctx->bsize; 2542 2542 stat->ino = CIFS_I(inode)->uniqueid; 2543 2543
+1 -1
fs/coda/coda_linux.h
··· 49 49 int coda_permission(struct user_namespace *mnt_userns, struct inode *inode, 50 50 int mask); 51 51 int coda_revalidate_inode(struct inode *); 52 - int coda_getattr(struct user_namespace *, const struct path *, struct kstat *, 52 + int coda_getattr(struct mnt_idmap *, const struct path *, struct kstat *, 53 53 u32, unsigned int); 54 54 int coda_setattr(struct mnt_idmap *, struct dentry *, struct iattr *); 55 55
+2 -2
fs/coda/inode.c
··· 251 251 coda_cache_clear_inode(inode); 252 252 } 253 253 254 - int coda_getattr(struct user_namespace *mnt_userns, const struct path *path, 254 + int coda_getattr(struct mnt_idmap *idmap, const struct path *path, 255 255 struct kstat *stat, u32 request_mask, unsigned int flags) 256 256 { 257 257 int err = coda_revalidate_inode(d_inode(path->dentry)); 258 258 if (!err) 259 - generic_fillattr(&init_user_ns, d_inode(path->dentry), stat); 259 + generic_fillattr(&nop_mnt_idmap, d_inode(path->dentry), stat); 260 260 return err; 261 261 } 262 262
+4 -4
fs/ecryptfs/inode.c
··· 972 972 return rc; 973 973 } 974 974 975 - static int ecryptfs_getattr_link(struct user_namespace *mnt_userns, 975 + static int ecryptfs_getattr_link(struct mnt_idmap *idmap, 976 976 const struct path *path, struct kstat *stat, 977 977 u32 request_mask, unsigned int flags) 978 978 { ··· 982 982 983 983 mount_crypt_stat = &ecryptfs_superblock_to_private( 984 984 dentry->d_sb)->mount_crypt_stat; 985 - generic_fillattr(&init_user_ns, d_inode(dentry), stat); 985 + generic_fillattr(&nop_mnt_idmap, d_inode(dentry), stat); 986 986 if (mount_crypt_stat->flags & ECRYPTFS_GLOBAL_ENCRYPT_FILENAMES) { 987 987 char *target; 988 988 size_t targetsiz; ··· 998 998 return rc; 999 999 } 1000 1000 1001 - static int ecryptfs_getattr(struct user_namespace *mnt_userns, 1001 + static int ecryptfs_getattr(struct mnt_idmap *idmap, 1002 1002 const struct path *path, struct kstat *stat, 1003 1003 u32 request_mask, unsigned int flags) 1004 1004 { ··· 1011 1011 if (!rc) { 1012 1012 fsstack_copy_attr_all(d_inode(dentry), 1013 1013 ecryptfs_inode_to_lower(d_inode(dentry))); 1014 - generic_fillattr(&init_user_ns, d_inode(dentry), stat); 1014 + generic_fillattr(&nop_mnt_idmap, d_inode(dentry), stat); 1015 1015 stat->blocks = lower_stat.blocks; 1016 1016 } 1017 1017 return rc;
+2 -2
fs/erofs/inode.c
··· 353 353 return inode; 354 354 } 355 355 356 - int erofs_getattr(struct user_namespace *mnt_userns, const struct path *path, 356 + int erofs_getattr(struct mnt_idmap *idmap, const struct path *path, 357 357 struct kstat *stat, u32 request_mask, 358 358 unsigned int query_flags) 359 359 { ··· 366 366 stat->attributes_mask |= (STATX_ATTR_COMPRESSED | 367 367 STATX_ATTR_IMMUTABLE); 368 368 369 - generic_fillattr(mnt_userns, inode, stat); 369 + generic_fillattr(idmap, inode, stat); 370 370 return 0; 371 371 } 372 372
+1 -1
fs/erofs/internal.h
··· 494 494 extern const struct inode_operations erofs_fast_symlink_iops; 495 495 496 496 struct inode *erofs_iget(struct super_block *sb, erofs_nid_t nid); 497 - int erofs_getattr(struct user_namespace *mnt_userns, const struct path *path, 497 + int erofs_getattr(struct mnt_idmap *idmap, const struct path *path, 498 498 struct kstat *stat, u32 request_mask, 499 499 unsigned int query_flags); 500 500
+1 -1
fs/exfat/exfat_fs.h
··· 452 452 void exfat_truncate(struct inode *inode); 453 453 int exfat_setattr(struct mnt_idmap *idmap, struct dentry *dentry, 454 454 struct iattr *attr); 455 - int exfat_getattr(struct user_namespace *mnt_userns, const struct path *path, 455 + int exfat_getattr(struct mnt_idmap *idmap, const struct path *path, 456 456 struct kstat *stat, unsigned int request_mask, 457 457 unsigned int query_flags); 458 458 int exfat_file_fsync(struct file *file, loff_t start, loff_t end, int datasync);
+2 -2
fs/exfat/file.c
··· 226 226 mutex_unlock(&sbi->s_lock); 227 227 } 228 228 229 - int exfat_getattr(struct user_namespace *mnt_uerns, const struct path *path, 229 + int exfat_getattr(struct mnt_idmap *idmap, const struct path *path, 230 230 struct kstat *stat, unsigned int request_mask, 231 231 unsigned int query_flags) 232 232 { 233 233 struct inode *inode = d_backing_inode(path->dentry); 234 234 struct exfat_inode_info *ei = EXFAT_I(inode); 235 235 236 - generic_fillattr(&init_user_ns, inode, stat); 236 + generic_fillattr(&nop_mnt_idmap, inode, stat); 237 237 exfat_truncate_atime(&stat->atime); 238 238 stat->result_mask |= STATX_BTIME; 239 239 stat->btime.tv_sec = ei->i_crtime.tv_sec;
+1 -1
fs/ext2/ext2.h
··· 754 754 extern void ext2_evict_inode(struct inode *); 755 755 extern int ext2_get_block(struct inode *, sector_t, struct buffer_head *, int); 756 756 extern int ext2_setattr (struct mnt_idmap *, struct dentry *, struct iattr *); 757 - extern int ext2_getattr (struct user_namespace *, const struct path *, 757 + extern int ext2_getattr (struct mnt_idmap *, const struct path *, 758 758 struct kstat *, u32, unsigned int); 759 759 extern void ext2_set_inode_flags(struct inode *inode); 760 760 extern int ext2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
+2 -2
fs/ext2/inode.c
··· 1592 1592 return __ext2_write_inode(inode, wbc->sync_mode == WB_SYNC_ALL); 1593 1593 } 1594 1594 1595 - int ext2_getattr(struct user_namespace *mnt_userns, const struct path *path, 1595 + int ext2_getattr(struct mnt_idmap *idmap, const struct path *path, 1596 1596 struct kstat *stat, u32 request_mask, unsigned int query_flags) 1597 1597 { 1598 1598 struct inode *inode = d_inode(path->dentry); ··· 1614 1614 STATX_ATTR_IMMUTABLE | 1615 1615 STATX_ATTR_NODUMP); 1616 1616 1617 - generic_fillattr(&init_user_ns, inode, stat); 1617 + generic_fillattr(&nop_mnt_idmap, inode, stat); 1618 1618 return 0; 1619 1619 } 1620 1620
+2 -2
fs/ext4/ext4.h
··· 2979 2979 extern int ext4_setattr(struct mnt_idmap *, struct dentry *, 2980 2980 struct iattr *); 2981 2981 extern u32 ext4_dio_alignment(struct inode *inode); 2982 - extern int ext4_getattr(struct user_namespace *, const struct path *, 2982 + extern int ext4_getattr(struct mnt_idmap *, const struct path *, 2983 2983 struct kstat *, u32, unsigned int); 2984 2984 extern void ext4_evict_inode(struct inode *); 2985 2985 extern void ext4_clear_inode(struct inode *); 2986 - extern int ext4_file_getattr(struct user_namespace *, const struct path *, 2986 + extern int ext4_file_getattr(struct mnt_idmap *, const struct path *, 2987 2987 struct kstat *, u32, unsigned int); 2988 2988 extern int ext4_sync_inode(handle_t *, struct inode *); 2989 2989 extern void ext4_dirty_inode(struct inode *, int);
+4 -4
fs/ext4/inode.c
··· 5669 5669 return 1; /* use the iomap defaults */ 5670 5670 } 5671 5671 5672 - int ext4_getattr(struct user_namespace *mnt_userns, const struct path *path, 5672 + int ext4_getattr(struct mnt_idmap *idmap, const struct path *path, 5673 5673 struct kstat *stat, u32 request_mask, unsigned int query_flags) 5674 5674 { 5675 5675 struct inode *inode = d_inode(path->dentry); ··· 5726 5726 STATX_ATTR_NODUMP | 5727 5727 STATX_ATTR_VERITY); 5728 5728 5729 - generic_fillattr(mnt_userns, inode, stat); 5729 + generic_fillattr(idmap, inode, stat); 5730 5730 return 0; 5731 5731 } 5732 5732 5733 - int ext4_file_getattr(struct user_namespace *mnt_userns, 5733 + int ext4_file_getattr(struct mnt_idmap *idmap, 5734 5734 const struct path *path, struct kstat *stat, 5735 5735 u32 request_mask, unsigned int query_flags) 5736 5736 { 5737 5737 struct inode *inode = d_inode(path->dentry); 5738 5738 u64 delalloc_blocks; 5739 5739 5740 - ext4_getattr(mnt_userns, path, stat, request_mask, query_flags); 5740 + ext4_getattr(idmap, path, stat, request_mask, query_flags); 5741 5741 5742 5742 /* 5743 5743 * If there is inline data in the inode, the inode will normally not
+2 -2
fs/ext4/symlink.c
··· 55 55 return paddr; 56 56 } 57 57 58 - static int ext4_encrypted_symlink_getattr(struct user_namespace *mnt_userns, 58 + static int ext4_encrypted_symlink_getattr(struct mnt_idmap *idmap, 59 59 const struct path *path, 60 60 struct kstat *stat, u32 request_mask, 61 61 unsigned int query_flags) 62 62 { 63 - ext4_getattr(mnt_userns, path, stat, request_mask, query_flags); 63 + ext4_getattr(idmap, path, stat, request_mask, query_flags); 64 64 65 65 return fscrypt_symlink_getattr(path, stat); 66 66 }
+1 -1
fs/f2fs/f2fs.h
··· 3469 3469 int f2fs_do_truncate_blocks(struct inode *inode, u64 from, bool lock); 3470 3470 int f2fs_truncate_blocks(struct inode *inode, u64 from, bool lock); 3471 3471 int f2fs_truncate(struct inode *inode); 3472 - int f2fs_getattr(struct user_namespace *mnt_userns, const struct path *path, 3472 + int f2fs_getattr(struct mnt_idmap *idmap, const struct path *path, 3473 3473 struct kstat *stat, u32 request_mask, unsigned int flags); 3474 3474 int f2fs_setattr(struct mnt_idmap *idmap, struct dentry *dentry, 3475 3475 struct iattr *attr);
+2 -2
fs/f2fs/file.c
··· 837 837 return false; 838 838 } 839 839 840 - int f2fs_getattr(struct user_namespace *mnt_userns, const struct path *path, 840 + int f2fs_getattr(struct mnt_idmap *idmap, const struct path *path, 841 841 struct kstat *stat, u32 request_mask, unsigned int query_flags) 842 842 { 843 843 struct inode *inode = d_inode(path->dentry); ··· 892 892 STATX_ATTR_NODUMP | 893 893 STATX_ATTR_VERITY); 894 894 895 - generic_fillattr(mnt_userns, inode, stat); 895 + generic_fillattr(idmap, inode, stat); 896 896 897 897 /* we need to show initial sectors used for inline_data/dentries */ 898 898 if ((S_ISREG(inode->i_mode) && f2fs_has_inline_data(inode)) ||
+2 -2
fs/f2fs/namei.c
··· 1342 1342 return target; 1343 1343 } 1344 1344 1345 - static int f2fs_encrypted_symlink_getattr(struct user_namespace *mnt_userns, 1345 + static int f2fs_encrypted_symlink_getattr(struct mnt_idmap *idmap, 1346 1346 const struct path *path, 1347 1347 struct kstat *stat, u32 request_mask, 1348 1348 unsigned int query_flags) 1349 1349 { 1350 - f2fs_getattr(mnt_userns, path, stat, request_mask, query_flags); 1350 + f2fs_getattr(idmap, path, stat, request_mask, query_flags); 1351 1351 1352 1352 return fscrypt_symlink_getattr(path, stat); 1353 1353 }
+1 -1
fs/fat/fat.h
··· 401 401 extern int fat_setattr(struct mnt_idmap *idmap, struct dentry *dentry, 402 402 struct iattr *attr); 403 403 extern void fat_truncate_blocks(struct inode *inode, loff_t offset); 404 - extern int fat_getattr(struct user_namespace *mnt_userns, 404 + extern int fat_getattr(struct mnt_idmap *idmap, 405 405 const struct path *path, struct kstat *stat, 406 406 u32 request_mask, unsigned int flags); 407 407 extern int fat_file_fsync(struct file *file, loff_t start, loff_t end,
+2 -2
fs/fat/file.c
··· 395 395 fat_flush_inodes(inode->i_sb, inode, NULL); 396 396 } 397 397 398 - int fat_getattr(struct user_namespace *mnt_userns, const struct path *path, 398 + int fat_getattr(struct mnt_idmap *idmap, const struct path *path, 399 399 struct kstat *stat, u32 request_mask, unsigned int flags) 400 400 { 401 401 struct inode *inode = d_inode(path->dentry); 402 402 struct msdos_sb_info *sbi = MSDOS_SB(inode->i_sb); 403 403 404 - generic_fillattr(mnt_userns, inode, stat); 404 + generic_fillattr(idmap, inode, stat); 405 405 stat->blksize = sbi->cluster_size; 406 406 407 407 if (sbi->options.nfs == FAT_NFS_NOSTALE_RO) {
+2 -2
fs/fuse/dir.c
··· 1156 1156 forget_all_cached_acls(inode); 1157 1157 err = fuse_do_getattr(inode, stat, file); 1158 1158 } else if (stat) { 1159 - generic_fillattr(&init_user_ns, inode, stat); 1159 + generic_fillattr(&nop_mnt_idmap, inode, stat); 1160 1160 stat->mode = fi->orig_i_mode; 1161 1161 stat->ino = fi->orig_ino; 1162 1162 } ··· 1900 1900 return ret; 1901 1901 } 1902 1902 1903 - static int fuse_getattr(struct user_namespace *mnt_userns, 1903 + static int fuse_getattr(struct mnt_idmap *idmap, 1904 1904 const struct path *path, struct kstat *stat, 1905 1905 u32 request_mask, unsigned int flags) 1906 1906 {
+3 -3
fs/gfs2/inode.c
··· 2022 2022 2023 2023 /** 2024 2024 * gfs2_getattr - Read out an inode's attributes 2025 - * @mnt_userns: user namespace of the mount the inode was found from 2025 + * @idmap: idmap of the mount the inode was found from 2026 2026 * @path: Object to query 2027 2027 * @stat: The inode's stats 2028 2028 * @request_mask: Mask of STATX_xxx flags indicating the caller's interests ··· 2037 2037 * Returns: errno 2038 2038 */ 2039 2039 2040 - static int gfs2_getattr(struct user_namespace *mnt_userns, 2040 + static int gfs2_getattr(struct mnt_idmap *idmap, 2041 2041 const struct path *path, struct kstat *stat, 2042 2042 u32 request_mask, unsigned int flags) 2043 2043 { ··· 2066 2066 STATX_ATTR_IMMUTABLE | 2067 2067 STATX_ATTR_NODUMP); 2068 2068 2069 - generic_fillattr(&init_user_ns, inode, stat); 2069 + generic_fillattr(&nop_mnt_idmap, inode, stat); 2070 2070 2071 2071 if (gfs2_holder_initialized(&gh)) 2072 2072 gfs2_glock_dq_uninit(&gh);
+1 -1
fs/hfsplus/hfsplus_fs.h
··· 481 481 struct hfsplus_fork_raw *fork); 482 482 int hfsplus_cat_read_inode(struct inode *inode, struct hfs_find_data *fd); 483 483 int hfsplus_cat_write_inode(struct inode *inode); 484 - int hfsplus_getattr(struct user_namespace *mnt_userns, const struct path *path, 484 + int hfsplus_getattr(struct mnt_idmap *idmap, const struct path *path, 485 485 struct kstat *stat, u32 request_mask, 486 486 unsigned int query_flags); 487 487 int hfsplus_file_fsync(struct file *file, loff_t start, loff_t end,
+2 -2
fs/hfsplus/inode.c
··· 276 276 return 0; 277 277 } 278 278 279 - int hfsplus_getattr(struct user_namespace *mnt_userns, const struct path *path, 279 + int hfsplus_getattr(struct mnt_idmap *idmap, const struct path *path, 280 280 struct kstat *stat, u32 request_mask, 281 281 unsigned int query_flags) 282 282 { ··· 298 298 stat->attributes_mask |= STATX_ATTR_APPEND | STATX_ATTR_IMMUTABLE | 299 299 STATX_ATTR_NODUMP; 300 300 301 - generic_fillattr(&init_user_ns, inode, stat); 301 + generic_fillattr(&nop_mnt_idmap, inode, stat); 302 302 return 0; 303 303 } 304 304
+2 -2
fs/kernfs/inode.c
··· 181 181 set_nlink(inode, kn->dir.subdirs + 2); 182 182 } 183 183 184 - int kernfs_iop_getattr(struct user_namespace *mnt_userns, 184 + int kernfs_iop_getattr(struct mnt_idmap *idmap, 185 185 const struct path *path, struct kstat *stat, 186 186 u32 request_mask, unsigned int query_flags) 187 187 { ··· 191 191 192 192 down_read(&root->kernfs_rwsem); 193 193 kernfs_refresh_inode(kn, inode); 194 - generic_fillattr(&init_user_ns, inode, stat); 194 + generic_fillattr(&nop_mnt_idmap, inode, stat); 195 195 up_read(&root->kernfs_rwsem); 196 196 197 197 return 0;
+1 -1
fs/kernfs/kernfs-internal.h
··· 131 131 struct inode *inode, int mask); 132 132 int kernfs_iop_setattr(struct mnt_idmap *idmap, struct dentry *dentry, 133 133 struct iattr *iattr); 134 - int kernfs_iop_getattr(struct user_namespace *mnt_userns, 134 + int kernfs_iop_getattr(struct mnt_idmap *idmap, 135 135 const struct path *path, struct kstat *stat, 136 136 u32 request_mask, unsigned int query_flags); 137 137 ssize_t kernfs_iop_listxattr(struct dentry *dentry, char *buf, size_t size);
+10 -9
fs/ksmbd/smb2pdu.c
··· 3631 3631 3632 3632 static int process_query_dir_entries(struct smb2_query_dir_private *priv) 3633 3633 { 3634 - struct user_namespace *user_ns = file_mnt_user_ns(priv->dir_fp->filp); 3634 + struct mnt_idmap *idmap = file_mnt_idmap(priv->dir_fp->filp); 3635 + struct user_namespace *user_ns = mnt_idmap_owner(idmap); 3635 3636 struct kstat kstat; 3636 3637 struct ksmbd_kstat ksmbd_kstat; 3637 3638 int rc; ··· 3666 3665 ksmbd_kstat.kstat = &kstat; 3667 3666 if (priv->info_level != FILE_NAMES_INFORMATION) 3668 3667 ksmbd_vfs_fill_dentry_attrs(priv->work, 3669 - user_ns, 3668 + idmap, 3670 3669 dent, 3671 3670 &ksmbd_kstat); 3672 3671 ··· 4332 4331 } 4333 4332 4334 4333 basic_info = (struct smb2_file_basic_info *)rsp->Buffer; 4335 - generic_fillattr(file_mnt_user_ns(fp->filp), file_inode(fp->filp), 4334 + generic_fillattr(file_mnt_idmap(fp->filp), file_inode(fp->filp), 4336 4335 &stat); 4337 4336 basic_info->CreationTime = cpu_to_le64(fp->create_time); 4338 4337 time = ksmbd_UnixTimeToNT(stat.atime); ··· 4373 4372 struct kstat stat; 4374 4373 4375 4374 inode = file_inode(fp->filp); 4376 - generic_fillattr(file_mnt_user_ns(fp->filp), inode, &stat); 4375 + generic_fillattr(file_mnt_idmap(fp->filp), inode, &stat); 4377 4376 4378 4377 sinfo = (struct smb2_file_standard_info *)rsp->Buffer; 4379 4378 delete_pending = ksmbd_inode_pending_delete(fp); ··· 4427 4426 return PTR_ERR(filename); 4428 4427 4429 4428 inode = file_inode(fp->filp); 4430 - generic_fillattr(file_mnt_user_ns(fp->filp), inode, &stat); 4429 + generic_fillattr(file_mnt_idmap(fp->filp), inode, &stat); 4431 4430 4432 4431 ksmbd_debug(SMB, "filename = %s\n", filename); 4433 4432 delete_pending = ksmbd_inode_pending_delete(fp); ··· 4504 4503 int buf_free_len; 4505 4504 struct smb2_query_info_req *req = ksmbd_req_buf_next(work); 4506 4505 4507 - generic_fillattr(file_mnt_user_ns(fp->filp), file_inode(fp->filp), 4506 + generic_fillattr(file_mnt_idmap(fp->filp), file_inode(fp->filp), 4508 4507 &stat); 4509 4508 file_info = (struct smb2_file_stream_info *)rsp->Buffer; 4510 4509 ··· 4595 4594 struct smb2_file_internal_info *file_info; 4596 4595 struct kstat stat; 4597 4596 4598 - generic_fillattr(file_mnt_user_ns(fp->filp), file_inode(fp->filp), 4597 + generic_fillattr(file_mnt_idmap(fp->filp), file_inode(fp->filp), 4599 4598 &stat); 4600 4599 file_info = (struct smb2_file_internal_info *)rsp->Buffer; 4601 4600 file_info->IndexNumber = cpu_to_le64(stat.ino); ··· 4621 4620 file_info = (struct smb2_file_ntwrk_info *)rsp->Buffer; 4622 4621 4623 4622 inode = file_inode(fp->filp); 4624 - generic_fillattr(file_mnt_user_ns(fp->filp), inode, &stat); 4623 + generic_fillattr(file_mnt_idmap(fp->filp), inode, &stat); 4625 4624 4626 4625 file_info->CreationTime = cpu_to_le64(fp->create_time); 4627 4626 time = ksmbd_UnixTimeToNT(stat.atime); ··· 4682 4681 struct smb2_file_comp_info *file_info; 4683 4682 struct kstat stat; 4684 4683 4685 - generic_fillattr(file_mnt_user_ns(fp->filp), file_inode(fp->filp), 4684 + generic_fillattr(file_mnt_idmap(fp->filp), file_inode(fp->filp), 4686 4685 &stat); 4687 4686 4688 4687 file_info = (struct smb2_file_comp_info *)rsp->Buffer;
+2 -2
fs/ksmbd/smb_common.c
··· 307 307 { 308 308 int i, rc = 0; 309 309 struct ksmbd_conn *conn = work->conn; 310 - struct user_namespace *user_ns = file_mnt_user_ns(dir->filp); 310 + struct mnt_idmap *idmap = file_mnt_idmap(dir->filp); 311 311 312 312 for (i = 0; i < 2; i++) { 313 313 struct kstat kstat; ··· 333 333 334 334 ksmbd_kstat.kstat = &kstat; 335 335 ksmbd_vfs_fill_dentry_attrs(work, 336 - user_ns, 336 + idmap, 337 337 dentry, 338 338 &ksmbd_kstat); 339 339 rc = fn(conn, info_level, d_info, &ksmbd_kstat);
+3 -3
fs/ksmbd/vfs.c
··· 1657 1657 } 1658 1658 1659 1659 int ksmbd_vfs_fill_dentry_attrs(struct ksmbd_work *work, 1660 - struct user_namespace *user_ns, 1660 + struct mnt_idmap *idmap, 1661 1661 struct dentry *dentry, 1662 1662 struct ksmbd_kstat *ksmbd_kstat) 1663 1663 { 1664 1664 u64 time; 1665 1665 int rc; 1666 1666 1667 - generic_fillattr(user_ns, d_inode(dentry), ksmbd_kstat->kstat); 1667 + generic_fillattr(idmap, d_inode(dentry), ksmbd_kstat->kstat); 1668 1668 1669 1669 time = ksmbd_UnixTimeToNT(ksmbd_kstat->kstat->ctime); 1670 1670 ksmbd_kstat->create_time = time; ··· 1682 1682 KSMBD_SHARE_FLAG_STORE_DOS_ATTRS)) { 1683 1683 struct xattr_dos_attrib da; 1684 1684 1685 - rc = ksmbd_vfs_get_dos_attrib_xattr(user_ns, dentry, &da); 1685 + rc = ksmbd_vfs_get_dos_attrib_xattr(mnt_idmap_owner(idmap), dentry, &da); 1686 1686 if (rc > 0) { 1687 1687 ksmbd_kstat->file_attributes = cpu_to_le32(da.attr); 1688 1688 ksmbd_kstat->create_time = da.create_time;
+1 -1
fs/ksmbd/vfs.h
··· 135 135 struct dentry *dentry); 136 136 void *ksmbd_vfs_init_kstat(char **p, struct ksmbd_kstat *ksmbd_kstat); 137 137 int ksmbd_vfs_fill_dentry_attrs(struct ksmbd_work *work, 138 - struct user_namespace *user_ns, 138 + struct mnt_idmap *idmap, 139 139 struct dentry *dentry, 140 140 struct ksmbd_kstat *ksmbd_kstat); 141 141 void ksmbd_vfs_posix_lock_wait(struct file_lock *flock);
+4 -4
fs/libfs.c
··· 28 28 29 29 #include "internal.h" 30 30 31 - int simple_getattr(struct user_namespace *mnt_userns, const struct path *path, 31 + int simple_getattr(struct mnt_idmap *idmap, const struct path *path, 32 32 struct kstat *stat, u32 request_mask, 33 33 unsigned int query_flags) 34 34 { 35 35 struct inode *inode = d_inode(path->dentry); 36 - generic_fillattr(&init_user_ns, inode, stat); 36 + generic_fillattr(&nop_mnt_idmap, inode, stat); 37 37 stat->blocks = inode->i_mapping->nrpages << (PAGE_SHIFT - 9); 38 38 return 0; 39 39 } ··· 1315 1315 return ERR_PTR(-ENOENT); 1316 1316 } 1317 1317 1318 - static int empty_dir_getattr(struct user_namespace *mnt_userns, 1318 + static int empty_dir_getattr(struct mnt_idmap *idmap, 1319 1319 const struct path *path, struct kstat *stat, 1320 1320 u32 request_mask, unsigned int query_flags) 1321 1321 { 1322 1322 struct inode *inode = d_inode(path->dentry); 1323 - generic_fillattr(&init_user_ns, inode, stat); 1323 + generic_fillattr(&nop_mnt_idmap, inode, stat); 1324 1324 return 0; 1325 1325 } 1326 1326
+2 -2
fs/minix/inode.c
··· 654 654 return err; 655 655 } 656 656 657 - int minix_getattr(struct user_namespace *mnt_userns, const struct path *path, 657 + int minix_getattr(struct mnt_idmap *idmap, const struct path *path, 658 658 struct kstat *stat, u32 request_mask, unsigned int flags) 659 659 { 660 660 struct super_block *sb = path->dentry->d_sb; 661 661 struct inode *inode = d_inode(path->dentry); 662 662 663 - generic_fillattr(&init_user_ns, inode, stat); 663 + generic_fillattr(&nop_mnt_idmap, inode, stat); 664 664 if (INODE_VERSION(inode) == MINIX_V1) 665 665 stat->blocks = (BLOCK_SIZE / 512) * V1_minix_blocks(stat->size, sb); 666 666 else
+1 -1
fs/minix/minix.h
··· 51 51 extern int minix_new_block(struct inode * inode); 52 52 extern void minix_free_block(struct inode *inode, unsigned long block); 53 53 extern unsigned long minix_count_free_blocks(struct super_block *sb); 54 - extern int minix_getattr(struct user_namespace *, const struct path *, 54 + extern int minix_getattr(struct mnt_idmap *, const struct path *, 55 55 struct kstat *, u32, unsigned int); 56 56 extern int minix_prepare_chunk(struct page *page, loff_t pos, unsigned len); 57 57
+2 -2
fs/nfs/inode.c
··· 828 828 return reply_mask; 829 829 } 830 830 831 - int nfs_getattr(struct user_namespace *mnt_userns, const struct path *path, 831 + int nfs_getattr(struct mnt_idmap *idmap, const struct path *path, 832 832 struct kstat *stat, u32 request_mask, unsigned int query_flags) 833 833 { 834 834 struct inode *inode = d_inode(path->dentry); ··· 908 908 /* Only return attributes that were revalidated. */ 909 909 stat->result_mask = nfs_get_valid_attrmask(inode) | request_mask; 910 910 911 - generic_fillattr(&init_user_ns, inode, stat); 911 + generic_fillattr(&nop_mnt_idmap, inode, stat); 912 912 stat->ino = nfs_compat_user_ino64(NFS_FILEID(inode)); 913 913 if (S_ISDIR(inode->i_mode)) 914 914 stat->blksize = NFS_SERVER(inode)->dtsize;
+3 -3
fs/nfs/namespace.c
··· 208 208 } 209 209 210 210 static int 211 - nfs_namespace_getattr(struct user_namespace *mnt_userns, 211 + nfs_namespace_getattr(struct mnt_idmap *idmap, 212 212 const struct path *path, struct kstat *stat, 213 213 u32 request_mask, unsigned int query_flags) 214 214 { 215 215 if (NFS_FH(d_inode(path->dentry))->size != 0) 216 - return nfs_getattr(mnt_userns, path, stat, request_mask, 216 + return nfs_getattr(idmap, path, stat, request_mask, 217 217 query_flags); 218 - generic_fillattr(&init_user_ns, d_inode(path->dentry), stat); 218 + generic_fillattr(&nop_mnt_idmap, d_inode(path->dentry), stat); 219 219 return 0; 220 220 } 221 221
+2 -2
fs/ntfs3/file.c
··· 70 70 /* 71 71 * ntfs_getattr - inode_operations::getattr 72 72 */ 73 - int ntfs_getattr(struct user_namespace *mnt_userns, const struct path *path, 73 + int ntfs_getattr(struct mnt_idmap *idmap, const struct path *path, 74 74 struct kstat *stat, u32 request_mask, u32 flags) 75 75 { 76 76 struct inode *inode = d_inode(path->dentry); ··· 84 84 85 85 stat->attributes_mask |= STATX_ATTR_COMPRESSED | STATX_ATTR_ENCRYPTED; 86 86 87 - generic_fillattr(mnt_userns, inode, stat); 87 + generic_fillattr(idmap, inode, stat); 88 88 89 89 stat->result_mask |= STATX_BTIME; 90 90 stat->btime = ni->i_crtime;
+1 -1
fs/ntfs3/ntfs_fs.h
··· 492 492 extern const struct file_operations ntfs_dir_operations; 493 493 494 494 /* Globals from file.c */ 495 - int ntfs_getattr(struct user_namespace *mnt_userns, const struct path *path, 495 + int ntfs_getattr(struct mnt_idmap *idmap, const struct path *path, 496 496 struct kstat *stat, u32 request_mask, u32 flags); 497 497 int ntfs3_setattr(struct mnt_idmap *idmap, struct dentry *dentry, 498 498 struct iattr *attr);
+2 -2
fs/ocfs2/file.c
··· 1303 1303 return status; 1304 1304 } 1305 1305 1306 - int ocfs2_getattr(struct user_namespace *mnt_userns, const struct path *path, 1306 + int ocfs2_getattr(struct mnt_idmap *idmap, const struct path *path, 1307 1307 struct kstat *stat, u32 request_mask, unsigned int flags) 1308 1308 { 1309 1309 struct inode *inode = d_inode(path->dentry); ··· 1318 1318 goto bail; 1319 1319 } 1320 1320 1321 - generic_fillattr(&init_user_ns, inode, stat); 1321 + generic_fillattr(&nop_mnt_idmap, inode, stat); 1322 1322 /* 1323 1323 * If there is inline data in the inode, the inode will normally not 1324 1324 * have data blocks allocated (it may have an external xattr block).
+1 -1
fs/ocfs2/file.h
··· 51 51 loff_t zero_to); 52 52 int ocfs2_setattr(struct mnt_idmap *idmap, struct dentry *dentry, 53 53 struct iattr *attr); 54 - int ocfs2_getattr(struct user_namespace *mnt_userns, const struct path *path, 54 + int ocfs2_getattr(struct mnt_idmap *idmap, const struct path *path, 55 55 struct kstat *stat, u32 request_mask, unsigned int flags); 56 56 int ocfs2_permission(struct user_namespace *mnt_userns, 57 57 struct inode *inode,
+2 -2
fs/orangefs/inode.c
··· 866 866 /* 867 867 * Obtain attributes of an object given a dentry 868 868 */ 869 - int orangefs_getattr(struct user_namespace *mnt_userns, const struct path *path, 869 + int orangefs_getattr(struct mnt_idmap *idmap, const struct path *path, 870 870 struct kstat *stat, u32 request_mask, unsigned int flags) 871 871 { 872 872 int ret; ··· 879 879 ret = orangefs_inode_getattr(inode, 880 880 request_mask & STATX_SIZE ? ORANGEFS_GETATTR_SIZE : 0); 881 881 if (ret == 0) { 882 - generic_fillattr(&init_user_ns, inode, stat); 882 + generic_fillattr(&nop_mnt_idmap, inode, stat); 883 883 884 884 /* override block size reported to stat */ 885 885 if (!(request_mask & STATX_SIZE))
+1 -1
fs/orangefs/orangefs-kernel.h
··· 364 364 int __orangefs_setattr_mode(struct dentry *dentry, struct iattr *iattr); 365 365 int orangefs_setattr(struct mnt_idmap *, struct dentry *, struct iattr *); 366 366 367 - int orangefs_getattr(struct user_namespace *mnt_userns, const struct path *path, 367 + int orangefs_getattr(struct mnt_idmap *idmap, const struct path *path, 368 368 struct kstat *stat, u32 request_mask, unsigned int flags); 369 369 370 370 int orangefs_permission(struct user_namespace *mnt_userns,
+1 -1
fs/overlayfs/inode.c
··· 153 153 } 154 154 } 155 155 156 - int ovl_getattr(struct user_namespace *mnt_userns, const struct path *path, 156 + int ovl_getattr(struct mnt_idmap *idmap, const struct path *path, 157 157 struct kstat *stat, u32 request_mask, unsigned int flags) 158 158 { 159 159 struct dentry *dentry = path->dentry;
+1 -1
fs/overlayfs/overlayfs.h
··· 599 599 unsigned int fallback); 600 600 int ovl_setattr(struct mnt_idmap *idmap, struct dentry *dentry, 601 601 struct iattr *attr); 602 - int ovl_getattr(struct user_namespace *mnt_userns, const struct path *path, 602 + int ovl_getattr(struct mnt_idmap *idmap, const struct path *path, 603 603 struct kstat *stat, u32 request_mask, unsigned int flags); 604 604 int ovl_permission(struct user_namespace *mnt_userns, struct inode *inode, 605 605 int mask);
+4 -4
fs/proc/base.c
··· 1959 1959 return inode; 1960 1960 } 1961 1961 1962 - int pid_getattr(struct user_namespace *mnt_userns, const struct path *path, 1962 + int pid_getattr(struct mnt_idmap *idmap, const struct path *path, 1963 1963 struct kstat *stat, u32 request_mask, unsigned int query_flags) 1964 1964 { 1965 1965 struct inode *inode = d_inode(path->dentry); 1966 1966 struct proc_fs_info *fs_info = proc_sb_info(inode->i_sb); 1967 1967 struct task_struct *task; 1968 1968 1969 - generic_fillattr(&init_user_ns, inode, stat); 1969 + generic_fillattr(&nop_mnt_idmap, inode, stat); 1970 1970 1971 1971 stat->uid = GLOBAL_ROOT_UID; 1972 1972 stat->gid = GLOBAL_ROOT_GID; ··· 3891 3891 return 0; 3892 3892 } 3893 3893 3894 - static int proc_task_getattr(struct user_namespace *mnt_userns, 3894 + static int proc_task_getattr(struct mnt_idmap *idmap, 3895 3895 const struct path *path, struct kstat *stat, 3896 3896 u32 request_mask, unsigned int query_flags) 3897 3897 { 3898 3898 struct inode *inode = d_inode(path->dentry); 3899 3899 struct task_struct *p = get_proc_task(inode); 3900 - generic_fillattr(&init_user_ns, inode, stat); 3900 + generic_fillattr(&nop_mnt_idmap, inode, stat); 3901 3901 3902 3902 if (p) { 3903 3903 stat->nlink += get_nr_threads(p);
+2 -2
fs/proc/fd.c
··· 344 344 return rv; 345 345 } 346 346 347 - static int proc_fd_getattr(struct user_namespace *mnt_userns, 347 + static int proc_fd_getattr(struct mnt_idmap *idmap, 348 348 const struct path *path, struct kstat *stat, 349 349 u32 request_mask, unsigned int query_flags) 350 350 { 351 351 struct inode *inode = d_inode(path->dentry); 352 352 int rv = 0; 353 353 354 - generic_fillattr(&init_user_ns, inode, stat); 354 + generic_fillattr(&nop_mnt_idmap, inode, stat); 355 355 356 356 /* If it's a directory, put the number of open fds there */ 357 357 if (S_ISDIR(inode->i_mode)) {
+2 -2
fs/proc/generic.c
··· 134 134 return 0; 135 135 } 136 136 137 - static int proc_getattr(struct user_namespace *mnt_userns, 137 + static int proc_getattr(struct mnt_idmap *idmap, 138 138 const struct path *path, struct kstat *stat, 139 139 u32 request_mask, unsigned int query_flags) 140 140 { ··· 147 147 } 148 148 } 149 149 150 - generic_fillattr(&init_user_ns, inode, stat); 150 + generic_fillattr(&nop_mnt_idmap, inode, stat); 151 151 return 0; 152 152 } 153 153
+1 -1
fs/proc/internal.h
··· 162 162 * base.c 163 163 */ 164 164 extern const struct dentry_operations pid_dentry_operations; 165 - extern int pid_getattr(struct user_namespace *, const struct path *, 165 + extern int pid_getattr(struct mnt_idmap *, const struct path *, 166 166 struct kstat *, u32, unsigned int); 167 167 extern int proc_setattr(struct mnt_idmap *, struct dentry *, 168 168 struct iattr *);
+2 -2
fs/proc/proc_net.c
··· 299 299 return de; 300 300 } 301 301 302 - static int proc_tgid_net_getattr(struct user_namespace *mnt_userns, 302 + static int proc_tgid_net_getattr(struct mnt_idmap *idmap, 303 303 const struct path *path, struct kstat *stat, 304 304 u32 request_mask, unsigned int query_flags) 305 305 { ··· 308 308 309 309 net = get_proc_task_net(inode); 310 310 311 - generic_fillattr(&init_user_ns, inode, stat); 311 + generic_fillattr(&nop_mnt_idmap, inode, stat); 312 312 313 313 if (net != NULL) { 314 314 stat->nlink = net->proc_net->nlink;
+2 -2
fs/proc/proc_sysctl.c
··· 845 845 return 0; 846 846 } 847 847 848 - static int proc_sys_getattr(struct user_namespace *mnt_userns, 848 + static int proc_sys_getattr(struct mnt_idmap *idmap, 849 849 const struct path *path, struct kstat *stat, 850 850 u32 request_mask, unsigned int query_flags) 851 851 { ··· 856 856 if (IS_ERR(head)) 857 857 return PTR_ERR(head); 858 858 859 - generic_fillattr(&init_user_ns, inode, stat); 859 + generic_fillattr(&nop_mnt_idmap, inode, stat); 860 860 if (table) 861 861 stat->mode = (stat->mode & S_IFMT) | table->mode; 862 862
+2 -2
fs/proc/root.c
··· 310 310 register_filesystem(&proc_fs_type); 311 311 } 312 312 313 - static int proc_root_getattr(struct user_namespace *mnt_userns, 313 + static int proc_root_getattr(struct mnt_idmap *idmap, 314 314 const struct path *path, struct kstat *stat, 315 315 u32 request_mask, unsigned int query_flags) 316 316 { 317 - generic_fillattr(&init_user_ns, d_inode(path->dentry), stat); 317 + generic_fillattr(&nop_mnt_idmap, d_inode(path->dentry), stat); 318 318 stat->nlink = proc_root.nlink + nr_processes(); 319 319 return 0; 320 320 }
+12 -10
fs/stat.c
··· 27 27 28 28 /** 29 29 * generic_fillattr - Fill in the basic attributes from the inode struct 30 - * @mnt_userns: user namespace of the mount the inode was found from 30 + * @idmap: idmap of the mount the inode was found from 31 31 * @inode: Inode to use as the source 32 32 * @stat: Where to fill in the attributes 33 33 * ··· 35 35 * found on the VFS inode structure. This is the default if no getattr inode 36 36 * operation is supplied. 37 37 * 38 - * If the inode has been found through an idmapped mount the user namespace of 39 - * the vfsmount must be passed through @mnt_userns. This function will then 40 - * take care to map the inode according to @mnt_userns before filling in the 38 + * If the inode has been found through an idmapped mount the idmap of 39 + * the vfsmount must be passed through @idmap. This function will then 40 + * take care to map the inode according to @idmap before filling in the 41 41 * uid and gid filds. On non-idmapped mounts or if permission checking is to be 42 - * performed on the raw inode simply passs init_user_ns. 42 + * performed on the raw inode simply passs @nop_mnt_idmap. 43 43 */ 44 - void generic_fillattr(struct user_namespace *mnt_userns, struct inode *inode, 44 + void generic_fillattr(struct mnt_idmap *idmap, struct inode *inode, 45 45 struct kstat *stat) 46 46 { 47 + struct user_namespace *mnt_userns = mnt_idmap_owner(idmap); 48 + 47 49 vfsuid_t vfsuid = i_uid_into_vfsuid(mnt_userns, inode); 48 50 vfsgid_t vfsgid = i_gid_into_vfsgid(mnt_userns, inode); 49 51 ··· 99 97 int vfs_getattr_nosec(const struct path *path, struct kstat *stat, 100 98 u32 request_mask, unsigned int query_flags) 101 99 { 102 - struct user_namespace *mnt_userns; 100 + struct mnt_idmap *idmap; 103 101 struct inode *inode = d_backing_inode(path->dentry); 104 102 105 103 memset(stat, 0, sizeof(*stat)); ··· 124 122 stat->attributes_mask |= (STATX_ATTR_AUTOMOUNT | 125 123 STATX_ATTR_DAX); 126 124 127 - mnt_userns = mnt_user_ns(path->mnt); 125 + idmap = mnt_idmap(path->mnt); 128 126 if (inode->i_op->getattr) 129 - return inode->i_op->getattr(mnt_userns, path, stat, 127 + return inode->i_op->getattr(idmap, path, stat, 130 128 request_mask, query_flags); 131 129 132 - generic_fillattr(mnt_userns, inode, stat); 130 + generic_fillattr(idmap, inode, stat); 133 131 return 0; 134 132 } 135 133 EXPORT_SYMBOL(vfs_getattr_nosec);
+2 -2
fs/sysv/itree.c
··· 441 441 return res; 442 442 } 443 443 444 - int sysv_getattr(struct user_namespace *mnt_userns, const struct path *path, 444 + int sysv_getattr(struct mnt_idmap *idmap, const struct path *path, 445 445 struct kstat *stat, u32 request_mask, unsigned int flags) 446 446 { 447 447 struct super_block *s = path->dentry->d_sb; 448 - generic_fillattr(&init_user_ns, d_inode(path->dentry), stat); 448 + generic_fillattr(&nop_mnt_idmap, d_inode(path->dentry), stat); 449 449 stat->blocks = (s->s_blocksize / 512) * sysv_nblocks(s, stat->size); 450 450 stat->blksize = s->s_blocksize; 451 451 return 0;
+1 -1
fs/sysv/sysv.h
··· 141 141 extern int sysv_write_inode(struct inode *, struct writeback_control *wbc); 142 142 extern int sysv_sync_inode(struct inode *); 143 143 extern void sysv_set_inode(struct inode *, dev_t); 144 - extern int sysv_getattr(struct user_namespace *, const struct path *, 144 + extern int sysv_getattr(struct mnt_idmap *, const struct path *, 145 145 struct kstat *, u32, unsigned int); 146 146 extern int sysv_init_icache(void); 147 147 extern void sysv_destroy_icache(void);
+2 -2
fs/ubifs/dir.c
··· 1631 1631 return do_rename(old_dir, old_dentry, new_dir, new_dentry, flags); 1632 1632 } 1633 1633 1634 - int ubifs_getattr(struct user_namespace *mnt_userns, const struct path *path, 1634 + int ubifs_getattr(struct mnt_idmap *idmap, const struct path *path, 1635 1635 struct kstat *stat, u32 request_mask, unsigned int flags) 1636 1636 { 1637 1637 loff_t size; ··· 1654 1654 STATX_ATTR_ENCRYPTED | 1655 1655 STATX_ATTR_IMMUTABLE); 1656 1656 1657 - generic_fillattr(&init_user_ns, inode, stat); 1657 + generic_fillattr(&nop_mnt_idmap, inode, stat); 1658 1658 stat->blksize = UBIFS_BLOCK_SIZE; 1659 1659 stat->size = ui->ui_size; 1660 1660
+2 -2
fs/ubifs/file.c
··· 1608 1608 return fscrypt_get_symlink(inode, ui->data, ui->data_len, done); 1609 1609 } 1610 1610 1611 - static int ubifs_symlink_getattr(struct user_namespace *mnt_userns, 1611 + static int ubifs_symlink_getattr(struct mnt_idmap *idmap, 1612 1612 const struct path *path, struct kstat *stat, 1613 1613 u32 request_mask, unsigned int query_flags) 1614 1614 { 1615 - ubifs_getattr(mnt_userns, path, stat, request_mask, query_flags); 1615 + ubifs_getattr(idmap, path, stat, request_mask, query_flags); 1616 1616 1617 1617 if (IS_ENCRYPTED(d_inode(path->dentry))) 1618 1618 return fscrypt_symlink_getattr(path, stat);
+2 -2
fs/ubifs/ubifs.h
··· 2027 2027 /* dir.c */ 2028 2028 struct inode *ubifs_new_inode(struct ubifs_info *c, struct inode *dir, 2029 2029 umode_t mode, bool is_xattr); 2030 - int ubifs_getattr(struct user_namespace *mnt_userns, const struct path *path, struct kstat *stat, 2031 - u32 request_mask, unsigned int flags); 2030 + int ubifs_getattr(struct mnt_idmap *idmap, const struct path *path, 2031 + struct kstat *stat, u32 request_mask, unsigned int flags); 2032 2032 int ubifs_check_dir_empty(struct inode *dir); 2033 2033 2034 2034 /* xattr.c */
+2 -2
fs/udf/symlink.c
··· 153 153 return err; 154 154 } 155 155 156 - static int udf_symlink_getattr(struct user_namespace *mnt_userns, 156 + static int udf_symlink_getattr(struct mnt_idmap *idmap, 157 157 const struct path *path, struct kstat *stat, 158 158 u32 request_mask, unsigned int flags) 159 159 { ··· 161 161 struct inode *inode = d_backing_inode(dentry); 162 162 struct page *page; 163 163 164 - generic_fillattr(&init_user_ns, inode, stat); 164 + generic_fillattr(&nop_mnt_idmap, inode, stat); 165 165 page = read_mapping_page(inode->i_mapping, 0, NULL); 166 166 if (IS_ERR(page)) 167 167 return PTR_ERR(page);
+2 -2
fs/vboxsf/utils.c
··· 231 231 return 0; 232 232 } 233 233 234 - int vboxsf_getattr(struct user_namespace *mnt_userns, const struct path *path, 234 + int vboxsf_getattr(struct mnt_idmap *idmap, const struct path *path, 235 235 struct kstat *kstat, u32 request_mask, unsigned int flags) 236 236 { 237 237 int err; ··· 252 252 if (err) 253 253 return err; 254 254 255 - generic_fillattr(&init_user_ns, d_inode(dentry), kstat); 255 + generic_fillattr(&nop_mnt_idmap, d_inode(dentry), kstat); 256 256 return 0; 257 257 } 258 258
+1 -1
fs/vboxsf/vfsmod.h
··· 97 97 struct shfl_fsobjinfo *info); 98 98 int vboxsf_stat_dentry(struct dentry *dentry, struct shfl_fsobjinfo *info); 99 99 int vboxsf_inode_revalidate(struct dentry *dentry); 100 - int vboxsf_getattr(struct user_namespace *mnt_userns, const struct path *path, 100 + int vboxsf_getattr(struct mnt_idmap *idmap, const struct path *path, 101 101 struct kstat *kstat, u32 request_mask, 102 102 unsigned int query_flags); 103 103 int vboxsf_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+2 -1
fs/xfs/xfs_iops.c
··· 549 549 550 550 STATIC int 551 551 xfs_vn_getattr( 552 - struct user_namespace *mnt_userns, 552 + struct mnt_idmap *idmap, 553 553 const struct path *path, 554 554 struct kstat *stat, 555 555 u32 request_mask, 556 556 unsigned int query_flags) 557 557 { 558 + struct user_namespace *mnt_userns = mnt_idmap_owner(idmap); 558 559 struct inode *inode = d_inode(path->dentry); 559 560 struct xfs_inode *ip = XFS_I(inode); 560 561 struct xfs_mount *mp = ip->i_mount;
+3 -3
include/linux/fs.h
··· 2153 2153 int (*rename) (struct user_namespace *, struct inode *, struct dentry *, 2154 2154 struct inode *, struct dentry *, unsigned int); 2155 2155 int (*setattr) (struct mnt_idmap *, struct dentry *, struct iattr *); 2156 - int (*getattr) (struct user_namespace *, const struct path *, 2156 + int (*getattr) (struct mnt_idmap *, const struct path *, 2157 2157 struct kstat *, u32, unsigned int); 2158 2158 ssize_t (*listxattr) (struct dentry *, char *, size_t); 2159 2159 int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start, ··· 3261 3261 extern int page_symlink(struct inode *inode, const char *symname, int len); 3262 3262 extern const struct inode_operations page_symlink_inode_operations; 3263 3263 extern void kfree_link(void *); 3264 - void generic_fillattr(struct user_namespace *, struct inode *, struct kstat *); 3264 + void generic_fillattr(struct mnt_idmap *, struct inode *, struct kstat *); 3265 3265 void generic_fill_statx_attr(struct inode *inode, struct kstat *stat); 3266 3266 extern int vfs_getattr_nosec(const struct path *, struct kstat *, u32, unsigned int); 3267 3267 extern int vfs_getattr(const struct path *, struct kstat *, u32, unsigned int); ··· 3314 3314 extern int dcache_readdir(struct file *, struct dir_context *); 3315 3315 extern int simple_setattr(struct mnt_idmap *, struct dentry *, 3316 3316 struct iattr *); 3317 - extern int simple_getattr(struct user_namespace *, const struct path *, 3317 + extern int simple_getattr(struct mnt_idmap *, const struct path *, 3318 3318 struct kstat *, u32, unsigned int); 3319 3319 extern int simple_statfs(struct dentry *, struct kstatfs *); 3320 3320 extern int simple_open(struct inode *inode, struct file *file);
+1 -1
include/linux/nfs_fs.h
··· 392 392 extern int nfs_post_op_update_inode(struct inode *inode, struct nfs_fattr *fattr); 393 393 extern int nfs_post_op_update_inode_force_wcc(struct inode *inode, struct nfs_fattr *fattr); 394 394 extern int nfs_post_op_update_inode_force_wcc_locked(struct inode *inode, struct nfs_fattr *fattr); 395 - extern int nfs_getattr(struct user_namespace *, const struct path *, 395 + extern int nfs_getattr(struct mnt_idmap *, const struct path *, 396 396 struct kstat *, u32, unsigned int); 397 397 extern void nfs_access_add_cache(struct inode *, struct nfs_access_entry *, const struct cred *); 398 398 extern void nfs_access_set_mask(struct nfs_access_entry *, u32);
+2 -2
mm/shmem.c
··· 1047 1047 } 1048 1048 EXPORT_SYMBOL_GPL(shmem_truncate_range); 1049 1049 1050 - static int shmem_getattr(struct user_namespace *mnt_userns, 1050 + static int shmem_getattr(struct mnt_idmap *idmap, 1051 1051 const struct path *path, struct kstat *stat, 1052 1052 u32 request_mask, unsigned int query_flags) 1053 1053 { ··· 1068 1068 stat->attributes_mask |= (STATX_ATTR_APPEND | 1069 1069 STATX_ATTR_IMMUTABLE | 1070 1070 STATX_ATTR_NODUMP); 1071 - generic_fillattr(&init_user_ns, inode, stat); 1071 + generic_fillattr(&nop_mnt_idmap, inode, stat); 1072 1072 1073 1073 if (shmem_is_huge(NULL, inode, 0, false)) 1074 1074 stat->blksize = HPAGE_PMD_SIZE;