mirror of
https://github.com/torvalds/linux.git
synced 2024-11-24 21:21:41 +00:00
fs: port inode_init_owner() to mnt_idmap
Convert to struct mnt_idmap.
Last cycle we merged the necessary infrastructure in
256c8aed2b
("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>
This commit is contained in:
parent
700b794052
commit
f2d40141d5
@ -237,7 +237,7 @@ spufs_mkdir(struct inode *dir, struct dentry *dentry, unsigned int flags,
|
||||
if (!inode)
|
||||
return -ENOSPC;
|
||||
|
||||
inode_init_owner(&init_user_ns, inode, dir, mode | S_IFDIR);
|
||||
inode_init_owner(&nop_mnt_idmap, inode, dir, mode | S_IFDIR);
|
||||
ctx = alloc_spu_context(SPUFS_I(dir)->i_gang); /* XXX gang */
|
||||
SPUFS_I(inode)->i_ctx = ctx;
|
||||
if (!ctx) {
|
||||
@ -468,7 +468,7 @@ spufs_mkgang(struct inode *dir, struct dentry *dentry, umode_t mode)
|
||||
goto out;
|
||||
|
||||
ret = 0;
|
||||
inode_init_owner(&init_user_ns, inode, dir, mode | S_IFDIR);
|
||||
inode_init_owner(&nop_mnt_idmap, inode, dir, mode | S_IFDIR);
|
||||
gang = alloc_spu_gang();
|
||||
SPUFS_I(inode)->i_ctx = NULL;
|
||||
SPUFS_I(inode)->i_gang = gang;
|
||||
|
@ -260,7 +260,7 @@ int v9fs_init_inode(struct v9fs_session_info *v9ses,
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
inode_init_owner(&init_user_ns, inode, NULL, mode);
|
||||
inode_init_owner(&nop_mnt_idmap, inode, NULL, mode);
|
||||
inode->i_blocks = 0;
|
||||
inode->i_rdev = rdev;
|
||||
inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
|
||||
|
@ -96,7 +96,7 @@ static int bfs_create(struct mnt_idmap *idmap, struct inode *dir,
|
||||
}
|
||||
set_bit(ino, info->si_imap);
|
||||
info->si_freei--;
|
||||
inode_init_owner(&init_user_ns, inode, dir, mode);
|
||||
inode_init_owner(&nop_mnt_idmap, inode, dir, mode);
|
||||
inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
|
||||
inode->i_blocks = 0;
|
||||
inode->i_op = &bfs_file_inops;
|
||||
|
@ -469,7 +469,7 @@ int btrfs_new_inode_prepare(struct btrfs_new_inode_args *args,
|
||||
int btrfs_create_new_inode(struct btrfs_trans_handle *trans,
|
||||
struct btrfs_new_inode_args *args);
|
||||
void btrfs_new_inode_args_destroy(struct btrfs_new_inode_args *args);
|
||||
struct inode *btrfs_new_subvol_inode(struct user_namespace *mnt_userns,
|
||||
struct inode *btrfs_new_subvol_inode(struct mnt_idmap *idmap,
|
||||
struct inode *dir);
|
||||
void btrfs_set_delalloc_extent(struct btrfs_inode *inode, struct extent_state *state,
|
||||
u32 bits);
|
||||
|
@ -6727,13 +6727,12 @@ out_inode:
|
||||
static int btrfs_mknod(struct mnt_idmap *idmap, struct inode *dir,
|
||||
struct dentry *dentry, umode_t mode, dev_t rdev)
|
||||
{
|
||||
struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
|
||||
struct inode *inode;
|
||||
|
||||
inode = new_inode(dir->i_sb);
|
||||
if (!inode)
|
||||
return -ENOMEM;
|
||||
inode_init_owner(mnt_userns, inode, dir, mode);
|
||||
inode_init_owner(idmap, inode, dir, mode);
|
||||
inode->i_op = &btrfs_special_inode_operations;
|
||||
init_special_inode(inode, inode->i_mode, rdev);
|
||||
return btrfs_create_common(dir, dentry, inode);
|
||||
@ -6742,13 +6741,12 @@ static int btrfs_mknod(struct mnt_idmap *idmap, struct inode *dir,
|
||||
static int btrfs_create(struct mnt_idmap *idmap, struct inode *dir,
|
||||
struct dentry *dentry, umode_t mode, bool excl)
|
||||
{
|
||||
struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
|
||||
struct inode *inode;
|
||||
|
||||
inode = new_inode(dir->i_sb);
|
||||
if (!inode)
|
||||
return -ENOMEM;
|
||||
inode_init_owner(mnt_userns, inode, dir, mode);
|
||||
inode_init_owner(idmap, inode, dir, mode);
|
||||
inode->i_fop = &btrfs_file_operations;
|
||||
inode->i_op = &btrfs_file_inode_operations;
|
||||
inode->i_mapping->a_ops = &btrfs_aops;
|
||||
@ -6842,13 +6840,12 @@ fail:
|
||||
static int btrfs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
|
||||
struct dentry *dentry, umode_t mode)
|
||||
{
|
||||
struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
|
||||
struct inode *inode;
|
||||
|
||||
inode = new_inode(dir->i_sb);
|
||||
if (!inode)
|
||||
return -ENOMEM;
|
||||
inode_init_owner(mnt_userns, inode, dir, S_IFDIR | mode);
|
||||
inode_init_owner(idmap, inode, dir, S_IFDIR | mode);
|
||||
inode->i_op = &btrfs_dir_inode_operations;
|
||||
inode->i_fop = &btrfs_dir_file_operations;
|
||||
return btrfs_create_common(dir, dentry, inode);
|
||||
@ -8805,7 +8802,7 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
struct inode *btrfs_new_subvol_inode(struct user_namespace *mnt_userns,
|
||||
struct inode *btrfs_new_subvol_inode(struct mnt_idmap *idmap,
|
||||
struct inode *dir)
|
||||
{
|
||||
struct inode *inode;
|
||||
@ -8816,7 +8813,7 @@ struct inode *btrfs_new_subvol_inode(struct user_namespace *mnt_userns,
|
||||
* Subvolumes don't inherit the sgid bit or the parent's gid if
|
||||
* the parent's sgid bit is set. This is probably a bug.
|
||||
*/
|
||||
inode_init_owner(mnt_userns, inode, NULL,
|
||||
inode_init_owner(idmap, inode, NULL,
|
||||
S_IFDIR | (~current_umask() & S_IRWXUGO));
|
||||
inode->i_op = &btrfs_dir_inode_operations;
|
||||
inode->i_fop = &btrfs_dir_file_operations;
|
||||
@ -9292,14 +9289,14 @@ out_notrans:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static struct inode *new_whiteout_inode(struct user_namespace *mnt_userns,
|
||||
static struct inode *new_whiteout_inode(struct mnt_idmap *idmap,
|
||||
struct inode *dir)
|
||||
{
|
||||
struct inode *inode;
|
||||
|
||||
inode = new_inode(dir->i_sb);
|
||||
if (inode) {
|
||||
inode_init_owner(mnt_userns, inode, dir,
|
||||
inode_init_owner(idmap, inode, dir,
|
||||
S_IFCHR | WHITEOUT_MODE);
|
||||
inode->i_op = &btrfs_special_inode_operations;
|
||||
init_special_inode(inode, inode->i_mode, WHITEOUT_DEV);
|
||||
@ -9307,7 +9304,7 @@ static struct inode *new_whiteout_inode(struct user_namespace *mnt_userns,
|
||||
return inode;
|
||||
}
|
||||
|
||||
static int btrfs_rename(struct user_namespace *mnt_userns,
|
||||
static int btrfs_rename(struct mnt_idmap *idmap,
|
||||
struct inode *old_dir, struct dentry *old_dentry,
|
||||
struct inode *new_dir, struct dentry *new_dentry,
|
||||
unsigned int flags)
|
||||
@ -9379,7 +9376,7 @@ static int btrfs_rename(struct user_namespace *mnt_userns,
|
||||
filemap_flush(old_inode->i_mapping);
|
||||
|
||||
if (flags & RENAME_WHITEOUT) {
|
||||
whiteout_args.inode = new_whiteout_inode(mnt_userns, old_dir);
|
||||
whiteout_args.inode = new_whiteout_inode(idmap, old_dir);
|
||||
if (!whiteout_args.inode)
|
||||
return -ENOMEM;
|
||||
ret = btrfs_new_inode_prepare(&whiteout_args, &trans_num_items);
|
||||
@ -9550,7 +9547,6 @@ static int btrfs_rename2(struct mnt_idmap *idmap, struct inode *old_dir,
|
||||
struct dentry *old_dentry, struct inode *new_dir,
|
||||
struct dentry *new_dentry, unsigned int flags)
|
||||
{
|
||||
struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
|
||||
int ret;
|
||||
|
||||
if (flags & ~(RENAME_NOREPLACE | RENAME_EXCHANGE | RENAME_WHITEOUT))
|
||||
@ -9560,7 +9556,7 @@ static int btrfs_rename2(struct mnt_idmap *idmap, struct inode *old_dir,
|
||||
ret = btrfs_rename_exchange(old_dir, old_dentry, new_dir,
|
||||
new_dentry);
|
||||
else
|
||||
ret = btrfs_rename(mnt_userns, old_dir, old_dentry, new_dir,
|
||||
ret = btrfs_rename(idmap, old_dir, old_dentry, new_dir,
|
||||
new_dentry, flags);
|
||||
|
||||
btrfs_btree_balance_dirty(BTRFS_I(new_dir)->root->fs_info);
|
||||
@ -9763,7 +9759,6 @@ out:
|
||||
static int btrfs_symlink(struct mnt_idmap *idmap, struct inode *dir,
|
||||
struct dentry *dentry, const char *symname)
|
||||
{
|
||||
struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
|
||||
struct btrfs_fs_info *fs_info = btrfs_sb(dir->i_sb);
|
||||
struct btrfs_trans_handle *trans;
|
||||
struct btrfs_root *root = BTRFS_I(dir)->root;
|
||||
@ -9789,7 +9784,7 @@ static int btrfs_symlink(struct mnt_idmap *idmap, struct inode *dir,
|
||||
inode = new_inode(dir->i_sb);
|
||||
if (!inode)
|
||||
return -ENOMEM;
|
||||
inode_init_owner(mnt_userns, inode, dir, S_IFLNK | S_IRWXUGO);
|
||||
inode_init_owner(idmap, inode, dir, S_IFLNK | S_IRWXUGO);
|
||||
inode->i_op = &btrfs_symlink_inode_operations;
|
||||
inode_nohighmem(inode);
|
||||
inode->i_mapping->a_ops = &btrfs_aops;
|
||||
@ -10097,7 +10092,6 @@ static int btrfs_permission(struct mnt_idmap *idmap,
|
||||
static int btrfs_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
|
||||
struct file *file, umode_t mode)
|
||||
{
|
||||
struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
|
||||
struct btrfs_fs_info *fs_info = btrfs_sb(dir->i_sb);
|
||||
struct btrfs_trans_handle *trans;
|
||||
struct btrfs_root *root = BTRFS_I(dir)->root;
|
||||
@ -10113,7 +10107,7 @@ static int btrfs_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
|
||||
inode = new_inode(dir->i_sb);
|
||||
if (!inode)
|
||||
return -ENOMEM;
|
||||
inode_init_owner(mnt_userns, inode, dir, mode);
|
||||
inode_init_owner(idmap, inode, dir, mode);
|
||||
inode->i_fop = &btrfs_file_operations;
|
||||
inode->i_op = &btrfs_file_inode_operations;
|
||||
inode->i_mapping->a_ops = &btrfs_aops;
|
||||
|
@ -578,7 +578,7 @@ static unsigned int create_subvol_num_items(struct btrfs_qgroup_inherit *inherit
|
||||
return num_items;
|
||||
}
|
||||
|
||||
static noinline int create_subvol(struct user_namespace *mnt_userns,
|
||||
static noinline int create_subvol(struct mnt_idmap *idmap,
|
||||
struct inode *dir, struct dentry *dentry,
|
||||
struct btrfs_qgroup_inherit *inherit)
|
||||
{
|
||||
@ -623,7 +623,7 @@ static noinline int create_subvol(struct user_namespace *mnt_userns,
|
||||
if (ret < 0)
|
||||
goto out_root_item;
|
||||
|
||||
new_inode_args.inode = btrfs_new_subvol_inode(mnt_userns, dir);
|
||||
new_inode_args.inode = btrfs_new_subvol_inode(idmap, dir);
|
||||
if (!new_inode_args.inode) {
|
||||
ret = -ENOMEM;
|
||||
goto out_anon_dev;
|
||||
@ -962,7 +962,6 @@ static noinline int btrfs_mksubvol(const struct path *parent,
|
||||
struct btrfs_fs_info *fs_info = btrfs_sb(dir->i_sb);
|
||||
struct dentry *dentry;
|
||||
struct fscrypt_str name_str = FSTR_INIT((char *)name, namelen);
|
||||
struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
|
||||
int error;
|
||||
|
||||
error = down_write_killable_nested(&dir->i_rwsem, I_MUTEX_PARENT);
|
||||
@ -995,7 +994,7 @@ static noinline int btrfs_mksubvol(const struct path *parent,
|
||||
if (snap_src)
|
||||
error = create_snapshot(snap_src, dir, dentry, readonly, inherit);
|
||||
else
|
||||
error = create_subvol(mnt_userns, dir, dentry, inherit);
|
||||
error = create_subvol(idmap, dir, dentry, inherit);
|
||||
|
||||
if (!error)
|
||||
fsnotify_mkdir(dir, dentry);
|
||||
|
@ -64,7 +64,7 @@ struct inode *btrfs_new_test_inode(void)
|
||||
BTRFS_I(inode)->location.type = BTRFS_INODE_ITEM_KEY;
|
||||
BTRFS_I(inode)->location.objectid = BTRFS_FIRST_FREE_OBJECTID;
|
||||
BTRFS_I(inode)->location.offset = 0;
|
||||
inode_init_owner(&init_user_ns, inode, NULL, S_IFREG);
|
||||
inode_init_owner(&nop_mnt_idmap, inode, NULL, S_IFREG);
|
||||
|
||||
return inode;
|
||||
}
|
||||
|
@ -545,7 +545,7 @@ got:
|
||||
inode->i_uid = current_fsuid();
|
||||
inode->i_gid = dir->i_gid;
|
||||
} else
|
||||
inode_init_owner(&init_user_ns, inode, dir, mode);
|
||||
inode_init_owner(&nop_mnt_idmap, inode, dir, mode);
|
||||
|
||||
inode->i_ino = ino;
|
||||
inode->i_blocks = 0;
|
||||
|
@ -2845,7 +2845,7 @@ extern int ext4fs_dirhash(const struct inode *dir, const char *name, int len,
|
||||
|
||||
/* ialloc.c */
|
||||
extern int ext4_mark_inode_used(struct super_block *sb, int ino);
|
||||
extern struct inode *__ext4_new_inode(struct user_namespace *, handle_t *,
|
||||
extern struct inode *__ext4_new_inode(struct mnt_idmap *, handle_t *,
|
||||
struct inode *, umode_t,
|
||||
const struct qstr *qstr, __u32 goal,
|
||||
uid_t *owner, __u32 i_flags,
|
||||
@ -2853,11 +2853,11 @@ extern struct inode *__ext4_new_inode(struct user_namespace *, handle_t *,
|
||||
int nblocks);
|
||||
|
||||
#define ext4_new_inode(handle, dir, mode, qstr, goal, owner, i_flags) \
|
||||
__ext4_new_inode(&init_user_ns, (handle), (dir), (mode), (qstr), \
|
||||
__ext4_new_inode(&nop_mnt_idmap, (handle), (dir), (mode), (qstr), \
|
||||
(goal), (owner), i_flags, 0, 0, 0)
|
||||
#define ext4_new_inode_start_handle(mnt_userns, dir, mode, qstr, goal, owner, \
|
||||
#define ext4_new_inode_start_handle(idmap, dir, mode, qstr, goal, owner, \
|
||||
type, nblocks) \
|
||||
__ext4_new_inode((mnt_userns), NULL, (dir), (mode), (qstr), (goal), (owner), \
|
||||
__ext4_new_inode((idmap), NULL, (dir), (mode), (qstr), (goal), (owner), \
|
||||
0, (type), __LINE__, (nblocks))
|
||||
|
||||
|
||||
|
@ -921,7 +921,7 @@ static int ext4_xattr_credits_for_new_inode(struct inode *dir, mode_t mode,
|
||||
* For other inodes, search forward from the parent directory's block
|
||||
* group to find a free inode.
|
||||
*/
|
||||
struct inode *__ext4_new_inode(struct user_namespace *mnt_userns,
|
||||
struct inode *__ext4_new_inode(struct mnt_idmap *idmap,
|
||||
handle_t *handle, struct inode *dir,
|
||||
umode_t mode, const struct qstr *qstr,
|
||||
__u32 goal, uid_t *owner, __u32 i_flags,
|
||||
@ -943,6 +943,7 @@ struct inode *__ext4_new_inode(struct user_namespace *mnt_userns,
|
||||
ext4_group_t flex_group;
|
||||
struct ext4_group_info *grp = NULL;
|
||||
bool encrypt = false;
|
||||
struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
|
||||
|
||||
/* Cannot create files in a deleted directory */
|
||||
if (!dir || !dir->i_nlink)
|
||||
@ -975,7 +976,7 @@ struct inode *__ext4_new_inode(struct user_namespace *mnt_userns,
|
||||
inode_fsuid_set(inode, mnt_userns);
|
||||
inode->i_gid = dir->i_gid;
|
||||
} else
|
||||
inode_init_owner(mnt_userns, inode, dir, mode);
|
||||
inode_init_owner(idmap, inode, dir, mode);
|
||||
|
||||
if (ext4_has_feature_project(sb) &&
|
||||
ext4_test_inode_flag(dir, EXT4_INODE_PROJINHERIT))
|
||||
|
@ -2795,7 +2795,6 @@ static int ext4_add_nondir(handle_t *handle,
|
||||
static int ext4_create(struct mnt_idmap *idmap, struct inode *dir,
|
||||
struct dentry *dentry, umode_t mode, bool excl)
|
||||
{
|
||||
struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
|
||||
handle_t *handle;
|
||||
struct inode *inode;
|
||||
int err, credits, retries = 0;
|
||||
@ -2807,7 +2806,7 @@ static int ext4_create(struct mnt_idmap *idmap, struct inode *dir,
|
||||
credits = (EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
|
||||
EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3);
|
||||
retry:
|
||||
inode = ext4_new_inode_start_handle(mnt_userns, dir, mode, &dentry->d_name,
|
||||
inode = ext4_new_inode_start_handle(idmap, dir, mode, &dentry->d_name,
|
||||
0, NULL, EXT4_HT_DIR, credits);
|
||||
handle = ext4_journal_current_handle();
|
||||
err = PTR_ERR(inode);
|
||||
@ -2831,7 +2830,6 @@ retry:
|
||||
static int ext4_mknod(struct mnt_idmap *idmap, struct inode *dir,
|
||||
struct dentry *dentry, umode_t mode, dev_t rdev)
|
||||
{
|
||||
struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
|
||||
handle_t *handle;
|
||||
struct inode *inode;
|
||||
int err, credits, retries = 0;
|
||||
@ -2843,7 +2841,7 @@ static int ext4_mknod(struct mnt_idmap *idmap, struct inode *dir,
|
||||
credits = (EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
|
||||
EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3);
|
||||
retry:
|
||||
inode = ext4_new_inode_start_handle(mnt_userns, dir, mode, &dentry->d_name,
|
||||
inode = ext4_new_inode_start_handle(idmap, dir, mode, &dentry->d_name,
|
||||
0, NULL, EXT4_HT_DIR, credits);
|
||||
handle = ext4_journal_current_handle();
|
||||
err = PTR_ERR(inode);
|
||||
@ -2866,7 +2864,6 @@ retry:
|
||||
static int ext4_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
|
||||
struct file *file, umode_t mode)
|
||||
{
|
||||
struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
|
||||
handle_t *handle;
|
||||
struct inode *inode;
|
||||
int err, retries = 0;
|
||||
@ -2876,7 +2873,7 @@ static int ext4_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
|
||||
return err;
|
||||
|
||||
retry:
|
||||
inode = ext4_new_inode_start_handle(mnt_userns, dir, mode,
|
||||
inode = ext4_new_inode_start_handle(idmap, dir, mode,
|
||||
NULL, 0, NULL,
|
||||
EXT4_HT_DIR,
|
||||
EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb) +
|
||||
@ -2978,7 +2975,6 @@ out:
|
||||
static int ext4_mkdir(struct mnt_idmap *idmap, struct inode *dir,
|
||||
struct dentry *dentry, umode_t mode)
|
||||
{
|
||||
struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
|
||||
handle_t *handle;
|
||||
struct inode *inode;
|
||||
int err, err2 = 0, credits, retries = 0;
|
||||
@ -2993,7 +2989,7 @@ static int ext4_mkdir(struct mnt_idmap *idmap, struct inode *dir,
|
||||
credits = (EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
|
||||
EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3);
|
||||
retry:
|
||||
inode = ext4_new_inode_start_handle(mnt_userns, dir, S_IFDIR | mode,
|
||||
inode = ext4_new_inode_start_handle(idmap, dir, S_IFDIR | mode,
|
||||
&dentry->d_name,
|
||||
0, NULL, EXT4_HT_DIR, credits);
|
||||
handle = ext4_journal_current_handle();
|
||||
@ -3346,7 +3342,6 @@ out:
|
||||
static int ext4_symlink(struct mnt_idmap *idmap, struct inode *dir,
|
||||
struct dentry *dentry, const char *symname)
|
||||
{
|
||||
struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
|
||||
handle_t *handle;
|
||||
struct inode *inode;
|
||||
int err, len = strlen(symname);
|
||||
@ -3375,7 +3370,7 @@ static int ext4_symlink(struct mnt_idmap *idmap, struct inode *dir,
|
||||
credits = EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
|
||||
EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3;
|
||||
retry:
|
||||
inode = ext4_new_inode_start_handle(mnt_userns, dir, S_IFLNK|S_IRWXUGO,
|
||||
inode = ext4_new_inode_start_handle(idmap, dir, S_IFLNK|S_IRWXUGO,
|
||||
&dentry->d_name, 0, NULL,
|
||||
EXT4_HT_DIR, credits);
|
||||
handle = ext4_journal_current_handle();
|
||||
@ -3725,7 +3720,7 @@ static void ext4_update_dir_count(handle_t *handle, struct ext4_renament *ent)
|
||||
}
|
||||
}
|
||||
|
||||
static struct inode *ext4_whiteout_for_rename(struct user_namespace *mnt_userns,
|
||||
static struct inode *ext4_whiteout_for_rename(struct mnt_idmap *idmap,
|
||||
struct ext4_renament *ent,
|
||||
int credits, handle_t **h)
|
||||
{
|
||||
@ -3740,7 +3735,7 @@ static struct inode *ext4_whiteout_for_rename(struct user_namespace *mnt_userns,
|
||||
credits += (EXT4_MAXQUOTAS_TRANS_BLOCKS(ent->dir->i_sb) +
|
||||
EXT4_XATTR_TRANS_BLOCKS + 4);
|
||||
retry:
|
||||
wh = ext4_new_inode_start_handle(mnt_userns, ent->dir,
|
||||
wh = ext4_new_inode_start_handle(idmap, ent->dir,
|
||||
S_IFCHR | WHITEOUT_MODE,
|
||||
&ent->dentry->d_name, 0, NULL,
|
||||
EXT4_HT_DIR, credits);
|
||||
@ -3768,7 +3763,7 @@ retry:
|
||||
* while new_{dentry,inode) refers to the destination dentry/inode
|
||||
* This comes from rename(const char *oldpath, const char *newpath)
|
||||
*/
|
||||
static int ext4_rename(struct user_namespace *mnt_userns, struct inode *old_dir,
|
||||
static int ext4_rename(struct mnt_idmap *idmap, struct inode *old_dir,
|
||||
struct dentry *old_dentry, struct inode *new_dir,
|
||||
struct dentry *new_dentry, unsigned int flags)
|
||||
{
|
||||
@ -3856,7 +3851,7 @@ static int ext4_rename(struct user_namespace *mnt_userns, struct inode *old_dir,
|
||||
goto release_bh;
|
||||
}
|
||||
} else {
|
||||
whiteout = ext4_whiteout_for_rename(mnt_userns, &old, credits, &handle);
|
||||
whiteout = ext4_whiteout_for_rename(idmap, &old, credits, &handle);
|
||||
if (IS_ERR(whiteout)) {
|
||||
retval = PTR_ERR(whiteout);
|
||||
goto release_bh;
|
||||
@ -4168,7 +4163,6 @@ static int ext4_rename2(struct mnt_idmap *idmap,
|
||||
struct inode *new_dir, struct dentry *new_dentry,
|
||||
unsigned int flags)
|
||||
{
|
||||
struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
|
||||
int err;
|
||||
|
||||
if (unlikely(ext4_forced_shutdown(EXT4_SB(old_dir->i_sb))))
|
||||
@ -4187,7 +4181,7 @@ static int ext4_rename2(struct mnt_idmap *idmap,
|
||||
new_dir, new_dentry);
|
||||
}
|
||||
|
||||
return ext4_rename(mnt_userns, old_dir, old_dentry, new_dir, new_dentry, flags);
|
||||
return ext4_rename(idmap, old_dir, old_dentry, new_dir, new_dentry, flags);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -3505,7 +3505,7 @@ void f2fs_handle_failed_inode(struct inode *inode);
|
||||
int f2fs_update_extension_list(struct f2fs_sb_info *sbi, const char *name,
|
||||
bool hot, bool set);
|
||||
struct dentry *f2fs_get_parent(struct dentry *child);
|
||||
int f2fs_get_tmpfile(struct user_namespace *mnt_userns, struct inode *dir,
|
||||
int f2fs_get_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
|
||||
struct inode **new_inode);
|
||||
|
||||
/*
|
||||
|
@ -2040,7 +2040,8 @@ static int f2fs_ioc_getversion(struct file *filp, unsigned long arg)
|
||||
static int f2fs_ioc_start_atomic_write(struct file *filp, bool truncate)
|
||||
{
|
||||
struct inode *inode = file_inode(filp);
|
||||
struct user_namespace *mnt_userns = file_mnt_user_ns(filp);
|
||||
struct mnt_idmap *idmap = file_mnt_idmap(filp);
|
||||
struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
|
||||
struct f2fs_inode_info *fi = F2FS_I(inode);
|
||||
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
|
||||
struct inode *pinode;
|
||||
@ -2097,7 +2098,7 @@ static int f2fs_ioc_start_atomic_write(struct file *filp, bool truncate)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = f2fs_get_tmpfile(mnt_userns, pinode, &fi->cow_inode);
|
||||
ret = f2fs_get_tmpfile(idmap, pinode, &fi->cow_inode);
|
||||
iput(pinode);
|
||||
if (ret) {
|
||||
f2fs_up_write(&fi->i_gc_rwsem[WRITE]);
|
||||
|
@ -202,7 +202,7 @@ static void set_file_temperature(struct f2fs_sb_info *sbi, struct inode *inode,
|
||||
file_set_hot(inode);
|
||||
}
|
||||
|
||||
static struct inode *f2fs_new_inode(struct user_namespace *mnt_userns,
|
||||
static struct inode *f2fs_new_inode(struct mnt_idmap *idmap,
|
||||
struct inode *dir, umode_t mode,
|
||||
const char *name)
|
||||
{
|
||||
@ -225,7 +225,7 @@ static struct inode *f2fs_new_inode(struct user_namespace *mnt_userns,
|
||||
|
||||
nid_free = true;
|
||||
|
||||
inode_init_owner(mnt_userns, inode, dir, mode);
|
||||
inode_init_owner(idmap, inode, dir, mode);
|
||||
|
||||
inode->i_ino = ino;
|
||||
inode->i_blocks = 0;
|
||||
@ -336,7 +336,6 @@ fail_drop:
|
||||
static int f2fs_create(struct mnt_idmap *idmap, struct inode *dir,
|
||||
struct dentry *dentry, umode_t mode, bool excl)
|
||||
{
|
||||
struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
|
||||
struct f2fs_sb_info *sbi = F2FS_I_SB(dir);
|
||||
struct inode *inode;
|
||||
nid_t ino = 0;
|
||||
@ -351,7 +350,7 @@ static int f2fs_create(struct mnt_idmap *idmap, struct inode *dir,
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
inode = f2fs_new_inode(mnt_userns, dir, mode, dentry->d_name.name);
|
||||
inode = f2fs_new_inode(idmap, dir, mode, dentry->d_name.name);
|
||||
if (IS_ERR(inode))
|
||||
return PTR_ERR(inode);
|
||||
|
||||
@ -663,7 +662,6 @@ static const char *f2fs_get_link(struct dentry *dentry,
|
||||
static int f2fs_symlink(struct mnt_idmap *idmap, struct inode *dir,
|
||||
struct dentry *dentry, const char *symname)
|
||||
{
|
||||
struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
|
||||
struct f2fs_sb_info *sbi = F2FS_I_SB(dir);
|
||||
struct inode *inode;
|
||||
size_t len = strlen(symname);
|
||||
@ -684,7 +682,7 @@ static int f2fs_symlink(struct mnt_idmap *idmap, struct inode *dir,
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
inode = f2fs_new_inode(mnt_userns, dir, S_IFLNK | S_IRWXUGO, NULL);
|
||||
inode = f2fs_new_inode(idmap, dir, S_IFLNK | S_IRWXUGO, NULL);
|
||||
if (IS_ERR(inode))
|
||||
return PTR_ERR(inode);
|
||||
|
||||
@ -744,7 +742,6 @@ out_free_encrypted_link:
|
||||
static int f2fs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
|
||||
struct dentry *dentry, umode_t mode)
|
||||
{
|
||||
struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
|
||||
struct f2fs_sb_info *sbi = F2FS_I_SB(dir);
|
||||
struct inode *inode;
|
||||
int err;
|
||||
@ -756,7 +753,7 @@ static int f2fs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
inode = f2fs_new_inode(mnt_userns, dir, S_IFDIR | mode, NULL);
|
||||
inode = f2fs_new_inode(idmap, dir, S_IFDIR | mode, NULL);
|
||||
if (IS_ERR(inode))
|
||||
return PTR_ERR(inode);
|
||||
|
||||
@ -800,7 +797,6 @@ static int f2fs_rmdir(struct inode *dir, struct dentry *dentry)
|
||||
static int f2fs_mknod(struct mnt_idmap *idmap, struct inode *dir,
|
||||
struct dentry *dentry, umode_t mode, dev_t rdev)
|
||||
{
|
||||
struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
|
||||
struct f2fs_sb_info *sbi = F2FS_I_SB(dir);
|
||||
struct inode *inode;
|
||||
int err = 0;
|
||||
@ -814,7 +810,7 @@ static int f2fs_mknod(struct mnt_idmap *idmap, struct inode *dir,
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
inode = f2fs_new_inode(mnt_userns, dir, mode, NULL);
|
||||
inode = f2fs_new_inode(idmap, dir, mode, NULL);
|
||||
if (IS_ERR(inode))
|
||||
return PTR_ERR(inode);
|
||||
|
||||
@ -841,7 +837,7 @@ out:
|
||||
return err;
|
||||
}
|
||||
|
||||
static int __f2fs_tmpfile(struct user_namespace *mnt_userns, struct inode *dir,
|
||||
static int __f2fs_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
|
||||
struct file *file, umode_t mode, bool is_whiteout,
|
||||
struct inode **new_inode)
|
||||
{
|
||||
@ -853,7 +849,7 @@ static int __f2fs_tmpfile(struct user_namespace *mnt_userns, struct inode *dir,
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
inode = f2fs_new_inode(mnt_userns, dir, mode, NULL);
|
||||
inode = f2fs_new_inode(idmap, dir, mode, NULL);
|
||||
if (IS_ERR(inode))
|
||||
return PTR_ERR(inode);
|
||||
|
||||
@ -914,7 +910,6 @@ out:
|
||||
static int f2fs_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
|
||||
struct file *file, umode_t mode)
|
||||
{
|
||||
struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
|
||||
struct f2fs_sb_info *sbi = F2FS_I_SB(dir);
|
||||
int err;
|
||||
|
||||
@ -923,28 +918,28 @@ static int f2fs_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
|
||||
if (!f2fs_is_checkpoint_ready(sbi))
|
||||
return -ENOSPC;
|
||||
|
||||
err = __f2fs_tmpfile(mnt_userns, dir, file, mode, false, NULL);
|
||||
err = __f2fs_tmpfile(idmap, dir, file, mode, false, NULL);
|
||||
|
||||
return finish_open_simple(file, err);
|
||||
}
|
||||
|
||||
static int f2fs_create_whiteout(struct user_namespace *mnt_userns,
|
||||
static int f2fs_create_whiteout(struct mnt_idmap *idmap,
|
||||
struct inode *dir, struct inode **whiteout)
|
||||
{
|
||||
if (unlikely(f2fs_cp_error(F2FS_I_SB(dir))))
|
||||
return -EIO;
|
||||
|
||||
return __f2fs_tmpfile(mnt_userns, dir, NULL,
|
||||
return __f2fs_tmpfile(idmap, dir, NULL,
|
||||
S_IFCHR | WHITEOUT_MODE, true, whiteout);
|
||||
}
|
||||
|
||||
int f2fs_get_tmpfile(struct user_namespace *mnt_userns, struct inode *dir,
|
||||
int f2fs_get_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
|
||||
struct inode **new_inode)
|
||||
{
|
||||
return __f2fs_tmpfile(mnt_userns, dir, NULL, S_IFREG, false, new_inode);
|
||||
return __f2fs_tmpfile(idmap, dir, NULL, S_IFREG, false, new_inode);
|
||||
}
|
||||
|
||||
static int f2fs_rename(struct user_namespace *mnt_userns, struct inode *old_dir,
|
||||
static int f2fs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
|
||||
struct dentry *old_dentry, struct inode *new_dir,
|
||||
struct dentry *new_dentry, unsigned int flags)
|
||||
{
|
||||
@ -984,7 +979,7 @@ static int f2fs_rename(struct user_namespace *mnt_userns, struct inode *old_dir,
|
||||
}
|
||||
|
||||
if (flags & RENAME_WHITEOUT) {
|
||||
err = f2fs_create_whiteout(mnt_userns, old_dir, &whiteout);
|
||||
err = f2fs_create_whiteout(idmap, old_dir, &whiteout);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
@ -1305,7 +1300,6 @@ static int f2fs_rename2(struct mnt_idmap *idmap,
|
||||
struct inode *new_dir, struct dentry *new_dentry,
|
||||
unsigned int flags)
|
||||
{
|
||||
struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
|
||||
int err;
|
||||
|
||||
if (flags & ~(RENAME_NOREPLACE | RENAME_EXCHANGE | RENAME_WHITEOUT))
|
||||
@ -1324,7 +1318,7 @@ static int f2fs_rename2(struct mnt_idmap *idmap,
|
||||
* VFS has already handled the new dentry existence case,
|
||||
* here, we just deal with "RENAME_NOREPLACE" as regular rename.
|
||||
*/
|
||||
return f2fs_rename(mnt_userns, old_dir, old_dentry,
|
||||
return f2fs_rename(idmap, old_dir, old_dentry,
|
||||
new_dir, new_dentry, flags);
|
||||
}
|
||||
|
||||
|
@ -390,7 +390,7 @@ struct inode *hfsplus_new_inode(struct super_block *sb, struct inode *dir,
|
||||
return NULL;
|
||||
|
||||
inode->i_ino = sbi->next_cnid++;
|
||||
inode_init_owner(&init_user_ns, inode, dir, mode);
|
||||
inode_init_owner(&nop_mnt_idmap, inode, dir, mode);
|
||||
set_nlink(inode, 1);
|
||||
inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
|
||||
|
||||
|
@ -980,7 +980,7 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb,
|
||||
struct hugetlbfs_inode_info *info = HUGETLBFS_I(inode);
|
||||
|
||||
inode->i_ino = get_next_ino();
|
||||
inode_init_owner(&init_user_ns, inode, dir, mode);
|
||||
inode_init_owner(&nop_mnt_idmap, inode, dir, mode);
|
||||
lockdep_set_class(&inode->i_mapping->i_mmap_rwsem,
|
||||
&hugetlbfs_i_mmap_rwsem_key);
|
||||
inode->i_mapping->a_ops = &hugetlbfs_aops;
|
||||
|
14
fs/inode.c
14
fs/inode.c
@ -2279,20 +2279,22 @@ EXPORT_SYMBOL(init_special_inode);
|
||||
|
||||
/**
|
||||
* inode_init_owner - Init uid,gid,mode for new inode according to posix standards
|
||||
* @mnt_userns: User namespace of the mount the inode was created from
|
||||
* @idmap: idmap of the mount the inode was created from
|
||||
* @inode: New inode
|
||||
* @dir: Directory inode
|
||||
* @mode: mode of the new inode
|
||||
*
|
||||
* If the inode has been created through an idmapped mount the user namespace of
|
||||
* the vfsmount must be passed through @mnt_userns. This function will then take
|
||||
* care to map the inode according to @mnt_userns before checking permissions
|
||||
* If the inode has been created through an idmapped mount the idmap of
|
||||
* the vfsmount must be passed through @idmap. This function will then take
|
||||
* care to map the inode according to @idmap before checking permissions
|
||||
* and initializing i_uid and i_gid. On non-idmapped mounts or if permission
|
||||
* checking is to be performed on the raw inode simply passs init_user_ns.
|
||||
* checking is to be performed on the raw inode simply pass @nop_mnt_idmap.
|
||||
*/
|
||||
void inode_init_owner(struct user_namespace *mnt_userns, struct inode *inode,
|
||||
void inode_init_owner(struct mnt_idmap *idmap, struct inode *inode,
|
||||
const struct inode *dir, umode_t mode)
|
||||
{
|
||||
struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
|
||||
|
||||
inode_fsuid_set(inode, mnt_userns);
|
||||
if (dir && dir->i_mode & S_ISGID) {
|
||||
inode->i_gid = dir->i_gid;
|
||||
|
@ -64,7 +64,7 @@ struct inode *ialloc(struct inode *parent, umode_t mode)
|
||||
goto fail_put;
|
||||
}
|
||||
|
||||
inode_init_owner(&init_user_ns, inode, parent, mode);
|
||||
inode_init_owner(&nop_mnt_idmap, inode, parent, mode);
|
||||
/*
|
||||
* New inodes need to save sane values on disk when
|
||||
* uid & gid mount options are used
|
||||
|
@ -252,7 +252,7 @@ struct inode *minix_new_inode(const struct inode *dir, umode_t mode, int *error)
|
||||
iput(inode);
|
||||
return NULL;
|
||||
}
|
||||
inode_init_owner(&init_user_ns, inode, dir, mode);
|
||||
inode_init_owner(&nop_mnt_idmap, inode, dir, mode);
|
||||
inode->i_ino = j;
|
||||
inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
|
||||
inode->i_blocks = 0;
|
||||
|
@ -364,7 +364,7 @@ struct inode *nilfs_new_inode(struct inode *dir, umode_t mode)
|
||||
ii->i_bh = bh;
|
||||
|
||||
atomic64_inc(&root->inodes_count);
|
||||
inode_init_owner(&init_user_ns, inode, dir, mode);
|
||||
inode_init_owner(&nop_mnt_idmap, inode, dir, mode);
|
||||
inode->i_ino = ino;
|
||||
inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
|
||||
|
||||
|
@ -1192,7 +1192,6 @@ struct inode *ntfs_create_inode(struct mnt_idmap *idmap,
|
||||
struct ntfs_fnd *fnd)
|
||||
{
|
||||
int err;
|
||||
struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
|
||||
struct super_block *sb = dir->i_sb;
|
||||
struct ntfs_sb_info *sbi = sb->s_fs_info;
|
||||
const struct qstr *name = &dentry->d_name;
|
||||
@ -1308,7 +1307,7 @@ struct inode *ntfs_create_inode(struct mnt_idmap *idmap,
|
||||
goto out3;
|
||||
}
|
||||
inode = &ni->vfs_inode;
|
||||
inode_init_owner(mnt_userns, inode, dir, mode);
|
||||
inode_init_owner(idmap, inode, dir, mode);
|
||||
mode = inode->i_mode;
|
||||
|
||||
inode->i_atime = inode->i_mtime = inode->i_ctime = ni->i_crtime =
|
||||
|
@ -336,7 +336,7 @@ static struct inode *dlmfs_get_root_inode(struct super_block *sb)
|
||||
|
||||
if (inode) {
|
||||
inode->i_ino = get_next_ino();
|
||||
inode_init_owner(&init_user_ns, inode, NULL, mode);
|
||||
inode_init_owner(&nop_mnt_idmap, inode, NULL, mode);
|
||||
inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
|
||||
inc_nlink(inode);
|
||||
|
||||
@ -359,7 +359,7 @@ static struct inode *dlmfs_get_inode(struct inode *parent,
|
||||
return NULL;
|
||||
|
||||
inode->i_ino = get_next_ino();
|
||||
inode_init_owner(&init_user_ns, inode, parent, mode);
|
||||
inode_init_owner(&nop_mnt_idmap, inode, parent, mode);
|
||||
inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
|
||||
|
||||
ip = DLMFS_I(inode);
|
||||
|
@ -198,7 +198,7 @@ static struct inode *ocfs2_get_init_inode(struct inode *dir, umode_t mode)
|
||||
if (S_ISDIR(mode))
|
||||
set_nlink(inode, 2);
|
||||
mode = mode_strip_sgid(&init_user_ns, dir, mode);
|
||||
inode_init_owner(&init_user_ns, inode, dir, mode);
|
||||
inode_init_owner(&nop_mnt_idmap, inode, dir, mode);
|
||||
status = dquot_initialize(inode);
|
||||
if (status)
|
||||
return ERR_PTR(status);
|
||||
|
@ -48,7 +48,7 @@ struct inode *omfs_new_inode(struct inode *dir, umode_t mode)
|
||||
goto fail;
|
||||
|
||||
inode->i_ino = new_block;
|
||||
inode_init_owner(&init_user_ns, inode, NULL, mode);
|
||||
inode_init_owner(&nop_mnt_idmap, inode, NULL, mode);
|
||||
inode->i_mapping->a_ops = &omfs_aops;
|
||||
|
||||
inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
|
||||
|
@ -641,7 +641,7 @@ static int ovl_create_object(struct dentry *dentry, int mode, dev_t rdev,
|
||||
inode->i_state |= I_CREATING;
|
||||
spin_unlock(&inode->i_lock);
|
||||
|
||||
inode_init_owner(&init_user_ns, inode, dentry->d_parent->d_inode, mode);
|
||||
inode_init_owner(&nop_mnt_idmap, inode, dentry->d_parent->d_inode, mode);
|
||||
attr.mode = inode->i_mode;
|
||||
|
||||
err = ovl_create_or_link(dentry, inode, &attr, false);
|
||||
|
@ -61,7 +61,7 @@ struct inode *ramfs_get_inode(struct super_block *sb,
|
||||
|
||||
if (inode) {
|
||||
inode->i_ino = get_next_ino();
|
||||
inode_init_owner(&init_user_ns, inode, dir, mode);
|
||||
inode_init_owner(&nop_mnt_idmap, inode, dir, mode);
|
||||
inode->i_mapping->a_ops = &ram_aops;
|
||||
mapping_set_gfp_mask(inode->i_mapping, GFP_HIGHUSER);
|
||||
mapping_set_unevictable(inode->i_mapping);
|
||||
|
@ -616,7 +616,7 @@ static int new_inode_init(struct inode *inode, struct inode *dir, umode_t mode)
|
||||
* the quota init calls have to know who to charge the quota to, so
|
||||
* we have to set uid and gid here
|
||||
*/
|
||||
inode_init_owner(&init_user_ns, inode, dir, mode);
|
||||
inode_init_owner(&nop_mnt_idmap, inode, dir, mode);
|
||||
return dquot_initialize(inode);
|
||||
}
|
||||
|
||||
|
@ -163,7 +163,7 @@ struct inode * sysv_new_inode(const struct inode * dir, umode_t mode)
|
||||
*sbi->s_sb_fic_count = cpu_to_fs16(sbi, count);
|
||||
fs16_add(sbi, sbi->s_sb_total_free_inodes, -1);
|
||||
dirty_sb(sb);
|
||||
inode_init_owner(&init_user_ns, inode, dir, mode);
|
||||
inode_init_owner(&nop_mnt_idmap, inode, dir, mode);
|
||||
inode->i_ino = fs16_to_cpu(sbi, ino);
|
||||
inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
|
||||
inode->i_blocks = 0;
|
||||
|
@ -95,7 +95,7 @@ struct inode *ubifs_new_inode(struct ubifs_info *c, struct inode *dir,
|
||||
*/
|
||||
inode->i_flags |= S_NOCMTIME;
|
||||
|
||||
inode_init_owner(&init_user_ns, inode, dir, mode);
|
||||
inode_init_owner(&nop_mnt_idmap, inode, dir, mode);
|
||||
inode->i_mtime = inode->i_atime = inode->i_ctime =
|
||||
current_time(inode);
|
||||
inode->i_mapping->nrpages = 0;
|
||||
|
@ -105,7 +105,7 @@ struct inode *udf_new_inode(struct inode *dir, umode_t mode)
|
||||
mutex_unlock(&sbi->s_alloc_mutex);
|
||||
}
|
||||
|
||||
inode_init_owner(&init_user_ns, inode, dir, mode);
|
||||
inode_init_owner(&nop_mnt_idmap, inode, dir, mode);
|
||||
if (UDF_QUERY_FLAG(sb, UDF_FLAG_UID_SET))
|
||||
inode->i_uid = sbi->s_uid;
|
||||
if (UDF_QUERY_FLAG(sb, UDF_FLAG_GID_SET))
|
||||
|
@ -289,7 +289,7 @@ cg_found:
|
||||
ufs_mark_sb_dirty(sb);
|
||||
|
||||
inode->i_ino = cg * uspi->s_ipg + bit;
|
||||
inode_init_owner(&init_user_ns, inode, dir, mode);
|
||||
inode_init_owner(&nop_mnt_idmap, inode, dir, mode);
|
||||
inode->i_blocks = 0;
|
||||
inode->i_generation = 0;
|
||||
inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
|
||||
|
@ -777,7 +777,7 @@ xfs_inode_inherit_flags2(
|
||||
*/
|
||||
int
|
||||
xfs_init_new_inode(
|
||||
struct user_namespace *mnt_userns,
|
||||
struct mnt_idmap *idmap,
|
||||
struct xfs_trans *tp,
|
||||
struct xfs_inode *pip,
|
||||
xfs_ino_t ino,
|
||||
@ -788,6 +788,7 @@ xfs_init_new_inode(
|
||||
bool init_xattrs,
|
||||
struct xfs_inode **ipp)
|
||||
{
|
||||
struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
|
||||
struct inode *dir = pip ? VFS_I(pip) : NULL;
|
||||
struct xfs_mount *mp = tp->t_mountp;
|
||||
struct xfs_inode *ip;
|
||||
@ -827,7 +828,7 @@ xfs_init_new_inode(
|
||||
inode->i_gid = dir->i_gid;
|
||||
inode->i_mode = mode;
|
||||
} else {
|
||||
inode_init_owner(mnt_userns, inode, dir, mode);
|
||||
inode_init_owner(idmap, inode, dir, mode);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -946,7 +947,7 @@ xfs_bumplink(
|
||||
|
||||
int
|
||||
xfs_create(
|
||||
struct user_namespace *mnt_userns,
|
||||
struct mnt_idmap *idmap,
|
||||
xfs_inode_t *dp,
|
||||
struct xfs_name *name,
|
||||
umode_t mode,
|
||||
@ -954,6 +955,7 @@ xfs_create(
|
||||
bool init_xattrs,
|
||||
xfs_inode_t **ipp)
|
||||
{
|
||||
struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
|
||||
int is_dir = S_ISDIR(mode);
|
||||
struct xfs_mount *mp = dp->i_mount;
|
||||
struct xfs_inode *ip = NULL;
|
||||
@ -1020,7 +1022,7 @@ xfs_create(
|
||||
*/
|
||||
error = xfs_dialloc(&tp, dp->i_ino, mode, &ino);
|
||||
if (!error)
|
||||
error = xfs_init_new_inode(mnt_userns, tp, dp, ino, mode,
|
||||
error = xfs_init_new_inode(idmap, tp, dp, ino, mode,
|
||||
is_dir ? 2 : 1, rdev, prid, init_xattrs, &ip);
|
||||
if (error)
|
||||
goto out_trans_cancel;
|
||||
@ -1102,11 +1104,12 @@ xfs_create(
|
||||
|
||||
int
|
||||
xfs_create_tmpfile(
|
||||
struct user_namespace *mnt_userns,
|
||||
struct mnt_idmap *idmap,
|
||||
struct xfs_inode *dp,
|
||||
umode_t mode,
|
||||
struct xfs_inode **ipp)
|
||||
{
|
||||
struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
|
||||
struct xfs_mount *mp = dp->i_mount;
|
||||
struct xfs_inode *ip = NULL;
|
||||
struct xfs_trans *tp = NULL;
|
||||
@ -1144,7 +1147,7 @@ xfs_create_tmpfile(
|
||||
|
||||
error = xfs_dialloc(&tp, dp->i_ino, mode, &ino);
|
||||
if (!error)
|
||||
error = xfs_init_new_inode(mnt_userns, tp, dp, ino, mode,
|
||||
error = xfs_init_new_inode(idmap, tp, dp, ino, mode,
|
||||
0, 0, prid, false, &ip);
|
||||
if (error)
|
||||
goto out_trans_cancel;
|
||||
@ -2709,7 +2712,7 @@ out_trans_abort:
|
||||
*/
|
||||
static int
|
||||
xfs_rename_alloc_whiteout(
|
||||
struct user_namespace *mnt_userns,
|
||||
struct mnt_idmap *idmap,
|
||||
struct xfs_name *src_name,
|
||||
struct xfs_inode *dp,
|
||||
struct xfs_inode **wip)
|
||||
@ -2718,7 +2721,7 @@ xfs_rename_alloc_whiteout(
|
||||
struct qstr name;
|
||||
int error;
|
||||
|
||||
error = xfs_create_tmpfile(mnt_userns, dp, S_IFCHR | WHITEOUT_MODE,
|
||||
error = xfs_create_tmpfile(idmap, dp, S_IFCHR | WHITEOUT_MODE,
|
||||
&tmpfile);
|
||||
if (error)
|
||||
return error;
|
||||
@ -2750,7 +2753,7 @@ xfs_rename_alloc_whiteout(
|
||||
*/
|
||||
int
|
||||
xfs_rename(
|
||||
struct user_namespace *mnt_userns,
|
||||
struct mnt_idmap *idmap,
|
||||
struct xfs_inode *src_dp,
|
||||
struct xfs_name *src_name,
|
||||
struct xfs_inode *src_ip,
|
||||
@ -2782,7 +2785,7 @@ xfs_rename(
|
||||
* appropriately.
|
||||
*/
|
||||
if (flags & RENAME_WHITEOUT) {
|
||||
error = xfs_rename_alloc_whiteout(mnt_userns, src_name,
|
||||
error = xfs_rename_alloc_whiteout(idmap, src_name,
|
||||
target_dp, &wip);
|
||||
if (error)
|
||||
return error;
|
||||
|
@ -473,18 +473,18 @@ int xfs_release(struct xfs_inode *ip);
|
||||
void xfs_inactive(struct xfs_inode *ip);
|
||||
int xfs_lookup(struct xfs_inode *dp, const struct xfs_name *name,
|
||||
struct xfs_inode **ipp, struct xfs_name *ci_name);
|
||||
int xfs_create(struct user_namespace *mnt_userns,
|
||||
int xfs_create(struct mnt_idmap *idmap,
|
||||
struct xfs_inode *dp, struct xfs_name *name,
|
||||
umode_t mode, dev_t rdev, bool need_xattr,
|
||||
struct xfs_inode **ipp);
|
||||
int xfs_create_tmpfile(struct user_namespace *mnt_userns,
|
||||
int xfs_create_tmpfile(struct mnt_idmap *idmap,
|
||||
struct xfs_inode *dp, umode_t mode,
|
||||
struct xfs_inode **ipp);
|
||||
int xfs_remove(struct xfs_inode *dp, struct xfs_name *name,
|
||||
struct xfs_inode *ip);
|
||||
int xfs_link(struct xfs_inode *tdp, struct xfs_inode *sip,
|
||||
struct xfs_name *target_name);
|
||||
int xfs_rename(struct user_namespace *mnt_userns,
|
||||
int xfs_rename(struct mnt_idmap *idmap,
|
||||
struct xfs_inode *src_dp, struct xfs_name *src_name,
|
||||
struct xfs_inode *src_ip, struct xfs_inode *target_dp,
|
||||
struct xfs_name *target_name,
|
||||
@ -515,7 +515,7 @@ void xfs_lock_two_inodes(struct xfs_inode *ip0, uint ip0_mode,
|
||||
xfs_extlen_t xfs_get_extsz_hint(struct xfs_inode *ip);
|
||||
xfs_extlen_t xfs_get_cowextsz_hint(struct xfs_inode *ip);
|
||||
|
||||
int xfs_init_new_inode(struct user_namespace *mnt_userns, struct xfs_trans *tp,
|
||||
int xfs_init_new_inode(struct mnt_idmap *idmap, struct xfs_trans *tp,
|
||||
struct xfs_inode *pip, xfs_ino_t ino, umode_t mode,
|
||||
xfs_nlink_t nlink, dev_t rdev, prid_t prid, bool init_xattrs,
|
||||
struct xfs_inode **ipp);
|
||||
|
@ -162,12 +162,12 @@ xfs_create_need_xattr(
|
||||
|
||||
STATIC int
|
||||
xfs_generic_create(
|
||||
struct user_namespace *mnt_userns,
|
||||
struct inode *dir,
|
||||
struct dentry *dentry,
|
||||
umode_t mode,
|
||||
dev_t rdev,
|
||||
struct file *tmpfile) /* unnamed file */
|
||||
struct mnt_idmap *idmap,
|
||||
struct inode *dir,
|
||||
struct dentry *dentry,
|
||||
umode_t mode,
|
||||
dev_t rdev,
|
||||
struct file *tmpfile) /* unnamed file */
|
||||
{
|
||||
struct inode *inode;
|
||||
struct xfs_inode *ip = NULL;
|
||||
@ -196,11 +196,11 @@ xfs_generic_create(
|
||||
goto out_free_acl;
|
||||
|
||||
if (!tmpfile) {
|
||||
error = xfs_create(mnt_userns, XFS_I(dir), &name, mode, rdev,
|
||||
error = xfs_create(idmap, XFS_I(dir), &name, mode, rdev,
|
||||
xfs_create_need_xattr(dir, default_acl, acl),
|
||||
&ip);
|
||||
} else {
|
||||
error = xfs_create_tmpfile(mnt_userns, XFS_I(dir), mode, &ip);
|
||||
error = xfs_create_tmpfile(idmap, XFS_I(dir), mode, &ip);
|
||||
}
|
||||
if (unlikely(error))
|
||||
goto out_free_acl;
|
||||
@ -261,8 +261,7 @@ xfs_vn_mknod(
|
||||
umode_t mode,
|
||||
dev_t rdev)
|
||||
{
|
||||
return xfs_generic_create(mnt_idmap_owner(idmap), dir, dentry, mode,
|
||||
rdev, NULL);
|
||||
return xfs_generic_create(idmap, dir, dentry, mode, rdev, NULL);
|
||||
}
|
||||
|
||||
STATIC int
|
||||
@ -273,8 +272,7 @@ xfs_vn_create(
|
||||
umode_t mode,
|
||||
bool flags)
|
||||
{
|
||||
struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
|
||||
return xfs_generic_create(mnt_userns, dir, dentry, mode, 0, NULL);
|
||||
return xfs_generic_create(idmap, dir, dentry, mode, 0, NULL);
|
||||
}
|
||||
|
||||
STATIC int
|
||||
@ -284,8 +282,7 @@ xfs_vn_mkdir(
|
||||
struct dentry *dentry,
|
||||
umode_t mode)
|
||||
{
|
||||
return xfs_generic_create(mnt_idmap_owner(idmap), dir, dentry,
|
||||
mode | S_IFDIR, 0, NULL);
|
||||
return xfs_generic_create(idmap, dir, dentry, mode | S_IFDIR, 0, NULL);
|
||||
}
|
||||
|
||||
STATIC struct dentry *
|
||||
@ -407,7 +404,6 @@ xfs_vn_symlink(
|
||||
struct dentry *dentry,
|
||||
const char *symname)
|
||||
{
|
||||
struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
|
||||
struct inode *inode;
|
||||
struct xfs_inode *cip = NULL;
|
||||
struct xfs_name name;
|
||||
@ -420,7 +416,7 @@ xfs_vn_symlink(
|
||||
if (unlikely(error))
|
||||
goto out;
|
||||
|
||||
error = xfs_symlink(mnt_userns, XFS_I(dir), &name, symname, mode, &cip);
|
||||
error = xfs_symlink(idmap, XFS_I(dir), &name, symname, mode, &cip);
|
||||
if (unlikely(error))
|
||||
goto out;
|
||||
|
||||
@ -453,7 +449,6 @@ xfs_vn_rename(
|
||||
struct dentry *ndentry,
|
||||
unsigned int flags)
|
||||
{
|
||||
struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
|
||||
struct inode *new_inode = d_inode(ndentry);
|
||||
int omode = 0;
|
||||
int error;
|
||||
@ -476,7 +471,7 @@ xfs_vn_rename(
|
||||
if (unlikely(error))
|
||||
return error;
|
||||
|
||||
return xfs_rename(mnt_userns, XFS_I(odir), &oname,
|
||||
return xfs_rename(idmap, XFS_I(odir), &oname,
|
||||
XFS_I(d_inode(odentry)), XFS_I(ndir), &nname,
|
||||
new_inode ? XFS_I(new_inode) : NULL, flags);
|
||||
}
|
||||
@ -1103,9 +1098,7 @@ xfs_vn_tmpfile(
|
||||
struct file *file,
|
||||
umode_t mode)
|
||||
{
|
||||
struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
|
||||
|
||||
int err = xfs_generic_create(mnt_userns, dir, file->f_path.dentry, mode, 0, file);
|
||||
int err = xfs_generic_create(idmap, dir, file->f_path.dentry, mode, 0, file);
|
||||
|
||||
return finish_open_simple(file, err);
|
||||
}
|
||||
|
@ -787,7 +787,7 @@ xfs_qm_qino_alloc(
|
||||
|
||||
error = xfs_dialloc(&tp, 0, S_IFREG, &ino);
|
||||
if (!error)
|
||||
error = xfs_init_new_inode(&init_user_ns, tp, NULL, ino,
|
||||
error = xfs_init_new_inode(&nop_mnt_idmap, tp, NULL, ino,
|
||||
S_IFREG, 1, 0, 0, false, ipp);
|
||||
if (error) {
|
||||
xfs_trans_cancel(tp);
|
||||
|
@ -144,13 +144,14 @@ xfs_readlink(
|
||||
|
||||
int
|
||||
xfs_symlink(
|
||||
struct user_namespace *mnt_userns,
|
||||
struct mnt_idmap *idmap,
|
||||
struct xfs_inode *dp,
|
||||
struct xfs_name *link_name,
|
||||
const char *target_path,
|
||||
umode_t mode,
|
||||
struct xfs_inode **ipp)
|
||||
{
|
||||
struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
|
||||
struct xfs_mount *mp = dp->i_mount;
|
||||
struct xfs_trans *tp = NULL;
|
||||
struct xfs_inode *ip = NULL;
|
||||
@ -231,7 +232,7 @@ xfs_symlink(
|
||||
*/
|
||||
error = xfs_dialloc(&tp, dp->i_ino, S_IFLNK, &ino);
|
||||
if (!error)
|
||||
error = xfs_init_new_inode(mnt_userns, tp, dp, ino,
|
||||
error = xfs_init_new_inode(idmap, tp, dp, ino,
|
||||
S_IFLNK | (mode & ~S_IFMT), 1, 0, prid,
|
||||
false, &ip);
|
||||
if (error)
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
/* Kernel only symlink definitions */
|
||||
|
||||
int xfs_symlink(struct user_namespace *mnt_userns, struct xfs_inode *dp,
|
||||
int xfs_symlink(struct mnt_idmap *idmap, struct xfs_inode *dp,
|
||||
struct xfs_name *link_name, const char *target_path,
|
||||
umode_t mode, struct xfs_inode **ipp);
|
||||
int xfs_readlink_bmap_ilocked(struct xfs_inode *ip, char *link);
|
||||
|
@ -1405,7 +1405,7 @@ static void zonefs_init_dir_inode(struct inode *parent, struct inode *inode,
|
||||
struct super_block *sb = parent->i_sb;
|
||||
|
||||
inode->i_ino = bdev_nr_zones(sb->s_bdev) + type + 1;
|
||||
inode_init_owner(&init_user_ns, inode, parent, S_IFDIR | 0555);
|
||||
inode_init_owner(&nop_mnt_idmap, inode, parent, S_IFDIR | 0555);
|
||||
inode->i_op = &zonefs_dir_inode_operations;
|
||||
inode->i_fop = &simple_dir_operations;
|
||||
set_nlink(inode, 2);
|
||||
|
@ -2014,7 +2014,7 @@ extern long compat_ptr_ioctl(struct file *file, unsigned int cmd,
|
||||
/*
|
||||
* VFS file helper functions.
|
||||
*/
|
||||
void inode_init_owner(struct user_namespace *mnt_userns, struct inode *inode,
|
||||
void inode_init_owner(struct mnt_idmap *idmap, struct inode *inode,
|
||||
const struct inode *dir, umode_t mode);
|
||||
extern bool may_open_dev(const struct path *path);
|
||||
umode_t mode_strip_sgid(struct user_namespace *mnt_userns,
|
||||
|
@ -122,7 +122,7 @@ static struct inode *bpf_get_inode(struct super_block *sb,
|
||||
inode->i_mtime = inode->i_atime;
|
||||
inode->i_ctime = inode->i_atime;
|
||||
|
||||
inode_init_owner(&init_user_ns, inode, dir, mode);
|
||||
inode_init_owner(&nop_mnt_idmap, inode, dir, mode);
|
||||
|
||||
return inode;
|
||||
}
|
||||
|
@ -2343,7 +2343,7 @@ static struct inode *shmem_get_inode(struct super_block *sb, struct inode *dir,
|
||||
inode = new_inode(sb);
|
||||
if (inode) {
|
||||
inode->i_ino = ino;
|
||||
inode_init_owner(&init_user_ns, inode, dir, mode);
|
||||
inode_init_owner(&nop_mnt_idmap, inode, dir, mode);
|
||||
inode->i_blocks = 0;
|
||||
inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
|
||||
inode->i_generation = get_random_u32();
|
||||
|
Loading…
Reference in New Issue
Block a user