diff options
author | Steve French <sfrench@us.ibm.com> | 2011-02-25 02:11:56 -0500 |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2011-04-11 20:42:06 -0400 |
commit | 8727c8a85f3951ef0eef36a665f5dceebb4c495d (patch) | |
tree | f35b215604127ebb05a977a1b8c093b7b441b6af /fs/cifs | |
parent | bdf1b03e093bdbc571f404e751c7b0e2dca412ea (diff) |
Allow user names longer than 32 bytes
We artificially limited the user name to 32 bytes, but modern servers handle
larger. Set the maximum length to a reasonable 256, and make the user name
string dynamically allocated rather than a fixed size in session structure.
Also clean up old checkpatch warning.
Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/cifs')
-rw-r--r-- | fs/cifs/cifs_spnego.c | 4 | ||||
-rw-r--r-- | fs/cifs/cifsencrypt.c | 6 | ||||
-rw-r--r-- | fs/cifs/cifsfs.c | 4 | ||||
-rw-r--r-- | fs/cifs/cifsglob.h | 7 | ||||
-rw-r--r-- | fs/cifs/connect.c | 15 | ||||
-rw-r--r-- | fs/cifs/misc.c | 1 | ||||
-rw-r--r-- | fs/cifs/sess.c | 19 |
7 files changed, 30 insertions, 26 deletions
diff --git a/fs/cifs/cifs_spnego.c b/fs/cifs/cifs_spnego.c index 4dfba8283165..33d221394aca 100644 --- a/fs/cifs/cifs_spnego.c +++ b/fs/cifs/cifs_spnego.c | |||
@@ -113,7 +113,7 @@ cifs_get_spnego_key(struct cifsSesInfo *sesInfo) | |||
113 | MAX_MECH_STR_LEN + | 113 | MAX_MECH_STR_LEN + |
114 | UID_KEY_LEN + (sizeof(uid_t) * 2) + | 114 | UID_KEY_LEN + (sizeof(uid_t) * 2) + |
115 | CREDUID_KEY_LEN + (sizeof(uid_t) * 2) + | 115 | CREDUID_KEY_LEN + (sizeof(uid_t) * 2) + |
116 | USER_KEY_LEN + strlen(sesInfo->userName) + | 116 | USER_KEY_LEN + strlen(sesInfo->user_name) + |
117 | PID_KEY_LEN + (sizeof(pid_t) * 2) + 1; | 117 | PID_KEY_LEN + (sizeof(pid_t) * 2) + 1; |
118 | 118 | ||
119 | spnego_key = ERR_PTR(-ENOMEM); | 119 | spnego_key = ERR_PTR(-ENOMEM); |
@@ -153,7 +153,7 @@ cifs_get_spnego_key(struct cifsSesInfo *sesInfo) | |||
153 | sprintf(dp, ";creduid=0x%x", sesInfo->cred_uid); | 153 | sprintf(dp, ";creduid=0x%x", sesInfo->cred_uid); |
154 | 154 | ||
155 | dp = description + strlen(description); | 155 | dp = description + strlen(description); |
156 | sprintf(dp, ";user=%s", sesInfo->userName); | 156 | sprintf(dp, ";user=%s", sesInfo->user_name); |
157 | 157 | ||
158 | dp = description + strlen(description); | 158 | dp = description + strlen(description); |
159 | sprintf(dp, ";pid=0x%x", current->pid); | 159 | sprintf(dp, ";pid=0x%x", current->pid); |
diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c index a51585f9852b..e307a286a1e5 100644 --- a/fs/cifs/cifsencrypt.c +++ b/fs/cifs/cifsencrypt.c | |||
@@ -469,15 +469,15 @@ static int calc_ntlmv2_hash(struct cifsSesInfo *ses, char *ntlmv2_hash, | |||
469 | return rc; | 469 | return rc; |
470 | } | 470 | } |
471 | 471 | ||
472 | /* convert ses->userName to unicode and uppercase */ | 472 | /* convert ses->user_name to unicode and uppercase */ |
473 | len = strlen(ses->userName); | 473 | len = strlen(ses->user_name); |
474 | user = kmalloc(2 + (len * 2), GFP_KERNEL); | 474 | user = kmalloc(2 + (len * 2), GFP_KERNEL); |
475 | if (user == NULL) { | 475 | if (user == NULL) { |
476 | cERROR(1, "calc_ntlmv2_hash: user mem alloc failure\n"); | 476 | cERROR(1, "calc_ntlmv2_hash: user mem alloc failure\n"); |
477 | rc = -ENOMEM; | 477 | rc = -ENOMEM; |
478 | goto calc_exit_2; | 478 | goto calc_exit_2; |
479 | } | 479 | } |
480 | len = cifs_strtoUCS((__le16 *)user, ses->userName, len, nls_cp); | 480 | len = cifs_strtoUCS((__le16 *)user, ses->user_name, len, nls_cp); |
481 | UniStrupr(user); | 481 | UniStrupr(user); |
482 | 482 | ||
483 | crypto_shash_update(&ses->server->secmech.sdeschmacmd5->shash, | 483 | crypto_shash_update(&ses->server->secmech.sdeschmacmd5->shash, |
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 41c78e8fc591..0e0cc60dbde0 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c | |||
@@ -412,8 +412,8 @@ cifs_show_options(struct seq_file *s, struct vfsmount *m) | |||
412 | 412 | ||
413 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MULTIUSER) | 413 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MULTIUSER) |
414 | seq_printf(s, ",multiuser"); | 414 | seq_printf(s, ",multiuser"); |
415 | else if (tcon->ses->userName) | 415 | else if (tcon->ses->user_name) |
416 | seq_printf(s, ",username=%s", tcon->ses->userName); | 416 | seq_printf(s, ",username=%s", tcon->ses->user_name); |
417 | 417 | ||
418 | if (tcon->ses->domainName) | 418 | if (tcon->ses->domainName) |
419 | seq_printf(s, ",domain=%s", tcon->ses->domainName); | 419 | seq_printf(s, ",domain=%s", tcon->ses->domainName); |
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index 10e4afe54e22..94cd8747d28b 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h | |||
@@ -38,9 +38,8 @@ | |||
38 | #define MAX_TREE_SIZE (2 + MAX_SERVER_SIZE + 1 + MAX_SHARE_SIZE + 1) | 38 | #define MAX_TREE_SIZE (2 + MAX_SERVER_SIZE + 1 + MAX_SHARE_SIZE + 1) |
39 | #define MAX_SERVER_SIZE 15 | 39 | #define MAX_SERVER_SIZE 15 |
40 | #define MAX_SHARE_SIZE 64 /* used to be 20, this should still be enough */ | 40 | #define MAX_SHARE_SIZE 64 /* used to be 20, this should still be enough */ |
41 | #define MAX_USERNAME_SIZE 32 /* 32 is to allow for 15 char names + null | 41 | #define MAX_USERNAME_SIZE 256 /* reasonable maximum for current servers */ |
42 | termination then *2 for unicode versions */ | 42 | #define MAX_PASSWORD_SIZE 512 /* max for windows seems to be 256 wide chars */ |
43 | #define MAX_PASSWORD_SIZE 512 /* max for windows seems to be 256 wide chars */ | ||
44 | 43 | ||
45 | #define CIFS_MIN_RCV_POOL 4 | 44 | #define CIFS_MIN_RCV_POOL 4 |
46 | 45 | ||
@@ -274,7 +273,7 @@ struct cifsSesInfo { | |||
274 | int capabilities; | 273 | int capabilities; |
275 | char serverName[SERVER_NAME_LEN_WITH_NULL * 2]; /* BB make bigger for | 274 | char serverName[SERVER_NAME_LEN_WITH_NULL * 2]; /* BB make bigger for |
276 | TCP names - will ipv6 and sctp addresses fit? */ | 275 | TCP names - will ipv6 and sctp addresses fit? */ |
277 | char userName[MAX_USERNAME_SIZE + 1]; | 276 | char *user_name; |
278 | char *domainName; | 277 | char *domainName; |
279 | char *password; | 278 | char *password; |
280 | struct session_key auth_key; | 279 | struct session_key auth_key; |
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 6e2b2addfc78..54436a3a3348 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c | |||
@@ -881,7 +881,8 @@ cifs_parse_mount_options(char *options, const char *devname, | |||
881 | /* null user, ie anonymous, authentication */ | 881 | /* null user, ie anonymous, authentication */ |
882 | vol->nullauth = 1; | 882 | vol->nullauth = 1; |
883 | } | 883 | } |
884 | if (strnlen(value, 200) < 200) { | 884 | if (strnlen(value, MAX_USERNAME_SIZE) < |
885 | MAX_USERNAME_SIZE) { | ||
885 | vol->username = value; | 886 | vol->username = value; |
886 | } else { | 887 | } else { |
887 | printk(KERN_WARNING "CIFS: username too long\n"); | 888 | printk(KERN_WARNING "CIFS: username too long\n"); |
@@ -1808,7 +1809,9 @@ cifs_find_smb_ses(struct TCP_Server_Info *server, struct smb_vol *vol) | |||
1808 | break; | 1809 | break; |
1809 | default: | 1810 | default: |
1810 | /* anything else takes username/password */ | 1811 | /* anything else takes username/password */ |
1811 | if (strncmp(ses->userName, vol->username, | 1812 | if (ses->user_name == NULL) |
1813 | continue; | ||
1814 | if (strncmp(ses->user_name, vol->username, | ||
1812 | MAX_USERNAME_SIZE)) | 1815 | MAX_USERNAME_SIZE)) |
1813 | continue; | 1816 | continue; |
1814 | if (strlen(vol->username) != 0 && | 1817 | if (strlen(vol->username) != 0 && |
@@ -1906,9 +1909,11 @@ cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb_vol *volume_info) | |||
1906 | else | 1909 | else |
1907 | sprintf(ses->serverName, "%pI4", &addr->sin_addr); | 1910 | sprintf(ses->serverName, "%pI4", &addr->sin_addr); |
1908 | 1911 | ||
1909 | if (volume_info->username) | 1912 | if (volume_info->username) { |
1910 | strncpy(ses->userName, volume_info->username, | 1913 | ses->user_name = kstrdup(volume_info->username, GFP_KERNEL); |
1911 | MAX_USERNAME_SIZE); | 1914 | if (!ses->user_name) |
1915 | goto get_ses_fail; | ||
1916 | } | ||
1912 | 1917 | ||
1913 | /* volume_info->password freed at unmount */ | 1918 | /* volume_info->password freed at unmount */ |
1914 | if (volume_info->password) { | 1919 | if (volume_info->password) { |
diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c index 2a930a752a78..7228179ef5b0 100644 --- a/fs/cifs/misc.c +++ b/fs/cifs/misc.c | |||
@@ -100,6 +100,7 @@ sesInfoFree(struct cifsSesInfo *buf_to_free) | |||
100 | memset(buf_to_free->password, 0, strlen(buf_to_free->password)); | 100 | memset(buf_to_free->password, 0, strlen(buf_to_free->password)); |
101 | kfree(buf_to_free->password); | 101 | kfree(buf_to_free->password); |
102 | } | 102 | } |
103 | kfree(buf_to_free->user_name); | ||
103 | kfree(buf_to_free->domainName); | 104 | kfree(buf_to_free->domainName); |
104 | kfree(buf_to_free); | 105 | kfree(buf_to_free); |
105 | } | 106 | } |
diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c index 16765703131b..006485fbc669 100644 --- a/fs/cifs/sess.c +++ b/fs/cifs/sess.c | |||
@@ -219,12 +219,12 @@ static void unicode_ssetup_strings(char **pbcc_area, struct cifsSesInfo *ses, | |||
219 | bcc_ptr++; | 219 | bcc_ptr++; |
220 | } */ | 220 | } */ |
221 | /* copy user */ | 221 | /* copy user */ |
222 | if (ses->userName == NULL) { | 222 | if (ses->user_name == NULL) { |
223 | /* null user mount */ | 223 | /* null user mount */ |
224 | *bcc_ptr = 0; | 224 | *bcc_ptr = 0; |
225 | *(bcc_ptr+1) = 0; | 225 | *(bcc_ptr+1) = 0; |
226 | } else { | 226 | } else { |
227 | bytes_ret = cifs_strtoUCS((__le16 *) bcc_ptr, ses->userName, | 227 | bytes_ret = cifs_strtoUCS((__le16 *) bcc_ptr, ses->user_name, |
228 | MAX_USERNAME_SIZE, nls_cp); | 228 | MAX_USERNAME_SIZE, nls_cp); |
229 | } | 229 | } |
230 | bcc_ptr += 2 * bytes_ret; | 230 | bcc_ptr += 2 * bytes_ret; |
@@ -244,12 +244,11 @@ static void ascii_ssetup_strings(char **pbcc_area, struct cifsSesInfo *ses, | |||
244 | /* copy user */ | 244 | /* copy user */ |
245 | /* BB what about null user mounts - check that we do this BB */ | 245 | /* BB what about null user mounts - check that we do this BB */ |
246 | /* copy user */ | 246 | /* copy user */ |
247 | if (ses->userName == NULL) { | 247 | if (ses->user_name != NULL) |
248 | /* BB what about null user mounts - check that we do this BB */ | 248 | strncpy(bcc_ptr, ses->user_name, MAX_USERNAME_SIZE); |
249 | } else { | 249 | /* else null user mount */ |
250 | strncpy(bcc_ptr, ses->userName, MAX_USERNAME_SIZE); | 250 | |
251 | } | 251 | bcc_ptr += strnlen(ses->user_name, MAX_USERNAME_SIZE); |
252 | bcc_ptr += strnlen(ses->userName, MAX_USERNAME_SIZE); | ||
253 | *bcc_ptr = 0; | 252 | *bcc_ptr = 0; |
254 | bcc_ptr++; /* account for null termination */ | 253 | bcc_ptr++; /* account for null termination */ |
255 | 254 | ||
@@ -523,14 +522,14 @@ static int build_ntlmssp_auth_blob(unsigned char *pbuffer, | |||
523 | tmp += len; | 522 | tmp += len; |
524 | } | 523 | } |
525 | 524 | ||
526 | if (ses->userName == NULL) { | 525 | if (ses->user_name == NULL) { |
527 | sec_blob->UserName.BufferOffset = cpu_to_le32(tmp - pbuffer); | 526 | sec_blob->UserName.BufferOffset = cpu_to_le32(tmp - pbuffer); |
528 | sec_blob->UserName.Length = 0; | 527 | sec_blob->UserName.Length = 0; |
529 | sec_blob->UserName.MaximumLength = 0; | 528 | sec_blob->UserName.MaximumLength = 0; |
530 | tmp += 2; | 529 | tmp += 2; |
531 | } else { | 530 | } else { |
532 | int len; | 531 | int len; |
533 | len = cifs_strtoUCS((__le16 *)tmp, ses->userName, | 532 | len = cifs_strtoUCS((__le16 *)tmp, ses->user_name, |
534 | MAX_USERNAME_SIZE, nls_cp); | 533 | MAX_USERNAME_SIZE, nls_cp); |
535 | len *= 2; /* unicode is 2 bytes each */ | 534 | len *= 2; /* unicode is 2 bytes each */ |
536 | sec_blob->UserName.BufferOffset = cpu_to_le32(tmp - pbuffer); | 535 | sec_blob->UserName.BufferOffset = cpu_to_le32(tmp - pbuffer); |