* [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 ` [PATCH 01/11] ext4: Don't clear SGID when inheriting ACLs Jan Kara
2017-06-22 13:31 ` [PATCH 02/11] ext2: " Jan Kara
0 siblings, 2 replies; 6+ messages in thread
From: Jan Kara @ 2017-06-22 13:31 UTC (permalink / raw)
To: linux-fsdevel
Cc: Theodore Ts'o, Dave Kleikamp, jfs-discussion, cluster-devel,
Jan Kara, Darrick J . Wong, linux-btrfs, reiserfs-devel,
linux-xfs, David Sterba, pvfs2-developers, linux-ext4,
ocfs2-devel, Mike Marshall
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] 6+ messages in thread
* [PATCH 01/11] ext4: Don't clear SGID when inheriting ACLs
2017-06-22 13:31 [PATCH 0/11 v1] Fix inheritance of SGID in presence of default ACLs Jan Kara
@ 2017-06-22 13:31 ` Jan Kara
2017-06-22 15:32 ` Andreas Gruenbacher
2017-07-18 16:16 ` Jan Kara
2017-06-22 13:31 ` [PATCH 02/11] ext2: " Jan Kara
1 sibling, 2 replies; 6+ messages in thread
From: Jan Kara @ 2017-06-22 13:31 UTC (permalink / raw)
To: linux-fsdevel
Cc: Andreas Gruenbacher, Jan Kara, stable, linux-ext4,
Theodore Ts'o
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
__ext4_set_acl() into ext4_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@vger.kernel.org
CC: linux-ext4@vger.kernel.org
CC: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Jan Kara <jack@suse.cz>
---
fs/ext4/acl.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/fs/ext4/acl.c b/fs/ext4/acl.c
index 3ec0e46de95f..37242af33ff2 100644
--- a/fs/ext4/acl.c
+++ b/fs/ext4/acl.c
@@ -193,13 +193,6 @@ __ext4_set_acl(handle_t *handle, struct inode *inode, int type,
switch (type) {
case ACL_TYPE_ACCESS:
name_index = EXT4_XATTR_INDEX_POSIX_ACL_ACCESS;
- if (acl) {
- error = posix_acl_update_mode(inode, &inode->i_mode, &acl);
- if (error)
- return error;
- inode->i_ctime = current_time(inode);
- ext4_mark_inode_dirty(handle, inode);
- }
break;
case ACL_TYPE_DEFAULT:
@@ -242,7 +235,16 @@ ext4_set_acl(struct inode *inode, struct posix_acl *acl, int type)
if (IS_ERR(handle))
return PTR_ERR(handle);
+ if (type == ACL_TYPE_ACCESS && acl) {
+ error = posix_acl_update_mode(inode, &inode->i_mode, &acl);
+ if (error)
+ goto out_stop;
+ inode->i_ctime = current_time(inode);
+ ext4_mark_inode_dirty(handle, inode);
+ }
+
error = __ext4_set_acl(handle, inode, type, acl);
+out_stop:
ext4_journal_stop(handle);
if (error == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries))
goto retry;
--
2.12.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 02/11] ext2: Don't clear SGID when inheriting ACLs
2017-06-22 13:31 [PATCH 0/11 v1] Fix inheritance of SGID in presence of default ACLs Jan Kara
2017-06-22 13:31 ` [PATCH 01/11] ext4: Don't clear SGID when inheriting ACLs Jan Kara
@ 2017-06-22 13:31 ` Jan Kara
1 sibling, 0 replies; 6+ messages in thread
From: Jan Kara @ 2017-06-22 13:31 UTC (permalink / raw)
To: linux-fsdevel; +Cc: Andreas Gruenbacher, Jan Kara, stable, linux-ext4
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 creating __ext2_set_acl() function that does not call
posix_acl_update_mode() and use it when inheriting ACLs. That prevents
SGID bit clearing and the mode has been properly set by
posix_acl_create() anyway.
Fixes: 073931017b49d9458aa351605b43a7e34598caef
CC: stable@vger.kernel.org
CC: linux-ext4@vger.kernel.org
Signed-off-by: Jan Kara <jack@suse.cz>
---
fs/ext2/acl.c | 36 ++++++++++++++++++++++--------------
1 file changed, 22 insertions(+), 14 deletions(-)
diff --git a/fs/ext2/acl.c b/fs/ext2/acl.c
index 79dafa71effd..069c0dceda01 100644
--- a/fs/ext2/acl.c
+++ b/fs/ext2/acl.c
@@ -175,11 +175,8 @@ ext2_get_acl(struct inode *inode, int type)
return acl;
}
-/*
- * inode->i_mutex: down
- */
-int
-ext2_set_acl(struct inode *inode, struct posix_acl *acl, int type)
+static int
+__ext2_set_acl(struct inode *inode, struct posix_acl *acl, int type)
{
int name_index;
void *value = NULL;
@@ -189,13 +186,6 @@ ext2_set_acl(struct inode *inode, struct posix_acl *acl, int type)
switch(type) {
case ACL_TYPE_ACCESS:
name_index = EXT2_XATTR_INDEX_POSIX_ACL_ACCESS;
- if (acl) {
- error = posix_acl_update_mode(inode, &inode->i_mode, &acl);
- if (error)
- return error;
- inode->i_ctime = current_time(inode);
- mark_inode_dirty(inode);
- }
break;
case ACL_TYPE_DEFAULT:
@@ -222,6 +212,24 @@ ext2_set_acl(struct inode *inode, struct posix_acl *acl, int type)
}
/*
+ * inode->i_mutex: down
+ */
+int
+ext2_set_acl(struct inode *inode, struct posix_acl *acl, int type)
+{
+ int error;
+
+ if (type == ACL_TYPE_ACCESS && acl) {
+ error = posix_acl_update_mode(inode, &inode->i_mode, &acl);
+ if (error)
+ return error;
+ inode->i_ctime = current_time(inode);
+ mark_inode_dirty(inode);
+ }
+ return __ext2_set_acl(inode, acl, type);
+}
+
+/*
* Initialize the ACLs of a new inode. Called from ext2_new_inode.
*
* dir->i_mutex: down
@@ -238,12 +246,12 @@ ext2_init_acl(struct inode *inode, struct inode *dir)
return error;
if (default_acl) {
- error = ext2_set_acl(inode, default_acl, ACL_TYPE_DEFAULT);
+ error = __ext2_set_acl(inode, default_acl, ACL_TYPE_DEFAULT);
posix_acl_release(default_acl);
}
if (acl) {
if (!error)
- error = ext2_set_acl(inode, acl, ACL_TYPE_ACCESS);
+ error = __ext2_set_acl(inode, acl, ACL_TYPE_ACCESS);
posix_acl_release(acl);
}
return error;
--
2.12.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 01/11] ext4: Don't clear SGID when inheriting ACLs
2017-06-22 13:31 ` [PATCH 01/11] ext4: Don't clear SGID when inheriting ACLs Jan Kara
@ 2017-06-22 15:32 ` Andreas Gruenbacher
2017-07-18 16:16 ` Jan Kara
1 sibling, 0 replies; 6+ messages in thread
From: Andreas Gruenbacher @ 2017-06-22 15:32 UTC (permalink / raw)
To: Jan Kara; +Cc: linux-fsdevel, stable, linux-ext4, Theodore Ts'o
On Thu, Jun 22, 2017 at 3:31 PM, Jan Kara <jack@suse.cz> 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
> __ext4_set_acl() into ext4_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@vger.kernel.org
> CC: linux-ext4@vger.kernel.org
> CC: "Theodore Ts'o" <tytso@mit.edu>
> Signed-off-by: Jan Kara <jack@suse.cz>
This is looking good, thanks.
Reviewed-by: Andreas Gruenbacher <agruenba@redhat.com>
> ---
> fs/ext4/acl.c | 16 +++++++++-------
> 1 file changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/fs/ext4/acl.c b/fs/ext4/acl.c
> index 3ec0e46de95f..37242af33ff2 100644
> --- a/fs/ext4/acl.c
> +++ b/fs/ext4/acl.c
> @@ -193,13 +193,6 @@ __ext4_set_acl(handle_t *handle, struct inode *inode, int type,
> switch (type) {
> case ACL_TYPE_ACCESS:
> name_index = EXT4_XATTR_INDEX_POSIX_ACL_ACCESS;
> - if (acl) {
> - error = posix_acl_update_mode(inode, &inode->i_mode, &acl);
> - if (error)
> - return error;
> - inode->i_ctime = current_time(inode);
> - ext4_mark_inode_dirty(handle, inode);
> - }
> break;
>
> case ACL_TYPE_DEFAULT:
> @@ -242,7 +235,16 @@ ext4_set_acl(struct inode *inode, struct posix_acl *acl, int type)
> if (IS_ERR(handle))
> return PTR_ERR(handle);
>
> + if (type == ACL_TYPE_ACCESS && acl) {
> + error = posix_acl_update_mode(inode, &inode->i_mode, &acl);
> + if (error)
> + goto out_stop;
> + inode->i_ctime = current_time(inode);
> + ext4_mark_inode_dirty(handle, inode);
> + }
> +
> error = __ext4_set_acl(handle, inode, type, acl);
> +out_stop:
> ext4_journal_stop(handle);
> if (error == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries))
> goto retry;
> --
> 2.12.3
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 01/11] ext4: Don't clear SGID when inheriting ACLs
2017-06-22 13:31 ` [PATCH 01/11] ext4: Don't clear SGID when inheriting ACLs Jan Kara
2017-06-22 15:32 ` Andreas Gruenbacher
@ 2017-07-18 16:16 ` Jan Kara
2017-07-31 3:34 ` Theodore Ts'o
1 sibling, 1 reply; 6+ messages in thread
From: Jan Kara @ 2017-07-18 16:16 UTC (permalink / raw)
To: linux-fsdevel
Cc: Andreas Gruenbacher, Jan Kara, linux-ext4, Theodore Ts'o
On Thu 22-06-17 15:31:05, 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
> __ext4_set_acl() into ext4_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@vger.kernel.org
> CC: linux-ext4@vger.kernel.org
> CC: "Theodore Ts'o" <tytso@mit.edu>
> Signed-off-by: Jan Kara <jack@suse.cz>
Ted, can you please pick up this fix? Thanks!
Honza
> ---
> fs/ext4/acl.c | 16 +++++++++-------
> 1 file changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/fs/ext4/acl.c b/fs/ext4/acl.c
> index 3ec0e46de95f..37242af33ff2 100644
> --- a/fs/ext4/acl.c
> +++ b/fs/ext4/acl.c
> @@ -193,13 +193,6 @@ __ext4_set_acl(handle_t *handle, struct inode *inode, int type,
> switch (type) {
> case ACL_TYPE_ACCESS:
> name_index = EXT4_XATTR_INDEX_POSIX_ACL_ACCESS;
> - if (acl) {
> - error = posix_acl_update_mode(inode, &inode->i_mode, &acl);
> - if (error)
> - return error;
> - inode->i_ctime = current_time(inode);
> - ext4_mark_inode_dirty(handle, inode);
> - }
> break;
>
> case ACL_TYPE_DEFAULT:
> @@ -242,7 +235,16 @@ ext4_set_acl(struct inode *inode, struct posix_acl *acl, int type)
> if (IS_ERR(handle))
> return PTR_ERR(handle);
>
> + if (type == ACL_TYPE_ACCESS && acl) {
> + error = posix_acl_update_mode(inode, &inode->i_mode, &acl);
> + if (error)
> + goto out_stop;
> + inode->i_ctime = current_time(inode);
> + ext4_mark_inode_dirty(handle, inode);
> + }
> +
> error = __ext4_set_acl(handle, inode, type, acl);
> +out_stop:
> ext4_journal_stop(handle);
> if (error == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries))
> goto retry;
> --
> 2.12.3
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 01/11] ext4: Don't clear SGID when inheriting ACLs
2017-07-18 16:16 ` Jan Kara
@ 2017-07-31 3:34 ` Theodore Ts'o
0 siblings, 0 replies; 6+ messages in thread
From: Theodore Ts'o @ 2017-07-31 3:34 UTC (permalink / raw)
To: Jan Kara; +Cc: linux-fsdevel, Andreas Gruenbacher, linux-ext4
On Tue, Jul 18, 2017 at 06:16:31PM +0200, Jan Kara wrote:
> On Thu 22-06-17 15:31:05, 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
> > __ext4_set_acl() into ext4_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@vger.kernel.org
> > CC: linux-ext4@vger.kernel.org
> > CC: "Theodore Ts'o" <tytso@mit.edu>
> > Signed-off-by: Jan Kara <jack@suse.cz>
>
> Ted, can you please pick up this fix? Thanks!
Thanks, applied.
- Ted
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-07-31 3:34 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-22 13:31 [PATCH 0/11 v1] Fix inheritance of SGID in presence of default ACLs Jan Kara
2017-06-22 13:31 ` [PATCH 01/11] ext4: Don't clear SGID when inheriting ACLs Jan Kara
2017-06-22 15:32 ` Andreas Gruenbacher
2017-07-18 16:16 ` Jan Kara
2017-07-31 3:34 ` Theodore Ts'o
2017-06-22 13:31 ` [PATCH 02/11] ext2: " Jan Kara
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).