Skip to content

Commit 6883cd7

Browse files
committed
reiserfs: Don't clear SGID when inheriting ACLs
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 __reiserfs_set_acl() into reiserfs_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: 0739310 CC: [email protected] CC: [email protected] Signed-off-by: Jan Kara <[email protected]>
1 parent 87b2c3f commit 6883cd7

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

fs/reiserfs/xattr_acl.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,14 @@ reiserfs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
3737
error = journal_begin(&th, inode->i_sb, jcreate_blocks);
3838
reiserfs_write_unlock(inode->i_sb);
3939
if (error == 0) {
40+
if (type == ACL_TYPE_ACCESS && acl) {
41+
error = posix_acl_update_mode(inode, &inode->i_mode,
42+
&acl);
43+
if (error)
44+
goto unlock;
45+
}
4046
error = __reiserfs_set_acl(&th, inode, type, acl);
47+
unlock:
4148
reiserfs_write_lock(inode->i_sb);
4249
error2 = journal_end(&th);
4350
reiserfs_write_unlock(inode->i_sb);
@@ -241,11 +248,6 @@ __reiserfs_set_acl(struct reiserfs_transaction_handle *th, struct inode *inode,
241248
switch (type) {
242249
case ACL_TYPE_ACCESS:
243250
name = XATTR_NAME_POSIX_ACL_ACCESS;
244-
if (acl) {
245-
error = posix_acl_update_mode(inode, &inode->i_mode, &acl);
246-
if (error)
247-
return error;
248-
}
249251
break;
250252
case ACL_TYPE_DEFAULT:
251253
name = XATTR_NAME_POSIX_ACL_DEFAULT;

0 commit comments

Comments
 (0)