linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Christoph Hellwig <hch@lst.de>
Cc: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 3/3] xfs: remove the kuid/kgid conversion wrappers
Date: Fri, 21 Feb 2020 08:19:43 -0800	[thread overview]
Message-ID: <20200221161943.GY9506@magnolia> (raw)
In-Reply-To: <20200221155450.GA9228@lst.de>

On Fri, Feb 21, 2020 at 04:54:50PM +0100, Christoph Hellwig wrote:
> On Thu, Feb 20, 2020 at 05:26:16PM -0800, Darrick J. Wong wrote:
> > >  	to->di_format = from->di_format;
> > > -	inode->i_uid = xfs_uid_to_kuid(be32_to_cpu(from->di_uid));
> > 
> > Hmm.  I'm not up on my userns-fu, but right now this is effectively:
> > 
> > inode->i_uid = make_kuid(&init_user_ns, be32_to_cpu(from->di_uid));
> > 
> > > -	inode->i_gid = xfs_gid_to_kgid(be32_to_cpu(from->di_gid));
> > > +	i_uid_write(inode, be32_to_cpu(from->di_uid));
> > 
> > Whereas this is:
> > 
> > inode->i_uid = make_kuid(inode->i_sb->s_user_ns, be32_to_cpu(...));
> 
> Yes.  Which is intentional and mentioned in the commit log.
> 
> > 
> > What happens if s_user_ns != init_user_ns?  Isn't this a behavior
> > change?  Granted, it looks like many of the other filesystems use
> > i_uid_write so maybe we're the ones who are doing it wrong...?
> 
> In that case the uid gets translated.  Which is intentional as it is
> done everywhere else and XFS is the ugly ducking out that fails
> to properly take the user_ns into account.

Ok, we were doing it wrong.  Should this series have fixed that as the
first patch (so that we could push it into old kernels) followed by the
actual icdinode field removal?

(Granted nobody seems to have complained...)

> > > --- a/fs/xfs/xfs_acl.c
> > > +++ b/fs/xfs/xfs_acl.c
> > > @@ -67,10 +67,12 @@ xfs_acl_from_disk(
> > >  
> > >  		switch (acl_e->e_tag) {
> > >  		case ACL_USER:
> > > -			acl_e->e_uid = xfs_uid_to_kuid(be32_to_cpu(ace->ae_id));
> > > +			acl_e->e_uid = make_kuid(&init_user_ns,
> > > +						 be32_to_cpu(ace->ae_id));
> > 
> > And I'm assuming that the "gross layering violation in the vfs xattr
> > code" is why it's init_user_ns here?
> 
> Yes.  The generic xattr code checks if the attr is one of the ACL ones
> in common code before calling into the fs and already translates them,
> causing a giant mess.

Got it.

--D

  reply	other threads:[~2020-02-21 16:21 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-18 21:00 remove the di_uid/di_gid fields from the XFS icdinode Christoph Hellwig
2020-02-18 21:00 ` [PATCH 1/3] xfs: ensure that the inode uid/gid match values match the icdinode ones Christoph Hellwig
2020-02-19 10:32   ` Carlos Maiolino
2020-02-19 14:26   ` Brian Foster
2020-02-19 14:47   ` Chandan Rajendra
2020-02-18 21:00 ` [PATCH 2/3] xfs: remove the icdinode di_uid/di_gid members Christoph Hellwig
2020-02-19 10:51   ` Carlos Maiolino
2020-02-19 14:26   ` Brian Foster
2020-02-19 16:25   ` Chandan Rajendra
2020-02-18 21:00 ` [PATCH 3/3] xfs: remove the kuid/kgid conversion wrappers Christoph Hellwig
2020-02-19 11:05   ` Carlos Maiolino
2020-02-19 14:26   ` Brian Foster
2020-02-21  1:26   ` Darrick J. Wong
2020-02-21 15:54     ` Christoph Hellwig
2020-02-21 16:19       ` Darrick J. Wong [this message]
2020-02-21 16:29         ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200221161943.GY9506@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=hch@lst.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).