Skip to content

Commit e37a02c

Browse files
aaptelsmfrench
authored andcommitted
cifs: modefromsid: write mode ACE first
DACL should start with mode ACE first but we are putting it at the end. reorder them to put it first. Signed-off-by: Aurelien Aptel <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 352f2c9 commit e37a02c

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

fs/cifs/cifsacl.c

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -809,43 +809,45 @@ static int set_chmod_dacl(struct cifs_acl *pndacl, struct cifs_sid *pownersid,
809809
struct cifs_sid *pgrpsid, __u64 nmode, bool modefromsid)
810810
{
811811
u16 size = 0;
812+
u32 num_aces = 0;
812813
struct cifs_acl *pnndacl;
813814

814815
pnndacl = (struct cifs_acl *)((char *)pndacl + sizeof(struct cifs_acl));
815816

816-
size += fill_ace_for_sid((struct cifs_ace *) ((char *)pnndacl + size),
817-
pownersid, nmode, S_IRWXU);
818-
size += fill_ace_for_sid((struct cifs_ace *)((char *)pnndacl + size),
819-
pgrpsid, nmode, S_IRWXG);
820-
size += fill_ace_for_sid((struct cifs_ace *)((char *)pnndacl + size),
821-
&sid_everyone, nmode, S_IRWXO);
822-
823-
/* TBD: Move this ACE to the top of ACE list instead of bottom */
824817
if (modefromsid) {
825818
struct cifs_ace *pntace =
826819
(struct cifs_ace *)((char *)pnndacl + size);
827820
int i;
828821

829-
pntace->type = ACCESS_DENIED;
822+
pntace->type = ACCESS_ALLOWED;
830823
pntace->flags = 0x0;
824+
pntace->access_req = 0;
831825
pntace->sid.num_subauth = 3;
832826
pntace->sid.revision = 1;
833-
/* size = 1 + 1 + 2 + 4 + 1 + 1 + 6 + (psid->num_subauth * 4) */
834-
pntace->size = cpu_to_le16(28);
835-
size += 28;
836827
for (i = 0; i < NUM_AUTHS; i++)
837828
pntace->sid.authority[i] =
838829
sid_unix_NFS_mode.authority[i];
839830
pntace->sid.sub_auth[0] = sid_unix_NFS_mode.sub_auth[0];
840831
pntace->sid.sub_auth[1] = sid_unix_NFS_mode.sub_auth[1];
841832
pntace->sid.sub_auth[2] = cpu_to_le32(nmode & 07777);
842833

843-
pndacl->num_aces = cpu_to_le32(4);
844-
size += fill_ace_for_sid((struct cifs_ace *)((char *)pnndacl + size),
845-
&sid_unix_NFS_mode, nmode, S_IRWXO);
846-
} else
847-
pndacl->num_aces = cpu_to_le32(3);
834+
/* size = 1 + 1 + 2 + 4 + 1 + 1 + 6 + (psid->num_subauth*4) */
835+
pntace->size = cpu_to_le16(28);
836+
size += 28;
837+
num_aces++;
838+
}
839+
840+
size += fill_ace_for_sid((struct cifs_ace *) ((char *)pnndacl + size),
841+
pownersid, nmode, S_IRWXU);
842+
num_aces++;
843+
size += fill_ace_for_sid((struct cifs_ace *)((char *)pnndacl + size),
844+
pgrpsid, nmode, S_IRWXG);
845+
num_aces++;
846+
size += fill_ace_for_sid((struct cifs_ace *)((char *)pnndacl + size),
847+
&sid_everyone, nmode, S_IRWXO);
848+
num_aces++;
848849

850+
pndacl->num_aces = cpu_to_le32(num_aces);
849851
pndacl->size = cpu_to_le16(size + sizeof(struct cifs_acl));
850852

851853
return 0;

0 commit comments

Comments
 (0)