* [Cluster-devel] [PATCH 0/11 v1] Fix inheritance of SGID in presence of default ACLs @ 2017-06-22 13:31 Jan Kara 2017-06-22 13:31 ` [Cluster-devel] [PATCH 04/11] gfs2: Don't clear SGID when inheriting ACLs Jan Kara 0 siblings, 1 reply; 4+ messages in thread From: Jan Kara @ 2017-06-22 13:31 UTC (permalink / raw) To: cluster-devel.redhat.com Hello, this patch set fixes a problem introduced by commit 073931017b49 "posix_acl: Clear SGID bit when setting file permissions". The problem is that when new directory 'DIR1' is created in a directory 'DIR0' with SGID bit set, DIR1 is expected to have SGID bit set (and owning group equal to the owning group of 'DIR0'). However when 'DIR0' also has some default ACLs that 'DIR1' inherits, setting these ACLs will result in SGID bit on 'DIR1' to get cleared if user is not member of the owning group. The problem is fixed by moving posix_acl_update_mode() so that it does not get called when default ACLs are inherited. I have created new generic/441 test for this and verified that generic/314, generic/375, and generic/441 pass for ext2, ext4, btrfs, xfs, ocfs2, reiserfs. All patches in this series are completely independent so fs maintainers please pick them up as soon as they get reviewed. I'm leaving for three weeks of vacation at the end of the week so I won't be able to push this further for some time. Honza ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Cluster-devel] [PATCH 04/11] gfs2: Don't clear SGID when inheriting ACLs 2017-06-22 13:31 [Cluster-devel] [PATCH 0/11 v1] Fix inheritance of SGID in presence of default ACLs Jan Kara @ 2017-06-22 13:31 ` Jan Kara 2017-07-18 16:18 ` Jan Kara 0 siblings, 1 reply; 4+ messages in thread From: Jan Kara @ 2017-06-22 13:31 UTC (permalink / raw) To: cluster-devel.redhat.com When new directory 'DIR1' is created in a directory 'DIR0' with SGID bit set, DIR1 is expected to have SGID bit set (and owning group equal to the owning group of 'DIR0'). However when 'DIR0' also has some default ACLs that 'DIR1' inherits, setting these ACLs will result in SGID bit on 'DIR1' to get cleared if user is not member of the owning group. Fix the problem by moving posix_acl_update_mode() out of __gfs2_set_acl() into gfs2_set_acl(). That way the function will not be called when inheriting ACLs which is what we want as it prevents SGID bit clearing and the mode has been properly set by posix_acl_create() anyway. Fixes: 073931017b49d9458aa351605b43a7e34598caef CC: stable at vger.kernel.org CC: cluster-devel at redhat.com CC: Bob Peterson <rpeterso@redhat.com> Signed-off-by: Jan Kara <jack@suse.cz> --- fs/gfs2/acl.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/fs/gfs2/acl.c b/fs/gfs2/acl.c index 2524807ee070..a6d962323790 100644 --- a/fs/gfs2/acl.c +++ b/fs/gfs2/acl.c @@ -86,19 +86,6 @@ int __gfs2_set_acl(struct inode *inode, struct posix_acl *acl, int type) char *data; const char *name = gfs2_acl_name(type); - if (acl && acl->a_count > GFS2_ACL_MAX_ENTRIES(GFS2_SB(inode))) - return -E2BIG; - - if (type == ACL_TYPE_ACCESS) { - umode_t mode = inode->i_mode; - - error = posix_acl_update_mode(inode, &inode->i_mode, &acl); - if (error) - return error; - if (mode != inode->i_mode) - mark_inode_dirty(inode); - } - if (acl) { len = posix_acl_to_xattr(&init_user_ns, acl, NULL, 0); if (len == 0) @@ -130,6 +117,9 @@ int gfs2_set_acl(struct inode *inode, struct posix_acl *acl, int type) bool need_unlock = false; int ret; + if (acl && acl->a_count > GFS2_ACL_MAX_ENTRIES(GFS2_SB(inode))) + return -E2BIG; + ret = gfs2_rsqa_alloc(ip); if (ret) return ret; @@ -140,7 +130,18 @@ int gfs2_set_acl(struct inode *inode, struct posix_acl *acl, int type) return ret; need_unlock = true; } + if (type == ACL_TYPE_ACCESS && acl) { + umode_t mode = inode->i_mode; + + ret = posix_acl_update_mode(inode, &inode->i_mode, &acl); + if (ret) + goto unlock; + if (mode != inode->i_mode) + mark_inode_dirty(inode); + } + ret = __gfs2_set_acl(inode, acl, type); +unlock: if (need_unlock) gfs2_glock_dq_uninit(&gh); return ret; -- 2.12.3 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Cluster-devel] [PATCH 04/11] gfs2: Don't clear SGID when inheriting ACLs 2017-06-22 13:31 ` [Cluster-devel] [PATCH 04/11] gfs2: Don't clear SGID when inheriting ACLs Jan Kara @ 2017-07-18 16:18 ` Jan Kara 2017-07-19 16:17 ` Bob Peterson 0 siblings, 1 reply; 4+ messages in thread From: Jan Kara @ 2017-07-18 16:18 UTC (permalink / raw) To: cluster-devel.redhat.com On Thu 22-06-17 15:31:08, Jan Kara wrote: > When new directory 'DIR1' is created in a directory 'DIR0' with SGID bit > set, DIR1 is expected to have SGID bit set (and owning group equal to > the owning group of 'DIR0'). However when 'DIR0' also has some default > ACLs that 'DIR1' inherits, setting these ACLs will result in SGID bit on > 'DIR1' to get cleared if user is not member of the owning group. > > Fix the problem by moving posix_acl_update_mode() out of > __gfs2_set_acl() into gfs2_set_acl(). That way the function will not be > called when inheriting ACLs which is what we want as it prevents SGID > bit clearing and the mode has been properly set by posix_acl_create() > anyway. > > Fixes: 073931017b49d9458aa351605b43a7e34598caef > CC: stable at vger.kernel.org > CC: cluster-devel at redhat.com > CC: Bob Peterson <rpeterso@redhat.com> > Signed-off-by: Jan Kara <jack@suse.cz> Bob, can you please pick up this fix? Thanks! Honza > --- > fs/gfs2/acl.c | 27 ++++++++++++++------------- > 1 file changed, 14 insertions(+), 13 deletions(-) > > diff --git a/fs/gfs2/acl.c b/fs/gfs2/acl.c > index 2524807ee070..a6d962323790 100644 > --- a/fs/gfs2/acl.c > +++ b/fs/gfs2/acl.c > @@ -86,19 +86,6 @@ int __gfs2_set_acl(struct inode *inode, struct posix_acl *acl, int type) > char *data; > const char *name = gfs2_acl_name(type); > > - if (acl && acl->a_count > GFS2_ACL_MAX_ENTRIES(GFS2_SB(inode))) > - return -E2BIG; > - > - if (type == ACL_TYPE_ACCESS) { > - umode_t mode = inode->i_mode; > - > - error = posix_acl_update_mode(inode, &inode->i_mode, &acl); > - if (error) > - return error; > - if (mode != inode->i_mode) > - mark_inode_dirty(inode); > - } > - > if (acl) { > len = posix_acl_to_xattr(&init_user_ns, acl, NULL, 0); > if (len == 0) > @@ -130,6 +117,9 @@ int gfs2_set_acl(struct inode *inode, struct posix_acl *acl, int type) > bool need_unlock = false; > int ret; > > + if (acl && acl->a_count > GFS2_ACL_MAX_ENTRIES(GFS2_SB(inode))) > + return -E2BIG; > + > ret = gfs2_rsqa_alloc(ip); > if (ret) > return ret; > @@ -140,7 +130,18 @@ int gfs2_set_acl(struct inode *inode, struct posix_acl *acl, int type) > return ret; > need_unlock = true; > } > + if (type == ACL_TYPE_ACCESS && acl) { > + umode_t mode = inode->i_mode; > + > + ret = posix_acl_update_mode(inode, &inode->i_mode, &acl); > + if (ret) > + goto unlock; > + if (mode != inode->i_mode) > + mark_inode_dirty(inode); > + } > + > ret = __gfs2_set_acl(inode, acl, type); > +unlock: > if (need_unlock) > gfs2_glock_dq_uninit(&gh); > return ret; > -- > 2.12.3 > -- Jan Kara <jack@suse.com> SUSE Labs, CR ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Cluster-devel] [PATCH 04/11] gfs2: Don't clear SGID when inheriting ACLs 2017-07-18 16:18 ` Jan Kara @ 2017-07-19 16:17 ` Bob Peterson 0 siblings, 0 replies; 4+ messages in thread From: Bob Peterson @ 2017-07-19 16:17 UTC (permalink / raw) To: cluster-devel.redhat.com ----- Original Message ----- | On Thu 22-06-17 15:31:08, Jan Kara wrote: | > When new directory 'DIR1' is created in a directory 'DIR0' with SGID bit | > set, DIR1 is expected to have SGID bit set (and owning group equal to | > the owning group of 'DIR0'). However when 'DIR0' also has some default | > ACLs that 'DIR1' inherits, setting these ACLs will result in SGID bit on | > 'DIR1' to get cleared if user is not member of the owning group. | > | > Fix the problem by moving posix_acl_update_mode() out of | > __gfs2_set_acl() into gfs2_set_acl(). That way the function will not be | > called when inheriting ACLs which is what we want as it prevents SGID | > bit clearing and the mode has been properly set by posix_acl_create() | > anyway. | > | > Fixes: 073931017b49d9458aa351605b43a7e34598caef | > CC: stable at vger.kernel.org | > CC: cluster-devel at redhat.com | > CC: Bob Peterson <rpeterso@redhat.com> | > Signed-off-by: Jan Kara <jack@suse.cz> | | Bob, can you please pick up this fix? Thanks! Hi Honza, Sorry this slipped my attention for so long. This is now applied to the for-next branch of the linux-gfs2 tree: https://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2.git/commit/fs/gfs2?h=for-next&id=914cea93dd89f00b41c1d8ff93f17be47356a36a Regards, Bob Peterson Red Hat File Systems ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-07-19 16:17 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-06-22 13:31 [Cluster-devel] [PATCH 0/11 v1] Fix inheritance of SGID in presence of default ACLs Jan Kara 2017-06-22 13:31 ` [Cluster-devel] [PATCH 04/11] gfs2: Don't clear SGID when inheriting ACLs Jan Kara 2017-07-18 16:18 ` Jan Kara 2017-07-19 16:17 ` Bob Peterson
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).