mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-11-19 05:06:53 +00:00
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>
This commit is contained in:
parent
bdf1b03e09
commit
8727c8a85f
7 changed files with 30 additions and 26 deletions
|
|
@ -113,7 +113,7 @@ cifs_get_spnego_key(struct cifsSesInfo *sesInfo)
|
||||||
MAX_MECH_STR_LEN +
|
MAX_MECH_STR_LEN +
|
||||||
UID_KEY_LEN + (sizeof(uid_t) * 2) +
|
UID_KEY_LEN + (sizeof(uid_t) * 2) +
|
||||||
CREDUID_KEY_LEN + (sizeof(uid_t) * 2) +
|
CREDUID_KEY_LEN + (sizeof(uid_t) * 2) +
|
||||||
USER_KEY_LEN + strlen(sesInfo->userName) +
|
USER_KEY_LEN + strlen(sesInfo->user_name) +
|
||||||
PID_KEY_LEN + (sizeof(pid_t) * 2) + 1;
|
PID_KEY_LEN + (sizeof(pid_t) * 2) + 1;
|
||||||
|
|
||||||
spnego_key = ERR_PTR(-ENOMEM);
|
spnego_key = ERR_PTR(-ENOMEM);
|
||||||
|
|
@ -153,7 +153,7 @@ cifs_get_spnego_key(struct cifsSesInfo *sesInfo)
|
||||||
sprintf(dp, ";creduid=0x%x", sesInfo->cred_uid);
|
sprintf(dp, ";creduid=0x%x", sesInfo->cred_uid);
|
||||||
|
|
||||||
dp = description + strlen(description);
|
dp = description + strlen(description);
|
||||||
sprintf(dp, ";user=%s", sesInfo->userName);
|
sprintf(dp, ";user=%s", sesInfo->user_name);
|
||||||
|
|
||||||
dp = description + strlen(description);
|
dp = description + strlen(description);
|
||||||
sprintf(dp, ";pid=0x%x", current->pid);
|
sprintf(dp, ";pid=0x%x", current->pid);
|
||||||
|
|
|
||||||
|
|
@ -469,15 +469,15 @@ static int calc_ntlmv2_hash(struct cifsSesInfo *ses, char *ntlmv2_hash,
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* convert ses->userName to unicode and uppercase */
|
/* convert ses->user_name to unicode and uppercase */
|
||||||
len = strlen(ses->userName);
|
len = strlen(ses->user_name);
|
||||||
user = kmalloc(2 + (len * 2), GFP_KERNEL);
|
user = kmalloc(2 + (len * 2), GFP_KERNEL);
|
||||||
if (user == NULL) {
|
if (user == NULL) {
|
||||||
cERROR(1, "calc_ntlmv2_hash: user mem alloc failure\n");
|
cERROR(1, "calc_ntlmv2_hash: user mem alloc failure\n");
|
||||||
rc = -ENOMEM;
|
rc = -ENOMEM;
|
||||||
goto calc_exit_2;
|
goto calc_exit_2;
|
||||||
}
|
}
|
||||||
len = cifs_strtoUCS((__le16 *)user, ses->userName, len, nls_cp);
|
len = cifs_strtoUCS((__le16 *)user, ses->user_name, len, nls_cp);
|
||||||
UniStrupr(user);
|
UniStrupr(user);
|
||||||
|
|
||||||
crypto_shash_update(&ses->server->secmech.sdeschmacmd5->shash,
|
crypto_shash_update(&ses->server->secmech.sdeschmacmd5->shash,
|
||||||
|
|
|
||||||
|
|
@ -412,8 +412,8 @@ cifs_show_options(struct seq_file *s, struct vfsmount *m)
|
||||||
|
|
||||||
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MULTIUSER)
|
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MULTIUSER)
|
||||||
seq_printf(s, ",multiuser");
|
seq_printf(s, ",multiuser");
|
||||||
else if (tcon->ses->userName)
|
else if (tcon->ses->user_name)
|
||||||
seq_printf(s, ",username=%s", tcon->ses->userName);
|
seq_printf(s, ",username=%s", tcon->ses->user_name);
|
||||||
|
|
||||||
if (tcon->ses->domainName)
|
if (tcon->ses->domainName)
|
||||||
seq_printf(s, ",domain=%s", tcon->ses->domainName);
|
seq_printf(s, ",domain=%s", tcon->ses->domainName);
|
||||||
|
|
|
||||||
|
|
@ -38,9 +38,8 @@
|
||||||
#define MAX_TREE_SIZE (2 + MAX_SERVER_SIZE + 1 + MAX_SHARE_SIZE + 1)
|
#define MAX_TREE_SIZE (2 + MAX_SERVER_SIZE + 1 + MAX_SHARE_SIZE + 1)
|
||||||
#define MAX_SERVER_SIZE 15
|
#define MAX_SERVER_SIZE 15
|
||||||
#define MAX_SHARE_SIZE 64 /* used to be 20, this should still be enough */
|
#define MAX_SHARE_SIZE 64 /* used to be 20, this should still be enough */
|
||||||
#define MAX_USERNAME_SIZE 32 /* 32 is to allow for 15 char names + null
|
#define MAX_USERNAME_SIZE 256 /* reasonable maximum for current servers */
|
||||||
termination then *2 for unicode versions */
|
#define MAX_PASSWORD_SIZE 512 /* max for windows seems to be 256 wide chars */
|
||||||
#define MAX_PASSWORD_SIZE 512 /* max for windows seems to be 256 wide chars */
|
|
||||||
|
|
||||||
#define CIFS_MIN_RCV_POOL 4
|
#define CIFS_MIN_RCV_POOL 4
|
||||||
|
|
||||||
|
|
@ -274,7 +273,7 @@ struct cifsSesInfo {
|
||||||
int capabilities;
|
int capabilities;
|
||||||
char serverName[SERVER_NAME_LEN_WITH_NULL * 2]; /* BB make bigger for
|
char serverName[SERVER_NAME_LEN_WITH_NULL * 2]; /* BB make bigger for
|
||||||
TCP names - will ipv6 and sctp addresses fit? */
|
TCP names - will ipv6 and sctp addresses fit? */
|
||||||
char userName[MAX_USERNAME_SIZE + 1];
|
char *user_name;
|
||||||
char *domainName;
|
char *domainName;
|
||||||
char *password;
|
char *password;
|
||||||
struct session_key auth_key;
|
struct session_key auth_key;
|
||||||
|
|
|
||||||
|
|
@ -881,7 +881,8 @@ cifs_parse_mount_options(char *options, const char *devname,
|
||||||
/* null user, ie anonymous, authentication */
|
/* null user, ie anonymous, authentication */
|
||||||
vol->nullauth = 1;
|
vol->nullauth = 1;
|
||||||
}
|
}
|
||||||
if (strnlen(value, 200) < 200) {
|
if (strnlen(value, MAX_USERNAME_SIZE) <
|
||||||
|
MAX_USERNAME_SIZE) {
|
||||||
vol->username = value;
|
vol->username = value;
|
||||||
} else {
|
} else {
|
||||||
printk(KERN_WARNING "CIFS: username too long\n");
|
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)
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/* anything else takes username/password */
|
/* anything else takes username/password */
|
||||||
if (strncmp(ses->userName, vol->username,
|
if (ses->user_name == NULL)
|
||||||
|
continue;
|
||||||
|
if (strncmp(ses->user_name, vol->username,
|
||||||
MAX_USERNAME_SIZE))
|
MAX_USERNAME_SIZE))
|
||||||
continue;
|
continue;
|
||||||
if (strlen(vol->username) != 0 &&
|
if (strlen(vol->username) != 0 &&
|
||||||
|
|
@ -1906,9 +1909,11 @@ cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb_vol *volume_info)
|
||||||
else
|
else
|
||||||
sprintf(ses->serverName, "%pI4", &addr->sin_addr);
|
sprintf(ses->serverName, "%pI4", &addr->sin_addr);
|
||||||
|
|
||||||
if (volume_info->username)
|
if (volume_info->username) {
|
||||||
strncpy(ses->userName, volume_info->username,
|
ses->user_name = kstrdup(volume_info->username, GFP_KERNEL);
|
||||||
MAX_USERNAME_SIZE);
|
if (!ses->user_name)
|
||||||
|
goto get_ses_fail;
|
||||||
|
}
|
||||||
|
|
||||||
/* volume_info->password freed at unmount */
|
/* volume_info->password freed at unmount */
|
||||||
if (volume_info->password) {
|
if (volume_info->password) {
|
||||||
|
|
|
||||||
|
|
@ -100,6 +100,7 @@ sesInfoFree(struct cifsSesInfo *buf_to_free)
|
||||||
memset(buf_to_free->password, 0, strlen(buf_to_free->password));
|
memset(buf_to_free->password, 0, strlen(buf_to_free->password));
|
||||||
kfree(buf_to_free->password);
|
kfree(buf_to_free->password);
|
||||||
}
|
}
|
||||||
|
kfree(buf_to_free->user_name);
|
||||||
kfree(buf_to_free->domainName);
|
kfree(buf_to_free->domainName);
|
||||||
kfree(buf_to_free);
|
kfree(buf_to_free);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -219,12 +219,12 @@ static void unicode_ssetup_strings(char **pbcc_area, struct cifsSesInfo *ses,
|
||||||
bcc_ptr++;
|
bcc_ptr++;
|
||||||
} */
|
} */
|
||||||
/* copy user */
|
/* copy user */
|
||||||
if (ses->userName == NULL) {
|
if (ses->user_name == NULL) {
|
||||||
/* null user mount */
|
/* null user mount */
|
||||||
*bcc_ptr = 0;
|
*bcc_ptr = 0;
|
||||||
*(bcc_ptr+1) = 0;
|
*(bcc_ptr+1) = 0;
|
||||||
} else {
|
} else {
|
||||||
bytes_ret = cifs_strtoUCS((__le16 *) bcc_ptr, ses->userName,
|
bytes_ret = cifs_strtoUCS((__le16 *) bcc_ptr, ses->user_name,
|
||||||
MAX_USERNAME_SIZE, nls_cp);
|
MAX_USERNAME_SIZE, nls_cp);
|
||||||
}
|
}
|
||||||
bcc_ptr += 2 * bytes_ret;
|
bcc_ptr += 2 * bytes_ret;
|
||||||
|
|
@ -244,12 +244,11 @@ static void ascii_ssetup_strings(char **pbcc_area, struct cifsSesInfo *ses,
|
||||||
/* copy user */
|
/* copy user */
|
||||||
/* BB what about null user mounts - check that we do this BB */
|
/* BB what about null user mounts - check that we do this BB */
|
||||||
/* copy user */
|
/* copy user */
|
||||||
if (ses->userName == NULL) {
|
if (ses->user_name != NULL)
|
||||||
/* BB what about null user mounts - check that we do this BB */
|
strncpy(bcc_ptr, ses->user_name, MAX_USERNAME_SIZE);
|
||||||
} else {
|
/* else null user mount */
|
||||||
strncpy(bcc_ptr, ses->userName, MAX_USERNAME_SIZE);
|
|
||||||
}
|
bcc_ptr += strnlen(ses->user_name, MAX_USERNAME_SIZE);
|
||||||
bcc_ptr += strnlen(ses->userName, MAX_USERNAME_SIZE);
|
|
||||||
*bcc_ptr = 0;
|
*bcc_ptr = 0;
|
||||||
bcc_ptr++; /* account for null termination */
|
bcc_ptr++; /* account for null termination */
|
||||||
|
|
||||||
|
|
@ -523,14 +522,14 @@ static int build_ntlmssp_auth_blob(unsigned char *pbuffer,
|
||||||
tmp += len;
|
tmp += len;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ses->userName == NULL) {
|
if (ses->user_name == NULL) {
|
||||||
sec_blob->UserName.BufferOffset = cpu_to_le32(tmp - pbuffer);
|
sec_blob->UserName.BufferOffset = cpu_to_le32(tmp - pbuffer);
|
||||||
sec_blob->UserName.Length = 0;
|
sec_blob->UserName.Length = 0;
|
||||||
sec_blob->UserName.MaximumLength = 0;
|
sec_blob->UserName.MaximumLength = 0;
|
||||||
tmp += 2;
|
tmp += 2;
|
||||||
} else {
|
} else {
|
||||||
int len;
|
int len;
|
||||||
len = cifs_strtoUCS((__le16 *)tmp, ses->userName,
|
len = cifs_strtoUCS((__le16 *)tmp, ses->user_name,
|
||||||
MAX_USERNAME_SIZE, nls_cp);
|
MAX_USERNAME_SIZE, nls_cp);
|
||||||
len *= 2; /* unicode is 2 bytes each */
|
len *= 2; /* unicode is 2 bytes each */
|
||||||
sec_blob->UserName.BufferOffset = cpu_to_le32(tmp - pbuffer);
|
sec_blob->UserName.BufferOffset = cpu_to_le32(tmp - pbuffer);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue