aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2012-11-25 08:00:37 -0500
committerSteve French <smfrench@gmail.com>2012-12-05 14:13:11 -0500
commit30c9d6cca526243abe6c08eb6fa03db9d2b1a630 (patch)
tree1f520868df107ccad9c78b88be0ccea87a24766b /fs/cifs
parent36f87ee70f754d04e55518853e6fb30ed4732dda (diff)
cifs: redefine NUM_SUBAUTH constant from 5 to 15
According to several places on the Internet and the samba winbind code, this is hard limited to 15 in windows, not 5. This does balloon out the allocation of each by 40 bytes, but I don't see any alternative. Also, rename it to SID_MAX_SUB_AUTHORITIES to match the alleged name of this constant in the windows header files Finally, rename SIDLEN to SID_STRING_MAX, fix the value to reflect the change to SID_MAX_SUB_AUTHORITIES and document how it was determined. Reviewed-by: Shirish Pargaonkar <shirishpargaonkar@gmail.com> Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Steve French <smfrench@gmail.com>
Diffstat (limited to 'fs/cifs')
-rw-r--r--fs/cifs/cifsacl.c6
-rw-r--r--fs/cifs/cifsacl.h19
2 files changed, 19 insertions, 6 deletions
diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c
index 141a944c9df..dd8d3df7429 100644
--- a/fs/cifs/cifsacl.c
+++ b/fs/cifs/cifsacl.c
@@ -280,7 +280,7 @@ cifs_copy_sid(struct cifs_sid *dst, const struct cifs_sid *src)
280 int i; 280 int i;
281 281
282 dst->revision = src->revision; 282 dst->revision = src->revision;
283 dst->num_subauth = min_t(u8, src->num_subauth, NUM_SUBAUTHS); 283 dst->num_subauth = min_t(u8, src->num_subauth, SID_MAX_SUB_AUTHORITIES);
284 for (i = 0; i < NUM_AUTHS; ++i) 284 for (i = 0; i < NUM_AUTHS; ++i)
285 dst->authority[i] = src->authority[i]; 285 dst->authority[i] = src->authority[i];
286 for (i = 0; i < dst->num_subauth; ++i) 286 for (i = 0; i < dst->num_subauth; ++i)
@@ -383,7 +383,7 @@ id_to_sid(unsigned long cid, uint sidtype, struct cifs_sid *ssid)
383 if (!npsidid) 383 if (!npsidid)
384 return -ENOMEM; 384 return -ENOMEM;
385 385
386 npsidid->sidstr = kmalloc(SIDLEN, GFP_KERNEL); 386 npsidid->sidstr = kmalloc(SID_STRING_MAX, GFP_KERNEL);
387 if (!npsidid->sidstr) { 387 if (!npsidid->sidstr) {
388 kfree(npsidid); 388 kfree(npsidid);
389 return -ENOMEM; 389 return -ENOMEM;
@@ -500,7 +500,7 @@ sid_to_id(struct cifs_sb_info *cifs_sb, struct cifs_sid *psid,
500 if (!npsidid) 500 if (!npsidid)
501 return -ENOMEM; 501 return -ENOMEM;
502 502
503 npsidid->sidstr = kmalloc(SIDLEN, GFP_KERNEL); 503 npsidid->sidstr = kmalloc(SID_STRING_MAX, GFP_KERNEL);
504 if (!npsidid->sidstr) { 504 if (!npsidid->sidstr) {
505 kfree(npsidid); 505 kfree(npsidid);
506 return -ENOMEM; 506 return -ENOMEM;
diff --git a/fs/cifs/cifsacl.h b/fs/cifs/cifsacl.h
index 7e52f19f996..8b980cd445c 100644
--- a/fs/cifs/cifsacl.h
+++ b/fs/cifs/cifsacl.h
@@ -24,7 +24,7 @@
24 24
25 25
26#define NUM_AUTHS 6 /* number of authority fields */ 26#define NUM_AUTHS 6 /* number of authority fields */
27#define NUM_SUBAUTHS 5 /* number of sub authority fields */ 27#define SID_MAX_SUB_AUTHORITIES (15) /* max number of sub authority fields */
28#define NUM_WK_SIDS 7 /* number of well known sids */ 28#define NUM_WK_SIDS 7 /* number of well known sids */
29#define SIDNAMELENGTH 20 /* long enough for the ones we care about */ 29#define SIDNAMELENGTH 20 /* long enough for the ones we care about */
30#define DEFSECDESCLEN 192 /* sec desc len contaiting a dacl with three aces */ 30#define DEFSECDESCLEN 192 /* sec desc len contaiting a dacl with three aces */
@@ -41,7 +41,20 @@
41 41
42#define SIDOWNER 1 42#define SIDOWNER 1
43#define SIDGROUP 2 43#define SIDGROUP 2
44#define SIDLEN 150 /* S- 1 revision- 6 authorities- max 5 sub authorities */ 44
45/*
46 * Maximum size of a string representation of a SID:
47 *
48 * The fields are unsigned values in decimal. So:
49 *
50 * u8: max 3 bytes in decimal
51 * u32: max 10 bytes in decimal
52 *
53 * "S-" + 3 bytes for version field + 4 bytes for each authority field (3 bytes
54 * per number + 1 for '-') + 11 bytes for each subauthority field (10 bytes
55 * per number + 1 for '-') + NULL terminator.
56 */
57#define SID_STRING_MAX (195)
45 58
46#define SID_ID_MAPPED 0 59#define SID_ID_MAPPED 0
47#define SID_ID_PENDING 1 60#define SID_ID_PENDING 1
@@ -61,7 +74,7 @@ struct cifs_sid {
61 __u8 revision; /* revision level */ 74 __u8 revision; /* revision level */
62 __u8 num_subauth; 75 __u8 num_subauth;
63 __u8 authority[NUM_AUTHS]; 76 __u8 authority[NUM_AUTHS];
64 __le32 sub_auth[NUM_SUBAUTHS]; /* sub_auth[num_subauth] */ 77 __le32 sub_auth[SID_MAX_SUB_AUTHORITIES]; /* sub_auth[num_subauth] */
65} __attribute__((packed)); 78} __attribute__((packed));
66 79
67/* size of a struct cifs_sid, sans sub_auth array */ 80/* size of a struct cifs_sid, sans sub_auth array */