public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* Request to cherry-pick 01ea173e103edd5ec41acec65b9261b87e123fc2 to v5.10
@ 2022-09-06 18:35 Varsha Teratipally
  2022-09-06 18:36 ` [PATCH] xfs: fix up non-directory creation in SGID directories Varsha Teratipally
  2022-09-07  7:46 ` Request to cherry-pick 01ea173e103edd5ec41acec65b9261b87e123fc2 to v5.10 Amir Goldstein
  0 siblings, 2 replies; 12+ messages in thread
From: Varsha Teratipally @ 2022-09-06 18:35 UTC (permalink / raw)
  To: Amir Goldstein, Darrick J. Wong; +Cc: linux-xfs, linux-kernel, stable

Hi all,

Commit 01ea173e103edd5ec41acec65b9261b87e123fc2 (upstream: xfs: fix up
non-directory creation in SGID directories) fixes an issue where in xfs
sometimes, a local user could create files with an unitended group
permissions as an owner and execution where a directory is SGID and belongs to a certain group and is writable by a user who is not a member of this group and seems like a good candidate for the v5.10 stable tree given that 5.10 is used in versions of debian, ubuntu.

This patch applies cleanly. Let me know what you think



^ permalink raw reply	[flat|nested] 12+ messages in thread
* [PATCH] xfs: fix up non-directory creation in SGID directories
@ 2021-01-13 18:46 Christoph Hellwig
  2021-01-14 10:45 ` Christian Brauner
  0 siblings, 1 reply; 12+ messages in thread
From: Christoph Hellwig @ 2021-01-13 18:46 UTC (permalink / raw)
  To: linux-xfs; +Cc: Christian Brauner

XFS always inherits the SGID bit if it is set on the parent inode, while
the generic inode_init_owner does not do this in a few cases where it can
create a possible security problem, see commit 0fa3ecd87848
("Fix up non-directory creation in SGID directories") for details.

Switch XFS to use the generic helper for the normal path to fix this,
just keeping the simple field inheritance open coded for the case of the
non-sgid case with the bsdgrpid mount option.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Reported-by: Christian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_inode.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index b7352bc4c81527..7289325aa5c7c0 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -775,6 +775,7 @@ xfs_init_new_inode(
 	prid_t			prid,
 	struct xfs_inode	**ipp)
 {
+	struct inode		*dir = pip ? VFS_I(pip) : NULL;
 	struct xfs_mount	*mp = tp->t_mountp;
 	struct xfs_inode	*ip;
 	unsigned int		flags;
@@ -804,18 +805,17 @@ xfs_init_new_inode(
 
 	ASSERT(ip != NULL);
 	inode = VFS_I(ip);
-	inode->i_mode = mode;
 	set_nlink(inode, nlink);
-	inode->i_uid = current_fsuid();
 	inode->i_rdev = rdev;
 	ip->i_d.di_projid = prid;
 
-	if (pip && XFS_INHERIT_GID(pip)) {
-		inode->i_gid = VFS_I(pip)->i_gid;
-		if ((VFS_I(pip)->i_mode & S_ISGID) && S_ISDIR(mode))
-			inode->i_mode |= S_ISGID;
+	if (dir && !(dir->i_mode & S_ISGID) &&
+	    (mp->m_flags & XFS_MOUNT_GRPID)) {
+		inode->i_uid = current_fsuid();
+		inode->i_gid = dir->i_gid;
+		inode->i_mode = mode;
 	} else {
-		inode->i_gid = current_fsgid();
+		inode_init_owner(inode, dir, mode);
 	}
 
 	/*
-- 
2.29.2


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

end of thread, other threads:[~2022-09-14 16:40 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-06 18:35 Request to cherry-pick 01ea173e103edd5ec41acec65b9261b87e123fc2 to v5.10 Varsha Teratipally
2022-09-06 18:36 ` [PATCH] xfs: fix up non-directory creation in SGID directories Varsha Teratipally
2022-09-07  7:40   ` Amir Goldstein
2022-09-07  7:43     ` Amir Goldstein
2022-09-08 11:48   ` Greg KH
2022-09-08 12:02     ` Amir Goldstein
2022-09-14 16:39       ` Darrick J. Wong
2022-09-07  7:46 ` Request to cherry-pick 01ea173e103edd5ec41acec65b9261b87e123fc2 to v5.10 Amir Goldstein
  -- strict thread matches above, loose matches on Subject: below --
2021-01-13 18:46 [PATCH] xfs: fix up non-directory creation in SGID directories Christoph Hellwig
2021-01-14 10:45 ` Christian Brauner
2021-01-14 16:06   ` Darrick J. Wong
2021-01-14 16:37     ` Christian Brauner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox