Skip to content

Commit 13e83a4

Browse files
committed
fs: port ->set_acl() to pass mnt_idmap
Convert to struct mnt_idmap. Last cycle we merged the necessary infrastructure in 256c8ae ("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>
1 parent 7743532 commit 13e83a4

62 files changed

Lines changed: 122 additions & 111 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Documentation/filesystems/vfs.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ As of kernel 2.6.22, the following members are defined:
444444
unsigned open_flag, umode_t create_mode);
445445
int (*tmpfile) (struct mnt_idmap *, struct inode *, struct file *, umode_t);
446446
struct posix_acl * (*get_acl)(struct mnt_idmap *, struct dentry *, int);
447-
int (*set_acl)(struct user_namespace *, struct dentry *, struct posix_acl *, int);
447+
int (*set_acl)(struct mnt_idmap *, struct dentry *, struct posix_acl *, int);
448448
int (*fileattr_set)(struct user_namespace *mnt_userns,
449449
struct dentry *dentry, struct fileattr *fa);
450450
int (*fileattr_get)(struct dentry *dentry, struct fileattr *fa);

fs/9p/acl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ struct posix_acl *v9fs_iop_get_acl(struct mnt_idmap *idmap,
151151
return v9fs_get_cached_acl(d_inode(dentry), type);
152152
}
153153

154-
int v9fs_iop_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry,
154+
int v9fs_iop_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
155155
struct posix_acl *acl, int type)
156156
{
157157
int retval;

fs/9p/acl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ struct posix_acl *v9fs_iop_get_inode_acl(struct inode *inode, int type,
1212
bool rcu);
1313
struct posix_acl *v9fs_iop_get_acl(struct mnt_idmap *idmap,
1414
struct dentry *dentry, int type);
15-
int v9fs_iop_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry,
15+
int v9fs_iop_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
1616
struct posix_acl *acl, int type);
1717
int v9fs_acl_chmod(struct inode *inode, struct p9_fid *fid);
1818
int v9fs_set_create_acl(struct inode *inode, struct p9_fid *fid,

fs/bad_inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ static int bad_inode_tmpfile(struct mnt_idmap *idmap,
153153
return -EIO;
154154
}
155155

156-
static int bad_inode_set_acl(struct user_namespace *mnt_userns,
156+
static int bad_inode_set_acl(struct mnt_idmap *idmap,
157157
struct dentry *dentry, struct posix_acl *acl,
158158
int type)
159159
{

fs/btrfs/acl.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,11 @@ int __btrfs_set_acl(struct btrfs_trans_handle *trans, struct inode *inode,
110110
return ret;
111111
}
112112

113-
int btrfs_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry,
113+
int btrfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
114114
struct posix_acl *acl, int type)
115115
{
116116
int ret;
117+
struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
117118
struct inode *inode = d_inode(dentry);
118119
umode_t old_mode = inode->i_mode;
119120

fs/btrfs/acl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#ifdef CONFIG_BTRFS_FS_POSIX_ACL
77

88
struct posix_acl *btrfs_get_acl(struct inode *inode, int type, bool rcu);
9-
int btrfs_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry,
9+
int btrfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
1010
struct posix_acl *acl, int type);
1111
int __btrfs_set_acl(struct btrfs_trans_handle *trans, struct inode *inode,
1212
struct posix_acl *acl, int type);

fs/btrfs/inode.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5307,8 +5307,7 @@ static int btrfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
53075307
err = btrfs_dirty_inode(BTRFS_I(inode));
53085308

53095309
if (!err && attr->ia_valid & ATTR_MODE)
5310-
err = posix_acl_chmod(mnt_idmap_owner(idmap), dentry,
5311-
inode->i_mode);
5310+
err = posix_acl_chmod(idmap, dentry, inode->i_mode);
53125311
}
53135312

53145313
return err;

fs/ceph/acl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ struct posix_acl *ceph_get_acl(struct inode *inode, int type, bool rcu)
8585
return acl;
8686
}
8787

88-
int ceph_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry,
88+
int ceph_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
8989
struct posix_acl *acl, int type)
9090
{
9191
int ret = 0, size = 0;

fs/ceph/inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2255,7 +2255,7 @@ int ceph_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
22552255
err = __ceph_setattr(inode, attr);
22562256

22572257
if (err >= 0 && (attr->ia_valid & ATTR_MODE))
2258-
err = posix_acl_chmod(&init_user_ns, dentry, attr->ia_mode);
2258+
err = posix_acl_chmod(&nop_mnt_idmap, dentry, attr->ia_mode);
22592259

22602260
return err;
22612261
}

fs/ceph/super.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1118,7 +1118,7 @@ void ceph_release_acl_sec_ctx(struct ceph_acl_sec_ctx *as_ctx);
11181118
#ifdef CONFIG_CEPH_FS_POSIX_ACL
11191119

11201120
struct posix_acl *ceph_get_acl(struct inode *, int, bool);
1121-
int ceph_set_acl(struct user_namespace *mnt_userns,
1121+
int ceph_set_acl(struct mnt_idmap *idmap,
11221122
struct dentry *dentry, struct posix_acl *acl, int type);
11231123
int ceph_pre_init_acls(struct inode *dir, umode_t *mode,
11241124
struct ceph_acl_sec_ctx *as_ctx);

0 commit comments

Comments
 (0)