Skip to content

Commit 8496946

Browse files
committed
hfsplus: 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 creating __hfsplus_set_posix_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: 0739310 CC: [email protected] Signed-off-by: Jan Kara <[email protected]>
1 parent 34363c0 commit 8496946

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

fs/hfsplus/posix_acl.c

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ struct posix_acl *hfsplus_get_posix_acl(struct inode *inode, int type)
5151
return acl;
5252
}
5353

54-
int hfsplus_set_posix_acl(struct inode *inode, struct posix_acl *acl,
55-
int type)
54+
static int __hfsplus_set_posix_acl(struct inode *inode, struct posix_acl *acl,
55+
int type)
5656
{
5757
int err;
5858
char *xattr_name;
@@ -64,12 +64,6 @@ int hfsplus_set_posix_acl(struct inode *inode, struct posix_acl *acl,
6464
switch (type) {
6565
case ACL_TYPE_ACCESS:
6666
xattr_name = XATTR_NAME_POSIX_ACL_ACCESS;
67-
if (acl) {
68-
err = posix_acl_update_mode(inode, &inode->i_mode, &acl);
69-
if (err)
70-
return err;
71-
}
72-
err = 0;
7367
break;
7468

7569
case ACL_TYPE_DEFAULT:
@@ -105,6 +99,18 @@ int hfsplus_set_posix_acl(struct inode *inode, struct posix_acl *acl,
10599
return err;
106100
}
107101

102+
int hfsplus_set_posix_acl(struct inode *inode, struct posix_acl *acl, int type)
103+
{
104+
int err;
105+
106+
if (type == ACL_TYPE_ACCESS && acl) {
107+
err = posix_acl_update_mode(inode, &inode->i_mode, &acl);
108+
if (err)
109+
return err;
110+
}
111+
return __hfsplus_set_posix_acl(inode, acl, type);
112+
}
113+
108114
int hfsplus_init_posix_acl(struct inode *inode, struct inode *dir)
109115
{
110116
int err = 0;
@@ -122,15 +128,15 @@ int hfsplus_init_posix_acl(struct inode *inode, struct inode *dir)
122128
return err;
123129

124130
if (default_acl) {
125-
err = hfsplus_set_posix_acl(inode, default_acl,
126-
ACL_TYPE_DEFAULT);
131+
err = __hfsplus_set_posix_acl(inode, default_acl,
132+
ACL_TYPE_DEFAULT);
127133
posix_acl_release(default_acl);
128134
}
129135

130136
if (acl) {
131137
if (!err)
132-
err = hfsplus_set_posix_acl(inode, acl,
133-
ACL_TYPE_ACCESS);
138+
err = __hfsplus_set_posix_acl(inode, acl,
139+
ACL_TYPE_ACCESS);
134140
posix_acl_release(acl);
135141
}
136142
return err;

0 commit comments

Comments
 (0)