linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xfs: do not clear S_ISUID|S_ISGID for idmapped mounts
@ 2022-02-21 18:22 Andrey Zhadchenko
  2022-02-22  8:33 ` Christoph Hellwig
  2022-02-25  1:57 ` Darrick J. Wong
  0 siblings, 2 replies; 16+ messages in thread
From: Andrey Zhadchenko @ 2022-02-21 18:22 UTC (permalink / raw)
  To: linux-xfs; +Cc: christian.brauner, hch, djwong

xfs_fileattr_set() handles idmapped mounts correctly and do not drop this
bits.
Unfortunately chown syscall results in different callstask:
i_op->xfs_vn_setattr()->...->xfs_setattr_nonsize() which checks if process
has CAP_FSETID capable in init_user_ns rather than mntns userns.

Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>
---
 fs/xfs/xfs_iops.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index 09211e1d08ad..5b1fe635d153 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -774,7 +774,7 @@ xfs_setattr_nonsize(
 		 * cleared upon successful return from chown()
 		 */
 		if ((inode->i_mode & (S_ISUID|S_ISGID)) &&
-		    !capable(CAP_FSETID))
+		    !capable_wrt_inode_uidgid(mnt_userns, inode, CAP_FSETID))
 			inode->i_mode &= ~(S_ISUID|S_ISGID);
 
 		/*
-- 
2.35.0.rc2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2022-02-25 17:11 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-21 18:22 [PATCH] xfs: do not clear S_ISUID|S_ISGID for idmapped mounts Andrey Zhadchenko
2022-02-22  8:33 ` Christoph Hellwig
2022-02-22  9:25   ` Andrey Zhadchenko
2022-02-22 10:24   ` Christian Brauner
2022-02-22 11:19     ` Andrey Zhadchenko
2022-02-22 12:23       ` Christian Brauner
2022-02-22 12:36         ` Christian Brauner
2022-02-22 12:44           ` Christian Brauner
2022-02-22 14:54           ` Andrey Zhadchenko
2022-02-22 15:03             ` Christian Brauner
2022-02-22 21:40             ` Dave Chinner
2022-02-23  8:11             ` Christian Brauner
2022-02-25  1:57 ` Darrick J. Wong
2022-02-25  9:45   ` Christian Brauner
2022-02-25 10:42     ` Andrey Zhadchenko
2022-02-25 17:11       ` Darrick J. Wong

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).