aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/connect.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/cifs/connect.c')
-rw-r--r--fs/cifs/connect.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 3a84a375cb6f..3caadf12d76d 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -2282,9 +2282,12 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
2282 2282
2283 /* volume_info->password freed at unmount */ 2283 /* volume_info->password freed at unmount */
2284 if (volume_info->password) { 2284 if (volume_info->password) {
2285 pSesInfo->password = volume_info->password; 2285 pSesInfo->password = kstrdup(volume_info->password,
2286 /* set to NULL to prevent freeing on exit */ 2286 GFP_KERNEL);
2287 volume_info->password = NULL; 2287 if (!pSesInfo->password) {
2288 rc = -ENOMEM;
2289 goto mount_fail_check;
2290 }
2288 } 2291 }
2289 if (volume_info->username) 2292 if (volume_info->username)
2290 strncpy(pSesInfo->userName, volume_info->username, 2293 strncpy(pSesInfo->userName, volume_info->username,
@@ -2324,7 +2327,16 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
2324 rc = -ENOMEM; 2327 rc = -ENOMEM;
2325 goto mount_fail_check; 2328 goto mount_fail_check;
2326 } 2329 }
2330
2327 tcon->ses = pSesInfo; 2331 tcon->ses = pSesInfo;
2332 if (volume_info->password) {
2333 tcon->password = kstrdup(volume_info->password,
2334 GFP_KERNEL);
2335 if (!tcon->password) {
2336 rc = -ENOMEM;
2337 goto mount_fail_check;
2338 }
2339 }
2328 2340
2329 /* check for null share name ie connect to dfs root */ 2341 /* check for null share name ie connect to dfs root */
2330 if ((strchr(volume_info->UNC + 3, '\\') == NULL) 2342 if ((strchr(volume_info->UNC + 3, '\\') == NULL)
@@ -3532,15 +3544,14 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses,
3532 NTLMv2 password here) */ 3544 NTLMv2 password here) */
3533#ifdef CONFIG_CIFS_WEAK_PW_HASH 3545#ifdef CONFIG_CIFS_WEAK_PW_HASH
3534 if ((extended_security & CIFSSEC_MAY_LANMAN) && 3546 if ((extended_security & CIFSSEC_MAY_LANMAN) &&
3535 (ses->server->secType == LANMAN)) 3547 (ses->server->secType == LANMAN))
3536 calc_lanman_hash(ses->password, ses->server->cryptKey, 3548 calc_lanman_hash(tcon->password, ses->server->cryptKey,
3537 ses->server->secMode & 3549 ses->server->secMode &
3538 SECMODE_PW_ENCRYPT ? true : false, 3550 SECMODE_PW_ENCRYPT ? true : false,
3539 bcc_ptr); 3551 bcc_ptr);
3540 else 3552 else
3541#endif /* CIFS_WEAK_PW_HASH */ 3553#endif /* CIFS_WEAK_PW_HASH */
3542 SMBNTencrypt(ses->password, 3554 SMBNTencrypt(tcon->password, ses->server->cryptKey,
3543 ses->server->cryptKey,
3544 bcc_ptr); 3555 bcc_ptr);
3545 3556
3546 bcc_ptr += CIFS_SESS_KEY_SIZE; 3557 bcc_ptr += CIFS_SESS_KEY_SIZE;