summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAurelien Aptel <aaptel@suse.com>2019-09-16 19:47:27 -0400
committerSteve French <stfrench@microsoft.com>2019-09-16 19:49:11 -0400
commite37a02c7ebb9fa9af301c47c8c5a579cc51b509b (patch)
tree77a62d2b69486f485aca235e16d5a764ca4ff2c6
parent352f2c9a570d38bced287a273e79dccae7c5ef41 (diff)
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 <aaptel@suse.com> Signed-off-by: Steve French <stfrench@microsoft.com>
-rw-r--r--fs/cifs/cifsacl.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c
index 3e0c5ed9ca20..f842944a5c76 100644
--- a/fs/cifs/cifsacl.c
+++ b/fs/cifs/cifsacl.c
@@ -809,30 +809,21 @@ static int set_chmod_dacl(struct cifs_acl *pndacl, struct cifs_sid *pownersid,
809 struct cifs_sid *pgrpsid, __u64 nmode, bool modefromsid) 809 struct cifs_sid *pgrpsid, __u64 nmode, bool modefromsid)
810{ 810{
811 u16 size = 0; 811 u16 size = 0;
812 u32 num_aces = 0;
812 struct cifs_acl *pnndacl; 813 struct cifs_acl *pnndacl;
813 814
814 pnndacl = (struct cifs_acl *)((char *)pndacl + sizeof(struct cifs_acl)); 815 pnndacl = (struct cifs_acl *)((char *)pndacl + sizeof(struct cifs_acl));
815 816
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 */
824 if (modefromsid) { 817 if (modefromsid) {
825 struct cifs_ace *pntace = 818 struct cifs_ace *pntace =
826 (struct cifs_ace *)((char *)pnndacl + size); 819 (struct cifs_ace *)((char *)pnndacl + size);
827 int i; 820 int i;
828 821
829 pntace->type = ACCESS_DENIED; 822 pntace->type = ACCESS_ALLOWED;
830 pntace->flags = 0x0; 823 pntace->flags = 0x0;
824 pntace->access_req = 0;
831 pntace->sid.num_subauth = 3; 825 pntace->sid.num_subauth = 3;
832 pntace->sid.revision = 1; 826 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;
836 for (i = 0; i < NUM_AUTHS; i++) 827 for (i = 0; i < NUM_AUTHS; i++)
837 pntace->sid.authority[i] = 828 pntace->sid.authority[i] =
838 sid_unix_NFS_mode.authority[i]; 829 sid_unix_NFS_mode.authority[i];
@@ -840,12 +831,23 @@ static int set_chmod_dacl(struct cifs_acl *pndacl, struct cifs_sid *pownersid,
840 pntace->sid.sub_auth[1] = sid_unix_NFS_mode.sub_auth[1]; 831 pntace->sid.sub_auth[1] = sid_unix_NFS_mode.sub_auth[1];
841 pntace->sid.sub_auth[2] = cpu_to_le32(nmode & 07777); 832 pntace->sid.sub_auth[2] = cpu_to_le32(nmode & 07777);
842 833
843 pndacl->num_aces = cpu_to_le32(4); 834 /* size = 1 + 1 + 2 + 4 + 1 + 1 + 6 + (psid->num_subauth*4) */
844 size += fill_ace_for_sid((struct cifs_ace *)((char *)pnndacl + size), 835 pntace->size = cpu_to_le16(28);
845 &sid_unix_NFS_mode, nmode, S_IRWXO); 836 size += 28;
846 } else 837 num_aces++;
847 pndacl->num_aces = cpu_to_le32(3); 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++;
848 849
850 pndacl->num_aces = cpu_to_le32(num_aces);
849 pndacl->size = cpu_to_le16(size + sizeof(struct cifs_acl)); 851 pndacl->size = cpu_to_le16(size + sizeof(struct cifs_acl));
850 852
851 return 0; 853 return 0;