Re: [PATCH v5 37/42] xfs: support idmapped mounts

Dave Chinner
2021-01-14T20:53:07Z

On Tue, Jan 12, 2021 at 11:01:19PM +0100, Christian Brauner wrote:
> From: Christoph Hellwig <hch@lst.de>
>
> Enable idmapped mounts for xfs. This basically just means passing down
> the user_namespace argument from the VFS methods down to where it is
> passed to helper.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
....
> @@ -654,6 +658,7 @@ xfs_vn_change_ok(
> */
> static int
> xfs_setattr_nonsize(
> + struct user_namespace *mnt_userns,
> struct xfs_inode *ip,
> struct iattr *iattr)
> {
> @@ -813,7 +818,7 @@ xfs_setattr_nonsize(
> * Posix ACL code seems to care about this issue either.
> */
> if (mask & ATTR_MODE) {
> - error = posix_acl_chmod(&init_user_ns, inode, inode->i_mode);
> + error = posix_acl_chmod(mnt_userns, inode, inode->i_mode);
> if (error)
> return error;
> }
> @@ -868,7 +873,7 @@ xfs_setattr_size(
> * Use the regular setattr path to update the timestamps.
> */
> iattr->ia_valid &= ~ATTR_SIZE;
> - return xfs_setattr_nonsize(ip, iattr);
> + return xfs_setattr_nonsize(&init_user_ns, ip, iattr);

Shouldn't that be passing mnt_userns?

> }
>
> /*
> @@ -1037,6 +1042,7 @@ xfs_setattr_size(
>
> int
> xfs_vn_setattr_size(
> + struct user_namespace *mnt_userns,
> struct dentry *dentry,
> struct iattr *iattr)
> {
> @@ -1045,7 +1051,7 @@ xfs_vn_setattr_size(
>
> trace_xfs_setattr(ip);
>
> - error = xfs_vn_change_ok(dentry, iattr);
> + error = xfs_vn_change_ok(mnt_userns, dentry, iattr);
> if (error)
> return error;
> return xfs_setattr_size(ip, iattr);

And this passing mnt_userns down into xfs_setattr_size()? Seems
like a bit of a landmine...

Cheers,

Dave.
--
Dave Chinner
david@fromorbit.com