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

fs: port inode_init_owner() to 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>

+124 -143
+2 -2
arch/powerpc/platforms/cell/spufs/inode.c
··· 237 237 if (!inode) 238 238 return -ENOSPC; 239 239 240 - inode_init_owner(&init_user_ns, inode, dir, mode | S_IFDIR); 240 + inode_init_owner(&nop_mnt_idmap, inode, dir, mode | S_IFDIR); 241 241 ctx = alloc_spu_context(SPUFS_I(dir)->i_gang); /* XXX gang */ 242 242 SPUFS_I(inode)->i_ctx = ctx; 243 243 if (!ctx) { ··· 468 468 goto out; 469 469 470 470 ret = 0; 471 - inode_init_owner(&init_user_ns, inode, dir, mode | S_IFDIR); 471 + inode_init_owner(&nop_mnt_idmap, inode, dir, mode | S_IFDIR); 472 472 gang = alloc_spu_gang(); 473 473 SPUFS_I(inode)->i_ctx = NULL; 474 474 SPUFS_I(inode)->i_gang = gang;
+1 -1
fs/9p/vfs_inode.c
··· 260 260 { 261 261 int err = 0; 262 262 263 - inode_init_owner(&init_user_ns, inode, NULL, mode); 263 + inode_init_owner(&nop_mnt_idmap, inode, NULL, mode); 264 264 inode->i_blocks = 0; 265 265 inode->i_rdev = rdev; 266 266 inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
+1 -1
fs/bfs/dir.c
··· 96 96 } 97 97 set_bit(ino, info->si_imap); 98 98 info->si_freei--; 99 - inode_init_owner(&init_user_ns, inode, dir, mode); 99 + inode_init_owner(&nop_mnt_idmap, inode, dir, mode); 100 100 inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode); 101 101 inode->i_blocks = 0; 102 102 inode->i_op = &bfs_file_inops;
+1 -1
fs/btrfs/btrfs_inode.h
··· 469 469 int btrfs_create_new_inode(struct btrfs_trans_handle *trans, 470 470 struct btrfs_new_inode_args *args); 471 471 void btrfs_new_inode_args_destroy(struct btrfs_new_inode_args *args); 472 - struct inode *btrfs_new_subvol_inode(struct user_namespace *mnt_userns, 472 + struct inode *btrfs_new_subvol_inode(struct mnt_idmap *idmap, 473 473 struct inode *dir); 474 474 void btrfs_set_delalloc_extent(struct btrfs_inode *inode, struct extent_state *state, 475 475 u32 bits);
+12 -18
fs/btrfs/inode.c
··· 6727 6727 static int btrfs_mknod(struct mnt_idmap *idmap, struct inode *dir, 6728 6728 struct dentry *dentry, umode_t mode, dev_t rdev) 6729 6729 { 6730 - struct user_namespace *mnt_userns = mnt_idmap_owner(idmap); 6731 6730 struct inode *inode; 6732 6731 6733 6732 inode = new_inode(dir->i_sb); 6734 6733 if (!inode) 6735 6734 return -ENOMEM; 6736 - inode_init_owner(mnt_userns, inode, dir, mode); 6735 + inode_init_owner(idmap, inode, dir, mode); 6737 6736 inode->i_op = &btrfs_special_inode_operations; 6738 6737 init_special_inode(inode, inode->i_mode, rdev); 6739 6738 return btrfs_create_common(dir, dentry, inode); ··· 6741 6742 static int btrfs_create(struct mnt_idmap *idmap, struct inode *dir, 6742 6743 struct dentry *dentry, umode_t mode, bool excl) 6743 6744 { 6744 - struct user_namespace *mnt_userns = mnt_idmap_owner(idmap); 6745 6745 struct inode *inode; 6746 6746 6747 6747 inode = new_inode(dir->i_sb); 6748 6748 if (!inode) 6749 6749 return -ENOMEM; 6750 - inode_init_owner(mnt_userns, inode, dir, mode); 6750 + inode_init_owner(idmap, inode, dir, mode); 6751 6751 inode->i_fop = &btrfs_file_operations; 6752 6752 inode->i_op = &btrfs_file_inode_operations; 6753 6753 inode->i_mapping->a_ops = &btrfs_aops; ··· 6840 6842 static int btrfs_mkdir(struct mnt_idmap *idmap, struct inode *dir, 6841 6843 struct dentry *dentry, umode_t mode) 6842 6844 { 6843 - struct user_namespace *mnt_userns = mnt_idmap_owner(idmap); 6844 6845 struct inode *inode; 6845 6846 6846 6847 inode = new_inode(dir->i_sb); 6847 6848 if (!inode) 6848 6849 return -ENOMEM; 6849 - inode_init_owner(mnt_userns, inode, dir, S_IFDIR | mode); 6850 + inode_init_owner(idmap, inode, dir, S_IFDIR | mode); 6850 6851 inode->i_op = &btrfs_dir_inode_operations; 6851 6852 inode->i_fop = &btrfs_dir_file_operations; 6852 6853 return btrfs_create_common(dir, dentry, inode); ··· 8802 8805 return ret; 8803 8806 } 8804 8807 8805 - struct inode *btrfs_new_subvol_inode(struct user_namespace *mnt_userns, 8808 + struct inode *btrfs_new_subvol_inode(struct mnt_idmap *idmap, 8806 8809 struct inode *dir) 8807 8810 { 8808 8811 struct inode *inode; ··· 8813 8816 * Subvolumes don't inherit the sgid bit or the parent's gid if 8814 8817 * the parent's sgid bit is set. This is probably a bug. 8815 8818 */ 8816 - inode_init_owner(mnt_userns, inode, NULL, 8819 + inode_init_owner(idmap, inode, NULL, 8817 8820 S_IFDIR | (~current_umask() & S_IRWXUGO)); 8818 8821 inode->i_op = &btrfs_dir_inode_operations; 8819 8822 inode->i_fop = &btrfs_dir_file_operations; ··· 9289 9292 return ret; 9290 9293 } 9291 9294 9292 - static struct inode *new_whiteout_inode(struct user_namespace *mnt_userns, 9295 + static struct inode *new_whiteout_inode(struct mnt_idmap *idmap, 9293 9296 struct inode *dir) 9294 9297 { 9295 9298 struct inode *inode; 9296 9299 9297 9300 inode = new_inode(dir->i_sb); 9298 9301 if (inode) { 9299 - inode_init_owner(mnt_userns, inode, dir, 9302 + inode_init_owner(idmap, inode, dir, 9300 9303 S_IFCHR | WHITEOUT_MODE); 9301 9304 inode->i_op = &btrfs_special_inode_operations; 9302 9305 init_special_inode(inode, inode->i_mode, WHITEOUT_DEV); ··· 9304 9307 return inode; 9305 9308 } 9306 9309 9307 - static int btrfs_rename(struct user_namespace *mnt_userns, 9310 + static int btrfs_rename(struct mnt_idmap *idmap, 9308 9311 struct inode *old_dir, struct dentry *old_dentry, 9309 9312 struct inode *new_dir, struct dentry *new_dentry, 9310 9313 unsigned int flags) ··· 9376 9379 filemap_flush(old_inode->i_mapping); 9377 9380 9378 9381 if (flags & RENAME_WHITEOUT) { 9379 - whiteout_args.inode = new_whiteout_inode(mnt_userns, old_dir); 9382 + whiteout_args.inode = new_whiteout_inode(idmap, old_dir); 9380 9383 if (!whiteout_args.inode) 9381 9384 return -ENOMEM; 9382 9385 ret = btrfs_new_inode_prepare(&whiteout_args, &trans_num_items); ··· 9547 9550 struct dentry *old_dentry, struct inode *new_dir, 9548 9551 struct dentry *new_dentry, unsigned int flags) 9549 9552 { 9550 - struct user_namespace *mnt_userns = mnt_idmap_owner(idmap); 9551 9553 int ret; 9552 9554 9553 9555 if (flags & ~(RENAME_NOREPLACE | RENAME_EXCHANGE | RENAME_WHITEOUT)) ··· 9556 9560 ret = btrfs_rename_exchange(old_dir, old_dentry, new_dir, 9557 9561 new_dentry); 9558 9562 else 9559 - ret = btrfs_rename(mnt_userns, old_dir, old_dentry, new_dir, 9563 + ret = btrfs_rename(idmap, old_dir, old_dentry, new_dir, 9560 9564 new_dentry, flags); 9561 9565 9562 9566 btrfs_btree_balance_dirty(BTRFS_I(new_dir)->root->fs_info); ··· 9759 9763 static int btrfs_symlink(struct mnt_idmap *idmap, struct inode *dir, 9760 9764 struct dentry *dentry, const char *symname) 9761 9765 { 9762 - struct user_namespace *mnt_userns = mnt_idmap_owner(idmap); 9763 9766 struct btrfs_fs_info *fs_info = btrfs_sb(dir->i_sb); 9764 9767 struct btrfs_trans_handle *trans; 9765 9768 struct btrfs_root *root = BTRFS_I(dir)->root; ··· 9784 9789 inode = new_inode(dir->i_sb); 9785 9790 if (!inode) 9786 9791 return -ENOMEM; 9787 - inode_init_owner(mnt_userns, inode, dir, S_IFLNK | S_IRWXUGO); 9792 + inode_init_owner(idmap, inode, dir, S_IFLNK | S_IRWXUGO); 9788 9793 inode->i_op = &btrfs_symlink_inode_operations; 9789 9794 inode_nohighmem(inode); 9790 9795 inode->i_mapping->a_ops = &btrfs_aops; ··· 10092 10097 static int btrfs_tmpfile(struct mnt_idmap *idmap, struct inode *dir, 10093 10098 struct file *file, umode_t mode) 10094 10099 { 10095 - struct user_namespace *mnt_userns = mnt_idmap_owner(idmap); 10096 10100 struct btrfs_fs_info *fs_info = btrfs_sb(dir->i_sb); 10097 10101 struct btrfs_trans_handle *trans; 10098 10102 struct btrfs_root *root = BTRFS_I(dir)->root; ··· 10107 10113 inode = new_inode(dir->i_sb); 10108 10114 if (!inode) 10109 10115 return -ENOMEM; 10110 - inode_init_owner(mnt_userns, inode, dir, mode); 10116 + inode_init_owner(idmap, inode, dir, mode); 10111 10117 inode->i_fop = &btrfs_file_operations; 10112 10118 inode->i_op = &btrfs_file_inode_operations; 10113 10119 inode->i_mapping->a_ops = &btrfs_aops;
+3 -4
fs/btrfs/ioctl.c
··· 578 578 return num_items; 579 579 } 580 580 581 - static noinline int create_subvol(struct user_namespace *mnt_userns, 581 + static noinline int create_subvol(struct mnt_idmap *idmap, 582 582 struct inode *dir, struct dentry *dentry, 583 583 struct btrfs_qgroup_inherit *inherit) 584 584 { ··· 623 623 if (ret < 0) 624 624 goto out_root_item; 625 625 626 - new_inode_args.inode = btrfs_new_subvol_inode(mnt_userns, dir); 626 + new_inode_args.inode = btrfs_new_subvol_inode(idmap, dir); 627 627 if (!new_inode_args.inode) { 628 628 ret = -ENOMEM; 629 629 goto out_anon_dev; ··· 962 962 struct btrfs_fs_info *fs_info = btrfs_sb(dir->i_sb); 963 963 struct dentry *dentry; 964 964 struct fscrypt_str name_str = FSTR_INIT((char *)name, namelen); 965 - struct user_namespace *mnt_userns = mnt_idmap_owner(idmap); 966 965 int error; 967 966 968 967 error = down_write_killable_nested(&dir->i_rwsem, I_MUTEX_PARENT); ··· 994 995 if (snap_src) 995 996 error = create_snapshot(snap_src, dir, dentry, readonly, inherit); 996 997 else 997 - error = create_subvol(mnt_userns, dir, dentry, inherit); 998 + error = create_subvol(idmap, dir, dentry, inherit); 998 999 999 1000 if (!error) 1000 1001 fsnotify_mkdir(dir, dentry);
+1 -1
fs/btrfs/tests/btrfs-tests.c
··· 64 64 BTRFS_I(inode)->location.type = BTRFS_INODE_ITEM_KEY; 65 65 BTRFS_I(inode)->location.objectid = BTRFS_FIRST_FREE_OBJECTID; 66 66 BTRFS_I(inode)->location.offset = 0; 67 - inode_init_owner(&init_user_ns, inode, NULL, S_IFREG); 67 + inode_init_owner(&nop_mnt_idmap, inode, NULL, S_IFREG); 68 68 69 69 return inode; 70 70 }
+1 -1
fs/ext2/ialloc.c
··· 545 545 inode->i_uid = current_fsuid(); 546 546 inode->i_gid = dir->i_gid; 547 547 } else 548 - inode_init_owner(&init_user_ns, inode, dir, mode); 548 + inode_init_owner(&nop_mnt_idmap, inode, dir, mode); 549 549 550 550 inode->i_ino = ino; 551 551 inode->i_blocks = 0;
+4 -4
fs/ext4/ext4.h
··· 2845 2845 2846 2846 /* ialloc.c */ 2847 2847 extern int ext4_mark_inode_used(struct super_block *sb, int ino); 2848 - extern struct inode *__ext4_new_inode(struct user_namespace *, handle_t *, 2848 + extern struct inode *__ext4_new_inode(struct mnt_idmap *, handle_t *, 2849 2849 struct inode *, umode_t, 2850 2850 const struct qstr *qstr, __u32 goal, 2851 2851 uid_t *owner, __u32 i_flags, ··· 2853 2853 int nblocks); 2854 2854 2855 2855 #define ext4_new_inode(handle, dir, mode, qstr, goal, owner, i_flags) \ 2856 - __ext4_new_inode(&init_user_ns, (handle), (dir), (mode), (qstr), \ 2856 + __ext4_new_inode(&nop_mnt_idmap, (handle), (dir), (mode), (qstr), \ 2857 2857 (goal), (owner), i_flags, 0, 0, 0) 2858 - #define ext4_new_inode_start_handle(mnt_userns, dir, mode, qstr, goal, owner, \ 2858 + #define ext4_new_inode_start_handle(idmap, dir, mode, qstr, goal, owner, \ 2859 2859 type, nblocks) \ 2860 - __ext4_new_inode((mnt_userns), NULL, (dir), (mode), (qstr), (goal), (owner), \ 2860 + __ext4_new_inode((idmap), NULL, (dir), (mode), (qstr), (goal), (owner), \ 2861 2861 0, (type), __LINE__, (nblocks)) 2862 2862 2863 2863
+3 -2
fs/ext4/ialloc.c
··· 921 921 * For other inodes, search forward from the parent directory's block 922 922 * group to find a free inode. 923 923 */ 924 - struct inode *__ext4_new_inode(struct user_namespace *mnt_userns, 924 + struct inode *__ext4_new_inode(struct mnt_idmap *idmap, 925 925 handle_t *handle, struct inode *dir, 926 926 umode_t mode, const struct qstr *qstr, 927 927 __u32 goal, uid_t *owner, __u32 i_flags, ··· 943 943 ext4_group_t flex_group; 944 944 struct ext4_group_info *grp = NULL; 945 945 bool encrypt = false; 946 + struct user_namespace *mnt_userns = mnt_idmap_owner(idmap); 946 947 947 948 /* Cannot create files in a deleted directory */ 948 949 if (!dir || !dir->i_nlink) ··· 976 975 inode_fsuid_set(inode, mnt_userns); 977 976 inode->i_gid = dir->i_gid; 978 977 } else 979 - inode_init_owner(mnt_userns, inode, dir, mode); 978 + inode_init_owner(idmap, inode, dir, mode); 980 979 981 980 if (ext4_has_feature_project(sb) && 982 981 ext4_test_inode_flag(dir, EXT4_INODE_PROJINHERIT))
+10 -16
fs/ext4/namei.c
··· 2795 2795 static int ext4_create(struct mnt_idmap *idmap, struct inode *dir, 2796 2796 struct dentry *dentry, umode_t mode, bool excl) 2797 2797 { 2798 - struct user_namespace *mnt_userns = mnt_idmap_owner(idmap); 2799 2798 handle_t *handle; 2800 2799 struct inode *inode; 2801 2800 int err, credits, retries = 0; ··· 2806 2807 credits = (EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + 2807 2808 EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3); 2808 2809 retry: 2809 - inode = ext4_new_inode_start_handle(mnt_userns, dir, mode, &dentry->d_name, 2810 + inode = ext4_new_inode_start_handle(idmap, dir, mode, &dentry->d_name, 2810 2811 0, NULL, EXT4_HT_DIR, credits); 2811 2812 handle = ext4_journal_current_handle(); 2812 2813 err = PTR_ERR(inode); ··· 2830 2831 static int ext4_mknod(struct mnt_idmap *idmap, struct inode *dir, 2831 2832 struct dentry *dentry, umode_t mode, dev_t rdev) 2832 2833 { 2833 - struct user_namespace *mnt_userns = mnt_idmap_owner(idmap); 2834 2834 handle_t *handle; 2835 2835 struct inode *inode; 2836 2836 int err, credits, retries = 0; ··· 2841 2843 credits = (EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + 2842 2844 EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3); 2843 2845 retry: 2844 - inode = ext4_new_inode_start_handle(mnt_userns, dir, mode, &dentry->d_name, 2846 + inode = ext4_new_inode_start_handle(idmap, dir, mode, &dentry->d_name, 2845 2847 0, NULL, EXT4_HT_DIR, credits); 2846 2848 handle = ext4_journal_current_handle(); 2847 2849 err = PTR_ERR(inode); ··· 2864 2866 static int ext4_tmpfile(struct mnt_idmap *idmap, struct inode *dir, 2865 2867 struct file *file, umode_t mode) 2866 2868 { 2867 - struct user_namespace *mnt_userns = mnt_idmap_owner(idmap); 2868 2869 handle_t *handle; 2869 2870 struct inode *inode; 2870 2871 int err, retries = 0; ··· 2873 2876 return err; 2874 2877 2875 2878 retry: 2876 - inode = ext4_new_inode_start_handle(mnt_userns, dir, mode, 2879 + inode = ext4_new_inode_start_handle(idmap, dir, mode, 2877 2880 NULL, 0, NULL, 2878 2881 EXT4_HT_DIR, 2879 2882 EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb) + ··· 2975 2978 static int ext4_mkdir(struct mnt_idmap *idmap, struct inode *dir, 2976 2979 struct dentry *dentry, umode_t mode) 2977 2980 { 2978 - struct user_namespace *mnt_userns = mnt_idmap_owner(idmap); 2979 2981 handle_t *handle; 2980 2982 struct inode *inode; 2981 2983 int err, err2 = 0, credits, retries = 0; ··· 2989 2993 credits = (EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + 2990 2994 EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3); 2991 2995 retry: 2992 - inode = ext4_new_inode_start_handle(mnt_userns, dir, S_IFDIR | mode, 2996 + inode = ext4_new_inode_start_handle(idmap, dir, S_IFDIR | mode, 2993 2997 &dentry->d_name, 2994 2998 0, NULL, EXT4_HT_DIR, credits); 2995 2999 handle = ext4_journal_current_handle(); ··· 3342 3346 static int ext4_symlink(struct mnt_idmap *idmap, struct inode *dir, 3343 3347 struct dentry *dentry, const char *symname) 3344 3348 { 3345 - struct user_namespace *mnt_userns = mnt_idmap_owner(idmap); 3346 3349 handle_t *handle; 3347 3350 struct inode *inode; 3348 3351 int err, len = strlen(symname); ··· 3370 3375 credits = EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + 3371 3376 EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3; 3372 3377 retry: 3373 - inode = ext4_new_inode_start_handle(mnt_userns, dir, S_IFLNK|S_IRWXUGO, 3378 + inode = ext4_new_inode_start_handle(idmap, dir, S_IFLNK|S_IRWXUGO, 3374 3379 &dentry->d_name, 0, NULL, 3375 3380 EXT4_HT_DIR, credits); 3376 3381 handle = ext4_journal_current_handle(); ··· 3720 3725 } 3721 3726 } 3722 3727 3723 - static struct inode *ext4_whiteout_for_rename(struct user_namespace *mnt_userns, 3728 + static struct inode *ext4_whiteout_for_rename(struct mnt_idmap *idmap, 3724 3729 struct ext4_renament *ent, 3725 3730 int credits, handle_t **h) 3726 3731 { ··· 3735 3740 credits += (EXT4_MAXQUOTAS_TRANS_BLOCKS(ent->dir->i_sb) + 3736 3741 EXT4_XATTR_TRANS_BLOCKS + 4); 3737 3742 retry: 3738 - wh = ext4_new_inode_start_handle(mnt_userns, ent->dir, 3743 + wh = ext4_new_inode_start_handle(idmap, ent->dir, 3739 3744 S_IFCHR | WHITEOUT_MODE, 3740 3745 &ent->dentry->d_name, 0, NULL, 3741 3746 EXT4_HT_DIR, credits); ··· 3763 3768 * while new_{dentry,inode) refers to the destination dentry/inode 3764 3769 * This comes from rename(const char *oldpath, const char *newpath) 3765 3770 */ 3766 - static int ext4_rename(struct user_namespace *mnt_userns, struct inode *old_dir, 3771 + static int ext4_rename(struct mnt_idmap *idmap, struct inode *old_dir, 3767 3772 struct dentry *old_dentry, struct inode *new_dir, 3768 3773 struct dentry *new_dentry, unsigned int flags) 3769 3774 { ··· 3851 3856 goto release_bh; 3852 3857 } 3853 3858 } else { 3854 - whiteout = ext4_whiteout_for_rename(mnt_userns, &old, credits, &handle); 3859 + whiteout = ext4_whiteout_for_rename(idmap, &old, credits, &handle); 3855 3860 if (IS_ERR(whiteout)) { 3856 3861 retval = PTR_ERR(whiteout); 3857 3862 goto release_bh; ··· 4163 4168 struct inode *new_dir, struct dentry *new_dentry, 4164 4169 unsigned int flags) 4165 4170 { 4166 - struct user_namespace *mnt_userns = mnt_idmap_owner(idmap); 4167 4171 int err; 4168 4172 4169 4173 if (unlikely(ext4_forced_shutdown(EXT4_SB(old_dir->i_sb)))) ··· 4181 4187 new_dir, new_dentry); 4182 4188 } 4183 4189 4184 - return ext4_rename(mnt_userns, old_dir, old_dentry, new_dir, new_dentry, flags); 4190 + return ext4_rename(idmap, old_dir, old_dentry, new_dir, new_dentry, flags); 4185 4191 } 4186 4192 4187 4193 /*
+1 -1
fs/f2fs/f2fs.h
··· 3505 3505 int f2fs_update_extension_list(struct f2fs_sb_info *sbi, const char *name, 3506 3506 bool hot, bool set); 3507 3507 struct dentry *f2fs_get_parent(struct dentry *child); 3508 - int f2fs_get_tmpfile(struct user_namespace *mnt_userns, struct inode *dir, 3508 + int f2fs_get_tmpfile(struct mnt_idmap *idmap, struct inode *dir, 3509 3509 struct inode **new_inode); 3510 3510 3511 3511 /*
+3 -2
fs/f2fs/file.c
··· 2040 2040 static int f2fs_ioc_start_atomic_write(struct file *filp, bool truncate) 2041 2041 { 2042 2042 struct inode *inode = file_inode(filp); 2043 - struct user_namespace *mnt_userns = file_mnt_user_ns(filp); 2043 + struct mnt_idmap *idmap = file_mnt_idmap(filp); 2044 + struct user_namespace *mnt_userns = mnt_idmap_owner(idmap); 2044 2045 struct f2fs_inode_info *fi = F2FS_I(inode); 2045 2046 struct f2fs_sb_info *sbi = F2FS_I_SB(inode); 2046 2047 struct inode *pinode; ··· 2098 2097 goto out; 2099 2098 } 2100 2099 2101 - ret = f2fs_get_tmpfile(mnt_userns, pinode, &fi->cow_inode); 2100 + ret = f2fs_get_tmpfile(idmap, pinode, &fi->cow_inode); 2102 2101 iput(pinode); 2103 2102 if (ret) { 2104 2103 f2fs_up_write(&fi->i_gc_rwsem[WRITE]);
+16 -22
fs/f2fs/namei.c
··· 202 202 file_set_hot(inode); 203 203 } 204 204 205 - static struct inode *f2fs_new_inode(struct user_namespace *mnt_userns, 205 + static struct inode *f2fs_new_inode(struct mnt_idmap *idmap, 206 206 struct inode *dir, umode_t mode, 207 207 const char *name) 208 208 { ··· 225 225 226 226 nid_free = true; 227 227 228 - inode_init_owner(mnt_userns, inode, dir, mode); 228 + inode_init_owner(idmap, inode, dir, mode); 229 229 230 230 inode->i_ino = ino; 231 231 inode->i_blocks = 0; ··· 336 336 static int f2fs_create(struct mnt_idmap *idmap, struct inode *dir, 337 337 struct dentry *dentry, umode_t mode, bool excl) 338 338 { 339 - struct user_namespace *mnt_userns = mnt_idmap_owner(idmap); 340 339 struct f2fs_sb_info *sbi = F2FS_I_SB(dir); 341 340 struct inode *inode; 342 341 nid_t ino = 0; ··· 350 351 if (err) 351 352 return err; 352 353 353 - inode = f2fs_new_inode(mnt_userns, dir, mode, dentry->d_name.name); 354 + inode = f2fs_new_inode(idmap, dir, mode, dentry->d_name.name); 354 355 if (IS_ERR(inode)) 355 356 return PTR_ERR(inode); 356 357 ··· 662 663 static int f2fs_symlink(struct mnt_idmap *idmap, struct inode *dir, 663 664 struct dentry *dentry, const char *symname) 664 665 { 665 - struct user_namespace *mnt_userns = mnt_idmap_owner(idmap); 666 666 struct f2fs_sb_info *sbi = F2FS_I_SB(dir); 667 667 struct inode *inode; 668 668 size_t len = strlen(symname); ··· 682 684 if (err) 683 685 return err; 684 686 685 - inode = f2fs_new_inode(mnt_userns, dir, S_IFLNK | S_IRWXUGO, NULL); 687 + inode = f2fs_new_inode(idmap, dir, S_IFLNK | S_IRWXUGO, NULL); 686 688 if (IS_ERR(inode)) 687 689 return PTR_ERR(inode); 688 690 ··· 742 744 static int f2fs_mkdir(struct mnt_idmap *idmap, struct inode *dir, 743 745 struct dentry *dentry, umode_t mode) 744 746 { 745 - struct user_namespace *mnt_userns = mnt_idmap_owner(idmap); 746 747 struct f2fs_sb_info *sbi = F2FS_I_SB(dir); 747 748 struct inode *inode; 748 749 int err; ··· 753 756 if (err) 754 757 return err; 755 758 756 - inode = f2fs_new_inode(mnt_userns, dir, S_IFDIR | mode, NULL); 759 + inode = f2fs_new_inode(idmap, dir, S_IFDIR | mode, NULL); 757 760 if (IS_ERR(inode)) 758 761 return PTR_ERR(inode); 759 762 ··· 797 800 static int f2fs_mknod(struct mnt_idmap *idmap, struct inode *dir, 798 801 struct dentry *dentry, umode_t mode, dev_t rdev) 799 802 { 800 - struct user_namespace *mnt_userns = mnt_idmap_owner(idmap); 801 803 struct f2fs_sb_info *sbi = F2FS_I_SB(dir); 802 804 struct inode *inode; 803 805 int err = 0; ··· 810 814 if (err) 811 815 return err; 812 816 813 - inode = f2fs_new_inode(mnt_userns, dir, mode, NULL); 817 + inode = f2fs_new_inode(idmap, dir, mode, NULL); 814 818 if (IS_ERR(inode)) 815 819 return PTR_ERR(inode); 816 820 ··· 837 841 return err; 838 842 } 839 843 840 - static int __f2fs_tmpfile(struct user_namespace *mnt_userns, struct inode *dir, 844 + static int __f2fs_tmpfile(struct mnt_idmap *idmap, struct inode *dir, 841 845 struct file *file, umode_t mode, bool is_whiteout, 842 846 struct inode **new_inode) 843 847 { ··· 849 853 if (err) 850 854 return err; 851 855 852 - inode = f2fs_new_inode(mnt_userns, dir, mode, NULL); 856 + inode = f2fs_new_inode(idmap, dir, mode, NULL); 853 857 if (IS_ERR(inode)) 854 858 return PTR_ERR(inode); 855 859 ··· 910 914 static int f2fs_tmpfile(struct mnt_idmap *idmap, struct inode *dir, 911 915 struct file *file, umode_t mode) 912 916 { 913 - struct user_namespace *mnt_userns = mnt_idmap_owner(idmap); 914 917 struct f2fs_sb_info *sbi = F2FS_I_SB(dir); 915 918 int err; 916 919 ··· 918 923 if (!f2fs_is_checkpoint_ready(sbi)) 919 924 return -ENOSPC; 920 925 921 - err = __f2fs_tmpfile(mnt_userns, dir, file, mode, false, NULL); 926 + err = __f2fs_tmpfile(idmap, dir, file, mode, false, NULL); 922 927 923 928 return finish_open_simple(file, err); 924 929 } 925 930 926 - static int f2fs_create_whiteout(struct user_namespace *mnt_userns, 931 + static int f2fs_create_whiteout(struct mnt_idmap *idmap, 927 932 struct inode *dir, struct inode **whiteout) 928 933 { 929 934 if (unlikely(f2fs_cp_error(F2FS_I_SB(dir)))) 930 935 return -EIO; 931 936 932 - return __f2fs_tmpfile(mnt_userns, dir, NULL, 937 + return __f2fs_tmpfile(idmap, dir, NULL, 933 938 S_IFCHR | WHITEOUT_MODE, true, whiteout); 934 939 } 935 940 936 - int f2fs_get_tmpfile(struct user_namespace *mnt_userns, struct inode *dir, 941 + int f2fs_get_tmpfile(struct mnt_idmap *idmap, struct inode *dir, 937 942 struct inode **new_inode) 938 943 { 939 - return __f2fs_tmpfile(mnt_userns, dir, NULL, S_IFREG, false, new_inode); 944 + return __f2fs_tmpfile(idmap, dir, NULL, S_IFREG, false, new_inode); 940 945 } 941 946 942 - static int f2fs_rename(struct user_namespace *mnt_userns, struct inode *old_dir, 947 + static int f2fs_rename(struct mnt_idmap *idmap, struct inode *old_dir, 943 948 struct dentry *old_dentry, struct inode *new_dir, 944 949 struct dentry *new_dentry, unsigned int flags) 945 950 { ··· 979 984 } 980 985 981 986 if (flags & RENAME_WHITEOUT) { 982 - err = f2fs_create_whiteout(mnt_userns, old_dir, &whiteout); 987 + err = f2fs_create_whiteout(idmap, old_dir, &whiteout); 983 988 if (err) 984 989 return err; 985 990 } ··· 1300 1305 struct inode *new_dir, struct dentry *new_dentry, 1301 1306 unsigned int flags) 1302 1307 { 1303 - struct user_namespace *mnt_userns = mnt_idmap_owner(idmap); 1304 1308 int err; 1305 1309 1306 1310 if (flags & ~(RENAME_NOREPLACE | RENAME_EXCHANGE | RENAME_WHITEOUT)) ··· 1318 1324 * VFS has already handled the new dentry existence case, 1319 1325 * here, we just deal with "RENAME_NOREPLACE" as regular rename. 1320 1326 */ 1321 - return f2fs_rename(mnt_userns, old_dir, old_dentry, 1327 + return f2fs_rename(idmap, old_dir, old_dentry, 1322 1328 new_dir, new_dentry, flags); 1323 1329 } 1324 1330
+1 -1
fs/hfsplus/inode.c
··· 390 390 return NULL; 391 391 392 392 inode->i_ino = sbi->next_cnid++; 393 - inode_init_owner(&init_user_ns, inode, dir, mode); 393 + inode_init_owner(&nop_mnt_idmap, inode, dir, mode); 394 394 set_nlink(inode, 1); 395 395 inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode); 396 396
+1 -1
fs/hugetlbfs/inode.c
··· 980 980 struct hugetlbfs_inode_info *info = HUGETLBFS_I(inode); 981 981 982 982 inode->i_ino = get_next_ino(); 983 - inode_init_owner(&init_user_ns, inode, dir, mode); 983 + inode_init_owner(&nop_mnt_idmap, inode, dir, mode); 984 984 lockdep_set_class(&inode->i_mapping->i_mmap_rwsem, 985 985 &hugetlbfs_i_mmap_rwsem_key); 986 986 inode->i_mapping->a_ops = &hugetlbfs_aops;
+8 -6
fs/inode.c
··· 2279 2279 2280 2280 /** 2281 2281 * inode_init_owner - Init uid,gid,mode for new inode according to posix standards 2282 - * @mnt_userns: User namespace of the mount the inode was created from 2282 + * @idmap: idmap of the mount the inode was created from 2283 2283 * @inode: New inode 2284 2284 * @dir: Directory inode 2285 2285 * @mode: mode of the new inode 2286 2286 * 2287 - * If the inode has been created through an idmapped mount the user namespace of 2288 - * the vfsmount must be passed through @mnt_userns. This function will then take 2289 - * care to map the inode according to @mnt_userns before checking permissions 2287 + * If the inode has been created through an idmapped mount the idmap of 2288 + * the vfsmount must be passed through @idmap. This function will then take 2289 + * care to map the inode according to @idmap before checking permissions 2290 2290 * and initializing i_uid and i_gid. On non-idmapped mounts or if permission 2291 - * checking is to be performed on the raw inode simply passs init_user_ns. 2291 + * checking is to be performed on the raw inode simply pass @nop_mnt_idmap. 2292 2292 */ 2293 - void inode_init_owner(struct user_namespace *mnt_userns, struct inode *inode, 2293 + void inode_init_owner(struct mnt_idmap *idmap, struct inode *inode, 2294 2294 const struct inode *dir, umode_t mode) 2295 2295 { 2296 + struct user_namespace *mnt_userns = mnt_idmap_owner(idmap); 2297 + 2296 2298 inode_fsuid_set(inode, mnt_userns); 2297 2299 if (dir && dir->i_mode & S_ISGID) { 2298 2300 inode->i_gid = dir->i_gid;
+1 -1
fs/jfs/jfs_inode.c
··· 64 64 goto fail_put; 65 65 } 66 66 67 - inode_init_owner(&init_user_ns, inode, parent, mode); 67 + inode_init_owner(&nop_mnt_idmap, inode, parent, mode); 68 68 /* 69 69 * New inodes need to save sane values on disk when 70 70 * uid & gid mount options are used
+1 -1
fs/minix/bitmap.c
··· 252 252 iput(inode); 253 253 return NULL; 254 254 } 255 - inode_init_owner(&init_user_ns, inode, dir, mode); 255 + inode_init_owner(&nop_mnt_idmap, inode, dir, mode); 256 256 inode->i_ino = j; 257 257 inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode); 258 258 inode->i_blocks = 0;
+1 -1
fs/nilfs2/inode.c
··· 364 364 ii->i_bh = bh; 365 365 366 366 atomic64_inc(&root->inodes_count); 367 - inode_init_owner(&init_user_ns, inode, dir, mode); 367 + inode_init_owner(&nop_mnt_idmap, inode, dir, mode); 368 368 inode->i_ino = ino; 369 369 inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode); 370 370
+1 -2
fs/ntfs3/inode.c
··· 1192 1192 struct ntfs_fnd *fnd) 1193 1193 { 1194 1194 int err; 1195 - struct user_namespace *mnt_userns = mnt_idmap_owner(idmap); 1196 1195 struct super_block *sb = dir->i_sb; 1197 1196 struct ntfs_sb_info *sbi = sb->s_fs_info; 1198 1197 const struct qstr *name = &dentry->d_name; ··· 1307 1308 goto out3; 1308 1309 } 1309 1310 inode = &ni->vfs_inode; 1310 - inode_init_owner(mnt_userns, inode, dir, mode); 1311 + inode_init_owner(idmap, inode, dir, mode); 1311 1312 mode = inode->i_mode; 1312 1313 1313 1314 inode->i_atime = inode->i_mtime = inode->i_ctime = ni->i_crtime =
+2 -2
fs/ocfs2/dlmfs/dlmfs.c
··· 336 336 337 337 if (inode) { 338 338 inode->i_ino = get_next_ino(); 339 - inode_init_owner(&init_user_ns, inode, NULL, mode); 339 + inode_init_owner(&nop_mnt_idmap, inode, NULL, mode); 340 340 inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); 341 341 inc_nlink(inode); 342 342 ··· 359 359 return NULL; 360 360 361 361 inode->i_ino = get_next_ino(); 362 - inode_init_owner(&init_user_ns, inode, parent, mode); 362 + inode_init_owner(&nop_mnt_idmap, inode, parent, mode); 363 363 inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); 364 364 365 365 ip = DLMFS_I(inode);
+1 -1
fs/ocfs2/namei.c
··· 198 198 if (S_ISDIR(mode)) 199 199 set_nlink(inode, 2); 200 200 mode = mode_strip_sgid(&init_user_ns, dir, mode); 201 - inode_init_owner(&init_user_ns, inode, dir, mode); 201 + inode_init_owner(&nop_mnt_idmap, inode, dir, mode); 202 202 status = dquot_initialize(inode); 203 203 if (status) 204 204 return ERR_PTR(status);
+1 -1
fs/omfs/inode.c
··· 48 48 goto fail; 49 49 50 50 inode->i_ino = new_block; 51 - inode_init_owner(&init_user_ns, inode, NULL, mode); 51 + inode_init_owner(&nop_mnt_idmap, inode, NULL, mode); 52 52 inode->i_mapping->a_ops = &omfs_aops; 53 53 54 54 inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
+1 -1
fs/overlayfs/dir.c
··· 641 641 inode->i_state |= I_CREATING; 642 642 spin_unlock(&inode->i_lock); 643 643 644 - inode_init_owner(&init_user_ns, inode, dentry->d_parent->d_inode, mode); 644 + inode_init_owner(&nop_mnt_idmap, inode, dentry->d_parent->d_inode, mode); 645 645 attr.mode = inode->i_mode; 646 646 647 647 err = ovl_create_or_link(dentry, inode, &attr, false);
+1 -1
fs/ramfs/inode.c
··· 61 61 62 62 if (inode) { 63 63 inode->i_ino = get_next_ino(); 64 - inode_init_owner(&init_user_ns, inode, dir, mode); 64 + inode_init_owner(&nop_mnt_idmap, inode, dir, mode); 65 65 inode->i_mapping->a_ops = &ram_aops; 66 66 mapping_set_gfp_mask(inode->i_mapping, GFP_HIGHUSER); 67 67 mapping_set_unevictable(inode->i_mapping);
+1 -1
fs/reiserfs/namei.c
··· 616 616 * the quota init calls have to know who to charge the quota to, so 617 617 * we have to set uid and gid here 618 618 */ 619 - inode_init_owner(&init_user_ns, inode, dir, mode); 619 + inode_init_owner(&nop_mnt_idmap, inode, dir, mode); 620 620 return dquot_initialize(inode); 621 621 } 622 622
+1 -1
fs/sysv/ialloc.c
··· 163 163 *sbi->s_sb_fic_count = cpu_to_fs16(sbi, count); 164 164 fs16_add(sbi, sbi->s_sb_total_free_inodes, -1); 165 165 dirty_sb(sb); 166 - inode_init_owner(&init_user_ns, inode, dir, mode); 166 + inode_init_owner(&nop_mnt_idmap, inode, dir, mode); 167 167 inode->i_ino = fs16_to_cpu(sbi, ino); 168 168 inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode); 169 169 inode->i_blocks = 0;
+1 -1
fs/ubifs/dir.c
··· 95 95 */ 96 96 inode->i_flags |= S_NOCMTIME; 97 97 98 - inode_init_owner(&init_user_ns, inode, dir, mode); 98 + inode_init_owner(&nop_mnt_idmap, inode, dir, mode); 99 99 inode->i_mtime = inode->i_atime = inode->i_ctime = 100 100 current_time(inode); 101 101 inode->i_mapping->nrpages = 0;
+1 -1
fs/udf/ialloc.c
··· 105 105 mutex_unlock(&sbi->s_alloc_mutex); 106 106 } 107 107 108 - inode_init_owner(&init_user_ns, inode, dir, mode); 108 + inode_init_owner(&nop_mnt_idmap, inode, dir, mode); 109 109 if (UDF_QUERY_FLAG(sb, UDF_FLAG_UID_SET)) 110 110 inode->i_uid = sbi->s_uid; 111 111 if (UDF_QUERY_FLAG(sb, UDF_FLAG_GID_SET))
+1 -1
fs/ufs/ialloc.c
··· 289 289 ufs_mark_sb_dirty(sb); 290 290 291 291 inode->i_ino = cg * uspi->s_ipg + bit; 292 - inode_init_owner(&init_user_ns, inode, dir, mode); 292 + inode_init_owner(&nop_mnt_idmap, inode, dir, mode); 293 293 inode->i_blocks = 0; 294 294 inode->i_generation = 0; 295 295 inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
+13 -10
fs/xfs/xfs_inode.c
··· 777 777 */ 778 778 int 779 779 xfs_init_new_inode( 780 - struct user_namespace *mnt_userns, 780 + struct mnt_idmap *idmap, 781 781 struct xfs_trans *tp, 782 782 struct xfs_inode *pip, 783 783 xfs_ino_t ino, ··· 788 788 bool init_xattrs, 789 789 struct xfs_inode **ipp) 790 790 { 791 + struct user_namespace *mnt_userns = mnt_idmap_owner(idmap); 791 792 struct inode *dir = pip ? VFS_I(pip) : NULL; 792 793 struct xfs_mount *mp = tp->t_mountp; 793 794 struct xfs_inode *ip; ··· 828 827 inode->i_gid = dir->i_gid; 829 828 inode->i_mode = mode; 830 829 } else { 831 - inode_init_owner(mnt_userns, inode, dir, mode); 830 + inode_init_owner(idmap, inode, dir, mode); 832 831 } 833 832 834 833 /* ··· 947 946 948 947 int 949 948 xfs_create( 950 - struct user_namespace *mnt_userns, 949 + struct mnt_idmap *idmap, 951 950 xfs_inode_t *dp, 952 951 struct xfs_name *name, 953 952 umode_t mode, ··· 955 954 bool init_xattrs, 956 955 xfs_inode_t **ipp) 957 956 { 957 + struct user_namespace *mnt_userns = mnt_idmap_owner(idmap); 958 958 int is_dir = S_ISDIR(mode); 959 959 struct xfs_mount *mp = dp->i_mount; 960 960 struct xfs_inode *ip = NULL; ··· 1022 1020 */ 1023 1021 error = xfs_dialloc(&tp, dp->i_ino, mode, &ino); 1024 1022 if (!error) 1025 - error = xfs_init_new_inode(mnt_userns, tp, dp, ino, mode, 1023 + error = xfs_init_new_inode(idmap, tp, dp, ino, mode, 1026 1024 is_dir ? 2 : 1, rdev, prid, init_xattrs, &ip); 1027 1025 if (error) 1028 1026 goto out_trans_cancel; ··· 1104 1102 1105 1103 int 1106 1104 xfs_create_tmpfile( 1107 - struct user_namespace *mnt_userns, 1105 + struct mnt_idmap *idmap, 1108 1106 struct xfs_inode *dp, 1109 1107 umode_t mode, 1110 1108 struct xfs_inode **ipp) 1111 1109 { 1110 + struct user_namespace *mnt_userns = mnt_idmap_owner(idmap); 1112 1111 struct xfs_mount *mp = dp->i_mount; 1113 1112 struct xfs_inode *ip = NULL; 1114 1113 struct xfs_trans *tp = NULL; ··· 1147 1144 1148 1145 error = xfs_dialloc(&tp, dp->i_ino, mode, &ino); 1149 1146 if (!error) 1150 - error = xfs_init_new_inode(mnt_userns, tp, dp, ino, mode, 1147 + error = xfs_init_new_inode(idmap, tp, dp, ino, mode, 1151 1148 0, 0, prid, false, &ip); 1152 1149 if (error) 1153 1150 goto out_trans_cancel; ··· 2712 2709 */ 2713 2710 static int 2714 2711 xfs_rename_alloc_whiteout( 2715 - struct user_namespace *mnt_userns, 2712 + struct mnt_idmap *idmap, 2716 2713 struct xfs_name *src_name, 2717 2714 struct xfs_inode *dp, 2718 2715 struct xfs_inode **wip) ··· 2721 2718 struct qstr name; 2722 2719 int error; 2723 2720 2724 - error = xfs_create_tmpfile(mnt_userns, dp, S_IFCHR | WHITEOUT_MODE, 2721 + error = xfs_create_tmpfile(idmap, dp, S_IFCHR | WHITEOUT_MODE, 2725 2722 &tmpfile); 2726 2723 if (error) 2727 2724 return error; ··· 2753 2750 */ 2754 2751 int 2755 2752 xfs_rename( 2756 - struct user_namespace *mnt_userns, 2753 + struct mnt_idmap *idmap, 2757 2754 struct xfs_inode *src_dp, 2758 2755 struct xfs_name *src_name, 2759 2756 struct xfs_inode *src_ip, ··· 2785 2782 * appropriately. 2786 2783 */ 2787 2784 if (flags & RENAME_WHITEOUT) { 2788 - error = xfs_rename_alloc_whiteout(mnt_userns, src_name, 2785 + error = xfs_rename_alloc_whiteout(idmap, src_name, 2789 2786 target_dp, &wip); 2790 2787 if (error) 2791 2788 return error;
+4 -4
fs/xfs/xfs_inode.h
··· 473 473 void xfs_inactive(struct xfs_inode *ip); 474 474 int xfs_lookup(struct xfs_inode *dp, const struct xfs_name *name, 475 475 struct xfs_inode **ipp, struct xfs_name *ci_name); 476 - int xfs_create(struct user_namespace *mnt_userns, 476 + int xfs_create(struct mnt_idmap *idmap, 477 477 struct xfs_inode *dp, struct xfs_name *name, 478 478 umode_t mode, dev_t rdev, bool need_xattr, 479 479 struct xfs_inode **ipp); 480 - int xfs_create_tmpfile(struct user_namespace *mnt_userns, 480 + int xfs_create_tmpfile(struct mnt_idmap *idmap, 481 481 struct xfs_inode *dp, umode_t mode, 482 482 struct xfs_inode **ipp); 483 483 int xfs_remove(struct xfs_inode *dp, struct xfs_name *name, 484 484 struct xfs_inode *ip); 485 485 int xfs_link(struct xfs_inode *tdp, struct xfs_inode *sip, 486 486 struct xfs_name *target_name); 487 - int xfs_rename(struct user_namespace *mnt_userns, 487 + int xfs_rename(struct mnt_idmap *idmap, 488 488 struct xfs_inode *src_dp, struct xfs_name *src_name, 489 489 struct xfs_inode *src_ip, struct xfs_inode *target_dp, 490 490 struct xfs_name *target_name, ··· 515 515 xfs_extlen_t xfs_get_extsz_hint(struct xfs_inode *ip); 516 516 xfs_extlen_t xfs_get_cowextsz_hint(struct xfs_inode *ip); 517 517 518 - int xfs_init_new_inode(struct user_namespace *mnt_userns, struct xfs_trans *tp, 518 + int xfs_init_new_inode(struct mnt_idmap *idmap, struct xfs_trans *tp, 519 519 struct xfs_inode *pip, xfs_ino_t ino, umode_t mode, 520 520 xfs_nlink_t nlink, dev_t rdev, prid_t prid, bool init_xattrs, 521 521 struct xfs_inode **ipp);
+14 -21
fs/xfs/xfs_iops.c
··· 162 162 163 163 STATIC int 164 164 xfs_generic_create( 165 - struct user_namespace *mnt_userns, 166 - struct inode *dir, 167 - struct dentry *dentry, 168 - umode_t mode, 169 - dev_t rdev, 170 - struct file *tmpfile) /* unnamed file */ 165 + struct mnt_idmap *idmap, 166 + struct inode *dir, 167 + struct dentry *dentry, 168 + umode_t mode, 169 + dev_t rdev, 170 + struct file *tmpfile) /* unnamed file */ 171 171 { 172 172 struct inode *inode; 173 173 struct xfs_inode *ip = NULL; ··· 196 196 goto out_free_acl; 197 197 198 198 if (!tmpfile) { 199 - error = xfs_create(mnt_userns, XFS_I(dir), &name, mode, rdev, 199 + error = xfs_create(idmap, XFS_I(dir), &name, mode, rdev, 200 200 xfs_create_need_xattr(dir, default_acl, acl), 201 201 &ip); 202 202 } else { 203 - error = xfs_create_tmpfile(mnt_userns, XFS_I(dir), mode, &ip); 203 + error = xfs_create_tmpfile(idmap, XFS_I(dir), mode, &ip); 204 204 } 205 205 if (unlikely(error)) 206 206 goto out_free_acl; ··· 261 261 umode_t mode, 262 262 dev_t rdev) 263 263 { 264 - return xfs_generic_create(mnt_idmap_owner(idmap), dir, dentry, mode, 265 - rdev, NULL); 264 + return xfs_generic_create(idmap, dir, dentry, mode, rdev, NULL); 266 265 } 267 266 268 267 STATIC int ··· 272 273 umode_t mode, 273 274 bool flags) 274 275 { 275 - struct user_namespace *mnt_userns = mnt_idmap_owner(idmap); 276 - return xfs_generic_create(mnt_userns, dir, dentry, mode, 0, NULL); 276 + return xfs_generic_create(idmap, dir, dentry, mode, 0, NULL); 277 277 } 278 278 279 279 STATIC int ··· 282 284 struct dentry *dentry, 283 285 umode_t mode) 284 286 { 285 - return xfs_generic_create(mnt_idmap_owner(idmap), dir, dentry, 286 - mode | S_IFDIR, 0, NULL); 287 + return xfs_generic_create(idmap, dir, dentry, mode | S_IFDIR, 0, NULL); 287 288 } 288 289 289 290 STATIC struct dentry * ··· 404 407 struct dentry *dentry, 405 408 const char *symname) 406 409 { 407 - struct user_namespace *mnt_userns = mnt_idmap_owner(idmap); 408 410 struct inode *inode; 409 411 struct xfs_inode *cip = NULL; 410 412 struct xfs_name name; ··· 416 420 if (unlikely(error)) 417 421 goto out; 418 422 419 - error = xfs_symlink(mnt_userns, XFS_I(dir), &name, symname, mode, &cip); 423 + error = xfs_symlink(idmap, XFS_I(dir), &name, symname, mode, &cip); 420 424 if (unlikely(error)) 421 425 goto out; 422 426 ··· 449 453 struct dentry *ndentry, 450 454 unsigned int flags) 451 455 { 452 - struct user_namespace *mnt_userns = mnt_idmap_owner(idmap); 453 456 struct inode *new_inode = d_inode(ndentry); 454 457 int omode = 0; 455 458 int error; ··· 471 476 if (unlikely(error)) 472 477 return error; 473 478 474 - return xfs_rename(mnt_userns, XFS_I(odir), &oname, 479 + return xfs_rename(idmap, XFS_I(odir), &oname, 475 480 XFS_I(d_inode(odentry)), XFS_I(ndir), &nname, 476 481 new_inode ? XFS_I(new_inode) : NULL, flags); 477 482 } ··· 1098 1103 struct file *file, 1099 1104 umode_t mode) 1100 1105 { 1101 - struct user_namespace *mnt_userns = mnt_idmap_owner(idmap); 1102 - 1103 - int err = xfs_generic_create(mnt_userns, dir, file->f_path.dentry, mode, 0, file); 1106 + int err = xfs_generic_create(idmap, dir, file->f_path.dentry, mode, 0, file); 1104 1107 1105 1108 return finish_open_simple(file, err); 1106 1109 }
+1 -1
fs/xfs/xfs_qm.c
··· 787 787 788 788 error = xfs_dialloc(&tp, 0, S_IFREG, &ino); 789 789 if (!error) 790 - error = xfs_init_new_inode(&init_user_ns, tp, NULL, ino, 790 + error = xfs_init_new_inode(&nop_mnt_idmap, tp, NULL, ino, 791 791 S_IFREG, 1, 0, 0, false, ipp); 792 792 if (error) { 793 793 xfs_trans_cancel(tp);
+3 -2
fs/xfs/xfs_symlink.c
··· 144 144 145 145 int 146 146 xfs_symlink( 147 - struct user_namespace *mnt_userns, 147 + struct mnt_idmap *idmap, 148 148 struct xfs_inode *dp, 149 149 struct xfs_name *link_name, 150 150 const char *target_path, 151 151 umode_t mode, 152 152 struct xfs_inode **ipp) 153 153 { 154 + struct user_namespace *mnt_userns = mnt_idmap_owner(idmap); 154 155 struct xfs_mount *mp = dp->i_mount; 155 156 struct xfs_trans *tp = NULL; 156 157 struct xfs_inode *ip = NULL; ··· 232 231 */ 233 232 error = xfs_dialloc(&tp, dp->i_ino, S_IFLNK, &ino); 234 233 if (!error) 235 - error = xfs_init_new_inode(mnt_userns, tp, dp, ino, 234 + error = xfs_init_new_inode(idmap, tp, dp, ino, 236 235 S_IFLNK | (mode & ~S_IFMT), 1, 0, prid, 237 236 false, &ip); 238 237 if (error)
+1 -1
fs/xfs/xfs_symlink.h
··· 7 7 8 8 /* Kernel only symlink definitions */ 9 9 10 - int xfs_symlink(struct user_namespace *mnt_userns, struct xfs_inode *dp, 10 + int xfs_symlink(struct mnt_idmap *idmap, struct xfs_inode *dp, 11 11 struct xfs_name *link_name, const char *target_path, 12 12 umode_t mode, struct xfs_inode **ipp); 13 13 int xfs_readlink_bmap_ilocked(struct xfs_inode *ip, char *link);
+1 -1
fs/zonefs/super.c
··· 1405 1405 struct super_block *sb = parent->i_sb; 1406 1406 1407 1407 inode->i_ino = bdev_nr_zones(sb->s_bdev) + type + 1; 1408 - inode_init_owner(&init_user_ns, inode, parent, S_IFDIR | 0555); 1408 + inode_init_owner(&nop_mnt_idmap, inode, parent, S_IFDIR | 0555); 1409 1409 inode->i_op = &zonefs_dir_inode_operations; 1410 1410 inode->i_fop = &simple_dir_operations; 1411 1411 set_nlink(inode, 2);
+1 -1
include/linux/fs.h
··· 2014 2014 /* 2015 2015 * VFS file helper functions. 2016 2016 */ 2017 - void inode_init_owner(struct user_namespace *mnt_userns, struct inode *inode, 2017 + void inode_init_owner(struct mnt_idmap *idmap, struct inode *inode, 2018 2018 const struct inode *dir, umode_t mode); 2019 2019 extern bool may_open_dev(const struct path *path); 2020 2020 umode_t mode_strip_sgid(struct user_namespace *mnt_userns,
+1 -1
kernel/bpf/inode.c
··· 122 122 inode->i_mtime = inode->i_atime; 123 123 inode->i_ctime = inode->i_atime; 124 124 125 - inode_init_owner(&init_user_ns, inode, dir, mode); 125 + inode_init_owner(&nop_mnt_idmap, inode, dir, mode); 126 126 127 127 return inode; 128 128 }
+1 -1
mm/shmem.c
··· 2343 2343 inode = new_inode(sb); 2344 2344 if (inode) { 2345 2345 inode->i_ino = ino; 2346 - inode_init_owner(&init_user_ns, inode, dir, mode); 2346 + inode_init_owner(&nop_mnt_idmap, inode, dir, mode); 2347 2347 inode->i_blocks = 0; 2348 2348 inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); 2349 2349 inode->i_generation = get_random_u32();