lkml.org 
[lkml]   [2023]   [Jun]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH v2 10/13] ceph: allow idmapped setattr inode op
From

On 5/24/23 23:33, Alexander Mikhalitsyn wrote:
> From: Christian Brauner <christian.brauner@ubuntu.com>
>
> Enable __ceph_setattr() to handle idmapped mounts. This is just a matter
> of passing down the mount's idmapping.
>
> Cc: Jeff Layton <jlayton@kernel.org>
> Cc: Ilya Dryomov <idryomov@gmail.com>
> Cc: ceph-devel@vger.kernel.org
> Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
> Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
> ---
> fs/ceph/inode.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
> index 37e1cbfc7c89..f1f934439be0 100644
> --- a/fs/ceph/inode.c
> +++ b/fs/ceph/inode.c
> @@ -2050,6 +2050,13 @@ int __ceph_setattr(struct inode *inode, struct iattr *attr)
>
> dout("setattr %p issued %s\n", inode, ceph_cap_string(issued));
>
> + /*
> + * The attr->ia_{g,u}id members contain the target {g,u}id we're
> + * sending over the wire. The mount idmapping only matters when we
> + * create new filesystem objects based on the caller's mapped
> + * fs{g,u}id.
> + */
> + req->r_mnt_idmap = &nop_mnt_idmap;

For example with an idmapping 1000:0 and in the /mnt/idmapped_ceph/.

This means the "__ceph_setattr()" will always use UID 0 to set the
caller_uid, right ? If it is then the client auth checking for the
setattr requests in cephfs MDS will succeed, since the UID 0 is root.
But if you use a different idmapping, such as 1000:2000, it will fail.

So here IMO we should set it to 'idmap' too ?

Thanks

- Xiubo

> if (ia_valid & ATTR_UID) {
> dout("setattr %p uid %d -> %d\n", inode,
> from_kuid(&init_user_ns, inode->i_uid),
> @@ -2240,7 +2247,7 @@ int ceph_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> if (ceph_inode_is_shutdown(inode))
> return -ESTALE;
>
> - err = setattr_prepare(&nop_mnt_idmap, dentry, attr);
> + err = setattr_prepare(idmap, dentry, attr);
> if (err != 0)
> return err;
>
> @@ -2255,7 +2262,7 @@ int ceph_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> err = __ceph_setattr(inode, attr);
>
> if (err >= 0 && (attr->ia_valid & ATTR_MODE))
> - err = posix_acl_chmod(&nop_mnt_idmap, dentry, attr->ia_mode);
> + err = posix_acl_chmod(idmap, dentry, attr->ia_mode);
>
> return err;
> }

\
 
 \ /
  Last update: 2023-06-02 03:33    [W:0.290 / U:0.560 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site