All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: "Darrick J. Wong" <djwong@kernel.org>
Cc: linux-xfs@vger.kernel.org, fdmanana@kernel.org,
	andrey.zhadchenko@virtuozzo.com, brauner@kernel.org, hch@lst.de
Subject: Re: [PATCH 1/2] xfs: use setattr_copy to set vfs inode attributes
Date: Thu, 10 Mar 2022 08:22:11 +1100	[thread overview]
Message-ID: <20220309212211.GF661808@dread.disaster.area> (raw)
In-Reply-To: <164685373184.495833.7593050602112292799.stgit@magnolia>

On Wed, Mar 09, 2022 at 11:22:11AM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> Filipe Manana pointed out that XFS' behavior w.r.t. setuid/setgid
> revocation isn't consistent with btrfs[1] or ext4.  Those two
> filesystems use the VFS function setattr_copy to convey certain
> attributes from struct iattr into the VFS inode structure.
> 
> Andrey Zhadchenko reported[2] that XFS uses the wrong user namespace to
> decide if it should clear setgid and setuid on a file attribute update.
> This is a second symptom of the problem that Filipe noticed.
> 
> XFS, on the other hand, open-codes setattr_copy in xfs_setattr_mode,
> xfs_setattr_nonsize, and xfs_setattr_time.  Regrettably, setattr_copy is
> /not/ a simple copy function; it contains additional logic to clear the
> setgid bit when setting the mode, and XFS' version no longer matches.
> 
> The VFS implements its own setuid/setgid stripping logic, which
> establishes consistent behavior.  It's a tad unfortunate that it's
> scattered across notify_change, should_remove_suid, and setattr_copy but
> XFS should really follow the Linux VFS.  Adapt XFS to use the VFS
> functions and get rid of the old functions.
> 
> [1] https://lore.kernel.org/fstests/CAL3q7H47iNQ=Wmk83WcGB-KBJVOEtR9+qGczzCeXJ9Y2KCV25Q@mail.gmail.com/
> [2] https://lore.kernel.org/linux-xfs/20220221182218.748084-1-andrey.zhadchenko@virtuozzo.com/
> 
> Fixes: f736d93d76d3 ("xfs: support idmapped mounts")
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> ---
>  fs/xfs/xfs_iops.c |   56 +++--------------------------------------------------
>  fs/xfs/xfs_pnfs.c |    3 ++-
>  2 files changed, 5 insertions(+), 54 deletions(-)

Looks good, nice cleanup as well as being more correct.

Reviewed-by: Dave Chinner <dchinner@redhat.com>
-- 
Dave Chinner
david@fromorbit.com

  reply	other threads:[~2022-03-09 21:22 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-09 19:22 [PATCHSET 0/2] xfs: use setattr_copy to set VFS file attributes Darrick J. Wong
2022-03-09 19:22 ` [PATCH 1/2] xfs: use setattr_copy to set vfs inode attributes Darrick J. Wong
2022-03-09 21:22   ` Dave Chinner [this message]
2022-03-10  8:07   ` Christoph Hellwig
2022-03-10 10:11   ` Christian Brauner
2022-03-10 17:34     ` Darrick J. Wong
2022-03-11  7:54       ` Christian Brauner
2022-03-09 19:22 ` [PATCH 2/2] xfs: refactor user/group quota chown in xfs_setattr_nonsize Darrick J. Wong
2022-03-09 21:25   ` Dave Chinner
2022-03-10  8:10   ` Christoph Hellwig
2022-03-10  9:59   ` Christian Brauner
2022-03-09 23:01 ` [PATCHSET 0/2] xfs: use setattr_copy to set VFS file attributes Andrey Zhadchenko

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=20220309212211.GF661808@dread.disaster.area \
    --to=david@fromorbit.com \
    --cc=andrey.zhadchenko@virtuozzo.com \
    --cc=brauner@kernel.org \
    --cc=djwong@kernel.org \
    --cc=fdmanana@kernel.org \
    --cc=hch@lst.de \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.