diff options
Diffstat (limited to 'fs/cifs/connect.c')
-rw-r--r-- | fs/cifs/connect.c | 153 |
1 files changed, 74 insertions, 79 deletions
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index e17106730168..791ca5c1a116 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c | |||
@@ -49,8 +49,6 @@ | |||
49 | #define CIFS_PORT 445 | 49 | #define CIFS_PORT 445 |
50 | #define RFC1001_PORT 139 | 50 | #define RFC1001_PORT 139 |
51 | 51 | ||
52 | static DECLARE_COMPLETION(cifsd_complete); | ||
53 | |||
54 | extern void SMBNTencrypt(unsigned char *passwd, unsigned char *c8, | 52 | extern void SMBNTencrypt(unsigned char *passwd, unsigned char *c8, |
55 | unsigned char *p24); | 53 | unsigned char *p24); |
56 | 54 | ||
@@ -71,23 +69,23 @@ struct smb_vol { | |||
71 | mode_t file_mode; | 69 | mode_t file_mode; |
72 | mode_t dir_mode; | 70 | mode_t dir_mode; |
73 | unsigned secFlg; | 71 | unsigned secFlg; |
74 | unsigned rw:1; | 72 | bool rw:1; |
75 | unsigned retry:1; | 73 | bool retry:1; |
76 | unsigned intr:1; | 74 | bool intr:1; |
77 | unsigned setuids:1; | 75 | bool setuids:1; |
78 | unsigned override_uid:1; | 76 | bool override_uid:1; |
79 | unsigned override_gid:1; | 77 | bool override_gid:1; |
80 | unsigned noperm:1; | 78 | bool noperm:1; |
81 | unsigned no_psx_acl:1; /* set if posix acl support should be disabled */ | 79 | bool no_psx_acl:1; /* set if posix acl support should be disabled */ |
82 | unsigned cifs_acl:1; | 80 | bool cifs_acl:1; |
83 | unsigned no_xattr:1; /* set if xattr (EA) support should be disabled*/ | 81 | bool no_xattr:1; /* set if xattr (EA) support should be disabled*/ |
84 | unsigned server_ino:1; /* use inode numbers from server ie UniqueId */ | 82 | bool server_ino:1; /* use inode numbers from server ie UniqueId */ |
85 | unsigned direct_io:1; | 83 | bool direct_io:1; |
86 | unsigned remap:1; /* set to remap seven reserved chars in filenames */ | 84 | bool remap:1; /* set to remap seven reserved chars in filenames */ |
87 | unsigned posix_paths:1; /* unset to not ask for posix pathnames. */ | 85 | bool posix_paths:1; /* unset to not ask for posix pathnames. */ |
88 | unsigned no_linux_ext:1; | 86 | bool no_linux_ext:1; |
89 | unsigned sfu_emul:1; | 87 | bool sfu_emul:1; |
90 | unsigned nullauth:1; /* attempt to authenticate with null user */ | 88 | bool nullauth:1; /* attempt to authenticate with null user */ |
91 | unsigned nocase; /* request case insensitive filenames */ | 89 | unsigned nocase; /* request case insensitive filenames */ |
92 | unsigned nobrl; /* disable sending byte range locks to srv */ | 90 | unsigned nobrl; /* disable sending byte range locks to srv */ |
93 | unsigned int rsize; | 91 | unsigned int rsize; |
@@ -345,8 +343,8 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) | |||
345 | struct task_struct *task_to_wake = NULL; | 343 | struct task_struct *task_to_wake = NULL; |
346 | struct mid_q_entry *mid_entry; | 344 | struct mid_q_entry *mid_entry; |
347 | char temp; | 345 | char temp; |
348 | int isLargeBuf = FALSE; | 346 | bool isLargeBuf = false; |
349 | int isMultiRsp; | 347 | bool isMultiRsp; |
350 | int reconnect; | 348 | int reconnect; |
351 | 349 | ||
352 | current->flags |= PF_MEMALLOC; | 350 | current->flags |= PF_MEMALLOC; |
@@ -356,7 +354,6 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) | |||
356 | atomic_inc(&tcpSesAllocCount); | 354 | atomic_inc(&tcpSesAllocCount); |
357 | length = tcpSesAllocCount.counter; | 355 | length = tcpSesAllocCount.counter; |
358 | write_unlock(&GlobalSMBSeslock); | 356 | write_unlock(&GlobalSMBSeslock); |
359 | complete(&cifsd_complete); | ||
360 | if (length > 1) | 357 | if (length > 1) |
361 | mempool_resize(cifs_req_poolp, length + cifs_min_rcv, | 358 | mempool_resize(cifs_req_poolp, length + cifs_min_rcv, |
362 | GFP_KERNEL); | 359 | GFP_KERNEL); |
@@ -390,8 +387,8 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) | |||
390 | } else /* if existing small buf clear beginning */ | 387 | } else /* if existing small buf clear beginning */ |
391 | memset(smallbuf, 0, sizeof(struct smb_hdr)); | 388 | memset(smallbuf, 0, sizeof(struct smb_hdr)); |
392 | 389 | ||
393 | isLargeBuf = FALSE; | 390 | isLargeBuf = false; |
394 | isMultiRsp = FALSE; | 391 | isMultiRsp = false; |
395 | smb_buffer = smallbuf; | 392 | smb_buffer = smallbuf; |
396 | iov.iov_base = smb_buffer; | 393 | iov.iov_base = smb_buffer; |
397 | iov.iov_len = 4; | 394 | iov.iov_len = 4; |
@@ -517,7 +514,7 @@ incomplete_rcv: | |||
517 | reconnect = 0; | 514 | reconnect = 0; |
518 | 515 | ||
519 | if (pdu_length > MAX_CIFS_SMALL_BUFFER_SIZE - 4) { | 516 | if (pdu_length > MAX_CIFS_SMALL_BUFFER_SIZE - 4) { |
520 | isLargeBuf = TRUE; | 517 | isLargeBuf = true; |
521 | memcpy(bigbuf, smallbuf, 4); | 518 | memcpy(bigbuf, smallbuf, 4); |
522 | smb_buffer = bigbuf; | 519 | smb_buffer = bigbuf; |
523 | } | 520 | } |
@@ -582,16 +579,18 @@ incomplete_rcv: | |||
582 | (mid_entry->command == smb_buffer->Command)) { | 579 | (mid_entry->command == smb_buffer->Command)) { |
583 | if (check2ndT2(smb_buffer,server->maxBuf) > 0) { | 580 | if (check2ndT2(smb_buffer,server->maxBuf) > 0) { |
584 | /* We have a multipart transact2 resp */ | 581 | /* We have a multipart transact2 resp */ |
585 | isMultiRsp = TRUE; | 582 | isMultiRsp = true; |
586 | if (mid_entry->resp_buf) { | 583 | if (mid_entry->resp_buf) { |
587 | /* merge response - fix up 1st*/ | 584 | /* merge response - fix up 1st*/ |
588 | if (coalesce_t2(smb_buffer, | 585 | if (coalesce_t2(smb_buffer, |
589 | mid_entry->resp_buf)) { | 586 | mid_entry->resp_buf)) { |
590 | mid_entry->multiRsp = 1; | 587 | mid_entry->multiRsp = |
588 | true; | ||
591 | break; | 589 | break; |
592 | } else { | 590 | } else { |
593 | /* all parts received */ | 591 | /* all parts received */ |
594 | mid_entry->multiEnd = 1; | 592 | mid_entry->multiEnd = |
593 | true; | ||
595 | goto multi_t2_fnd; | 594 | goto multi_t2_fnd; |
596 | } | 595 | } |
597 | } else { | 596 | } else { |
@@ -603,17 +602,15 @@ incomplete_rcv: | |||
603 | /* Have first buffer */ | 602 | /* Have first buffer */ |
604 | mid_entry->resp_buf = | 603 | mid_entry->resp_buf = |
605 | smb_buffer; | 604 | smb_buffer; |
606 | mid_entry->largeBuf = 1; | 605 | mid_entry->largeBuf = |
606 | true; | ||
607 | bigbuf = NULL; | 607 | bigbuf = NULL; |
608 | } | 608 | } |
609 | } | 609 | } |
610 | break; | 610 | break; |
611 | } | 611 | } |
612 | mid_entry->resp_buf = smb_buffer; | 612 | mid_entry->resp_buf = smb_buffer; |
613 | if (isLargeBuf) | 613 | mid_entry->largeBuf = isLargeBuf; |
614 | mid_entry->largeBuf = 1; | ||
615 | else | ||
616 | mid_entry->largeBuf = 0; | ||
617 | multi_t2_fnd: | 614 | multi_t2_fnd: |
618 | task_to_wake = mid_entry->tsk; | 615 | task_to_wake = mid_entry->tsk; |
619 | mid_entry->midState = MID_RESPONSE_RECEIVED; | 616 | mid_entry->midState = MID_RESPONSE_RECEIVED; |
@@ -638,8 +635,8 @@ multi_t2_fnd: | |||
638 | smallbuf = NULL; | 635 | smallbuf = NULL; |
639 | } | 636 | } |
640 | wake_up_process(task_to_wake); | 637 | wake_up_process(task_to_wake); |
641 | } else if ((is_valid_oplock_break(smb_buffer, server) == FALSE) | 638 | } else if (!is_valid_oplock_break(smb_buffer, server) && |
642 | && (isMultiRsp == FALSE)) { | 639 | !isMultiRsp) { |
643 | cERROR(1, ("No task to wake, unknown frame received! " | 640 | cERROR(1, ("No task to wake, unknown frame received! " |
644 | "NumMids %d", midCount.counter)); | 641 | "NumMids %d", midCount.counter)); |
645 | cifs_dump_mem("Received Data is: ", (char *)smb_buffer, | 642 | cifs_dump_mem("Received Data is: ", (char *)smb_buffer, |
@@ -825,7 +822,7 @@ cifs_parse_mount_options(char *options, const char *devname, | |||
825 | vol->file_mode = (S_IRWXUGO | S_ISGID) & (~S_IXGRP); | 822 | vol->file_mode = (S_IRWXUGO | S_ISGID) & (~S_IXGRP); |
826 | 823 | ||
827 | /* vol->retry default is 0 (i.e. "soft" limited retry not hard retry) */ | 824 | /* vol->retry default is 0 (i.e. "soft" limited retry not hard retry) */ |
828 | vol->rw = TRUE; | 825 | vol->rw = true; |
829 | /* default is always to request posix paths. */ | 826 | /* default is always to request posix paths. */ |
830 | vol->posix_paths = 1; | 827 | vol->posix_paths = 1; |
831 | 828 | ||
@@ -1181,7 +1178,7 @@ cifs_parse_mount_options(char *options, const char *devname, | |||
1181 | } else if (strnicmp(data, "guest", 5) == 0) { | 1178 | } else if (strnicmp(data, "guest", 5) == 0) { |
1182 | /* ignore */ | 1179 | /* ignore */ |
1183 | } else if (strnicmp(data, "rw", 2) == 0) { | 1180 | } else if (strnicmp(data, "rw", 2) == 0) { |
1184 | vol->rw = TRUE; | 1181 | vol->rw = true; |
1185 | } else if ((strnicmp(data, "suid", 4) == 0) || | 1182 | } else if ((strnicmp(data, "suid", 4) == 0) || |
1186 | (strnicmp(data, "nosuid", 6) == 0) || | 1183 | (strnicmp(data, "nosuid", 6) == 0) || |
1187 | (strnicmp(data, "exec", 4) == 0) || | 1184 | (strnicmp(data, "exec", 4) == 0) || |
@@ -1197,7 +1194,7 @@ cifs_parse_mount_options(char *options, const char *devname, | |||
1197 | is ok to just ignore them */ | 1194 | is ok to just ignore them */ |
1198 | continue; | 1195 | continue; |
1199 | } else if (strnicmp(data, "ro", 2) == 0) { | 1196 | } else if (strnicmp(data, "ro", 2) == 0) { |
1200 | vol->rw = FALSE; | 1197 | vol->rw = false; |
1201 | } else if (strnicmp(data, "hard", 4) == 0) { | 1198 | } else if (strnicmp(data, "hard", 4) == 0) { |
1202 | vol->retry = 1; | 1199 | vol->retry = 1; |
1203 | } else if (strnicmp(data, "soft", 4) == 0) { | 1200 | } else if (strnicmp(data, "soft", 4) == 0) { |
@@ -1305,6 +1302,9 @@ cifs_parse_mount_options(char *options, const char *devname, | |||
1305 | "begin with // or \\\\ \n"); | 1302 | "begin with // or \\\\ \n"); |
1306 | return 1; | 1303 | return 1; |
1307 | } | 1304 | } |
1305 | value = strpbrk(vol->UNC+2, "/\\"); | ||
1306 | if (value) | ||
1307 | *value = '\\'; | ||
1308 | } else { | 1308 | } else { |
1309 | printk(KERN_WARNING "CIFS: UNC name too long\n"); | 1309 | printk(KERN_WARNING "CIFS: UNC name too long\n"); |
1310 | return 1; | 1310 | return 1; |
@@ -1362,45 +1362,43 @@ find_unc(__be32 new_target_ip_addr, char *uncName, char *userName) | |||
1362 | { | 1362 | { |
1363 | struct list_head *tmp; | 1363 | struct list_head *tmp; |
1364 | struct cifsTconInfo *tcon; | 1364 | struct cifsTconInfo *tcon; |
1365 | __be32 old_ip; | ||
1365 | 1366 | ||
1366 | read_lock(&GlobalSMBSeslock); | 1367 | read_lock(&GlobalSMBSeslock); |
1368 | |||
1367 | list_for_each(tmp, &GlobalTreeConnectionList) { | 1369 | list_for_each(tmp, &GlobalTreeConnectionList) { |
1368 | cFYI(1, ("Next tcon")); | 1370 | cFYI(1, ("Next tcon")); |
1369 | tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); | 1371 | tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); |
1370 | if (tcon->ses) { | 1372 | if (!tcon->ses || !tcon->ses->server) |
1371 | if (tcon->ses->server) { | 1373 | continue; |
1372 | cFYI(1, | 1374 | |
1373 | ("old ip addr: %x == new ip %x ?", | 1375 | old_ip = tcon->ses->server->addr.sockAddr.sin_addr.s_addr; |
1374 | tcon->ses->server->addr.sockAddr.sin_addr. | 1376 | cFYI(1, ("old ip addr: %x == new ip %x ?", |
1375 | s_addr, new_target_ip_addr)); | 1377 | old_ip, new_target_ip_addr)); |
1376 | if (tcon->ses->server->addr.sockAddr.sin_addr. | 1378 | |
1377 | s_addr == new_target_ip_addr) { | 1379 | if (old_ip != new_target_ip_addr) |
1378 | /* BB lock tcon, server and tcp session and increment use count here? */ | 1380 | continue; |
1379 | /* found a match on the TCP session */ | 1381 | |
1380 | /* BB check if reconnection needed */ | 1382 | /* BB lock tcon, server, tcp session and increment use count? */ |
1381 | cFYI(1, | 1383 | /* found a match on the TCP session */ |
1382 | ("IP match, old UNC: %s new: %s", | 1384 | /* BB check if reconnection needed */ |
1383 | tcon->treeName, uncName)); | 1385 | cFYI(1, ("IP match, old UNC: %s new: %s", |
1384 | if (strncmp | 1386 | tcon->treeName, uncName)); |
1385 | (tcon->treeName, uncName, | 1387 | |
1386 | MAX_TREE_SIZE) == 0) { | 1388 | if (strncmp(tcon->treeName, uncName, MAX_TREE_SIZE)) |
1387 | cFYI(1, | 1389 | continue; |
1388 | ("and old usr: %s new: %s", | 1390 | |
1389 | tcon->treeName, uncName)); | 1391 | cFYI(1, ("and old usr: %s new: %s", |
1390 | if (strncmp | 1392 | tcon->treeName, uncName)); |
1391 | (tcon->ses->userName, | 1393 | |
1392 | userName, | 1394 | if (strncmp(tcon->ses->userName, userName, MAX_USERNAME_SIZE)) |
1393 | MAX_USERNAME_SIZE) == 0) { | 1395 | continue; |
1394 | read_unlock(&GlobalSMBSeslock); | 1396 | |
1395 | /* matched smb session | 1397 | /* matched smb session (user name) */ |
1396 | (user name */ | 1398 | read_unlock(&GlobalSMBSeslock); |
1397 | return tcon; | 1399 | return tcon; |
1398 | } | ||
1399 | } | ||
1400 | } | ||
1401 | } | ||
1402 | } | ||
1403 | } | 1400 | } |
1401 | |||
1404 | read_unlock(&GlobalSMBSeslock); | 1402 | read_unlock(&GlobalSMBSeslock); |
1405 | return NULL; | 1403 | return NULL; |
1406 | } | 1404 | } |
@@ -1982,7 +1980,6 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1982 | kfree(srvTcp->hostname); | 1980 | kfree(srvTcp->hostname); |
1983 | goto out; | 1981 | goto out; |
1984 | } | 1982 | } |
1985 | wait_for_completion(&cifsd_complete); | ||
1986 | rc = 0; | 1983 | rc = 0; |
1987 | memcpy(srvTcp->workstation_RFC1001_name, | 1984 | memcpy(srvTcp->workstation_RFC1001_name, |
1988 | volume_info.source_rfc1001_name, 16); | 1985 | volume_info.source_rfc1001_name, 16); |
@@ -2602,7 +2599,7 @@ sesssetup_nomem: /* do not return an error on nomem for the info strings, | |||
2602 | 2599 | ||
2603 | static int | 2600 | static int |
2604 | CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, | 2601 | CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, |
2605 | struct cifsSesInfo *ses, int *pNTLMv2_flag, | 2602 | struct cifsSesInfo *ses, bool *pNTLMv2_flag, |
2606 | const struct nls_table *nls_codepage) | 2603 | const struct nls_table *nls_codepage) |
2607 | { | 2604 | { |
2608 | struct smb_hdr *smb_buffer; | 2605 | struct smb_hdr *smb_buffer; |
@@ -2625,7 +2622,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, | |||
2625 | if (ses == NULL) | 2622 | if (ses == NULL) |
2626 | return -EINVAL; | 2623 | return -EINVAL; |
2627 | domain = ses->domainName; | 2624 | domain = ses->domainName; |
2628 | *pNTLMv2_flag = FALSE; | 2625 | *pNTLMv2_flag = false; |
2629 | smb_buffer = cifs_buf_get(); | 2626 | smb_buffer = cifs_buf_get(); |
2630 | if (smb_buffer == NULL) { | 2627 | if (smb_buffer == NULL) { |
2631 | return -ENOMEM; | 2628 | return -ENOMEM; |
@@ -2778,7 +2775,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, | |||
2778 | CIFS_CRYPTO_KEY_SIZE); | 2775 | CIFS_CRYPTO_KEY_SIZE); |
2779 | if (SecurityBlob2->NegotiateFlags & | 2776 | if (SecurityBlob2->NegotiateFlags & |
2780 | cpu_to_le32(NTLMSSP_NEGOTIATE_NTLMV2)) | 2777 | cpu_to_le32(NTLMSSP_NEGOTIATE_NTLMV2)) |
2781 | *pNTLMv2_flag = TRUE; | 2778 | *pNTLMv2_flag = true; |
2782 | 2779 | ||
2783 | if ((SecurityBlob2->NegotiateFlags & | 2780 | if ((SecurityBlob2->NegotiateFlags & |
2784 | cpu_to_le32(NTLMSSP_NEGOTIATE_ALWAYS_SIGN)) | 2781 | cpu_to_le32(NTLMSSP_NEGOTIATE_ALWAYS_SIGN)) |
@@ -2939,7 +2936,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, | |||
2939 | } | 2936 | } |
2940 | static int | 2937 | static int |
2941 | CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, | 2938 | CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, |
2942 | char *ntlm_session_key, int ntlmv2_flag, | 2939 | char *ntlm_session_key, bool ntlmv2_flag, |
2943 | const struct nls_table *nls_codepage) | 2940 | const struct nls_table *nls_codepage) |
2944 | { | 2941 | { |
2945 | struct smb_hdr *smb_buffer; | 2942 | struct smb_hdr *smb_buffer; |
@@ -3556,8 +3553,6 @@ cifs_umount(struct super_block *sb, struct cifs_sb_info *cifs_sb) | |||
3556 | cifs_sb->prepath = NULL; | 3553 | cifs_sb->prepath = NULL; |
3557 | kfree(tmp); | 3554 | kfree(tmp); |
3558 | if (ses) | 3555 | if (ses) |
3559 | schedule_timeout_interruptible(msecs_to_jiffies(500)); | ||
3560 | if (ses) | ||
3561 | sesInfoFree(ses); | 3556 | sesInfoFree(ses); |
3562 | 3557 | ||
3563 | FreeXid(xid); | 3558 | FreeXid(xid); |
@@ -3569,7 +3564,7 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo, | |||
3569 | { | 3564 | { |
3570 | int rc = 0; | 3565 | int rc = 0; |
3571 | char ntlm_session_key[CIFS_SESS_KEY_SIZE]; | 3566 | char ntlm_session_key[CIFS_SESS_KEY_SIZE]; |
3572 | int ntlmv2_flag = FALSE; | 3567 | bool ntlmv2_flag = false; |
3573 | int first_time = 0; | 3568 | int first_time = 0; |
3574 | 3569 | ||
3575 | /* what if server changes its buffer size after dropping the session? */ | 3570 | /* what if server changes its buffer size after dropping the session? */ |