diff options
Diffstat (limited to 'fs/cifs/connect.c')
-rw-r--r-- | fs/cifs/connect.c | 51 |
1 files changed, 36 insertions, 15 deletions
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 7e73176acb58..9eb327defa1d 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c | |||
@@ -175,6 +175,9 @@ cifs_reconnect(struct TCP_Server_Info *server) | |||
175 | } | 175 | } |
176 | server->sequence_number = 0; | 176 | server->sequence_number = 0; |
177 | server->session_estab = false; | 177 | server->session_estab = false; |
178 | kfree(server->session_key.response); | ||
179 | server->session_key.response = NULL; | ||
180 | server->session_key.len = 0; | ||
178 | 181 | ||
179 | spin_lock(&GlobalMid_Lock); | 182 | spin_lock(&GlobalMid_Lock); |
180 | list_for_each(tmp, &server->pending_mid_q) { | 183 | list_for_each(tmp, &server->pending_mid_q) { |
@@ -1064,7 +1067,7 @@ cifs_parse_mount_options(char *options, const char *devname, | |||
1064 | } | 1067 | } |
1065 | i = cifs_convert_address((struct sockaddr *)&vol->srcaddr, | 1068 | i = cifs_convert_address((struct sockaddr *)&vol->srcaddr, |
1066 | value, strlen(value)); | 1069 | value, strlen(value)); |
1067 | if (i < 0) { | 1070 | if (i == 0) { |
1068 | printk(KERN_WARNING "CIFS: Could not parse" | 1071 | printk(KERN_WARNING "CIFS: Could not parse" |
1069 | " srcaddr: %s\n", | 1072 | " srcaddr: %s\n", |
1070 | value); | 1073 | value); |
@@ -1560,8 +1563,13 @@ cifs_put_tcp_session(struct TCP_Server_Info *server) | |||
1560 | server->tcpStatus = CifsExiting; | 1563 | server->tcpStatus = CifsExiting; |
1561 | spin_unlock(&GlobalMid_Lock); | 1564 | spin_unlock(&GlobalMid_Lock); |
1562 | 1565 | ||
1566 | cifs_crypto_shash_release(server); | ||
1563 | cifs_fscache_release_client_cookie(server); | 1567 | cifs_fscache_release_client_cookie(server); |
1564 | 1568 | ||
1569 | kfree(server->session_key.response); | ||
1570 | server->session_key.response = NULL; | ||
1571 | server->session_key.len = 0; | ||
1572 | |||
1565 | task = xchg(&server->tsk, NULL); | 1573 | task = xchg(&server->tsk, NULL); |
1566 | if (task) | 1574 | if (task) |
1567 | force_sig(SIGKILL, task); | 1575 | force_sig(SIGKILL, task); |
@@ -1614,10 +1622,16 @@ cifs_get_tcp_session(struct smb_vol *volume_info) | |||
1614 | goto out_err; | 1622 | goto out_err; |
1615 | } | 1623 | } |
1616 | 1624 | ||
1625 | rc = cifs_crypto_shash_allocate(tcp_ses); | ||
1626 | if (rc) { | ||
1627 | cERROR(1, "could not setup hash structures rc %d", rc); | ||
1628 | goto out_err; | ||
1629 | } | ||
1630 | |||
1617 | tcp_ses->hostname = extract_hostname(volume_info->UNC); | 1631 | tcp_ses->hostname = extract_hostname(volume_info->UNC); |
1618 | if (IS_ERR(tcp_ses->hostname)) { | 1632 | if (IS_ERR(tcp_ses->hostname)) { |
1619 | rc = PTR_ERR(tcp_ses->hostname); | 1633 | rc = PTR_ERR(tcp_ses->hostname); |
1620 | goto out_err; | 1634 | goto out_err_crypto_release; |
1621 | } | 1635 | } |
1622 | 1636 | ||
1623 | tcp_ses->noblocksnd = volume_info->noblocksnd; | 1637 | tcp_ses->noblocksnd = volume_info->noblocksnd; |
@@ -1661,7 +1675,7 @@ cifs_get_tcp_session(struct smb_vol *volume_info) | |||
1661 | } | 1675 | } |
1662 | if (rc < 0) { | 1676 | if (rc < 0) { |
1663 | cERROR(1, "Error connecting to socket. Aborting operation"); | 1677 | cERROR(1, "Error connecting to socket. Aborting operation"); |
1664 | goto out_err; | 1678 | goto out_err_crypto_release; |
1665 | } | 1679 | } |
1666 | 1680 | ||
1667 | /* | 1681 | /* |
@@ -1675,7 +1689,7 @@ cifs_get_tcp_session(struct smb_vol *volume_info) | |||
1675 | rc = PTR_ERR(tcp_ses->tsk); | 1689 | rc = PTR_ERR(tcp_ses->tsk); |
1676 | cERROR(1, "error %d create cifsd thread", rc); | 1690 | cERROR(1, "error %d create cifsd thread", rc); |
1677 | module_put(THIS_MODULE); | 1691 | module_put(THIS_MODULE); |
1678 | goto out_err; | 1692 | goto out_err_crypto_release; |
1679 | } | 1693 | } |
1680 | 1694 | ||
1681 | /* thread spawned, put it on the list */ | 1695 | /* thread spawned, put it on the list */ |
@@ -1687,6 +1701,9 @@ cifs_get_tcp_session(struct smb_vol *volume_info) | |||
1687 | 1701 | ||
1688 | return tcp_ses; | 1702 | return tcp_ses; |
1689 | 1703 | ||
1704 | out_err_crypto_release: | ||
1705 | cifs_crypto_shash_release(tcp_ses); | ||
1706 | |||
1690 | out_err: | 1707 | out_err: |
1691 | if (tcp_ses) { | 1708 | if (tcp_ses) { |
1692 | if (!IS_ERR(tcp_ses->hostname)) | 1709 | if (!IS_ERR(tcp_ses->hostname)) |
@@ -1801,8 +1818,6 @@ cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb_vol *volume_info) | |||
1801 | if (ses == NULL) | 1818 | if (ses == NULL) |
1802 | goto get_ses_fail; | 1819 | goto get_ses_fail; |
1803 | 1820 | ||
1804 | ses->tilen = 0; | ||
1805 | ses->tiblob = NULL; | ||
1806 | /* new SMB session uses our server ref */ | 1821 | /* new SMB session uses our server ref */ |
1807 | ses->server = server; | 1822 | ses->server = server; |
1808 | if (server->addr.sockAddr6.sin6_family == AF_INET6) | 1823 | if (server->addr.sockAddr6.sin6_family == AF_INET6) |
@@ -1823,10 +1838,9 @@ cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb_vol *volume_info) | |||
1823 | goto get_ses_fail; | 1838 | goto get_ses_fail; |
1824 | } | 1839 | } |
1825 | if (volume_info->domainname) { | 1840 | if (volume_info->domainname) { |
1826 | int len = strlen(volume_info->domainname); | 1841 | ses->domainName = kstrdup(volume_info->domainname, GFP_KERNEL); |
1827 | ses->domainName = kmalloc(len + 1, GFP_KERNEL); | 1842 | if (!ses->domainName) |
1828 | if (ses->domainName) | 1843 | goto get_ses_fail; |
1829 | strcpy(ses->domainName, volume_info->domainname); | ||
1830 | } | 1844 | } |
1831 | ses->cred_uid = volume_info->cred_uid; | 1845 | ses->cred_uid = volume_info->cred_uid; |
1832 | ses->linux_uid = volume_info->linux_uid; | 1846 | ses->linux_uid = volume_info->linux_uid; |
@@ -2985,13 +2999,13 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, | |||
2985 | #ifdef CONFIG_CIFS_WEAK_PW_HASH | 2999 | #ifdef CONFIG_CIFS_WEAK_PW_HASH |
2986 | if ((global_secflags & CIFSSEC_MAY_LANMAN) && | 3000 | if ((global_secflags & CIFSSEC_MAY_LANMAN) && |
2987 | (ses->server->secType == LANMAN)) | 3001 | (ses->server->secType == LANMAN)) |
2988 | calc_lanman_hash(tcon->password, ses->cryptKey, | 3002 | calc_lanman_hash(tcon->password, ses->server->cryptkey, |
2989 | ses->server->secMode & | 3003 | ses->server->secMode & |
2990 | SECMODE_PW_ENCRYPT ? true : false, | 3004 | SECMODE_PW_ENCRYPT ? true : false, |
2991 | bcc_ptr); | 3005 | bcc_ptr); |
2992 | else | 3006 | else |
2993 | #endif /* CIFS_WEAK_PW_HASH */ | 3007 | #endif /* CIFS_WEAK_PW_HASH */ |
2994 | SMBNTencrypt(tcon->password, ses->cryptKey, bcc_ptr); | 3008 | SMBNTencrypt(tcon->password, ses->server->cryptkey, bcc_ptr); |
2995 | 3009 | ||
2996 | bcc_ptr += CIFS_SESS_KEY_SIZE; | 3010 | bcc_ptr += CIFS_SESS_KEY_SIZE; |
2997 | if (ses->capabilities & CAP_UNICODE) { | 3011 | if (ses->capabilities & CAP_UNICODE) { |
@@ -3178,10 +3192,11 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *ses, | |||
3178 | } else { | 3192 | } else { |
3179 | mutex_lock(&ses->server->srv_mutex); | 3193 | mutex_lock(&ses->server->srv_mutex); |
3180 | if (!server->session_estab) { | 3194 | if (!server->session_estab) { |
3181 | memcpy(&server->session_key.data, | 3195 | server->session_key.response = ses->auth_key.response; |
3182 | &ses->auth_key.data, ses->auth_key.len); | ||
3183 | server->session_key.len = ses->auth_key.len; | 3196 | server->session_key.len = ses->auth_key.len; |
3184 | ses->server->session_estab = true; | 3197 | server->sequence_number = 0x2; |
3198 | server->session_estab = true; | ||
3199 | ses->auth_key.response = NULL; | ||
3185 | } | 3200 | } |
3186 | mutex_unlock(&server->srv_mutex); | 3201 | mutex_unlock(&server->srv_mutex); |
3187 | 3202 | ||
@@ -3192,6 +3207,12 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *ses, | |||
3192 | spin_unlock(&GlobalMid_Lock); | 3207 | spin_unlock(&GlobalMid_Lock); |
3193 | } | 3208 | } |
3194 | 3209 | ||
3210 | kfree(ses->auth_key.response); | ||
3211 | ses->auth_key.response = NULL; | ||
3212 | ses->auth_key.len = 0; | ||
3213 | kfree(ses->ntlmssp); | ||
3214 | ses->ntlmssp = NULL; | ||
3215 | |||
3195 | return rc; | 3216 | return rc; |
3196 | } | 3217 | } |
3197 | 3218 | ||