aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve French <sfrench@us.ibm.com>2007-10-16 14:40:37 -0400
committerSteve French <sfrench@us.ibm.com>2007-10-16 14:40:37 -0400
commitaf6f4612fdfd782c6d35272836a2b97e7e5b790e (patch)
tree6456435d2c845c43b0094473c6248ab59e7284b3
parent016ec75f1a0c0e765fce65d794569979104f031d (diff)
[CIFS] Fix some endianness problems in new acl code
Signed-off-by: Steve French <sfrench@us.ibm.com>
-rw-r--r--fs/cifs/cifsacl.c28
-rw-r--r--fs/cifs/cifsacl.h23
-rw-r--r--fs/cifs/cifssmb.c2
3 files changed, 26 insertions, 27 deletions
diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c
index 601587724f9d..4735e9b47590 100644
--- a/fs/cifs/cifsacl.c
+++ b/fs/cifs/cifsacl.c
@@ -31,7 +31,7 @@
31 31
32#ifdef CONFIG_CIFS_EXPERIMENTAL 32#ifdef CONFIG_CIFS_EXPERIMENTAL
33 33
34struct cifs_wksid wksidarr[NUM_WK_SIDS] = { 34static struct cifs_wksid wksidarr[NUM_WK_SIDS] = {
35 {{1, 0, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0} }, "null user"}, 35 {{1, 0, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0} }, "null user"},
36 {{1, 1, {0, 0, 0, 0, 0, 1}, {0, 0, 0, 0, 0} }, "nobody"}, 36 {{1, 1, {0, 0, 0, 0, 0, 1}, {0, 0, 0, 0, 0} }, "nobody"},
37 {{1, 1, {0, 0, 0, 0, 0, 5}, {11, 0, 0, 0, 0} }, "net-users"}, 37 {{1, 1, {0, 0, 0, 0, 0, 5}, {11, 0, 0, 0, 0} }, "net-users"},
@@ -192,14 +192,15 @@ static void parse_dacl(struct cifs_acl *pdacl, char *end_of_acl)
192 /* BB need to add parm so we can store the SID BB */ 192 /* BB need to add parm so we can store the SID BB */
193 193
194 /* validate that we do not go past end of acl */ 194 /* validate that we do not go past end of acl */
195 if (end_of_acl < (char *)pdacl + pdacl->size) { 195 if (end_of_acl < (char *)pdacl + le16_to_cpu(pdacl->size)) {
196 cERROR(1, ("ACL too small to parse DACL")); 196 cERROR(1, ("ACL too small to parse DACL"));
197 return; 197 return;
198 } 198 }
199 199
200#ifdef CONFIG_CIFS_DEBUG2 200#ifdef CONFIG_CIFS_DEBUG2
201 cFYI(1, ("DACL revision %d size %d num aces %d", 201 cFYI(1, ("DACL revision %d size %d num aces %d",
202 pdacl->revision, pdacl->size, pdacl->num_aces)); 202 le16_to_cpu(pdacl->revision), le16_to_cpu(pdacl->size),
203 le32_to_cpu(pdacl->num_aces)));
203#endif 204#endif
204 205
205 acl_base = (char *)pdacl; 206 acl_base = (char *)pdacl;
@@ -255,7 +256,6 @@ static void parse_dacl(struct cifs_acl *pdacl, char *end_of_acl)
255 256
256static int parse_sid(struct cifs_sid *psid, char *end_of_acl) 257static int parse_sid(struct cifs_sid *psid, char *end_of_acl)
257{ 258{
258 int num_subauth;
259 259
260 /* BB need to add parm so we can store the SID BB */ 260 /* BB need to add parm so we can store the SID BB */
261 261
@@ -265,14 +265,13 @@ static int parse_sid(struct cifs_sid *psid, char *end_of_acl)
265 return -EINVAL; 265 return -EINVAL;
266 } 266 }
267 267
268 num_subauth = cpu_to_le32(psid->num_subauth); 268 if (psid->num_subauth) {
269 if (num_subauth) {
270#ifdef CONFIG_CIFS_DEBUG2 269#ifdef CONFIG_CIFS_DEBUG2
271 int i; 270 int i;
272 cFYI(1, ("SID revision %d num_auth %d First subauth 0x%x", 271 cFYI(1, ("SID revision %d num_auth %d First subauth 0x%x",
273 psid->revision, psid->num_subauth, psid->sub_auth[0])); 272 psid->revision, psid->num_subauth, psid->sub_auth[0]));
274 273
275 for (i = 0; i < num_subauth; ++i) { 274 for (i = 0; i < psid->num_subauth; i++) {
276 cFYI(1, ("SID sub_auth[%d]: 0x%x ", i, 275 cFYI(1, ("SID sub_auth[%d]: 0x%x ", i,
277 le32_to_cpu(psid->sub_auth[i]))); 276 le32_to_cpu(psid->sub_auth[i])));
278 } 277 }
@@ -280,7 +279,7 @@ static int parse_sid(struct cifs_sid *psid, char *end_of_acl)
280 /* BB add length check to make sure that we do not have huge 279 /* BB add length check to make sure that we do not have huge
281 num auths and therefore go off the end */ 280 num auths and therefore go off the end */
282 cFYI(1, ("RID 0x%x", 281 cFYI(1, ("RID 0x%x",
283 le32_to_cpu(psid->sub_auth[num_subauth-1]))); 282 le32_to_cpu(psid->sub_auth[psid->num_subauth-1])));
284#endif 283#endif
285 } 284 }
286 285
@@ -297,17 +296,18 @@ int parse_sec_desc(struct cifs_ntsd *pntsd, int acl_len)
297 char *end_of_acl = ((char *)pntsd) + acl_len; 296 char *end_of_acl = ((char *)pntsd) + acl_len;
298 297
299 owner_sid_ptr = (struct cifs_sid *)((char *)pntsd + 298 owner_sid_ptr = (struct cifs_sid *)((char *)pntsd +
300 cpu_to_le32(pntsd->osidoffset)); 299 le32_to_cpu(pntsd->osidoffset));
301 group_sid_ptr = (struct cifs_sid *)((char *)pntsd + 300 group_sid_ptr = (struct cifs_sid *)((char *)pntsd +
302 cpu_to_le32(pntsd->gsidoffset)); 301 le32_to_cpu(pntsd->gsidoffset));
303 dacl_ptr = (struct cifs_acl *)((char *)pntsd + 302 dacl_ptr = (struct cifs_acl *)((char *)pntsd +
304 cpu_to_le32(pntsd->dacloffset)); 303 le32_to_cpu(pntsd->dacloffset));
305#ifdef CONFIG_CIFS_DEBUG2 304#ifdef CONFIG_CIFS_DEBUG2
306 cFYI(1, ("revision %d type 0x%x ooffset 0x%x goffset 0x%x " 305 cFYI(1, ("revision %d type 0x%x ooffset 0x%x goffset 0x%x "
307 "sacloffset 0x%x dacloffset 0x%x", 306 "sacloffset 0x%x dacloffset 0x%x",
308 pntsd->revision, pntsd->type, 307 pntsd->revision, pntsd->type, le32_to_cpu(pntsd->osidoffset),
309 pntsd->osidoffset, pntsd->gsidoffset, pntsd->sacloffset, 308 le32_to_cpu(pntsd->gsidoffset),
310 pntsd->dacloffset)); 309 le32_to_cpu(pntsd->sacloffset),
310 le32_to_cpu(pntsd->dacloffset));
311#endif 311#endif
312 rc = parse_sid(owner_sid_ptr, end_of_acl); 312 rc = parse_sid(owner_sid_ptr, end_of_acl);
313 if (rc) 313 if (rc)
diff --git a/fs/cifs/cifsacl.h b/fs/cifs/cifsacl.h
index 0362cd11f03e..fa01053fc5fa 100644
--- a/fs/cifs/cifsacl.h
+++ b/fs/cifs/cifsacl.h
@@ -27,25 +27,25 @@
27#define SIDNAMELENGTH 20 /* long enough for the ones we care about */ 27#define SIDNAMELENGTH 20 /* long enough for the ones we care about */
28 28
29struct cifs_ntsd { 29struct cifs_ntsd {
30 __u16 revision; /* revision level */ 30 __le16 revision; /* revision level */
31 __u16 type; 31 __le16 type;
32 __u32 osidoffset; 32 __le32 osidoffset;
33 __u32 gsidoffset; 33 __le32 gsidoffset;
34 __u32 sacloffset; 34 __le32 sacloffset;
35 __u32 dacloffset; 35 __le32 dacloffset;
36} __attribute__((packed)); 36} __attribute__((packed));
37 37
38struct cifs_sid { 38struct cifs_sid {
39 __u8 revision; /* revision level */ 39 __u8 revision; /* revision level */
40 __u8 num_subauth; 40 __u8 num_subauth;
41 __u8 authority[6]; 41 __u8 authority[6];
42 __u32 sub_auth[5]; /* sub_auth[num_subauth] */ 42 __le32 sub_auth[5]; /* sub_auth[num_subauth] */ /* BB FIXME endianness BB */
43} __attribute__((packed)); 43} __attribute__((packed));
44 44
45struct cifs_acl { 45struct cifs_acl {
46 __u16 revision; /* revision level */ 46 __le16 revision; /* revision level */
47 __u16 size; 47 __le16 size;
48 __u32 num_aces; 48 __le32 num_aces;
49} __attribute__((packed)); 49} __attribute__((packed));
50 50
51struct cifs_ntace { /* first part of ACE which contains perms */ 51struct cifs_ntace { /* first part of ACE which contains perms */
@@ -59,7 +59,7 @@ struct cifs_ace { /* last part of ACE which includes user info */
59 __u8 revision; /* revision level */ 59 __u8 revision; /* revision level */
60 __u8 num_subauth; 60 __u8 num_subauth;
61 __u8 authority[6]; 61 __u8 authority[6];
62 __u32 sub_auth[5]; 62 __le32 sub_auth[5];
63} __attribute__((packed)); 63} __attribute__((packed));
64 64
65struct cifs_wksid { 65struct cifs_wksid {
@@ -69,7 +69,6 @@ struct cifs_wksid {
69 69
70#ifdef CONFIG_CIFS_EXPERIMENTAL 70#ifdef CONFIG_CIFS_EXPERIMENTAL
71 71
72extern struct cifs_wksid wksidarr[NUM_WK_SIDS];
73extern int match_sid(struct cifs_sid *); 72extern int match_sid(struct cifs_sid *);
74extern int compare_sids(struct cifs_sid *, struct cifs_sid *); 73extern int compare_sids(struct cifs_sid *, struct cifs_sid *);
75 74
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index 14dabbbd8134..d22af63e8f1f 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -3121,7 +3121,7 @@ CIFSSMBGetCIFSACL(const int xid, struct cifsTconInfo *tcon, __u16 fid,
3121 3121
3122/* BB check that data area is minimum length and as big as acl_len */ 3122/* BB check that data area is minimum length and as big as acl_len */
3123 3123
3124 acl_len = le32_to_cpu(*(__le32 *)parm); 3124 acl_len = le32_to_cpu(*parm);
3125 /* BB check if (acl_len > bufsize) */ 3125 /* BB check if (acl_len > bufsize) */
3126 3126
3127 parse_sec_desc(psec_desc, acl_len); 3127 parse_sec_desc(psec_desc, acl_len);