diff options
Diffstat (limited to 'fs/cifs/connect.c')
-rw-r--r-- | fs/cifs/connect.c | 755 |
1 files changed, 413 insertions, 342 deletions
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index ef10c3717fb5..9d6d9a09d973 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c | |||
@@ -121,7 +121,7 @@ cifs_reconnect(struct TCP_Server_Info *server) | |||
121 | struct cifsSesInfo *ses; | 121 | struct cifsSesInfo *ses; |
122 | struct cifsTconInfo *tcon; | 122 | struct cifsTconInfo *tcon; |
123 | struct mid_q_entry *mid_entry; | 123 | struct mid_q_entry *mid_entry; |
124 | 124 | ||
125 | spin_lock(&GlobalMid_Lock); | 125 | spin_lock(&GlobalMid_Lock); |
126 | if ( kthread_should_stop() ) { | 126 | if ( kthread_should_stop() ) { |
127 | /* the demux thread will exit normally | 127 | /* the demux thread will exit normally |
@@ -284,13 +284,13 @@ static int coalesce_t2(struct smb_hdr *psecond, struct smb_hdr *pTargetSMB) | |||
284 | total_in_buf = le16_to_cpu(pSMBt->t2_rsp.DataCount); | 284 | total_in_buf = le16_to_cpu(pSMBt->t2_rsp.DataCount); |
285 | 285 | ||
286 | remaining = total_data_size - total_in_buf; | 286 | remaining = total_data_size - total_in_buf; |
287 | 287 | ||
288 | if (remaining < 0) | 288 | if (remaining < 0) |
289 | return -EINVAL; | 289 | return -EINVAL; |
290 | 290 | ||
291 | if (remaining == 0) /* nothing to do, ignore */ | 291 | if (remaining == 0) /* nothing to do, ignore */ |
292 | return 0; | 292 | return 0; |
293 | 293 | ||
294 | total_in_buf2 = le16_to_cpu(pSMB2->t2_rsp.DataCount); | 294 | total_in_buf2 = le16_to_cpu(pSMB2->t2_rsp.DataCount); |
295 | if (remaining < total_in_buf2) { | 295 | if (remaining < total_in_buf2) { |
296 | cFYI(1, ("transact2 2nd response contains too much data")); | 296 | cFYI(1, ("transact2 2nd response contains too much data")); |
@@ -318,7 +318,7 @@ static int coalesce_t2(struct smb_hdr *psecond, struct smb_hdr *pTargetSMB) | |||
318 | byte_count += total_in_buf2; | 318 | byte_count += total_in_buf2; |
319 | 319 | ||
320 | /* BB also add check that we are not beyond maximum buffer size */ | 320 | /* BB also add check that we are not beyond maximum buffer size */ |
321 | 321 | ||
322 | pTargetSMB->smb_buf_length = byte_count; | 322 | pTargetSMB->smb_buf_length = byte_count; |
323 | 323 | ||
324 | if (remaining == total_in_buf2) { | 324 | if (remaining == total_in_buf2) { |
@@ -560,7 +560,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) | |||
560 | continue; | 560 | continue; |
561 | 561 | ||
562 | length += 4; /* account for rfc1002 hdr */ | 562 | length += 4; /* account for rfc1002 hdr */ |
563 | 563 | ||
564 | 564 | ||
565 | dump_smb(smb_buffer, length); | 565 | dump_smb(smb_buffer, length); |
566 | if (checkSMB(smb_buffer, smb_buffer->Mid, total_read+4)) { | 566 | if (checkSMB(smb_buffer, smb_buffer->Mid, total_read+4)) { |
@@ -574,7 +574,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) | |||
574 | list_for_each(tmp, &server->pending_mid_q) { | 574 | list_for_each(tmp, &server->pending_mid_q) { |
575 | mid_entry = list_entry(tmp, struct mid_q_entry, qhead); | 575 | mid_entry = list_entry(tmp, struct mid_q_entry, qhead); |
576 | 576 | ||
577 | if ((mid_entry->mid == smb_buffer->Mid) && | 577 | if ((mid_entry->mid == smb_buffer->Mid) && |
578 | (mid_entry->midState == MID_REQUEST_SUBMITTED) && | 578 | (mid_entry->midState == MID_REQUEST_SUBMITTED) && |
579 | (mid_entry->command == smb_buffer->Command)) { | 579 | (mid_entry->command == smb_buffer->Command)) { |
580 | if (check2ndT2(smb_buffer,server->maxBuf) > 0) { | 580 | if (check2ndT2(smb_buffer,server->maxBuf) > 0) { |
@@ -582,20 +582,20 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) | |||
582 | isMultiRsp = TRUE; | 582 | isMultiRsp = TRUE; |
583 | if (mid_entry->resp_buf) { | 583 | if (mid_entry->resp_buf) { |
584 | /* merge response - fix up 1st*/ | 584 | /* merge response - fix up 1st*/ |
585 | if (coalesce_t2(smb_buffer, | 585 | if (coalesce_t2(smb_buffer, |
586 | mid_entry->resp_buf)) { | 586 | mid_entry->resp_buf)) { |
587 | mid_entry->multiRsp = 1; | 587 | mid_entry->multiRsp = 1; |
588 | break; | 588 | break; |
589 | } else { | 589 | } else { |
590 | /* all parts received */ | 590 | /* all parts received */ |
591 | mid_entry->multiEnd = 1; | 591 | mid_entry->multiEnd = 1; |
592 | goto multi_t2_fnd; | 592 | goto multi_t2_fnd; |
593 | } | 593 | } |
594 | } else { | 594 | } else { |
595 | if (!isLargeBuf) { | 595 | if (!isLargeBuf) { |
596 | cERROR(1,("1st trans2 resp needs bigbuf")); | 596 | cERROR(1,("1st trans2 resp needs bigbuf")); |
597 | /* BB maybe we can fix this up, switch | 597 | /* BB maybe we can fix this up, switch |
598 | to already allocated large buffer? */ | 598 | to already allocated large buffer? */ |
599 | } else { | 599 | } else { |
600 | /* Have first buffer */ | 600 | /* Have first buffer */ |
601 | mid_entry->resp_buf = | 601 | mid_entry->resp_buf = |
@@ -605,7 +605,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) | |||
605 | } | 605 | } |
606 | } | 606 | } |
607 | break; | 607 | break; |
608 | } | 608 | } |
609 | mid_entry->resp_buf = smb_buffer; | 609 | mid_entry->resp_buf = smb_buffer; |
610 | if (isLargeBuf) | 610 | if (isLargeBuf) |
611 | mid_entry->largeBuf = 1; | 611 | mid_entry->largeBuf = 1; |
@@ -636,15 +636,16 @@ multi_t2_fnd: | |||
636 | } | 636 | } |
637 | wake_up_process(task_to_wake); | 637 | wake_up_process(task_to_wake); |
638 | } else if ((is_valid_oplock_break(smb_buffer, server) == FALSE) | 638 | } else if ((is_valid_oplock_break(smb_buffer, server) == FALSE) |
639 | && (isMultiRsp == FALSE)) { | 639 | && (isMultiRsp == FALSE)) { |
640 | cERROR(1, ("No task to wake, unknown frame rcvd! NumMids %d", midCount.counter)); | 640 | cERROR(1, ("No task to wake, unknown frame received! " |
641 | cifs_dump_mem("Received Data is: ",(char *)smb_buffer, | 641 | "NumMids %d", midCount.counter)); |
642 | cifs_dump_mem("Received Data is: ", (char *)smb_buffer, | ||
642 | sizeof(struct smb_hdr)); | 643 | sizeof(struct smb_hdr)); |
643 | #ifdef CONFIG_CIFS_DEBUG2 | 644 | #ifdef CONFIG_CIFS_DEBUG2 |
644 | cifs_dump_detail(smb_buffer); | 645 | cifs_dump_detail(smb_buffer); |
645 | cifs_dump_mids(server); | 646 | cifs_dump_mids(server); |
646 | #endif /* CIFS_DEBUG2 */ | 647 | #endif /* CIFS_DEBUG2 */ |
647 | 648 | ||
648 | } | 649 | } |
649 | } /* end while !EXITING */ | 650 | } /* end while !EXITING */ |
650 | 651 | ||
@@ -659,7 +660,7 @@ multi_t2_fnd: | |||
659 | /* We do not want to set the max_pending too low or we | 660 | /* We do not want to set the max_pending too low or we |
660 | could end up with the counter going negative */ | 661 | could end up with the counter going negative */ |
661 | spin_unlock(&GlobalMid_Lock); | 662 | spin_unlock(&GlobalMid_Lock); |
662 | /* Although there should not be any requests blocked on | 663 | /* Although there should not be any requests blocked on |
663 | this queue it can not hurt to be paranoid and try to wake up requests | 664 | this queue it can not hurt to be paranoid and try to wake up requests |
664 | that may haven been blocked when more than 50 at time were on the wire | 665 | that may haven been blocked when more than 50 at time were on the wire |
665 | to the same server - they now will see the session is in exit state | 666 | to the same server - they now will see the session is in exit state |
@@ -667,7 +668,7 @@ multi_t2_fnd: | |||
667 | wake_up_all(&server->request_q); | 668 | wake_up_all(&server->request_q); |
668 | /* give those requests time to exit */ | 669 | /* give those requests time to exit */ |
669 | msleep(125); | 670 | msleep(125); |
670 | 671 | ||
671 | if (server->ssocket) { | 672 | if (server->ssocket) { |
672 | sock_release(csocket); | 673 | sock_release(csocket); |
673 | server->ssocket = NULL; | 674 | server->ssocket = NULL; |
@@ -708,8 +709,8 @@ multi_t2_fnd: | |||
708 | list_for_each(tmp, &server->pending_mid_q) { | 709 | list_for_each(tmp, &server->pending_mid_q) { |
709 | mid_entry = list_entry(tmp, struct mid_q_entry, qhead); | 710 | mid_entry = list_entry(tmp, struct mid_q_entry, qhead); |
710 | if (mid_entry->midState == MID_REQUEST_SUBMITTED) { | 711 | if (mid_entry->midState == MID_REQUEST_SUBMITTED) { |
711 | cFYI(1, | 712 | cFYI(1, ("Clearing Mid 0x%x - waking up ", |
712 | ("Clearing Mid 0x%x - waking up ",mid_entry->mid)); | 713 | mid_entry->mid)); |
713 | task_to_wake = mid_entry->tsk; | 714 | task_to_wake = mid_entry->tsk; |
714 | if (task_to_wake) { | 715 | if (task_to_wake) { |
715 | wake_up_process(task_to_wake); | 716 | wake_up_process(task_to_wake); |
@@ -723,7 +724,7 @@ multi_t2_fnd: | |||
723 | } | 724 | } |
724 | 725 | ||
725 | if (!list_empty(&server->pending_mid_q)) { | 726 | if (!list_empty(&server->pending_mid_q)) { |
726 | /* mpx threads have not exited yet give them | 727 | /* mpx threads have not exited yet give them |
727 | at least the smb send timeout time for long ops */ | 728 | at least the smb send timeout time for long ops */ |
728 | /* due to delays on oplock break requests, we need | 729 | /* due to delays on oplock break requests, we need |
729 | to wait at least 45 seconds before giving up | 730 | to wait at least 45 seconds before giving up |
@@ -741,7 +742,7 @@ multi_t2_fnd: | |||
741 | 742 | ||
742 | /* last chance to mark ses pointers invalid | 743 | /* last chance to mark ses pointers invalid |
743 | if there are any pointing to this (e.g | 744 | if there are any pointing to this (e.g |
744 | if a crazy root user tried to kill cifsd | 745 | if a crazy root user tried to kill cifsd |
745 | kernel thread explicitly this might happen) */ | 746 | kernel thread explicitly this might happen) */ |
746 | list_for_each(tmp, &GlobalSMBSessionList) { | 747 | list_for_each(tmp, &GlobalSMBSessionList) { |
747 | ses = list_entry(tmp, struct cifsSesInfo, | 748 | ses = list_entry(tmp, struct cifsSesInfo, |
@@ -758,12 +759,13 @@ multi_t2_fnd: | |||
758 | length + cifs_min_rcv, | 759 | length + cifs_min_rcv, |
759 | GFP_KERNEL); | 760 | GFP_KERNEL); |
760 | } | 761 | } |
761 | 762 | ||
762 | return 0; | 763 | return 0; |
763 | } | 764 | } |
764 | 765 | ||
765 | static int | 766 | static int |
766 | cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | 767 | cifs_parse_mount_options(char *options, const char *devname, |
768 | struct smb_vol *vol) | ||
767 | { | 769 | { |
768 | char *value; | 770 | char *value; |
769 | char *data; | 771 | char *data; |
@@ -771,15 +773,15 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
771 | char separator[2]; | 773 | char separator[2]; |
772 | 774 | ||
773 | separator[0] = ','; | 775 | separator[0] = ','; |
774 | separator[1] = 0; | 776 | separator[1] = 0; |
775 | 777 | ||
776 | if (Local_System_Name[0] != 0) | 778 | if (Local_System_Name[0] != 0) |
777 | memcpy(vol->source_rfc1001_name, Local_System_Name,15); | 779 | memcpy(vol->source_rfc1001_name, Local_System_Name, 15); |
778 | else { | 780 | else { |
779 | char *nodename = utsname()->nodename; | 781 | char *nodename = utsname()->nodename; |
780 | int n = strnlen(nodename,15); | 782 | int n = strnlen(nodename, 15); |
781 | memset(vol->source_rfc1001_name,0x20,15); | 783 | memset(vol->source_rfc1001_name, 0x20, 15); |
782 | for(i=0 ; i < n ; i++) { | 784 | for (i = 0; i < n; i++) { |
783 | /* does not have to be perfect mapping since field is | 785 | /* does not have to be perfect mapping since field is |
784 | informational, only used for servers that do not support | 786 | informational, only used for servers that do not support |
785 | port 445 and it can be overridden at mount time */ | 787 | port 445 and it can be overridden at mount time */ |
@@ -804,7 +806,7 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
804 | if (!options) | 806 | if (!options) |
805 | return 1; | 807 | return 1; |
806 | 808 | ||
807 | if (strncmp(options,"sep=",4) == 0) { | 809 | if (strncmp(options, "sep=", 4) == 0) { |
808 | if (options[4] != 0) { | 810 | if (options[4] != 0) { |
809 | separator[0] = options[4]; | 811 | separator[0] = options[4]; |
810 | options += 5; | 812 | options += 5; |
@@ -812,16 +814,17 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
812 | cFYI(1, ("Null separator not allowed")); | 814 | cFYI(1, ("Null separator not allowed")); |
813 | } | 815 | } |
814 | } | 816 | } |
815 | 817 | ||
816 | while ((data = strsep(&options, separator)) != NULL) { | 818 | while ((data = strsep(&options, separator)) != NULL) { |
817 | if (!*data) | 819 | if (!*data) |
818 | continue; | 820 | continue; |
819 | if ((value = strchr(data, '=')) != NULL) | 821 | if ((value = strchr(data, '=')) != NULL) |
820 | *value++ = '\0'; | 822 | *value++ = '\0'; |
821 | 823 | ||
822 | if (strnicmp(data, "user_xattr",10) == 0) {/*parse before user*/ | 824 | /* Have to parse this before we parse for "user" */ |
825 | if (strnicmp(data, "user_xattr", 10) == 0) { | ||
823 | vol->no_xattr = 0; | 826 | vol->no_xattr = 0; |
824 | } else if (strnicmp(data, "nouser_xattr",12) == 0) { | 827 | } else if (strnicmp(data, "nouser_xattr", 12) == 0) { |
825 | vol->no_xattr = 1; | 828 | vol->no_xattr = 1; |
826 | } else if (strnicmp(data, "user", 4) == 0) { | 829 | } else if (strnicmp(data, "user", 4) == 0) { |
827 | if (!value) { | 830 | if (!value) { |
@@ -856,7 +859,7 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
856 | /* removed password length check, NTLM passwords | 859 | /* removed password length check, NTLM passwords |
857 | can be arbitrarily long */ | 860 | can be arbitrarily long */ |
858 | 861 | ||
859 | /* if comma in password, the string will be | 862 | /* if comma in password, the string will be |
860 | prematurely null terminated. Commas in password are | 863 | prematurely null terminated. Commas in password are |
861 | specified across the cifs mount interface by a double | 864 | specified across the cifs mount interface by a double |
862 | comma ie ,, and a comma used as in other cases ie ',' | 865 | comma ie ,, and a comma used as in other cases ie ',' |
@@ -866,18 +869,18 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
866 | /* NB: password legally can have multiple commas and | 869 | /* NB: password legally can have multiple commas and |
867 | the only illegal character in a password is null */ | 870 | the only illegal character in a password is null */ |
868 | 871 | ||
869 | if ((value[temp_len] == 0) && | 872 | if ((value[temp_len] == 0) && |
870 | (value[temp_len+1] == separator[0])) { | 873 | (value[temp_len+1] == separator[0])) { |
871 | /* reinsert comma */ | 874 | /* reinsert comma */ |
872 | value[temp_len] = separator[0]; | 875 | value[temp_len] = separator[0]; |
873 | temp_len+=2; /* move after the second comma */ | 876 | temp_len += 2; /* move after second comma */ |
874 | while(value[temp_len] != 0) { | 877 | while (value[temp_len] != 0) { |
875 | if (value[temp_len] == separator[0]) { | 878 | if (value[temp_len] == separator[0]) { |
876 | if (value[temp_len+1] == | 879 | if (value[temp_len+1] == |
877 | separator[0]) { | 880 | separator[0]) { |
878 | /* skip second comma */ | 881 | /* skip second comma */ |
879 | temp_len++; | 882 | temp_len++; |
880 | } else { | 883 | } else { |
881 | /* single comma indicating start | 884 | /* single comma indicating start |
882 | of next parm */ | 885 | of next parm */ |
883 | break; | 886 | break; |
@@ -892,15 +895,16 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
892 | /* point option to start of next parm */ | 895 | /* point option to start of next parm */ |
893 | options = value + temp_len + 1; | 896 | options = value + temp_len + 1; |
894 | } | 897 | } |
895 | /* go from value to value + temp_len condensing | 898 | /* go from value to value + temp_len condensing |
896 | double commas to singles. Note that this ends up | 899 | double commas to singles. Note that this ends up |
897 | allocating a few bytes too many, which is ok */ | 900 | allocating a few bytes too many, which is ok */ |
898 | vol->password = kzalloc(temp_len, GFP_KERNEL); | 901 | vol->password = kzalloc(temp_len, GFP_KERNEL); |
899 | if (vol->password == NULL) { | 902 | if (vol->password == NULL) { |
900 | printk("CIFS: no memory for pass\n"); | 903 | printk(KERN_WARNING "CIFS: no memory " |
904 | "for password\n"); | ||
901 | return 1; | 905 | return 1; |
902 | } | 906 | } |
903 | for(i=0,j=0;i<temp_len;i++,j++) { | 907 | for (i = 0, j = 0; i < temp_len; i++, j++) { |
904 | vol->password[j] = value[i]; | 908 | vol->password[j] = value[i]; |
905 | if (value[i] == separator[0] | 909 | if (value[i] == separator[0] |
906 | && value[i+1] == separator[0]) { | 910 | && value[i+1] == separator[0]) { |
@@ -912,7 +916,8 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
912 | } else { | 916 | } else { |
913 | vol->password = kzalloc(temp_len+1, GFP_KERNEL); | 917 | vol->password = kzalloc(temp_len+1, GFP_KERNEL); |
914 | if (vol->password == NULL) { | 918 | if (vol->password == NULL) { |
915 | printk("CIFS: no memory for pass\n"); | 919 | printk(KERN_WARNING "CIFS: no memory " |
920 | "for password\n"); | ||
916 | return 1; | 921 | return 1; |
917 | } | 922 | } |
918 | strcpy(vol->password, value); | 923 | strcpy(vol->password, value); |
@@ -923,20 +928,21 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
923 | } else if (strnlen(value, 35) < 35) { | 928 | } else if (strnlen(value, 35) < 35) { |
924 | vol->UNCip = value; | 929 | vol->UNCip = value; |
925 | } else { | 930 | } else { |
926 | printk(KERN_WARNING "CIFS: ip address too long\n"); | 931 | printk(KERN_WARNING "CIFS: ip address " |
932 | "too long\n"); | ||
927 | return 1; | 933 | return 1; |
928 | } | 934 | } |
929 | } else if (strnicmp(data, "sec", 3) == 0) { | 935 | } else if (strnicmp(data, "sec", 3) == 0) { |
930 | if (!value || !*value) { | 936 | if (!value || !*value) { |
931 | cERROR(1,("no security value specified")); | 937 | cERROR(1, ("no security value specified")); |
932 | continue; | 938 | continue; |
933 | } else if (strnicmp(value, "krb5i", 5) == 0) { | 939 | } else if (strnicmp(value, "krb5i", 5) == 0) { |
934 | vol->secFlg |= CIFSSEC_MAY_KRB5 | | 940 | vol->secFlg |= CIFSSEC_MAY_KRB5 | |
935 | CIFSSEC_MUST_SIGN; | 941 | CIFSSEC_MUST_SIGN; |
936 | } else if (strnicmp(value, "krb5p", 5) == 0) { | 942 | } else if (strnicmp(value, "krb5p", 5) == 0) { |
937 | /* vol->secFlg |= CIFSSEC_MUST_SEAL | | 943 | /* vol->secFlg |= CIFSSEC_MUST_SEAL | |
938 | CIFSSEC_MAY_KRB5; */ | 944 | CIFSSEC_MAY_KRB5; */ |
939 | cERROR(1,("Krb5 cifs privacy not supported")); | 945 | cERROR(1, ("Krb5 cifs privacy not supported")); |
940 | return 1; | 946 | return 1; |
941 | } else if (strnicmp(value, "krb5", 4) == 0) { | 947 | } else if (strnicmp(value, "krb5", 4) == 0) { |
942 | vol->secFlg |= CIFSSEC_MAY_KRB5; | 948 | vol->secFlg |= CIFSSEC_MAY_KRB5; |
@@ -956,33 +962,34 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
956 | vol->secFlg |= CIFSSEC_MAY_NTLMV2; | 962 | vol->secFlg |= CIFSSEC_MAY_NTLMV2; |
957 | #ifdef CONFIG_CIFS_WEAK_PW_HASH | 963 | #ifdef CONFIG_CIFS_WEAK_PW_HASH |
958 | } else if (strnicmp(value, "lanman", 6) == 0) { | 964 | } else if (strnicmp(value, "lanman", 6) == 0) { |
959 | vol->secFlg |= CIFSSEC_MAY_LANMAN; | 965 | vol->secFlg |= CIFSSEC_MAY_LANMAN; |
960 | #endif | 966 | #endif |
961 | } else if (strnicmp(value, "none", 4) == 0) { | 967 | } else if (strnicmp(value, "none", 4) == 0) { |
962 | vol->nullauth = 1; | 968 | vol->nullauth = 1; |
963 | } else { | 969 | } else { |
964 | cERROR(1,("bad security option: %s", value)); | 970 | cERROR(1, ("bad security option: %s", value)); |
965 | return 1; | 971 | return 1; |
966 | } | 972 | } |
967 | } else if ((strnicmp(data, "unc", 3) == 0) | 973 | } else if ((strnicmp(data, "unc", 3) == 0) |
968 | || (strnicmp(data, "target", 6) == 0) | 974 | || (strnicmp(data, "target", 6) == 0) |
969 | || (strnicmp(data, "path", 4) == 0)) { | 975 | || (strnicmp(data, "path", 4) == 0)) { |
970 | if (!value || !*value) { | 976 | if (!value || !*value) { |
971 | printk(KERN_WARNING | 977 | printk(KERN_WARNING "CIFS: invalid path to " |
972 | "CIFS: invalid path to network resource\n"); | 978 | "network resource\n"); |
973 | return 1; /* needs_arg; */ | 979 | return 1; /* needs_arg; */ |
974 | } | 980 | } |
975 | if ((temp_len = strnlen(value, 300)) < 300) { | 981 | if ((temp_len = strnlen(value, 300)) < 300) { |
976 | vol->UNC = kmalloc(temp_len+1,GFP_KERNEL); | 982 | vol->UNC = kmalloc(temp_len+1, GFP_KERNEL); |
977 | if (vol->UNC == NULL) | 983 | if (vol->UNC == NULL) |
978 | return 1; | 984 | return 1; |
979 | strcpy(vol->UNC,value); | 985 | strcpy(vol->UNC, value); |
980 | if (strncmp(vol->UNC, "//", 2) == 0) { | 986 | if (strncmp(vol->UNC, "//", 2) == 0) { |
981 | vol->UNC[0] = '\\'; | 987 | vol->UNC[0] = '\\'; |
982 | vol->UNC[1] = '\\'; | 988 | vol->UNC[1] = '\\'; |
983 | } else if (strncmp(vol->UNC, "\\\\", 2) != 0) { | 989 | } else if (strncmp(vol->UNC, "\\\\", 2) != 0) { |
984 | printk(KERN_WARNING | 990 | printk(KERN_WARNING |
985 | "CIFS: UNC Path does not begin with // or \\\\ \n"); | 991 | "CIFS: UNC Path does not begin " |
992 | "with // or \\\\ \n"); | ||
986 | return 1; | 993 | return 1; |
987 | } | 994 | } |
988 | } else { | 995 | } else { |
@@ -1001,41 +1008,43 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
1001 | vol->domainname = value; | 1008 | vol->domainname = value; |
1002 | cFYI(1, ("Domain name set")); | 1009 | cFYI(1, ("Domain name set")); |
1003 | } else { | 1010 | } else { |
1004 | printk(KERN_WARNING "CIFS: domain name too long\n"); | 1011 | printk(KERN_WARNING "CIFS: domain name too " |
1012 | "long\n"); | ||
1005 | return 1; | 1013 | return 1; |
1006 | } | 1014 | } |
1007 | } else if (strnicmp(data, "prefixpath", 10) == 0) { | 1015 | } else if (strnicmp(data, "prefixpath", 10) == 0) { |
1008 | if (!value || !*value) { | 1016 | if (!value || !*value) { |
1009 | printk(KERN_WARNING | 1017 | printk(KERN_WARNING |
1010 | "CIFS: invalid path prefix\n"); | 1018 | "CIFS: invalid path prefix\n"); |
1011 | return 1; /* needs_arg; */ | 1019 | return 1; /* needs_argument */ |
1012 | } | 1020 | } |
1013 | if ((temp_len = strnlen(value, 1024)) < 1024) { | 1021 | if ((temp_len = strnlen(value, 1024)) < 1024) { |
1014 | if (value[0] != '/') | 1022 | if (value[0] != '/') |
1015 | temp_len++; /* missing leading slash */ | 1023 | temp_len++; /* missing leading slash */ |
1016 | vol->prepath = kmalloc(temp_len+1,GFP_KERNEL); | 1024 | vol->prepath = kmalloc(temp_len+1, GFP_KERNEL); |
1017 | if (vol->prepath == NULL) | 1025 | if (vol->prepath == NULL) |
1018 | return 1; | 1026 | return 1; |
1019 | if (value[0] != '/') { | 1027 | if (value[0] != '/') { |
1020 | vol->prepath[0] = '/'; | 1028 | vol->prepath[0] = '/'; |
1021 | strcpy(vol->prepath+1,value); | 1029 | strcpy(vol->prepath+1, value); |
1022 | } else | 1030 | } else |
1023 | strcpy(vol->prepath,value); | 1031 | strcpy(vol->prepath, value); |
1024 | cFYI(1, ("prefix path %s",vol->prepath)); | 1032 | cFYI(1, ("prefix path %s", vol->prepath)); |
1025 | } else { | 1033 | } else { |
1026 | printk(KERN_WARNING "CIFS: prefix too long\n"); | 1034 | printk(KERN_WARNING "CIFS: prefix too long\n"); |
1027 | return 1; | 1035 | return 1; |
1028 | } | 1036 | } |
1029 | } else if (strnicmp(data, "iocharset", 9) == 0) { | 1037 | } else if (strnicmp(data, "iocharset", 9) == 0) { |
1030 | if (!value || !*value) { | 1038 | if (!value || !*value) { |
1031 | printk(KERN_WARNING "CIFS: invalid iocharset specified\n"); | 1039 | printk(KERN_WARNING "CIFS: invalid iocharset specified\n"); |
1032 | return 1; /* needs_arg; */ | 1040 | return 1; /* needs_arg; */ |
1033 | } | 1041 | } |
1034 | if (strnlen(value, 65) < 65) { | 1042 | if (strnlen(value, 65) < 65) { |
1035 | if (strnicmp(value,"default",7)) | 1043 | if (strnicmp(value, "default", 7)) |
1036 | vol->iocharset = value; | 1044 | vol->iocharset = value; |
1037 | /* if iocharset not set load_nls_default used by caller */ | 1045 | /* if iocharset not set then load_nls_default |
1038 | cFYI(1, ("iocharset set to %s",value)); | 1046 | is used by caller */ |
1047 | cFYI(1, ("iocharset set to %s", value)); | ||
1039 | } else { | 1048 | } else { |
1040 | printk(KERN_WARNING "CIFS: iocharset name too long.\n"); | 1049 | printk(KERN_WARNING "CIFS: iocharset name too long.\n"); |
1041 | return 1; | 1050 | return 1; |
@@ -1091,22 +1100,24 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
1091 | if (!value || !*value || (*value == ' ')) { | 1100 | if (!value || !*value || (*value == ' ')) { |
1092 | cFYI(1, ("invalid (empty) netbiosname specified")); | 1101 | cFYI(1, ("invalid (empty) netbiosname specified")); |
1093 | } else { | 1102 | } else { |
1094 | memset(vol->source_rfc1001_name,0x20,15); | 1103 | memset(vol->source_rfc1001_name, 0x20, 15); |
1095 | for(i=0;i<15;i++) { | 1104 | for (i = 0; i < 15; i++) { |
1096 | /* BB are there cases in which a comma can be | 1105 | /* BB are there cases in which a comma can be |
1097 | valid in this workstation netbios name (and need | 1106 | valid in this workstation netbios name (and need |
1098 | special handling)? */ | 1107 | special handling)? */ |
1099 | 1108 | ||
1100 | /* We do not uppercase netbiosname for user */ | 1109 | /* We do not uppercase netbiosname for user */ |
1101 | if (value[i]==0) | 1110 | if (value[i] == 0) |
1102 | break; | 1111 | break; |
1103 | else | 1112 | else |
1104 | vol->source_rfc1001_name[i] = value[i]; | 1113 | vol->source_rfc1001_name[i] = |
1114 | value[i]; | ||
1105 | } | 1115 | } |
1106 | /* The string has 16th byte zero still from | 1116 | /* The string has 16th byte zero still from |
1107 | set at top of the function */ | 1117 | set at top of the function */ |
1108 | if ((i==15) && (value[i] != 0)) | 1118 | if ((i == 15) && (value[i] != 0)) |
1109 | printk(KERN_WARNING "CIFS: netbiosname longer than 15 truncated.\n"); | 1119 | printk(KERN_WARNING "CIFS: netbiosname" |
1120 | " longer than 15 truncated.\n"); | ||
1110 | } | 1121 | } |
1111 | } else if (strnicmp(data, "servern", 7) == 0) { | 1122 | } else if (strnicmp(data, "servern", 7) == 0) { |
1112 | /* servernetbiosname specified override *SMBSERVER */ | 1123 | /* servernetbiosname specified override *SMBSERVER */ |
@@ -1114,29 +1125,32 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
1114 | cFYI(1, ("empty server netbiosname specified")); | 1125 | cFYI(1, ("empty server netbiosname specified")); |
1115 | } else { | 1126 | } else { |
1116 | /* last byte, type, is 0x20 for servr type */ | 1127 | /* last byte, type, is 0x20 for servr type */ |
1117 | memset(vol->target_rfc1001_name,0x20,16); | 1128 | memset(vol->target_rfc1001_name, 0x20, 16); |
1118 | 1129 | ||
1119 | for(i=0;i<15;i++) { | 1130 | for (i = 0; i < 15; i++) { |
1120 | /* BB are there cases in which a comma can be | 1131 | /* BB are there cases in which a comma can be |
1121 | valid in this workstation netbios name (and need | 1132 | valid in this workstation netbios name |
1122 | special handling)? */ | 1133 | (and need special handling)? */ |
1123 | 1134 | ||
1124 | /* user or mount helper must uppercase netbiosname */ | 1135 | /* user or mount helper must uppercase |
1125 | if (value[i]==0) | 1136 | the netbiosname */ |
1137 | if (value[i] == 0) | ||
1126 | break; | 1138 | break; |
1127 | else | 1139 | else |
1128 | vol->target_rfc1001_name[i] = value[i]; | 1140 | vol->target_rfc1001_name[i] = |
1141 | value[i]; | ||
1129 | } | 1142 | } |
1130 | /* The string has 16th byte zero still from | 1143 | /* The string has 16th byte zero still from |
1131 | set at top of the function */ | 1144 | set at top of the function */ |
1132 | if ((i==15) && (value[i] != 0)) | 1145 | if ((i == 15) && (value[i] != 0)) |
1133 | printk(KERN_WARNING "CIFS: server netbiosname longer than 15 truncated.\n"); | 1146 | printk(KERN_WARNING "CIFS: server net" |
1147 | "biosname longer than 15 truncated.\n"); | ||
1134 | } | 1148 | } |
1135 | } else if (strnicmp(data, "credentials", 4) == 0) { | 1149 | } else if (strnicmp(data, "credentials", 4) == 0) { |
1136 | /* ignore */ | 1150 | /* ignore */ |
1137 | } else if (strnicmp(data, "version", 3) == 0) { | 1151 | } else if (strnicmp(data, "version", 3) == 0) { |
1138 | /* ignore */ | 1152 | /* ignore */ |
1139 | } else if (strnicmp(data, "guest",5) == 0) { | 1153 | } else if (strnicmp(data, "guest", 5) == 0) { |
1140 | /* ignore */ | 1154 | /* ignore */ |
1141 | } else if (strnicmp(data, "rw", 2) == 0) { | 1155 | } else if (strnicmp(data, "rw", 2) == 0) { |
1142 | vol->rw = TRUE; | 1156 | vol->rw = TRUE; |
@@ -1148,11 +1162,11 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
1148 | (strnicmp(data, "noauto", 6) == 0) || | 1162 | (strnicmp(data, "noauto", 6) == 0) || |
1149 | (strnicmp(data, "dev", 3) == 0)) { | 1163 | (strnicmp(data, "dev", 3) == 0)) { |
1150 | /* The mount tool or mount.cifs helper (if present) | 1164 | /* The mount tool or mount.cifs helper (if present) |
1151 | uses these opts to set flags, and the flags are read | 1165 | uses these opts to set flags, and the flags are read |
1152 | by the kernel vfs layer before we get here (ie | 1166 | by the kernel vfs layer before we get here (ie |
1153 | before read super) so there is no point trying to | 1167 | before read super) so there is no point trying to |
1154 | parse these options again and set anything and it | 1168 | parse these options again and set anything and it |
1155 | is ok to just ignore them */ | 1169 | is ok to just ignore them */ |
1156 | continue; | 1170 | continue; |
1157 | } else if (strnicmp(data, "ro", 2) == 0) { | 1171 | } else if (strnicmp(data, "ro", 2) == 0) { |
1158 | vol->rw = FALSE; | 1172 | vol->rw = FALSE; |
@@ -1168,26 +1182,27 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
1168 | vol->remap = 1; | 1182 | vol->remap = 1; |
1169 | } else if (strnicmp(data, "nomapchars", 10) == 0) { | 1183 | } else if (strnicmp(data, "nomapchars", 10) == 0) { |
1170 | vol->remap = 0; | 1184 | vol->remap = 0; |
1171 | } else if (strnicmp(data, "sfu", 3) == 0) { | 1185 | } else if (strnicmp(data, "sfu", 3) == 0) { |
1172 | vol->sfu_emul = 1; | 1186 | vol->sfu_emul = 1; |
1173 | } else if (strnicmp(data, "nosfu", 5) == 0) { | 1187 | } else if (strnicmp(data, "nosfu", 5) == 0) { |
1174 | vol->sfu_emul = 0; | 1188 | vol->sfu_emul = 0; |
1175 | } else if (strnicmp(data, "posixpaths", 10) == 0) { | 1189 | } else if (strnicmp(data, "posixpaths", 10) == 0) { |
1176 | vol->posix_paths = 1; | 1190 | vol->posix_paths = 1; |
1177 | } else if (strnicmp(data, "noposixpaths", 12) == 0) { | 1191 | } else if (strnicmp(data, "noposixpaths", 12) == 0) { |
1178 | vol->posix_paths = 0; | 1192 | vol->posix_paths = 0; |
1179 | } else if ((strnicmp(data, "nocase", 6) == 0) || | 1193 | } else if ((strnicmp(data, "nocase", 6) == 0) || |
1180 | (strnicmp(data, "ignorecase", 10) == 0)) { | 1194 | (strnicmp(data, "ignorecase", 10) == 0)) { |
1181 | vol->nocase = 1; | 1195 | vol->nocase = 1; |
1182 | } else if (strnicmp(data, "brl", 3) == 0) { | 1196 | } else if (strnicmp(data, "brl", 3) == 0) { |
1183 | vol->nobrl = 0; | 1197 | vol->nobrl = 0; |
1184 | } else if ((strnicmp(data, "nobrl", 5) == 0) || | 1198 | } else if ((strnicmp(data, "nobrl", 5) == 0) || |
1185 | (strnicmp(data, "nolock", 6) == 0)) { | 1199 | (strnicmp(data, "nolock", 6) == 0)) { |
1186 | vol->nobrl = 1; | 1200 | vol->nobrl = 1; |
1187 | /* turn off mandatory locking in mode | 1201 | /* turn off mandatory locking in mode |
1188 | if remote locking is turned off since the | 1202 | if remote locking is turned off since the |
1189 | local vfs will do advisory */ | 1203 | local vfs will do advisory */ |
1190 | if (vol->file_mode == (S_IALLUGO & ~(S_ISUID | S_IXGRP))) | 1204 | if (vol->file_mode == |
1205 | (S_IALLUGO & ~(S_ISUID | S_IXGRP))) | ||
1191 | vol->file_mode = S_IALLUGO; | 1206 | vol->file_mode = S_IALLUGO; |
1192 | } else if (strnicmp(data, "setuids", 7) == 0) { | 1207 | } else if (strnicmp(data, "setuids", 7) == 0) { |
1193 | vol->setuids = 1; | 1208 | vol->setuids = 1; |
@@ -1201,55 +1216,61 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
1201 | vol->intr = 0; | 1216 | vol->intr = 0; |
1202 | } else if (strnicmp(data, "intr", 4) == 0) { | 1217 | } else if (strnicmp(data, "intr", 4) == 0) { |
1203 | vol->intr = 1; | 1218 | vol->intr = 1; |
1204 | } else if (strnicmp(data, "serverino",7) == 0) { | 1219 | } else if (strnicmp(data, "serverino", 7) == 0) { |
1205 | vol->server_ino = 1; | 1220 | vol->server_ino = 1; |
1206 | } else if (strnicmp(data, "noserverino",9) == 0) { | 1221 | } else if (strnicmp(data, "noserverino", 9) == 0) { |
1207 | vol->server_ino = 0; | 1222 | vol->server_ino = 0; |
1208 | } else if (strnicmp(data, "cifsacl",7) == 0) { | 1223 | } else if (strnicmp(data, "cifsacl", 7) == 0) { |
1209 | vol->cifs_acl = 1; | 1224 | vol->cifs_acl = 1; |
1210 | } else if (strnicmp(data, "nocifsacl", 9) == 0) { | 1225 | } else if (strnicmp(data, "nocifsacl", 9) == 0) { |
1211 | vol->cifs_acl = 0; | 1226 | vol->cifs_acl = 0; |
1212 | } else if (strnicmp(data, "acl",3) == 0) { | 1227 | } else if (strnicmp(data, "acl", 3) == 0) { |
1213 | vol->no_psx_acl = 0; | 1228 | vol->no_psx_acl = 0; |
1214 | } else if (strnicmp(data, "noacl",5) == 0) { | 1229 | } else if (strnicmp(data, "noacl", 5) == 0) { |
1215 | vol->no_psx_acl = 1; | 1230 | vol->no_psx_acl = 1; |
1216 | } else if (strnicmp(data, "sign",4) == 0) { | 1231 | } else if (strnicmp(data, "sign", 4) == 0) { |
1217 | vol->secFlg |= CIFSSEC_MUST_SIGN; | 1232 | vol->secFlg |= CIFSSEC_MUST_SIGN; |
1218 | /* } else if (strnicmp(data, "seal",4) == 0) { | 1233 | /* } else if (strnicmp(data, "seal",4) == 0) { |
1219 | vol->secFlg |= CIFSSEC_MUST_SEAL; */ | 1234 | vol->secFlg |= CIFSSEC_MUST_SEAL; */ |
1220 | } else if (strnicmp(data, "direct",6) == 0) { | 1235 | } else if (strnicmp(data, "direct", 6) == 0) { |
1221 | vol->direct_io = 1; | 1236 | vol->direct_io = 1; |
1222 | } else if (strnicmp(data, "forcedirectio",13) == 0) { | 1237 | } else if (strnicmp(data, "forcedirectio", 13) == 0) { |
1223 | vol->direct_io = 1; | 1238 | vol->direct_io = 1; |
1224 | } else if (strnicmp(data, "in6_addr",8) == 0) { | 1239 | } else if (strnicmp(data, "in6_addr", 8) == 0) { |
1225 | if (!value || !*value) { | 1240 | if (!value || !*value) { |
1226 | vol->in6_addr = NULL; | 1241 | vol->in6_addr = NULL; |
1227 | } else if (strnlen(value, 49) == 48) { | 1242 | } else if (strnlen(value, 49) == 48) { |
1228 | vol->in6_addr = value; | 1243 | vol->in6_addr = value; |
1229 | } else { | 1244 | } else { |
1230 | printk(KERN_WARNING "CIFS: ip v6 address not 48 characters long\n"); | 1245 | printk(KERN_WARNING "CIFS: ip v6 address not " |
1246 | "48 characters long\n"); | ||
1231 | return 1; | 1247 | return 1; |
1232 | } | 1248 | } |
1233 | } else if (strnicmp(data, "noac", 4) == 0) { | 1249 | } else if (strnicmp(data, "noac", 4) == 0) { |
1234 | printk(KERN_WARNING "CIFS: Mount option noac not supported. Instead set /proc/fs/cifs/LookupCacheEnabled to 0\n"); | 1250 | printk(KERN_WARNING "CIFS: Mount option noac not " |
1251 | "supported. Instead set " | ||
1252 | "/proc/fs/cifs/LookupCacheEnabled to 0\n"); | ||
1235 | } else | 1253 | } else |
1236 | printk(KERN_WARNING "CIFS: Unknown mount option %s\n",data); | 1254 | printk(KERN_WARNING "CIFS: Unknown mount option %s\n", |
1255 | data); | ||
1237 | } | 1256 | } |
1238 | if (vol->UNC == NULL) { | 1257 | if (vol->UNC == NULL) { |
1239 | if (devname == NULL) { | 1258 | if (devname == NULL) { |
1240 | printk(KERN_WARNING "CIFS: Missing UNC name for mount target\n"); | 1259 | printk(KERN_WARNING "CIFS: Missing UNC name for mount " |
1260 | "target\n"); | ||
1241 | return 1; | 1261 | return 1; |
1242 | } | 1262 | } |
1243 | if ((temp_len = strnlen(devname, 300)) < 300) { | 1263 | if ((temp_len = strnlen(devname, 300)) < 300) { |
1244 | vol->UNC = kmalloc(temp_len+1,GFP_KERNEL); | 1264 | vol->UNC = kmalloc(temp_len+1, GFP_KERNEL); |
1245 | if (vol->UNC == NULL) | 1265 | if (vol->UNC == NULL) |
1246 | return 1; | 1266 | return 1; |
1247 | strcpy(vol->UNC,devname); | 1267 | strcpy(vol->UNC, devname); |
1248 | if (strncmp(vol->UNC, "//", 2) == 0) { | 1268 | if (strncmp(vol->UNC, "//", 2) == 0) { |
1249 | vol->UNC[0] = '\\'; | 1269 | vol->UNC[0] = '\\'; |
1250 | vol->UNC[1] = '\\'; | 1270 | vol->UNC[1] = '\\'; |
1251 | } else if (strncmp(vol->UNC, "\\\\", 2) != 0) { | 1271 | } else if (strncmp(vol->UNC, "\\\\", 2) != 0) { |
1252 | printk(KERN_WARNING "CIFS: UNC Path does not begin with // or \\\\ \n"); | 1272 | printk(KERN_WARNING "CIFS: UNC Path does not " |
1273 | "begin with // or \\\\ \n"); | ||
1253 | return 1; | 1274 | return 1; |
1254 | } | 1275 | } |
1255 | } else { | 1276 | } else { |
@@ -1264,7 +1285,7 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
1264 | } | 1285 | } |
1265 | 1286 | ||
1266 | static struct cifsSesInfo * | 1287 | static struct cifsSesInfo * |
1267 | cifs_find_tcp_session(struct in_addr * target_ip_addr, | 1288 | cifs_find_tcp_session(struct in_addr *target_ip_addr, |
1268 | struct in6_addr *target_ip6_addr, | 1289 | struct in6_addr *target_ip6_addr, |
1269 | char *userName, struct TCP_Server_Info **psrvTcp) | 1290 | char *userName, struct TCP_Server_Info **psrvTcp) |
1270 | { | 1291 | { |
@@ -1276,19 +1297,25 @@ cifs_find_tcp_session(struct in_addr * target_ip_addr, | |||
1276 | list_for_each(tmp, &GlobalSMBSessionList) { | 1297 | list_for_each(tmp, &GlobalSMBSessionList) { |
1277 | ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList); | 1298 | ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList); |
1278 | if (ses->server) { | 1299 | if (ses->server) { |
1279 | if ((target_ip_addr && | 1300 | if ((target_ip_addr && |
1280 | (ses->server->addr.sockAddr.sin_addr.s_addr | 1301 | (ses->server->addr.sockAddr.sin_addr.s_addr |
1281 | == target_ip_addr->s_addr)) || (target_ip6_addr | 1302 | == target_ip_addr->s_addr)) || (target_ip6_addr |
1282 | && memcmp(&ses->server->addr.sockAddr6.sin6_addr, | 1303 | && memcmp(&ses->server->addr.sockAddr6.sin6_addr, |
1283 | target_ip6_addr,sizeof(*target_ip6_addr)))){ | 1304 | target_ip6_addr, sizeof(*target_ip6_addr)))) { |
1284 | /* BB lock server and tcp session and increment use count here?? */ | 1305 | /* BB lock server and tcp session and increment |
1285 | *psrvTcp = ses->server; /* found a match on the TCP session */ | 1306 | use count here?? */ |
1307 | |||
1308 | /* found a match on the TCP session */ | ||
1309 | *psrvTcp = ses->server; | ||
1310 | |||
1286 | /* BB check if reconnection needed */ | 1311 | /* BB check if reconnection needed */ |
1287 | if (strncmp | 1312 | if (strncmp |
1288 | (ses->userName, userName, | 1313 | (ses->userName, userName, |
1289 | MAX_USERNAME_SIZE) == 0){ | 1314 | MAX_USERNAME_SIZE) == 0){ |
1290 | read_unlock(&GlobalSMBSeslock); | 1315 | read_unlock(&GlobalSMBSeslock); |
1291 | return ses; /* found exact match on both tcp and SMB sessions */ | 1316 | /* Found exact match on both TCP and |
1317 | SMB sessions */ | ||
1318 | return ses; | ||
1292 | } | 1319 | } |
1293 | } | 1320 | } |
1294 | } | 1321 | } |
@@ -1319,7 +1346,8 @@ find_unc(__be32 new_target_ip_addr, char *uncName, char *userName) | |||
1319 | /* BB lock tcon, server and tcp session and increment use count here? */ | 1346 | /* BB lock tcon, server and tcp session and increment use count here? */ |
1320 | /* found a match on the TCP session */ | 1347 | /* found a match on the TCP session */ |
1321 | /* BB check if reconnection needed */ | 1348 | /* BB check if reconnection needed */ |
1322 | cFYI(1, ("IP match, old UNC: %s new: %s", | 1349 | cFYI(1, |
1350 | ("IP match, old UNC: %s new: %s", | ||
1323 | tcon->treeName, uncName)); | 1351 | tcon->treeName, uncName)); |
1324 | if (strncmp | 1352 | if (strncmp |
1325 | (tcon->treeName, uncName, | 1353 | (tcon->treeName, uncName, |
@@ -1354,11 +1382,11 @@ connect_to_dfs_path(int xid, struct cifsSesInfo *pSesInfo, | |||
1354 | unsigned int num_referrals; | 1382 | unsigned int num_referrals; |
1355 | int rc = 0; | 1383 | int rc = 0; |
1356 | 1384 | ||
1357 | rc = get_dfs_path(xid, pSesInfo,old_path, nls_codepage, | 1385 | rc = get_dfs_path(xid, pSesInfo, old_path, nls_codepage, |
1358 | &num_referrals, &referrals, remap); | 1386 | &num_referrals, &referrals, remap); |
1359 | 1387 | ||
1360 | /* BB Add in code to: if valid refrl, if not ip address contact | 1388 | /* BB Add in code to: if valid refrl, if not ip address contact |
1361 | the helper that resolves tcp names, mount to it, try to | 1389 | the helper that resolves tcp names, mount to it, try to |
1362 | tcon to it unmount it if fail */ | 1390 | tcon to it unmount it if fail */ |
1363 | 1391 | ||
1364 | kfree(referrals); | 1392 | kfree(referrals); |
@@ -1367,10 +1395,9 @@ connect_to_dfs_path(int xid, struct cifsSesInfo *pSesInfo, | |||
1367 | } | 1395 | } |
1368 | 1396 | ||
1369 | int | 1397 | int |
1370 | get_dfs_path(int xid, struct cifsSesInfo *pSesInfo, | 1398 | get_dfs_path(int xid, struct cifsSesInfo *pSesInfo, const char *old_path, |
1371 | const char *old_path, const struct nls_table *nls_codepage, | 1399 | const struct nls_table *nls_codepage, unsigned int *pnum_referrals, |
1372 | unsigned int *pnum_referrals, | 1400 | unsigned char **preferrals, int remap) |
1373 | unsigned char ** preferrals, int remap) | ||
1374 | { | 1401 | { |
1375 | char *temp_unc; | 1402 | char *temp_unc; |
1376 | int rc = 0; | 1403 | int rc = 0; |
@@ -1379,7 +1406,8 @@ get_dfs_path(int xid, struct cifsSesInfo *pSesInfo, | |||
1379 | 1406 | ||
1380 | if (pSesInfo->ipc_tid == 0) { | 1407 | if (pSesInfo->ipc_tid == 0) { |
1381 | temp_unc = kmalloc(2 /* for slashes */ + | 1408 | temp_unc = kmalloc(2 /* for slashes */ + |
1382 | strnlen(pSesInfo->serverName,SERVER_NAME_LEN_WITH_NULL * 2) | 1409 | strnlen(pSesInfo->serverName, |
1410 | SERVER_NAME_LEN_WITH_NULL * 2) | ||
1383 | + 1 + 4 /* slash IPC$ */ + 2, | 1411 | + 1 + 4 /* slash IPC$ */ + 2, |
1384 | GFP_KERNEL); | 1412 | GFP_KERNEL); |
1385 | if (temp_unc == NULL) | 1413 | if (temp_unc == NULL) |
@@ -1390,7 +1418,7 @@ get_dfs_path(int xid, struct cifsSesInfo *pSesInfo, | |||
1390 | strcpy(temp_unc + 2 + strlen(pSesInfo->serverName), "\\IPC$"); | 1418 | strcpy(temp_unc + 2 + strlen(pSesInfo->serverName), "\\IPC$"); |
1391 | rc = CIFSTCon(xid, pSesInfo, temp_unc, NULL, nls_codepage); | 1419 | rc = CIFSTCon(xid, pSesInfo, temp_unc, NULL, nls_codepage); |
1392 | cFYI(1, | 1420 | cFYI(1, |
1393 | ("CIFS Tcon rc = %d ipc_tid = %d", rc,pSesInfo->ipc_tid)); | 1421 | ("CIFS Tcon rc = %d ipc_tid = %d", rc, pSesInfo->ipc_tid)); |
1394 | kfree(temp_unc); | 1422 | kfree(temp_unc); |
1395 | } | 1423 | } |
1396 | if (rc == 0) | 1424 | if (rc == 0) |
@@ -1401,38 +1429,39 @@ get_dfs_path(int xid, struct cifsSesInfo *pSesInfo, | |||
1401 | } | 1429 | } |
1402 | 1430 | ||
1403 | /* See RFC1001 section 14 on representation of Netbios names */ | 1431 | /* See RFC1001 section 14 on representation of Netbios names */ |
1404 | static void rfc1002mangle(char * target,char * source, unsigned int length) | 1432 | static void rfc1002mangle(char *target, char *source, unsigned int length) |
1405 | { | 1433 | { |
1406 | unsigned int i,j; | 1434 | unsigned int i, j; |
1407 | 1435 | ||
1408 | for(i=0,j=0;i<(length);i++) { | 1436 | for (i = 0, j = 0; i < (length); i++) { |
1409 | /* mask a nibble at a time and encode */ | 1437 | /* mask a nibble at a time and encode */ |
1410 | target[j] = 'A' + (0x0F & (source[i] >> 4)); | 1438 | target[j] = 'A' + (0x0F & (source[i] >> 4)); |
1411 | target[j+1] = 'A' + (0x0F & source[i]); | 1439 | target[j+1] = 'A' + (0x0F & source[i]); |
1412 | j+=2; | 1440 | j += 2; |
1413 | } | 1441 | } |
1414 | 1442 | ||
1415 | } | 1443 | } |
1416 | 1444 | ||
1417 | 1445 | ||
1418 | static int | 1446 | static int |
1419 | ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket, | 1447 | ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket, |
1420 | char * netbios_name, char * target_name) | 1448 | char *netbios_name, char *target_name) |
1421 | { | 1449 | { |
1422 | int rc = 0; | 1450 | int rc = 0; |
1423 | int connected = 0; | 1451 | int connected = 0; |
1424 | __be16 orig_port = 0; | 1452 | __be16 orig_port = 0; |
1425 | 1453 | ||
1426 | if (*csocket == NULL) { | 1454 | if (*csocket == NULL) { |
1427 | rc = sock_create_kern(PF_INET, SOCK_STREAM, IPPROTO_TCP, csocket); | 1455 | rc = sock_create_kern(PF_INET, SOCK_STREAM, |
1456 | IPPROTO_TCP, csocket); | ||
1428 | if (rc < 0) { | 1457 | if (rc < 0) { |
1429 | cERROR(1, ("Error %d creating socket",rc)); | 1458 | cERROR(1, ("Error %d creating socket", rc)); |
1430 | *csocket = NULL; | 1459 | *csocket = NULL; |
1431 | return rc; | 1460 | return rc; |
1432 | } else { | 1461 | } else { |
1433 | /* BB other socket options to set KEEPALIVE, NODELAY? */ | 1462 | /* BB other socket options to set KEEPALIVE, NODELAY? */ |
1434 | cFYI(1, ("Socket created")); | 1463 | cFYI(1, ("Socket created")); |
1435 | (*csocket)->sk->sk_allocation = GFP_NOFS; | 1464 | (*csocket)->sk->sk_allocation = GFP_NOFS; |
1436 | } | 1465 | } |
1437 | } | 1466 | } |
1438 | 1467 | ||
@@ -1440,13 +1469,13 @@ ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket, | |||
1440 | if (psin_server->sin_port) { /* user overrode default port */ | 1469 | if (psin_server->sin_port) { /* user overrode default port */ |
1441 | rc = (*csocket)->ops->connect(*csocket, | 1470 | rc = (*csocket)->ops->connect(*csocket, |
1442 | (struct sockaddr *) psin_server, | 1471 | (struct sockaddr *) psin_server, |
1443 | sizeof (struct sockaddr_in),0); | 1472 | sizeof (struct sockaddr_in), 0); |
1444 | if (rc >= 0) | 1473 | if (rc >= 0) |
1445 | connected = 1; | 1474 | connected = 1; |
1446 | } | 1475 | } |
1447 | 1476 | ||
1448 | if (!connected) { | 1477 | if (!connected) { |
1449 | /* save original port so we can retry user specified port | 1478 | /* save original port so we can retry user specified port |
1450 | later if fall back ports fail this time */ | 1479 | later if fall back ports fail this time */ |
1451 | orig_port = psin_server->sin_port; | 1480 | orig_port = psin_server->sin_port; |
1452 | 1481 | ||
@@ -1456,7 +1485,7 @@ ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket, | |||
1456 | 1485 | ||
1457 | rc = (*csocket)->ops->connect(*csocket, | 1486 | rc = (*csocket)->ops->connect(*csocket, |
1458 | (struct sockaddr *) psin_server, | 1487 | (struct sockaddr *) psin_server, |
1459 | sizeof (struct sockaddr_in),0); | 1488 | sizeof (struct sockaddr_in), 0); |
1460 | if (rc >= 0) | 1489 | if (rc >= 0) |
1461 | connected = 1; | 1490 | connected = 1; |
1462 | } | 1491 | } |
@@ -1464,8 +1493,9 @@ ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket, | |||
1464 | if (!connected) { | 1493 | if (!connected) { |
1465 | psin_server->sin_port = htons(RFC1001_PORT); | 1494 | psin_server->sin_port = htons(RFC1001_PORT); |
1466 | rc = (*csocket)->ops->connect(*csocket, (struct sockaddr *) | 1495 | rc = (*csocket)->ops->connect(*csocket, (struct sockaddr *) |
1467 | psin_server, sizeof (struct sockaddr_in),0); | 1496 | psin_server, |
1468 | if (rc >= 0) | 1497 | sizeof (struct sockaddr_in), 0); |
1498 | if (rc >= 0) | ||
1469 | connected = 1; | 1499 | connected = 1; |
1470 | } | 1500 | } |
1471 | 1501 | ||
@@ -1474,15 +1504,16 @@ ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket, | |||
1474 | if (!connected) { | 1504 | if (!connected) { |
1475 | if (orig_port) | 1505 | if (orig_port) |
1476 | psin_server->sin_port = orig_port; | 1506 | psin_server->sin_port = orig_port; |
1477 | cFYI(1, ("Error %d connecting to server via ipv4",rc)); | 1507 | cFYI(1, ("Error %d connecting to server via ipv4", rc)); |
1478 | sock_release(*csocket); | 1508 | sock_release(*csocket); |
1479 | *csocket = NULL; | 1509 | *csocket = NULL; |
1480 | return rc; | 1510 | return rc; |
1481 | } | 1511 | } |
1482 | /* Eventually check for other socket options to change from | 1512 | /* Eventually check for other socket options to change from |
1483 | the default. sock_setsockopt not used because it expects | 1513 | the default. sock_setsockopt not used because it expects |
1484 | user space buffer */ | 1514 | user space buffer */ |
1485 | cFYI(1, ("sndbuf %d rcvbuf %d rcvtimeo 0x%lx",(*csocket)->sk->sk_sndbuf, | 1515 | cFYI(1, ("sndbuf %d rcvbuf %d rcvtimeo 0x%lx", |
1516 | (*csocket)->sk->sk_sndbuf, | ||
1486 | (*csocket)->sk->sk_rcvbuf, (*csocket)->sk->sk_rcvtimeo)); | 1517 | (*csocket)->sk->sk_rcvbuf, (*csocket)->sk->sk_rcvtimeo)); |
1487 | (*csocket)->sk->sk_rcvtimeo = 7 * HZ; | 1518 | (*csocket)->sk->sk_rcvtimeo = 7 * HZ; |
1488 | /* make the bufsizes depend on wsize/rsize and max requests */ | 1519 | /* make the bufsizes depend on wsize/rsize and max requests */ |
@@ -1494,11 +1525,12 @@ ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket, | |||
1494 | /* send RFC1001 sessinit */ | 1525 | /* send RFC1001 sessinit */ |
1495 | if (psin_server->sin_port == htons(RFC1001_PORT)) { | 1526 | if (psin_server->sin_port == htons(RFC1001_PORT)) { |
1496 | /* some servers require RFC1001 sessinit before sending | 1527 | /* some servers require RFC1001 sessinit before sending |
1497 | negprot - BB check reconnection in case where second | 1528 | negprot - BB check reconnection in case where second |
1498 | sessinit is sent but no second negprot */ | 1529 | sessinit is sent but no second negprot */ |
1499 | struct rfc1002_session_packet * ses_init_buf; | 1530 | struct rfc1002_session_packet *ses_init_buf; |
1500 | struct smb_hdr * smb_buf; | 1531 | struct smb_hdr *smb_buf; |
1501 | ses_init_buf = kzalloc(sizeof(struct rfc1002_session_packet), GFP_KERNEL); | 1532 | ses_init_buf = kzalloc(sizeof(struct rfc1002_session_packet), |
1533 | GFP_KERNEL); | ||
1502 | if (ses_init_buf) { | 1534 | if (ses_init_buf) { |
1503 | ses_init_buf->trailer.session_req.called_len = 32; | 1535 | ses_init_buf->trailer.session_req.called_len = 32; |
1504 | if (target_name && (target_name[0] != 0)) { | 1536 | if (target_name && (target_name[0] != 0)) { |
@@ -1506,18 +1538,18 @@ ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket, | |||
1506 | target_name, 16); | 1538 | target_name, 16); |
1507 | } else { | 1539 | } else { |
1508 | rfc1002mangle(ses_init_buf->trailer.session_req.called_name, | 1540 | rfc1002mangle(ses_init_buf->trailer.session_req.called_name, |
1509 | DEFAULT_CIFS_CALLED_NAME,16); | 1541 | DEFAULT_CIFS_CALLED_NAME, 16); |
1510 | } | 1542 | } |
1511 | 1543 | ||
1512 | ses_init_buf->trailer.session_req.calling_len = 32; | 1544 | ses_init_buf->trailer.session_req.calling_len = 32; |
1513 | /* calling name ends in null (byte 16) from old smb | 1545 | /* calling name ends in null (byte 16) from old smb |
1514 | convention. */ | 1546 | convention. */ |
1515 | if (netbios_name && (netbios_name[0] !=0)) { | 1547 | if (netbios_name && (netbios_name[0] != 0)) { |
1516 | rfc1002mangle(ses_init_buf->trailer.session_req.calling_name, | 1548 | rfc1002mangle(ses_init_buf->trailer.session_req.calling_name, |
1517 | netbios_name,16); | 1549 | netbios_name, 16); |
1518 | } else { | 1550 | } else { |
1519 | rfc1002mangle(ses_init_buf->trailer.session_req.calling_name, | 1551 | rfc1002mangle(ses_init_buf->trailer.session_req.calling_name, |
1520 | "LINUX_CIFS_CLNT",16); | 1552 | "LINUX_CIFS_CLNT", 16); |
1521 | } | 1553 | } |
1522 | ses_init_buf->trailer.session_req.scope1 = 0; | 1554 | ses_init_buf->trailer.session_req.scope1 = 0; |
1523 | ses_init_buf->trailer.session_req.scope2 = 0; | 1555 | ses_init_buf->trailer.session_req.scope2 = 0; |
@@ -1527,20 +1559,20 @@ ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket, | |||
1527 | rc = smb_send(*csocket, smb_buf, 0x44, | 1559 | rc = smb_send(*csocket, smb_buf, 0x44, |
1528 | (struct sockaddr *)psin_server); | 1560 | (struct sockaddr *)psin_server); |
1529 | kfree(ses_init_buf); | 1561 | kfree(ses_init_buf); |
1530 | msleep(1); /* RFC1001 layer in at least one server | 1562 | msleep(1); /* RFC1001 layer in at least one server |
1531 | requires very short break before negprot | 1563 | requires very short break before negprot |
1532 | presumably because not expecting negprot | 1564 | presumably because not expecting negprot |
1533 | to follow so fast. This is a simple | 1565 | to follow so fast. This is a simple |
1534 | solution that works without | 1566 | solution that works without |
1535 | complicating the code and causes no | 1567 | complicating the code and causes no |
1536 | significant slowing down on mount | 1568 | significant slowing down on mount |
1537 | for everyone else */ | 1569 | for everyone else */ |
1538 | } | 1570 | } |
1539 | /* else the negprot may still work without this | 1571 | /* else the negprot may still work without this |
1540 | even though malloc failed */ | 1572 | even though malloc failed */ |
1541 | 1573 | ||
1542 | } | 1574 | } |
1543 | 1575 | ||
1544 | return rc; | 1576 | return rc; |
1545 | } | 1577 | } |
1546 | 1578 | ||
@@ -1552,9 +1584,10 @@ ipv6_connect(struct sockaddr_in6 *psin_server, struct socket **csocket) | |||
1552 | __be16 orig_port = 0; | 1584 | __be16 orig_port = 0; |
1553 | 1585 | ||
1554 | if (*csocket == NULL) { | 1586 | if (*csocket == NULL) { |
1555 | rc = sock_create_kern(PF_INET6, SOCK_STREAM, IPPROTO_TCP, csocket); | 1587 | rc = sock_create_kern(PF_INET6, SOCK_STREAM, |
1588 | IPPROTO_TCP, csocket); | ||
1556 | if (rc < 0) { | 1589 | if (rc < 0) { |
1557 | cERROR(1, ("Error %d creating ipv6 socket",rc)); | 1590 | cERROR(1, ("Error %d creating ipv6 socket", rc)); |
1558 | *csocket = NULL; | 1591 | *csocket = NULL; |
1559 | return rc; | 1592 | return rc; |
1560 | } else { | 1593 | } else { |
@@ -1569,13 +1602,13 @@ ipv6_connect(struct sockaddr_in6 *psin_server, struct socket **csocket) | |||
1569 | if (psin_server->sin6_port) { /* user overrode default port */ | 1602 | if (psin_server->sin6_port) { /* user overrode default port */ |
1570 | rc = (*csocket)->ops->connect(*csocket, | 1603 | rc = (*csocket)->ops->connect(*csocket, |
1571 | (struct sockaddr *) psin_server, | 1604 | (struct sockaddr *) psin_server, |
1572 | sizeof (struct sockaddr_in6),0); | 1605 | sizeof (struct sockaddr_in6), 0); |
1573 | if (rc >= 0) | 1606 | if (rc >= 0) |
1574 | connected = 1; | 1607 | connected = 1; |
1575 | } | 1608 | } |
1576 | 1609 | ||
1577 | if (!connected) { | 1610 | if (!connected) { |
1578 | /* save original port so we can retry user specified port | 1611 | /* save original port so we can retry user specified port |
1579 | later if fall back ports fail this time */ | 1612 | later if fall back ports fail this time */ |
1580 | 1613 | ||
1581 | orig_port = psin_server->sin6_port; | 1614 | orig_port = psin_server->sin6_port; |
@@ -1585,7 +1618,7 @@ ipv6_connect(struct sockaddr_in6 *psin_server, struct socket **csocket) | |||
1585 | 1618 | ||
1586 | rc = (*csocket)->ops->connect(*csocket, | 1619 | rc = (*csocket)->ops->connect(*csocket, |
1587 | (struct sockaddr *) psin_server, | 1620 | (struct sockaddr *) psin_server, |
1588 | sizeof (struct sockaddr_in6),0); | 1621 | sizeof (struct sockaddr_in6), 0); |
1589 | if (rc >= 0) | 1622 | if (rc >= 0) |
1590 | connected = 1; | 1623 | connected = 1; |
1591 | } | 1624 | } |
@@ -1593,8 +1626,8 @@ ipv6_connect(struct sockaddr_in6 *psin_server, struct socket **csocket) | |||
1593 | if (!connected) { | 1626 | if (!connected) { |
1594 | psin_server->sin6_port = htons(RFC1001_PORT); | 1627 | psin_server->sin6_port = htons(RFC1001_PORT); |
1595 | rc = (*csocket)->ops->connect(*csocket, (struct sockaddr *) | 1628 | rc = (*csocket)->ops->connect(*csocket, (struct sockaddr *) |
1596 | psin_server, sizeof (struct sockaddr_in6),0); | 1629 | psin_server, sizeof (struct sockaddr_in6), 0); |
1597 | if (rc >= 0) | 1630 | if (rc >= 0) |
1598 | connected = 1; | 1631 | connected = 1; |
1599 | } | 1632 | } |
1600 | 1633 | ||
@@ -1603,21 +1636,21 @@ ipv6_connect(struct sockaddr_in6 *psin_server, struct socket **csocket) | |||
1603 | if (!connected) { | 1636 | if (!connected) { |
1604 | if (orig_port) | 1637 | if (orig_port) |
1605 | psin_server->sin6_port = orig_port; | 1638 | psin_server->sin6_port = orig_port; |
1606 | cFYI(1, ("Error %d connecting to server via ipv6",rc)); | 1639 | cFYI(1, ("Error %d connecting to server via ipv6", rc)); |
1607 | sock_release(*csocket); | 1640 | sock_release(*csocket); |
1608 | *csocket = NULL; | 1641 | *csocket = NULL; |
1609 | return rc; | 1642 | return rc; |
1610 | } | 1643 | } |
1611 | /* Eventually check for other socket options to change from | 1644 | /* Eventually check for other socket options to change from |
1612 | the default. sock_setsockopt not used because it expects | 1645 | the default. sock_setsockopt not used because it expects |
1613 | user space buffer */ | 1646 | user space buffer */ |
1614 | (*csocket)->sk->sk_rcvtimeo = 7 * HZ; | 1647 | (*csocket)->sk->sk_rcvtimeo = 7 * HZ; |
1615 | 1648 | ||
1616 | return rc; | 1649 | return rc; |
1617 | } | 1650 | } |
1618 | 1651 | ||
1619 | void reset_cifs_unix_caps(int xid, struct cifsTconInfo * tcon, | 1652 | void reset_cifs_unix_caps(int xid, struct cifsTconInfo *tcon, |
1620 | struct super_block * sb, struct smb_vol * vol_info) | 1653 | struct super_block *sb, struct smb_vol *vol_info) |
1621 | { | 1654 | { |
1622 | /* if we are reconnecting then should we check to see if | 1655 | /* if we are reconnecting then should we check to see if |
1623 | * any requested capabilities changed locally e.g. via | 1656 | * any requested capabilities changed locally e.g. via |
@@ -1629,26 +1662,26 @@ void reset_cifs_unix_caps(int xid, struct cifsTconInfo * tcon, | |||
1629 | * What if we wanted to mount the server share twice once with | 1662 | * What if we wanted to mount the server share twice once with |
1630 | * and once without posixacls or posix paths? */ | 1663 | * and once without posixacls or posix paths? */ |
1631 | __u64 saved_cap = le64_to_cpu(tcon->fsUnixInfo.Capability); | 1664 | __u64 saved_cap = le64_to_cpu(tcon->fsUnixInfo.Capability); |
1632 | 1665 | ||
1633 | 1666 | ||
1634 | if (!CIFSSMBQFSUnixInfo(xid, tcon)) { | 1667 | if (!CIFSSMBQFSUnixInfo(xid, tcon)) { |
1635 | __u64 cap = le64_to_cpu(tcon->fsUnixInfo.Capability); | 1668 | __u64 cap = le64_to_cpu(tcon->fsUnixInfo.Capability); |
1636 | 1669 | ||
1637 | /* check for reconnect case in which we do not | 1670 | /* check for reconnect case in which we do not |
1638 | want to change the mount behavior if we can avoid it */ | 1671 | want to change the mount behavior if we can avoid it */ |
1639 | if (vol_info == NULL) { | 1672 | if (vol_info == NULL) { |
1640 | /* turn off POSIX ACL and PATHNAMES if not set | 1673 | /* turn off POSIX ACL and PATHNAMES if not set |
1641 | originally at mount time */ | 1674 | originally at mount time */ |
1642 | if ((saved_cap & CIFS_UNIX_POSIX_ACL_CAP) == 0) | 1675 | if ((saved_cap & CIFS_UNIX_POSIX_ACL_CAP) == 0) |
1643 | cap &= ~CIFS_UNIX_POSIX_ACL_CAP; | 1676 | cap &= ~CIFS_UNIX_POSIX_ACL_CAP; |
1644 | if ((saved_cap & CIFS_UNIX_POSIX_PATHNAMES_CAP) == 0) | 1677 | if ((saved_cap & CIFS_UNIX_POSIX_PATHNAMES_CAP) == 0) |
1645 | cap &= ~CIFS_UNIX_POSIX_PATHNAMES_CAP; | 1678 | cap &= ~CIFS_UNIX_POSIX_PATHNAMES_CAP; |
1646 | |||
1647 | 1679 | ||
1648 | 1680 | ||
1649 | 1681 | ||
1682 | |||
1650 | } | 1683 | } |
1651 | 1684 | ||
1652 | cap &= CIFS_UNIX_CAP_MASK; | 1685 | cap &= CIFS_UNIX_CAP_MASK; |
1653 | if (vol_info && vol_info->no_psx_acl) | 1686 | if (vol_info && vol_info->no_psx_acl) |
1654 | cap &= ~CIFS_UNIX_POSIX_ACL_CAP; | 1687 | cap &= ~CIFS_UNIX_POSIX_ACL_CAP; |
@@ -1663,13 +1696,13 @@ void reset_cifs_unix_caps(int xid, struct cifsTconInfo * tcon, | |||
1663 | else if (cap & CIFS_UNIX_POSIX_PATHNAMES_CAP) { | 1696 | else if (cap & CIFS_UNIX_POSIX_PATHNAMES_CAP) { |
1664 | cFYI(1, ("negotiate posix pathnames")); | 1697 | cFYI(1, ("negotiate posix pathnames")); |
1665 | if (sb) | 1698 | if (sb) |
1666 | CIFS_SB(sb)->mnt_cifs_flags |= | 1699 | CIFS_SB(sb)->mnt_cifs_flags |= |
1667 | CIFS_MOUNT_POSIX_PATHS; | 1700 | CIFS_MOUNT_POSIX_PATHS; |
1668 | } | 1701 | } |
1669 | 1702 | ||
1670 | /* We might be setting the path sep back to a different | 1703 | /* We might be setting the path sep back to a different |
1671 | form if we are reconnecting and the server switched its | 1704 | form if we are reconnecting and the server switched its |
1672 | posix path capability for this share */ | 1705 | posix path capability for this share */ |
1673 | if (sb && (CIFS_SB(sb)->prepathlen > 0)) | 1706 | if (sb && (CIFS_SB(sb)->prepathlen > 0)) |
1674 | CIFS_SB(sb)->prepath[0] = CIFS_DIR_SEP(CIFS_SB(sb)); | 1707 | CIFS_SB(sb)->prepath[0] = CIFS_DIR_SEP(CIFS_SB(sb)); |
1675 | 1708 | ||
@@ -1681,9 +1714,9 @@ void reset_cifs_unix_caps(int xid, struct cifsTconInfo * tcon, | |||
1681 | #endif | 1714 | #endif |
1682 | } | 1715 | } |
1683 | } | 1716 | } |
1684 | 1717 | ||
1685 | 1718 | ||
1686 | cFYI(1, ("Negotiate caps 0x%x",(int)cap)); | 1719 | cFYI(1, ("Negotiate caps 0x%x", (int)cap)); |
1687 | #ifdef CONFIG_CIFS_DEBUG2 | 1720 | #ifdef CONFIG_CIFS_DEBUG2 |
1688 | if (cap & CIFS_UNIX_FCNTL_CAP) | 1721 | if (cap & CIFS_UNIX_FCNTL_CAP) |
1689 | cFYI(1, ("FCNTL cap")); | 1722 | cFYI(1, ("FCNTL cap")); |
@@ -1725,8 +1758,8 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1725 | xid = GetXid(); | 1758 | xid = GetXid(); |
1726 | 1759 | ||
1727 | /* cFYI(1, ("Entering cifs_mount. Xid: %d with: %s", xid, mount_data)); */ | 1760 | /* cFYI(1, ("Entering cifs_mount. Xid: %d with: %s", xid, mount_data)); */ |
1728 | 1761 | ||
1729 | memset(&volume_info,0,sizeof(struct smb_vol)); | 1762 | memset(&volume_info, 0, sizeof(struct smb_vol)); |
1730 | if (cifs_parse_mount_options(mount_data, devname, &volume_info)) { | 1763 | if (cifs_parse_mount_options(mount_data, devname, &volume_info)) { |
1731 | kfree(volume_info.UNC); | 1764 | kfree(volume_info.UNC); |
1732 | kfree(volume_info.password); | 1765 | kfree(volume_info.password); |
@@ -1743,8 +1776,8 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1743 | cFYI(1, ("Username: %s", volume_info.username)); | 1776 | cFYI(1, ("Username: %s", volume_info.username)); |
1744 | } else { | 1777 | } else { |
1745 | cifserror("No username specified"); | 1778 | cifserror("No username specified"); |
1746 | /* In userspace mount helper we can get user name from alternate | 1779 | /* In userspace mount helper we can get user name from alternate |
1747 | locations such as env variables and files on disk */ | 1780 | locations such as env variables and files on disk */ |
1748 | kfree(volume_info.UNC); | 1781 | kfree(volume_info.UNC); |
1749 | kfree(volume_info.password); | 1782 | kfree(volume_info.password); |
1750 | kfree(volume_info.prepath); | 1783 | kfree(volume_info.prepath); |
@@ -1753,17 +1786,19 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1753 | } | 1786 | } |
1754 | 1787 | ||
1755 | if (volume_info.UNCip && volume_info.UNC) { | 1788 | if (volume_info.UNCip && volume_info.UNC) { |
1756 | rc = cifs_inet_pton(AF_INET, volume_info.UNCip,&sin_server.sin_addr.s_addr); | 1789 | rc = cifs_inet_pton(AF_INET, volume_info.UNCip, |
1790 | &sin_server.sin_addr.s_addr); | ||
1757 | 1791 | ||
1758 | if (rc <= 0) { | 1792 | if (rc <= 0) { |
1759 | /* not ipv4 address, try ipv6 */ | 1793 | /* not ipv4 address, try ipv6 */ |
1760 | rc = cifs_inet_pton(AF_INET6,volume_info.UNCip,&sin_server6.sin6_addr.in6_u); | 1794 | rc = cifs_inet_pton(AF_INET6, volume_info.UNCip, |
1795 | &sin_server6.sin6_addr.in6_u); | ||
1761 | if (rc > 0) | 1796 | if (rc > 0) |
1762 | address_type = AF_INET6; | 1797 | address_type = AF_INET6; |
1763 | } else { | 1798 | } else { |
1764 | address_type = AF_INET; | 1799 | address_type = AF_INET; |
1765 | } | 1800 | } |
1766 | 1801 | ||
1767 | if (rc <= 0) { | 1802 | if (rc <= 0) { |
1768 | /* we failed translating address */ | 1803 | /* we failed translating address */ |
1769 | kfree(volume_info.UNC); | 1804 | kfree(volume_info.UNC); |
@@ -1776,9 +1811,10 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1776 | cFYI(1, ("UNC: %s ip: %s", volume_info.UNC, volume_info.UNCip)); | 1811 | cFYI(1, ("UNC: %s ip: %s", volume_info.UNC, volume_info.UNCip)); |
1777 | /* success */ | 1812 | /* success */ |
1778 | rc = 0; | 1813 | rc = 0; |
1779 | } else if (volume_info.UNCip){ | 1814 | } else if (volume_info.UNCip) { |
1780 | /* BB using ip addr as server name connect to the DFS root below */ | 1815 | /* BB using ip addr as server name to connect to the |
1781 | cERROR(1,("Connecting to DFS root not implemented yet")); | 1816 | DFS root below */ |
1817 | cERROR(1, ("Connecting to DFS root not implemented yet")); | ||
1782 | kfree(volume_info.UNC); | 1818 | kfree(volume_info.UNC); |
1783 | kfree(volume_info.password); | 1819 | kfree(volume_info.password); |
1784 | kfree(volume_info.prepath); | 1820 | kfree(volume_info.prepath); |
@@ -1786,7 +1822,8 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1786 | return -EINVAL; | 1822 | return -EINVAL; |
1787 | } else /* which servers DFS root would we conect to */ { | 1823 | } else /* which servers DFS root would we conect to */ { |
1788 | cERROR(1, | 1824 | cERROR(1, |
1789 | ("CIFS mount error: No UNC path (e.g. -o unc=//192.168.1.100/public) specified")); | 1825 | ("CIFS mount error: No UNC path (e.g. -o " |
1826 | "unc=//192.168.1.100/public) specified")); | ||
1790 | kfree(volume_info.UNC); | 1827 | kfree(volume_info.UNC); |
1791 | kfree(volume_info.password); | 1828 | kfree(volume_info.password); |
1792 | kfree(volume_info.prepath); | 1829 | kfree(volume_info.prepath); |
@@ -1801,7 +1838,8 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1801 | } else { | 1838 | } else { |
1802 | cifs_sb->local_nls = load_nls(volume_info.iocharset); | 1839 | cifs_sb->local_nls = load_nls(volume_info.iocharset); |
1803 | if (cifs_sb->local_nls == NULL) { | 1840 | if (cifs_sb->local_nls == NULL) { |
1804 | cERROR(1,("CIFS mount error: iocharset %s not found",volume_info.iocharset)); | 1841 | cERROR(1, ("CIFS mount error: iocharset %s not found", |
1842 | volume_info.iocharset)); | ||
1805 | kfree(volume_info.UNC); | 1843 | kfree(volume_info.UNC); |
1806 | kfree(volume_info.password); | 1844 | kfree(volume_info.password); |
1807 | kfree(volume_info.prepath); | 1845 | kfree(volume_info.prepath); |
@@ -1827,9 +1865,8 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1827 | return -EINVAL; | 1865 | return -EINVAL; |
1828 | } | 1866 | } |
1829 | 1867 | ||
1830 | |||
1831 | if (srvTcp) { | 1868 | if (srvTcp) { |
1832 | cFYI(1, ("Existing tcp session with server found")); | 1869 | cFYI(1, ("Existing tcp session with server found")); |
1833 | } else { /* create socket */ | 1870 | } else { /* create socket */ |
1834 | if (volume_info.port) | 1871 | if (volume_info.port) |
1835 | sin_server.sin_port = htons(volume_info.port); | 1872 | sin_server.sin_port = htons(volume_info.port); |
@@ -1839,14 +1876,14 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1839 | cFYI(1, ("attempting ipv6 connect")); | 1876 | cFYI(1, ("attempting ipv6 connect")); |
1840 | /* BB should we allow ipv6 on port 139? */ | 1877 | /* BB should we allow ipv6 on port 139? */ |
1841 | /* other OS never observed in Wild doing 139 with v6 */ | 1878 | /* other OS never observed in Wild doing 139 with v6 */ |
1842 | rc = ipv6_connect(&sin_server6,&csocket); | 1879 | rc = ipv6_connect(&sin_server6, &csocket); |
1843 | } else | 1880 | } else |
1844 | rc = ipv4_connect(&sin_server,&csocket, | 1881 | rc = ipv4_connect(&sin_server, &csocket, |
1845 | volume_info.source_rfc1001_name, | 1882 | volume_info.source_rfc1001_name, |
1846 | volume_info.target_rfc1001_name); | 1883 | volume_info.target_rfc1001_name); |
1847 | if (rc < 0) { | 1884 | if (rc < 0) { |
1848 | cERROR(1, | 1885 | cERROR(1, ("Error connecting to IPv4 socket. " |
1849 | ("Error connecting to IPv4 socket. Aborting operation")); | 1886 | "Aborting operation")); |
1850 | if (csocket != NULL) | 1887 | if (csocket != NULL) |
1851 | sock_release(csocket); | 1888 | sock_release(csocket); |
1852 | kfree(volume_info.UNC); | 1889 | kfree(volume_info.UNC); |
@@ -1867,8 +1904,9 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1867 | return rc; | 1904 | return rc; |
1868 | } else { | 1905 | } else { |
1869 | memset(srvTcp, 0, sizeof (struct TCP_Server_Info)); | 1906 | memset(srvTcp, 0, sizeof (struct TCP_Server_Info)); |
1870 | memcpy(&srvTcp->addr.sockAddr, &sin_server, sizeof (struct sockaddr_in)); | 1907 | memcpy(&srvTcp->addr.sockAddr, &sin_server, |
1871 | atomic_set(&srvTcp->inFlight,0); | 1908 | sizeof (struct sockaddr_in)); |
1909 | atomic_set(&srvTcp->inFlight, 0); | ||
1872 | /* BB Add code for ipv6 case too */ | 1910 | /* BB Add code for ipv6 case too */ |
1873 | srvTcp->ssocket = csocket; | 1911 | srvTcp->ssocket = csocket; |
1874 | srvTcp->protocolType = IPV4; | 1912 | srvTcp->protocolType = IPV4; |
@@ -1883,7 +1921,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1883 | srvTcp->tsk = kthread_run((void *)(void *)cifs_demultiplex_thread, srvTcp, "cifsd"); | 1921 | srvTcp->tsk = kthread_run((void *)(void *)cifs_demultiplex_thread, srvTcp, "cifsd"); |
1884 | if ( IS_ERR(srvTcp->tsk) ) { | 1922 | if ( IS_ERR(srvTcp->tsk) ) { |
1885 | rc = PTR_ERR(srvTcp->tsk); | 1923 | rc = PTR_ERR(srvTcp->tsk); |
1886 | cERROR(1,("error %d create cifsd thread", rc)); | 1924 | cERROR(1, ("error %d create cifsd thread", rc)); |
1887 | srvTcp->tsk = NULL; | 1925 | srvTcp->tsk = NULL; |
1888 | sock_release(csocket); | 1926 | sock_release(csocket); |
1889 | kfree(volume_info.UNC); | 1927 | kfree(volume_info.UNC); |
@@ -1894,8 +1932,10 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1894 | } | 1932 | } |
1895 | wait_for_completion(&cifsd_complete); | 1933 | wait_for_completion(&cifsd_complete); |
1896 | rc = 0; | 1934 | rc = 0; |
1897 | memcpy(srvTcp->workstation_RFC1001_name, volume_info.source_rfc1001_name,16); | 1935 | memcpy(srvTcp->workstation_RFC1001_name, |
1898 | memcpy(srvTcp->server_RFC1001_name, volume_info.target_rfc1001_name,16); | 1936 | volume_info.source_rfc1001_name, 16); |
1937 | memcpy(srvTcp->server_RFC1001_name, | ||
1938 | volume_info.target_rfc1001_name, 16); | ||
1899 | srvTcp->sequence_number = 0; | 1939 | srvTcp->sequence_number = 0; |
1900 | } | 1940 | } |
1901 | } | 1941 | } |
@@ -1916,16 +1956,17 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1916 | NIPQUAD(sin_server.sin_addr.s_addr)); | 1956 | NIPQUAD(sin_server.sin_addr.s_addr)); |
1917 | } | 1957 | } |
1918 | 1958 | ||
1919 | if (!rc){ | 1959 | if (!rc) { |
1920 | /* volume_info.password freed at unmount */ | 1960 | /* volume_info.password freed at unmount */ |
1921 | if (volume_info.password) | 1961 | if (volume_info.password) |
1922 | pSesInfo->password = volume_info.password; | 1962 | pSesInfo->password = volume_info.password; |
1923 | if (volume_info.username) | 1963 | if (volume_info.username) |
1924 | strncpy(pSesInfo->userName, | 1964 | strncpy(pSesInfo->userName, |
1925 | volume_info.username,MAX_USERNAME_SIZE); | 1965 | volume_info.username, |
1966 | MAX_USERNAME_SIZE); | ||
1926 | if (volume_info.domainname) { | 1967 | if (volume_info.domainname) { |
1927 | int len = strlen(volume_info.domainname); | 1968 | int len = strlen(volume_info.domainname); |
1928 | pSesInfo->domainName = | 1969 | pSesInfo->domainName = |
1929 | kmalloc(len + 1, GFP_KERNEL); | 1970 | kmalloc(len + 1, GFP_KERNEL); |
1930 | if (pSesInfo->domainName) | 1971 | if (pSesInfo->domainName) |
1931 | strcpy(pSesInfo->domainName, | 1972 | strcpy(pSesInfo->domainName, |
@@ -1935,18 +1976,19 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1935 | pSesInfo->overrideSecFlg = volume_info.secFlg; | 1976 | pSesInfo->overrideSecFlg = volume_info.secFlg; |
1936 | down(&pSesInfo->sesSem); | 1977 | down(&pSesInfo->sesSem); |
1937 | /* BB FIXME need to pass vol->secFlgs BB */ | 1978 | /* BB FIXME need to pass vol->secFlgs BB */ |
1938 | rc = cifs_setup_session(xid,pSesInfo, cifs_sb->local_nls); | 1979 | rc = cifs_setup_session(xid, pSesInfo, |
1980 | cifs_sb->local_nls); | ||
1939 | up(&pSesInfo->sesSem); | 1981 | up(&pSesInfo->sesSem); |
1940 | if (!rc) | 1982 | if (!rc) |
1941 | atomic_inc(&srvTcp->socketUseCount); | 1983 | atomic_inc(&srvTcp->socketUseCount); |
1942 | } else | 1984 | } else |
1943 | kfree(volume_info.password); | 1985 | kfree(volume_info.password); |
1944 | } | 1986 | } |
1945 | 1987 | ||
1946 | /* search for existing tcon to this server share */ | 1988 | /* search for existing tcon to this server share */ |
1947 | if (!rc) { | 1989 | if (!rc) { |
1948 | if (volume_info.rsize > CIFSMaxBufSize) { | 1990 | if (volume_info.rsize > CIFSMaxBufSize) { |
1949 | cERROR(1,("rsize %d too large, using MaxBufSize", | 1991 | cERROR(1, ("rsize %d too large, using MaxBufSize", |
1950 | volume_info.rsize)); | 1992 | volume_info.rsize)); |
1951 | cifs_sb->rsize = CIFSMaxBufSize; | 1993 | cifs_sb->rsize = CIFSMaxBufSize; |
1952 | } else if ((volume_info.rsize) && | 1994 | } else if ((volume_info.rsize) && |
@@ -1956,24 +1998,24 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1956 | cifs_sb->rsize = CIFSMaxBufSize; | 1998 | cifs_sb->rsize = CIFSMaxBufSize; |
1957 | 1999 | ||
1958 | if (volume_info.wsize > PAGEVEC_SIZE * PAGE_CACHE_SIZE) { | 2000 | if (volume_info.wsize > PAGEVEC_SIZE * PAGE_CACHE_SIZE) { |
1959 | cERROR(1,("wsize %d too large, using 4096 instead", | 2001 | cERROR(1, ("wsize %d too large, using 4096 instead", |
1960 | volume_info.wsize)); | 2002 | volume_info.wsize)); |
1961 | cifs_sb->wsize = 4096; | 2003 | cifs_sb->wsize = 4096; |
1962 | } else if (volume_info.wsize) | 2004 | } else if (volume_info.wsize) |
1963 | cifs_sb->wsize = volume_info.wsize; | 2005 | cifs_sb->wsize = volume_info.wsize; |
1964 | else | 2006 | else |
1965 | cifs_sb->wsize = | 2007 | cifs_sb->wsize = |
1966 | min_t(const int, PAGEVEC_SIZE * PAGE_CACHE_SIZE, | 2008 | min_t(const int, PAGEVEC_SIZE * PAGE_CACHE_SIZE, |
1967 | 127*1024); | 2009 | 127*1024); |
1968 | /* old default of CIFSMaxBufSize was too small now | 2010 | /* old default of CIFSMaxBufSize was too small now |
1969 | that SMB Write2 can send multiple pages in kvec. | 2011 | that SMB Write2 can send multiple pages in kvec. |
1970 | RFC1001 does not describe what happens when frame | 2012 | RFC1001 does not describe what happens when frame |
1971 | bigger than 128K is sent so use that as max in | 2013 | bigger than 128K is sent so use that as max in |
1972 | conjunction with 52K kvec constraint on arch with 4K | 2014 | conjunction with 52K kvec constraint on arch with 4K |
1973 | page size */ | 2015 | page size */ |
1974 | 2016 | ||
1975 | if (cifs_sb->rsize < 2048) { | 2017 | if (cifs_sb->rsize < 2048) { |
1976 | cifs_sb->rsize = 2048; | 2018 | cifs_sb->rsize = 2048; |
1977 | /* Windows ME may prefer this */ | 2019 | /* Windows ME may prefer this */ |
1978 | cFYI(1, ("readsize set to minimum: 2048")); | 2020 | cFYI(1, ("readsize set to minimum: 2048")); |
1979 | } | 2021 | } |
@@ -1983,7 +2025,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1983 | cifs_sb->prepathlen = strlen(cifs_sb->prepath); | 2025 | cifs_sb->prepathlen = strlen(cifs_sb->prepath); |
1984 | cifs_sb->prepath[0] = CIFS_DIR_SEP(cifs_sb); | 2026 | cifs_sb->prepath[0] = CIFS_DIR_SEP(cifs_sb); |
1985 | volume_info.prepath = NULL; | 2027 | volume_info.prepath = NULL; |
1986 | } else | 2028 | } else |
1987 | cifs_sb->prepathlen = 0; | 2029 | cifs_sb->prepathlen = 0; |
1988 | cifs_sb->mnt_uid = volume_info.linux_uid; | 2030 | cifs_sb->mnt_uid = volume_info.linux_uid; |
1989 | cifs_sb->mnt_gid = volume_info.linux_gid; | 2031 | cifs_sb->mnt_gid = volume_info.linux_gid; |
@@ -2024,7 +2066,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
2024 | cFYI(1, ("Found match on UNC path")); | 2066 | cFYI(1, ("Found match on UNC path")); |
2025 | /* we can have only one retry value for a connection | 2067 | /* we can have only one retry value for a connection |
2026 | to a share so for resources mounted more than once | 2068 | to a share so for resources mounted more than once |
2027 | to the same server share the last value passed in | 2069 | to the same server share the last value passed in |
2028 | for the retry flag is used */ | 2070 | for the retry flag is used */ |
2029 | tcon->retry = volume_info.retry; | 2071 | tcon->retry = volume_info.retry; |
2030 | tcon->nocase = volume_info.nocase; | 2072 | tcon->nocase = volume_info.nocase; |
@@ -2033,17 +2075,17 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
2033 | if (tcon == NULL) | 2075 | if (tcon == NULL) |
2034 | rc = -ENOMEM; | 2076 | rc = -ENOMEM; |
2035 | else { | 2077 | else { |
2036 | /* check for null share name ie connecting to | 2078 | /* check for null share name ie connecting to |
2037 | * dfs root */ | 2079 | * dfs root */ |
2038 | 2080 | ||
2039 | /* BB check if this works for exactly length | 2081 | /* BB check if this works for exactly length |
2040 | * three strings */ | 2082 | * three strings */ |
2041 | if ((strchr(volume_info.UNC + 3, '\\') == NULL) | 2083 | if ((strchr(volume_info.UNC + 3, '\\') == NULL) |
2042 | && (strchr(volume_info.UNC + 3, '/') == | 2084 | && (strchr(volume_info.UNC + 3, '/') == |
2043 | NULL)) { | 2085 | NULL)) { |
2044 | rc = connect_to_dfs_path(xid, pSesInfo, | 2086 | rc = connect_to_dfs_path(xid, pSesInfo, |
2045 | "", cifs_sb->local_nls, | 2087 | "", cifs_sb->local_nls, |
2046 | cifs_sb->mnt_cifs_flags & | 2088 | cifs_sb->mnt_cifs_flags & |
2047 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 2089 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
2048 | kfree(volume_info.UNC); | 2090 | kfree(volume_info.UNC); |
2049 | FreeXid(xid); | 2091 | FreeXid(xid); |
@@ -2052,7 +2094,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
2052 | /* BB Do we need to wrap sesSem around | 2094 | /* BB Do we need to wrap sesSem around |
2053 | * this TCon call and Unix SetFS as | 2095 | * this TCon call and Unix SetFS as |
2054 | * we do on SessSetup and reconnect? */ | 2096 | * we do on SessSetup and reconnect? */ |
2055 | rc = CIFSTCon(xid, pSesInfo, | 2097 | rc = CIFSTCon(xid, pSesInfo, |
2056 | volume_info.UNC, | 2098 | volume_info.UNC, |
2057 | tcon, cifs_sb->local_nls); | 2099 | tcon, cifs_sb->local_nls); |
2058 | cFYI(1, ("CIFS Tcon rc = %d", rc)); | 2100 | cFYI(1, ("CIFS Tcon rc = %d", rc)); |
@@ -2089,7 +2131,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
2089 | always wake up processes blocked in | 2131 | always wake up processes blocked in |
2090 | tcp in recv_mesg then we could remove the | 2132 | tcp in recv_mesg then we could remove the |
2091 | send_sig call */ | 2133 | send_sig call */ |
2092 | force_sig(SIGKILL,srvTcp->tsk); | 2134 | force_sig(SIGKILL, srvTcp->tsk); |
2093 | tsk = srvTcp->tsk; | 2135 | tsk = srvTcp->tsk; |
2094 | if (tsk) | 2136 | if (tsk) |
2095 | kthread_stop(tsk); | 2137 | kthread_stop(tsk); |
@@ -2100,13 +2142,13 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
2100 | tconInfoFree(tcon); | 2142 | tconInfoFree(tcon); |
2101 | if (existingCifsSes == NULL) { | 2143 | if (existingCifsSes == NULL) { |
2102 | if (pSesInfo) { | 2144 | if (pSesInfo) { |
2103 | if ((pSesInfo->server) && | 2145 | if ((pSesInfo->server) && |
2104 | (pSesInfo->status == CifsGood)) { | 2146 | (pSesInfo->status == CifsGood)) { |
2105 | int temp_rc; | 2147 | int temp_rc; |
2106 | temp_rc = CIFSSMBLogoff(xid, pSesInfo); | 2148 | temp_rc = CIFSSMBLogoff(xid, pSesInfo); |
2107 | /* if the socketUseCount is now zero */ | 2149 | /* if the socketUseCount is now zero */ |
2108 | if ((temp_rc == -ESHUTDOWN) && | 2150 | if ((temp_rc == -ESHUTDOWN) && |
2109 | (pSesInfo->server) && | 2151 | (pSesInfo->server) && |
2110 | (pSesInfo->server->tsk)) { | 2152 | (pSesInfo->server->tsk)) { |
2111 | struct task_struct *tsk; | 2153 | struct task_struct *tsk; |
2112 | force_sig(SIGKILL, | 2154 | force_sig(SIGKILL, |
@@ -2129,7 +2171,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
2129 | /* do not care if following two calls succeed - informational */ | 2171 | /* do not care if following two calls succeed - informational */ |
2130 | CIFSSMBQFSDeviceInfo(xid, tcon); | 2172 | CIFSSMBQFSDeviceInfo(xid, tcon); |
2131 | CIFSSMBQFSAttributeInfo(xid, tcon); | 2173 | CIFSSMBQFSAttributeInfo(xid, tcon); |
2132 | 2174 | ||
2133 | /* tell server which Unix caps we support */ | 2175 | /* tell server which Unix caps we support */ |
2134 | if (tcon->ses->capabilities & CAP_UNIX) | 2176 | if (tcon->ses->capabilities & CAP_UNIX) |
2135 | reset_cifs_unix_caps(xid, tcon, sb, &volume_info); | 2177 | reset_cifs_unix_caps(xid, tcon, sb, &volume_info); |
@@ -2138,16 +2180,16 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
2138 | #ifdef CONFIG_CIFS_DEBUG2 | 2180 | #ifdef CONFIG_CIFS_DEBUG2 |
2139 | cFYI(1, ("no very large read support, rsize 127K")); | 2181 | cFYI(1, ("no very large read support, rsize 127K")); |
2140 | #endif | 2182 | #endif |
2141 | 2183 | ||
2142 | } | 2184 | } |
2143 | if (!(tcon->ses->capabilities & CAP_LARGE_WRITE_X)) | 2185 | if (!(tcon->ses->capabilities & CAP_LARGE_WRITE_X)) |
2144 | cifs_sb->wsize = min(cifs_sb->wsize, | 2186 | cifs_sb->wsize = min(cifs_sb->wsize, |
2145 | (tcon->ses->server->maxBuf - | 2187 | (tcon->ses->server->maxBuf - |
2146 | MAX_CIFS_HDR_SIZE)); | 2188 | MAX_CIFS_HDR_SIZE)); |
2147 | if (!(tcon->ses->capabilities & CAP_LARGE_READ_X)) | 2189 | if (!(tcon->ses->capabilities & CAP_LARGE_READ_X)) |
2148 | cifs_sb->rsize = min(cifs_sb->rsize, | 2190 | cifs_sb->rsize = min(cifs_sb->rsize, |
2149 | (tcon->ses->server->maxBuf - | 2191 | (tcon->ses->server->maxBuf - |
2150 | MAX_CIFS_HDR_SIZE)); | 2192 | MAX_CIFS_HDR_SIZE)); |
2151 | } | 2193 | } |
2152 | 2194 | ||
2153 | /* volume_info.password is freed above when existing session found | 2195 | /* volume_info.password is freed above when existing session found |
@@ -2200,7 +2242,8 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2200 | pSMB->req_no_secext.MaxBufferSize = cpu_to_le16(ses->server->maxBuf); | 2242 | pSMB->req_no_secext.MaxBufferSize = cpu_to_le16(ses->server->maxBuf); |
2201 | pSMB->req_no_secext.MaxMpxCount = cpu_to_le16(ses->server->maxReq); | 2243 | pSMB->req_no_secext.MaxMpxCount = cpu_to_le16(ses->server->maxReq); |
2202 | 2244 | ||
2203 | if (ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) | 2245 | if (ses->server->secMode & |
2246 | (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) | ||
2204 | smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; | 2247 | smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; |
2205 | 2248 | ||
2206 | capabilities = CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS | | 2249 | capabilities = CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS | |
@@ -2219,7 +2262,7 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2219 | } | 2262 | } |
2220 | pSMB->req_no_secext.Capabilities = cpu_to_le32(capabilities); | 2263 | pSMB->req_no_secext.Capabilities = cpu_to_le32(capabilities); |
2221 | 2264 | ||
2222 | pSMB->req_no_secext.CaseInsensitivePasswordLength = | 2265 | pSMB->req_no_secext.CaseInsensitivePasswordLength = |
2223 | cpu_to_le16(CIFS_SESS_KEY_SIZE); | 2266 | cpu_to_le16(CIFS_SESS_KEY_SIZE); |
2224 | 2267 | ||
2225 | pSMB->req_no_secext.CaseSensitivePasswordLength = | 2268 | pSMB->req_no_secext.CaseSensitivePasswordLength = |
@@ -2237,9 +2280,9 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2237 | } | 2280 | } |
2238 | if (user == NULL) | 2281 | if (user == NULL) |
2239 | bytes_returned = 0; /* skip null user */ | 2282 | bytes_returned = 0; /* skip null user */ |
2240 | else | 2283 | else |
2241 | bytes_returned = | 2284 | bytes_returned = |
2242 | cifs_strtoUCS((__le16 *) bcc_ptr, user, 100, | 2285 | cifs_strtoUCS((__le16 *) bcc_ptr, user, 100, |
2243 | nls_codepage); | 2286 | nls_codepage); |
2244 | /* convert number of 16 bit words to bytes */ | 2287 | /* convert number of 16 bit words to bytes */ |
2245 | bcc_ptr += 2 * bytes_returned; | 2288 | bcc_ptr += 2 * bytes_returned; |
@@ -2269,7 +2312,7 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2269 | bcc_ptr += 2 * bytes_returned; | 2312 | bcc_ptr += 2 * bytes_returned; |
2270 | bcc_ptr += 2; | 2313 | bcc_ptr += 2; |
2271 | } else { | 2314 | } else { |
2272 | if (user != NULL) { | 2315 | if (user != NULL) { |
2273 | strncpy(bcc_ptr, user, 200); | 2316 | strncpy(bcc_ptr, user, 200); |
2274 | bcc_ptr += strnlen(user, 200); | 2317 | bcc_ptr += strnlen(user, 200); |
2275 | } | 2318 | } |
@@ -2304,11 +2347,12 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2304 | __u16 action = le16_to_cpu(pSMBr->resp.Action); | 2347 | __u16 action = le16_to_cpu(pSMBr->resp.Action); |
2305 | __u16 blob_len = le16_to_cpu(pSMBr->resp.SecurityBlobLength); | 2348 | __u16 blob_len = le16_to_cpu(pSMBr->resp.SecurityBlobLength); |
2306 | if (action & GUEST_LOGIN) | 2349 | if (action & GUEST_LOGIN) |
2307 | cFYI(1, (" Guest login")); /* do we want to mark SesInfo struct ? */ | 2350 | cFYI(1, (" Guest login")); /* BB mark SesInfo struct? */ |
2308 | ses->Suid = smb_buffer_response->Uid; /* UID left in wire format (le) */ | 2351 | ses->Suid = smb_buffer_response->Uid; /* UID left in wire format |
2352 | (little endian) */ | ||
2309 | cFYI(1, ("UID = %d ", ses->Suid)); | 2353 | cFYI(1, ("UID = %d ", ses->Suid)); |
2310 | /* response can have either 3 or 4 word count - Samba sends 3 */ | 2354 | /* response can have either 3 or 4 word count - Samba sends 3 */ |
2311 | bcc_ptr = pByteArea(smb_buffer_response); | 2355 | bcc_ptr = pByteArea(smb_buffer_response); |
2312 | if ((pSMBr->resp.hdr.WordCount == 3) | 2356 | if ((pSMBr->resp.hdr.WordCount == 3) |
2313 | || ((pSMBr->resp.hdr.WordCount == 4) | 2357 | || ((pSMBr->resp.hdr.WordCount == 4) |
2314 | && (blob_len < pSMBr->resp.ByteCount))) { | 2358 | && (blob_len < pSMBr->resp.ByteCount))) { |
@@ -2318,8 +2362,10 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2318 | if (smb_buffer->Flags2 & SMBFLG2_UNICODE) { | 2362 | if (smb_buffer->Flags2 & SMBFLG2_UNICODE) { |
2319 | if ((long) (bcc_ptr) % 2) { | 2363 | if ((long) (bcc_ptr) % 2) { |
2320 | remaining_words = | 2364 | remaining_words = |
2321 | (BCC(smb_buffer_response) - 1) /2; | 2365 | (BCC(smb_buffer_response) - 1) / 2; |
2322 | bcc_ptr++; /* Unicode strings must be word aligned */ | 2366 | /* Unicode strings must be word |
2367 | aligned */ | ||
2368 | bcc_ptr++; | ||
2323 | } else { | 2369 | } else { |
2324 | remaining_words = | 2370 | remaining_words = |
2325 | BCC(smb_buffer_response) / 2; | 2371 | BCC(smb_buffer_response) / 2; |
@@ -2332,11 +2378,13 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2332 | terminating last Unicode string in response */ | 2378 | terminating last Unicode string in response */ |
2333 | if (ses->serverOS) | 2379 | if (ses->serverOS) |
2334 | kfree(ses->serverOS); | 2380 | kfree(ses->serverOS); |
2335 | ses->serverOS = kzalloc(2 * (len + 1), GFP_KERNEL); | 2381 | ses->serverOS = kzalloc(2 * (len + 1), |
2382 | GFP_KERNEL); | ||
2336 | if (ses->serverOS == NULL) | 2383 | if (ses->serverOS == NULL) |
2337 | goto sesssetup_nomem; | 2384 | goto sesssetup_nomem; |
2338 | cifs_strfromUCS_le(ses->serverOS, | 2385 | cifs_strfromUCS_le(ses->serverOS, |
2339 | (__le16 *)bcc_ptr, len,nls_codepage); | 2386 | (__le16 *)bcc_ptr, |
2387 | len, nls_codepage); | ||
2340 | bcc_ptr += 2 * (len + 1); | 2388 | bcc_ptr += 2 * (len + 1); |
2341 | remaining_words -= len + 1; | 2389 | remaining_words -= len + 1; |
2342 | ses->serverOS[2 * len] = 0; | 2390 | ses->serverOS[2 * len] = 0; |
@@ -2345,42 +2393,49 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2345 | len = UniStrnlen((wchar_t *)bcc_ptr, | 2393 | len = UniStrnlen((wchar_t *)bcc_ptr, |
2346 | remaining_words-1); | 2394 | remaining_words-1); |
2347 | kfree(ses->serverNOS); | 2395 | kfree(ses->serverNOS); |
2348 | ses->serverNOS = kzalloc(2 * (len + 1),GFP_KERNEL); | 2396 | ses->serverNOS = kzalloc(2 * (len + 1), |
2397 | GFP_KERNEL); | ||
2349 | if (ses->serverNOS == NULL) | 2398 | if (ses->serverNOS == NULL) |
2350 | goto sesssetup_nomem; | 2399 | goto sesssetup_nomem; |
2351 | cifs_strfromUCS_le(ses->serverNOS, | 2400 | cifs_strfromUCS_le(ses->serverNOS, |
2352 | (__le16 *)bcc_ptr,len,nls_codepage); | 2401 | (__le16 *)bcc_ptr, |
2402 | len, nls_codepage); | ||
2353 | bcc_ptr += 2 * (len + 1); | 2403 | bcc_ptr += 2 * (len + 1); |
2354 | ses->serverNOS[2 * len] = 0; | 2404 | ses->serverNOS[2 * len] = 0; |
2355 | ses->serverNOS[1 + (2 * len)] = 0; | 2405 | ses->serverNOS[1 + (2 * len)] = 0; |
2356 | if (strncmp(ses->serverNOS, | 2406 | if (strncmp(ses->serverNOS, |
2357 | "NT LAN Manager 4",16) == 0) { | 2407 | "NT LAN Manager 4", 16) == 0) { |
2358 | cFYI(1, ("NT4 server")); | 2408 | cFYI(1, ("NT4 server")); |
2359 | ses->flags |= CIFS_SES_NT4; | 2409 | ses->flags |= CIFS_SES_NT4; |
2360 | } | 2410 | } |
2361 | remaining_words -= len + 1; | 2411 | remaining_words -= len + 1; |
2362 | if (remaining_words > 0) { | 2412 | if (remaining_words > 0) { |
2363 | len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words); | 2413 | len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words); |
2364 | /* last string is not always null terminated (for e.g. for Windows XP & 2000) */ | 2414 | /* last string is not always null terminated |
2415 | (for e.g. for Windows XP & 2000) */ | ||
2365 | if (ses->serverDomain) | 2416 | if (ses->serverDomain) |
2366 | kfree(ses->serverDomain); | 2417 | kfree(ses->serverDomain); |
2367 | ses->serverDomain = | 2418 | ses->serverDomain = |
2368 | kzalloc(2*(len+1),GFP_KERNEL); | 2419 | kzalloc(2*(len+1), |
2420 | GFP_KERNEL); | ||
2369 | if (ses->serverDomain == NULL) | 2421 | if (ses->serverDomain == NULL) |
2370 | goto sesssetup_nomem; | 2422 | goto sesssetup_nomem; |
2371 | cifs_strfromUCS_le(ses->serverDomain, | 2423 | cifs_strfromUCS_le(ses->serverDomain, |
2372 | (__le16 *)bcc_ptr,len,nls_codepage); | 2424 | (__le16 *)bcc_ptr, |
2425 | len, nls_codepage); | ||
2373 | bcc_ptr += 2 * (len + 1); | 2426 | bcc_ptr += 2 * (len + 1); |
2374 | ses->serverDomain[2*len] = 0; | 2427 | ses->serverDomain[2*len] = 0; |
2375 | ses->serverDomain[1+(2*len)] = 0; | 2428 | ses->serverDomain[1+(2*len)] = 0; |
2376 | } /* else no more room so create dummy domain string */ | 2429 | } else { /* else no more room so create |
2377 | else { | 2430 | dummy domain string */ |
2378 | if (ses->serverDomain) | 2431 | if (ses->serverDomain) |
2379 | kfree(ses->serverDomain); | 2432 | kfree(ses->serverDomain); |
2380 | ses->serverDomain = | 2433 | ses->serverDomain = |
2381 | kzalloc(2, GFP_KERNEL); | 2434 | kzalloc(2, GFP_KERNEL); |
2382 | } | 2435 | } |
2383 | } else { /* no room so create dummy domain and NOS string */ | 2436 | } else { /* no room so create dummy domain |
2437 | and NOS string */ | ||
2438 | |||
2384 | /* if these kcallocs fail not much we | 2439 | /* if these kcallocs fail not much we |
2385 | can do, but better to not fail the | 2440 | can do, but better to not fail the |
2386 | sesssetup itself */ | 2441 | sesssetup itself */ |
@@ -2397,18 +2452,21 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2397 | pByteArea(smb_buffer_response) | 2452 | pByteArea(smb_buffer_response) |
2398 | <= BCC(smb_buffer_response)) { | 2453 | <= BCC(smb_buffer_response)) { |
2399 | kfree(ses->serverOS); | 2454 | kfree(ses->serverOS); |
2400 | ses->serverOS = kzalloc(len + 1,GFP_KERNEL); | 2455 | ses->serverOS = kzalloc(len + 1, |
2456 | GFP_KERNEL); | ||
2401 | if (ses->serverOS == NULL) | 2457 | if (ses->serverOS == NULL) |
2402 | goto sesssetup_nomem; | 2458 | goto sesssetup_nomem; |
2403 | strncpy(ses->serverOS,bcc_ptr, len); | 2459 | strncpy(ses->serverOS, bcc_ptr, len); |
2404 | 2460 | ||
2405 | bcc_ptr += len; | 2461 | bcc_ptr += len; |
2406 | bcc_ptr[0] = 0; /* null terminate the string */ | 2462 | /* null terminate the string */ |
2463 | bcc_ptr[0] = 0; | ||
2407 | bcc_ptr++; | 2464 | bcc_ptr++; |
2408 | 2465 | ||
2409 | len = strnlen(bcc_ptr, 1024); | 2466 | len = strnlen(bcc_ptr, 1024); |
2410 | kfree(ses->serverNOS); | 2467 | kfree(ses->serverNOS); |
2411 | ses->serverNOS = kzalloc(len + 1,GFP_KERNEL); | 2468 | ses->serverNOS = kzalloc(len + 1, |
2469 | GFP_KERNEL); | ||
2412 | if (ses->serverNOS == NULL) | 2470 | if (ses->serverNOS == NULL) |
2413 | goto sesssetup_nomem; | 2471 | goto sesssetup_nomem; |
2414 | strncpy(ses->serverNOS, bcc_ptr, len); | 2472 | strncpy(ses->serverNOS, bcc_ptr, len); |
@@ -2419,21 +2477,25 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2419 | len = strnlen(bcc_ptr, 1024); | 2477 | len = strnlen(bcc_ptr, 1024); |
2420 | if (ses->serverDomain) | 2478 | if (ses->serverDomain) |
2421 | kfree(ses->serverDomain); | 2479 | kfree(ses->serverDomain); |
2422 | ses->serverDomain = kzalloc(len + 1,GFP_KERNEL); | 2480 | ses->serverDomain = kzalloc(len + 1, |
2481 | GFP_KERNEL); | ||
2423 | if (ses->serverDomain == NULL) | 2482 | if (ses->serverDomain == NULL) |
2424 | goto sesssetup_nomem; | 2483 | goto sesssetup_nomem; |
2425 | strncpy(ses->serverDomain, bcc_ptr, len); | 2484 | strncpy(ses->serverDomain, bcc_ptr, |
2485 | len); | ||
2426 | bcc_ptr += len; | 2486 | bcc_ptr += len; |
2427 | bcc_ptr[0] = 0; | 2487 | bcc_ptr[0] = 0; |
2428 | bcc_ptr++; | 2488 | bcc_ptr++; |
2429 | } else | 2489 | } else |
2430 | cFYI(1, | 2490 | cFYI(1, |
2431 | ("Variable field of length %d extends beyond end of smb ", | 2491 | ("Variable field of length %d " |
2492 | "extends beyond end of smb ", | ||
2432 | len)); | 2493 | len)); |
2433 | } | 2494 | } |
2434 | } else { | 2495 | } else { |
2435 | cERROR(1, | 2496 | cERROR(1, |
2436 | (" Security Blob Length extends beyond end of SMB")); | 2497 | (" Security Blob Length extends beyond " |
2498 | "end of SMB")); | ||
2437 | } | 2499 | } |
2438 | } else { | 2500 | } else { |
2439 | cERROR(1, | 2501 | cERROR(1, |
@@ -2452,7 +2514,7 @@ sesssetup_nomem: /* do not return an error on nomem for the info strings, | |||
2452 | 2514 | ||
2453 | static int | 2515 | static int |
2454 | CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, | 2516 | CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, |
2455 | struct cifsSesInfo *ses, int * pNTLMv2_flag, | 2517 | struct cifsSesInfo *ses, int *pNTLMv2_flag, |
2456 | const struct nls_table *nls_codepage) | 2518 | const struct nls_table *nls_codepage) |
2457 | { | 2519 | { |
2458 | struct smb_hdr *smb_buffer; | 2520 | struct smb_hdr *smb_buffer; |
@@ -2596,11 +2658,11 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, | |||
2596 | __u16 blob_len = le16_to_cpu(pSMBr->resp.SecurityBlobLength); | 2658 | __u16 blob_len = le16_to_cpu(pSMBr->resp.SecurityBlobLength); |
2597 | 2659 | ||
2598 | if (action & GUEST_LOGIN) | 2660 | if (action & GUEST_LOGIN) |
2599 | cFYI(1, (" Guest login")); | 2661 | cFYI(1, (" Guest login")); |
2600 | /* Do we want to set anything in SesInfo struct when guest login? */ | 2662 | /* Do we want to set anything in SesInfo struct when guest login? */ |
2601 | 2663 | ||
2602 | bcc_ptr = pByteArea(smb_buffer_response); | 2664 | bcc_ptr = pByteArea(smb_buffer_response); |
2603 | /* response can have either 3 or 4 word count - Samba sends 3 */ | 2665 | /* response can have either 3 or 4 word count - Samba sends 3 */ |
2604 | 2666 | ||
2605 | SecurityBlob2 = (PCHALLENGE_MESSAGE) bcc_ptr; | 2667 | SecurityBlob2 = (PCHALLENGE_MESSAGE) bcc_ptr; |
2606 | if (SecurityBlob2->MessageType != NtLmChallenge) { | 2668 | if (SecurityBlob2->MessageType != NtLmChallenge) { |
@@ -2608,7 +2670,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, | |||
2608 | ("Unexpected NTLMSSP message type received %d", | 2670 | ("Unexpected NTLMSSP message type received %d", |
2609 | SecurityBlob2->MessageType)); | 2671 | SecurityBlob2->MessageType)); |
2610 | } else if (ses) { | 2672 | } else if (ses) { |
2611 | ses->Suid = smb_buffer_response->Uid; /* UID left in le format */ | 2673 | ses->Suid = smb_buffer_response->Uid; /* UID left in le format */ |
2612 | cFYI(1, ("UID = %d", ses->Suid)); | 2674 | cFYI(1, ("UID = %d", ses->Suid)); |
2613 | if ((pSMBr->resp.hdr.WordCount == 3) | 2675 | if ((pSMBr->resp.hdr.WordCount == 3) |
2614 | || ((pSMBr->resp.hdr.WordCount == 4) | 2676 | || ((pSMBr->resp.hdr.WordCount == 4) |
@@ -2626,18 +2688,18 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, | |||
2626 | memcpy(ses->server->cryptKey, | 2688 | memcpy(ses->server->cryptKey, |
2627 | SecurityBlob2->Challenge, | 2689 | SecurityBlob2->Challenge, |
2628 | CIFS_CRYPTO_KEY_SIZE); | 2690 | CIFS_CRYPTO_KEY_SIZE); |
2629 | if (SecurityBlob2->NegotiateFlags & | 2691 | if (SecurityBlob2->NegotiateFlags & |
2630 | cpu_to_le32(NTLMSSP_NEGOTIATE_NTLMV2)) | 2692 | cpu_to_le32(NTLMSSP_NEGOTIATE_NTLMV2)) |
2631 | *pNTLMv2_flag = TRUE; | 2693 | *pNTLMv2_flag = TRUE; |
2632 | 2694 | ||
2633 | if ((SecurityBlob2->NegotiateFlags & | 2695 | if ((SecurityBlob2->NegotiateFlags & |
2634 | cpu_to_le32(NTLMSSP_NEGOTIATE_ALWAYS_SIGN)) | 2696 | cpu_to_le32(NTLMSSP_NEGOTIATE_ALWAYS_SIGN)) |
2635 | || (sign_CIFS_PDUs > 1)) | 2697 | || (sign_CIFS_PDUs > 1)) |
2636 | ses->server->secMode |= | 2698 | ses->server->secMode |= |
2637 | SECMODE_SIGN_REQUIRED; | 2699 | SECMODE_SIGN_REQUIRED; |
2638 | if ((SecurityBlob2->NegotiateFlags & | 2700 | if ((SecurityBlob2->NegotiateFlags & |
2639 | cpu_to_le32(NTLMSSP_NEGOTIATE_SIGN)) && (sign_CIFS_PDUs)) | 2701 | cpu_to_le32(NTLMSSP_NEGOTIATE_SIGN)) && (sign_CIFS_PDUs)) |
2640 | ses->server->secMode |= | 2702 | ses->server->secMode |= |
2641 | SECMODE_SIGN_ENABLED; | 2703 | SECMODE_SIGN_ENABLED; |
2642 | 2704 | ||
2643 | if (smb_buffer->Flags2 & SMBFLG2_UNICODE) { | 2705 | if (smb_buffer->Flags2 & SMBFLG2_UNICODE) { |
@@ -2645,7 +2707,8 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, | |||
2645 | remaining_words = | 2707 | remaining_words = |
2646 | (BCC(smb_buffer_response) | 2708 | (BCC(smb_buffer_response) |
2647 | - 1) / 2; | 2709 | - 1) / 2; |
2648 | bcc_ptr++; /* Unicode strings must be word aligned */ | 2710 | /* Must word align unicode strings */ |
2711 | bcc_ptr++; | ||
2649 | } else { | 2712 | } else { |
2650 | remaining_words = | 2713 | remaining_words = |
2651 | BCC | 2714 | BCC |
@@ -2690,8 +2753,9 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, | |||
2690 | (2 * len)] = 0; | 2753 | (2 * len)] = 0; |
2691 | remaining_words -= len + 1; | 2754 | remaining_words -= len + 1; |
2692 | if (remaining_words > 0) { | 2755 | if (remaining_words > 0) { |
2693 | len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words); | 2756 | len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words); |
2694 | /* last string is not always null terminated (for e.g. for Windows XP & 2000) */ | 2757 | /* last string not always null terminated |
2758 | (for e.g. for Windows XP & 2000) */ | ||
2695 | kfree(ses->serverDomain); | 2759 | kfree(ses->serverDomain); |
2696 | ses->serverDomain = | 2760 | ses->serverDomain = |
2697 | kzalloc(2 * | 2761 | kzalloc(2 * |
@@ -2756,7 +2820,8 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, | |||
2756 | ses->serverDomain = | 2820 | ses->serverDomain = |
2757 | kzalloc(len + 1, | 2821 | kzalloc(len + 1, |
2758 | GFP_KERNEL); | 2822 | GFP_KERNEL); |
2759 | strncpy(ses->serverDomain, bcc_ptr, len); | 2823 | strncpy(ses->serverDomain, |
2824 | bcc_ptr, len); | ||
2760 | bcc_ptr += len; | 2825 | bcc_ptr += len; |
2761 | bcc_ptr[0] = 0; | 2826 | bcc_ptr[0] = 0; |
2762 | bcc_ptr++; | 2827 | bcc_ptr++; |
@@ -2766,8 +2831,8 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, | |||
2766 | len)); | 2831 | len)); |
2767 | } | 2832 | } |
2768 | } else { | 2833 | } else { |
2769 | cERROR(1, | 2834 | cERROR(1, ("Security Blob Length extends beyond" |
2770 | (" Security Blob Length extends beyond end of SMB")); | 2835 | " end of SMB")); |
2771 | } | 2836 | } |
2772 | } else { | 2837 | } else { |
2773 | cERROR(1, ("No session structure passed in.")); | 2838 | cERROR(1, ("No session structure passed in.")); |
@@ -2855,7 +2920,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2855 | strncpy(SecurityBlob->Signature, NTLMSSP_SIGNATURE, 8); | 2920 | strncpy(SecurityBlob->Signature, NTLMSSP_SIGNATURE, 8); |
2856 | SecurityBlob->MessageType = NtLmAuthenticate; | 2921 | SecurityBlob->MessageType = NtLmAuthenticate; |
2857 | bcc_ptr += SecurityBlobLength; | 2922 | bcc_ptr += SecurityBlobLength; |
2858 | negotiate_flags = | 2923 | negotiate_flags = |
2859 | NTLMSSP_NEGOTIATE_UNICODE | NTLMSSP_REQUEST_TARGET | | 2924 | NTLMSSP_NEGOTIATE_UNICODE | NTLMSSP_REQUEST_TARGET | |
2860 | NTLMSSP_NEGOTIATE_NTLM | NTLMSSP_NEGOTIATE_TARGET_INFO | | 2925 | NTLMSSP_NEGOTIATE_NTLM | NTLMSSP_NEGOTIATE_TARGET_INFO | |
2861 | 0x80000000 | NTLMSSP_NEGOTIATE_128; | 2926 | 0x80000000 | NTLMSSP_NEGOTIATE_128; |
@@ -3017,17 +3082,20 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
3017 | __u16 blob_len = | 3082 | __u16 blob_len = |
3018 | le16_to_cpu(pSMBr->resp.SecurityBlobLength); | 3083 | le16_to_cpu(pSMBr->resp.SecurityBlobLength); |
3019 | if (action & GUEST_LOGIN) | 3084 | if (action & GUEST_LOGIN) |
3020 | cFYI(1, (" Guest login")); /* BB do we want to set anything in SesInfo struct ? */ | 3085 | cFYI(1, (" Guest login")); /* BB Should we set anything |
3021 | /* if (SecurityBlob2->MessageType != NtLm??){ | 3086 | in SesInfo struct ? */ |
3022 | cFYI("Unexpected message type on auth response is %d ")); | 3087 | /* if (SecurityBlob2->MessageType != NtLm??) { |
3023 | } */ | 3088 | cFYI("Unexpected message type on auth response is %d")); |
3089 | } */ | ||
3090 | |||
3024 | if (ses) { | 3091 | if (ses) { |
3025 | cFYI(1, | 3092 | cFYI(1, |
3026 | ("Does UID on challenge %d match auth response UID %d ", | 3093 | ("Check challenge UID %d vs auth response UID %d", |
3027 | ses->Suid, smb_buffer_response->Uid)); | 3094 | ses->Suid, smb_buffer_response->Uid)); |
3028 | ses->Suid = smb_buffer_response->Uid; /* UID left in wire format */ | 3095 | /* UID left in wire format */ |
3029 | bcc_ptr = pByteArea(smb_buffer_response); | 3096 | ses->Suid = smb_buffer_response->Uid; |
3030 | /* response can have either 3 or 4 word count - Samba sends 3 */ | 3097 | bcc_ptr = pByteArea(smb_buffer_response); |
3098 | /* response can have either 3 or 4 word count - Samba sends 3 */ | ||
3031 | if ((pSMBr->resp.hdr.WordCount == 3) | 3099 | if ((pSMBr->resp.hdr.WordCount == 3) |
3032 | || ((pSMBr->resp.hdr.WordCount == 4) | 3100 | || ((pSMBr->resp.hdr.WordCount == 4) |
3033 | && (blob_len < | 3101 | && (blob_len < |
@@ -3089,7 +3157,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
3089 | ses->serverNOS[1+(2*len)] = 0; | 3157 | ses->serverNOS[1+(2*len)] = 0; |
3090 | remaining_words -= len + 1; | 3158 | remaining_words -= len + 1; |
3091 | if (remaining_words > 0) { | 3159 | if (remaining_words > 0) { |
3092 | len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words); | 3160 | len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words); |
3093 | /* last string not always null terminated (e.g. for Windows XP & 2000) */ | 3161 | /* last string not always null terminated (e.g. for Windows XP & 2000) */ |
3094 | if (ses->serverDomain) | 3162 | if (ses->serverDomain) |
3095 | kfree(ses->serverDomain); | 3163 | kfree(ses->serverDomain); |
@@ -3132,8 +3200,8 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
3132 | } | 3200 | } |
3133 | } else { /* ASCII */ | 3201 | } else { /* ASCII */ |
3134 | len = strnlen(bcc_ptr, 1024); | 3202 | len = strnlen(bcc_ptr, 1024); |
3135 | if (((long) bcc_ptr + len) - | 3203 | if (((long) bcc_ptr + len) - |
3136 | (long) pByteArea(smb_buffer_response) | 3204 | (long) pByteArea(smb_buffer_response) |
3137 | <= BCC(smb_buffer_response)) { | 3205 | <= BCC(smb_buffer_response)) { |
3138 | if (ses->serverOS) | 3206 | if (ses->serverOS) |
3139 | kfree(ses->serverOS); | 3207 | kfree(ses->serverOS); |
@@ -3146,8 +3214,9 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
3146 | 3214 | ||
3147 | len = strnlen(bcc_ptr, 1024); | 3215 | len = strnlen(bcc_ptr, 1024); |
3148 | kfree(ses->serverNOS); | 3216 | kfree(ses->serverNOS); |
3149 | ses->serverNOS = kzalloc(len+1,GFP_KERNEL); | 3217 | ses->serverNOS = kzalloc(len+1, |
3150 | strncpy(ses->serverNOS, bcc_ptr, len); | 3218 | GFP_KERNEL); |
3219 | strncpy(ses->serverNOS, bcc_ptr, len); | ||
3151 | bcc_ptr += len; | 3220 | bcc_ptr += len; |
3152 | bcc_ptr[0] = 0; | 3221 | bcc_ptr[0] = 0; |
3153 | bcc_ptr++; | 3222 | bcc_ptr++; |
@@ -3233,7 +3302,7 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, | |||
3233 | by Samba (not sure whether other servers allow | 3302 | by Samba (not sure whether other servers allow |
3234 | NTLMv2 password here) */ | 3303 | NTLMv2 password here) */ |
3235 | #ifdef CONFIG_CIFS_WEAK_PW_HASH | 3304 | #ifdef CONFIG_CIFS_WEAK_PW_HASH |
3236 | if ((extended_security & CIFSSEC_MAY_LANMAN) && | 3305 | if ((extended_security & CIFSSEC_MAY_LANMAN) && |
3237 | (ses->server->secType == LANMAN)) | 3306 | (ses->server->secType == LANMAN)) |
3238 | calc_lanman_hash(ses, bcc_ptr); | 3307 | calc_lanman_hash(ses, bcc_ptr); |
3239 | else | 3308 | else |
@@ -3250,7 +3319,7 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, | |||
3250 | } | 3319 | } |
3251 | } | 3320 | } |
3252 | 3321 | ||
3253 | if (ses->server->secMode & | 3322 | if (ses->server->secMode & |
3254 | (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) | 3323 | (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) |
3255 | smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; | 3324 | smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; |
3256 | 3325 | ||
@@ -3263,8 +3332,8 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, | |||
3263 | if (ses->capabilities & CAP_UNICODE) { | 3332 | if (ses->capabilities & CAP_UNICODE) { |
3264 | smb_buffer->Flags2 |= SMBFLG2_UNICODE; | 3333 | smb_buffer->Flags2 |= SMBFLG2_UNICODE; |
3265 | length = | 3334 | length = |
3266 | cifs_strtoUCS((__le16 *) bcc_ptr, tree, | 3335 | cifs_strtoUCS((__le16 *) bcc_ptr, tree, |
3267 | 6 /* max utf8 char length in bytes */ * | 3336 | 6 /* max utf8 char length in bytes */ * |
3268 | (/* server len*/ + 256 /* share len */), nls_codepage); | 3337 | (/* server len*/ + 256 /* share len */), nls_codepage); |
3269 | bcc_ptr += 2 * length; /* convert num 16 bit words to bytes */ | 3338 | bcc_ptr += 2 * length; /* convert num 16 bit words to bytes */ |
3270 | bcc_ptr += 2; /* skip trailing null */ | 3339 | bcc_ptr += 2; /* skip trailing null */ |
@@ -3288,8 +3357,8 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, | |||
3288 | tcon->tid = smb_buffer_response->Tid; | 3357 | tcon->tid = smb_buffer_response->Tid; |
3289 | bcc_ptr = pByteArea(smb_buffer_response); | 3358 | bcc_ptr = pByteArea(smb_buffer_response); |
3290 | length = strnlen(bcc_ptr, BCC(smb_buffer_response) - 2); | 3359 | length = strnlen(bcc_ptr, BCC(smb_buffer_response) - 2); |
3291 | /* skip service field (NB: this field is always ASCII) */ | 3360 | /* skip service field (NB: this field is always ASCII) */ |
3292 | bcc_ptr += length + 1; | 3361 | bcc_ptr += length + 1; |
3293 | strncpy(tcon->treeName, tree, MAX_TREE_SIZE); | 3362 | strncpy(tcon->treeName, tree, MAX_TREE_SIZE); |
3294 | if (smb_buffer->Flags2 & SMBFLG2_UNICODE) { | 3363 | if (smb_buffer->Flags2 & SMBFLG2_UNICODE) { |
3295 | length = UniStrnlen((wchar_t *) bcc_ptr, 512); | 3364 | length = UniStrnlen((wchar_t *) bcc_ptr, 512); |
@@ -3307,7 +3376,7 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, | |||
3307 | bcc_ptr[1] = 0; | 3376 | bcc_ptr[1] = 0; |
3308 | bcc_ptr += 2; | 3377 | bcc_ptr += 2; |
3309 | } | 3378 | } |
3310 | /* else do not bother copying these informational fields */ | 3379 | /* else do not bother copying these information fields*/ |
3311 | } else { | 3380 | } else { |
3312 | length = strnlen(bcc_ptr, 1024); | 3381 | length = strnlen(bcc_ptr, 1024); |
3313 | if ((bcc_ptr + length) - | 3382 | if ((bcc_ptr + length) - |
@@ -3319,7 +3388,7 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, | |||
3319 | strncpy(tcon->nativeFileSystem, bcc_ptr, | 3388 | strncpy(tcon->nativeFileSystem, bcc_ptr, |
3320 | length); | 3389 | length); |
3321 | } | 3390 | } |
3322 | /* else do not bother copying these informational fields */ | 3391 | /* else do not bother copying these information fields*/ |
3323 | } | 3392 | } |
3324 | if ((smb_buffer_response->WordCount == 3) || | 3393 | if ((smb_buffer_response->WordCount == 3) || |
3325 | (smb_buffer_response->WordCount == 7)) | 3394 | (smb_buffer_response->WordCount == 7)) |
@@ -3329,7 +3398,7 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, | |||
3329 | tcon->Flags = 0; | 3398 | tcon->Flags = 0; |
3330 | cFYI(1, ("Tcon flags: 0x%x ", tcon->Flags)); | 3399 | cFYI(1, ("Tcon flags: 0x%x ", tcon->Flags)); |
3331 | } else if ((rc == 0) && tcon == NULL) { | 3400 | } else if ((rc == 0) && tcon == NULL) { |
3332 | /* all we need to save for IPC$ connection */ | 3401 | /* all we need to save for IPC$ connection */ |
3333 | ses->ipc_tid = smb_buffer_response->Tid; | 3402 | ses->ipc_tid = smb_buffer_response->Tid; |
3334 | } | 3403 | } |
3335 | 3404 | ||
@@ -3345,7 +3414,7 @@ cifs_umount(struct super_block *sb, struct cifs_sb_info *cifs_sb) | |||
3345 | int xid; | 3414 | int xid; |
3346 | struct cifsSesInfo *ses = NULL; | 3415 | struct cifsSesInfo *ses = NULL; |
3347 | struct task_struct *cifsd_task; | 3416 | struct task_struct *cifsd_task; |
3348 | char * tmp; | 3417 | char *tmp; |
3349 | 3418 | ||
3350 | xid = GetXid(); | 3419 | xid = GetXid(); |
3351 | 3420 | ||
@@ -3368,7 +3437,7 @@ cifs_umount(struct super_block *sb, struct cifs_sb_info *cifs_sb) | |||
3368 | } else if (rc == -ESHUTDOWN) { | 3437 | } else if (rc == -ESHUTDOWN) { |
3369 | cFYI(1, ("Waking up socket by sending signal")); | 3438 | cFYI(1, ("Waking up socket by sending signal")); |
3370 | if (cifsd_task) { | 3439 | if (cifsd_task) { |
3371 | force_sig(SIGKILL,cifsd_task); | 3440 | force_sig(SIGKILL, cifsd_task); |
3372 | kthread_stop(cifsd_task); | 3441 | kthread_stop(cifsd_task); |
3373 | } | 3442 | } |
3374 | rc = 0; | 3443 | rc = 0; |
@@ -3377,7 +3446,7 @@ cifs_umount(struct super_block *sb, struct cifs_sb_info *cifs_sb) | |||
3377 | } else | 3446 | } else |
3378 | cFYI(1, ("No session or bad tcon")); | 3447 | cFYI(1, ("No session or bad tcon")); |
3379 | } | 3448 | } |
3380 | 3449 | ||
3381 | cifs_sb->tcon = NULL; | 3450 | cifs_sb->tcon = NULL; |
3382 | tmp = cifs_sb->prepath; | 3451 | tmp = cifs_sb->prepath; |
3383 | cifs_sb->prepathlen = 0; | 3452 | cifs_sb->prepathlen = 0; |
@@ -3389,11 +3458,11 @@ cifs_umount(struct super_block *sb, struct cifs_sb_info *cifs_sb) | |||
3389 | sesInfoFree(ses); | 3458 | sesInfoFree(ses); |
3390 | 3459 | ||
3391 | FreeXid(xid); | 3460 | FreeXid(xid); |
3392 | return rc; /* BB check if we should always return zero here */ | 3461 | return rc; /* BB check if we should always return zero here */ |
3393 | } | 3462 | } |
3394 | 3463 | ||
3395 | int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo, | 3464 | int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo, |
3396 | struct nls_table * nls_info) | 3465 | struct nls_table *nls_info) |
3397 | { | 3466 | { |
3398 | int rc = 0; | 3467 | int rc = 0; |
3399 | char ntlm_session_key[CIFS_SESS_KEY_SIZE]; | 3468 | char ntlm_session_key[CIFS_SESS_KEY_SIZE]; |
@@ -3405,7 +3474,7 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo, | |||
3405 | rc = CIFSSMBNegotiate(xid, pSesInfo); | 3474 | rc = CIFSSMBNegotiate(xid, pSesInfo); |
3406 | if (rc == -EAGAIN) /* retry only once on 1st time connection */ { | 3475 | if (rc == -EAGAIN) /* retry only once on 1st time connection */ { |
3407 | rc = CIFSSMBNegotiate(xid, pSesInfo); | 3476 | rc = CIFSSMBNegotiate(xid, pSesInfo); |
3408 | if (rc == -EAGAIN) | 3477 | if (rc == -EAGAIN) |
3409 | rc = -EHOSTDOWN; | 3478 | rc = -EHOSTDOWN; |
3410 | } | 3479 | } |
3411 | if (rc == 0) { | 3480 | if (rc == 0) { |
@@ -3425,7 +3494,8 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo, | |||
3425 | if (linuxExtEnabled == 0) | 3494 | if (linuxExtEnabled == 0) |
3426 | pSesInfo->capabilities &= (~CAP_UNIX); | 3495 | pSesInfo->capabilities &= (~CAP_UNIX); |
3427 | /* pSesInfo->sequence_number = 0;*/ | 3496 | /* pSesInfo->sequence_number = 0;*/ |
3428 | cFYI(1, ("Security Mode: 0x%x Capabilities: 0x%x TimeAdjust: %d", | 3497 | cFYI(1, |
3498 | ("Security Mode: 0x%x Capabilities: 0x%x TimeAdjust: %d", | ||
3429 | pSesInfo->server->secMode, | 3499 | pSesInfo->server->secMode, |
3430 | pSesInfo->server->capabilities, | 3500 | pSesInfo->server->capabilities, |
3431 | pSesInfo->server->timeAdj)); | 3501 | pSesInfo->server->timeAdj)); |
@@ -3433,7 +3503,7 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo, | |||
3433 | rc = CIFS_SessSetup(xid, pSesInfo, | 3503 | rc = CIFS_SessSetup(xid, pSesInfo, |
3434 | first_time, nls_info); | 3504 | first_time, nls_info); |
3435 | else if (extended_security | 3505 | else if (extended_security |
3436 | && (pSesInfo->capabilities | 3506 | && (pSesInfo->capabilities |
3437 | & CAP_EXTENDED_SECURITY) | 3507 | & CAP_EXTENDED_SECURITY) |
3438 | && (pSesInfo->server->secType == NTLMSSP)) { | 3508 | && (pSesInfo->server->secType == NTLMSSP)) { |
3439 | rc = -EOPNOTSUPP; | 3509 | rc = -EOPNOTSUPP; |
@@ -3447,20 +3517,21 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo, | |||
3447 | nls_info); | 3517 | nls_info); |
3448 | if (!rc) { | 3518 | if (!rc) { |
3449 | if (ntlmv2_flag) { | 3519 | if (ntlmv2_flag) { |
3450 | char * v2_response; | 3520 | char *v2_response; |
3451 | cFYI(1, ("more secure NTLM ver2 hash")); | 3521 | cFYI(1, ("more secure NTLM ver2 hash")); |
3452 | if (CalcNTLMv2_partial_mac_key(pSesInfo, | 3522 | if (CalcNTLMv2_partial_mac_key(pSesInfo, |
3453 | nls_info)) { | 3523 | nls_info)) { |
3454 | rc = -ENOMEM; | 3524 | rc = -ENOMEM; |
3455 | goto ss_err_exit; | 3525 | goto ss_err_exit; |
3456 | } else | 3526 | } else |
3457 | v2_response = kmalloc(16 + 64 /* blob */, GFP_KERNEL); | 3527 | v2_response = kmalloc(16 + 64 /* blob */, GFP_KERNEL); |
3458 | if (v2_response) { | 3528 | if (v2_response) { |
3459 | CalcNTLMv2_response(pSesInfo,v2_response); | 3529 | CalcNTLMv2_response(pSesInfo, |
3530 | v2_response); | ||
3460 | /* if (first_time) | 3531 | /* if (first_time) |
3461 | cifs_calculate_ntlmv2_mac_key( | 3532 | cifs_calculate_ntlmv2_mac_key( |
3462 | pSesInfo->server->mac_signing_key, | 3533 | pSesInfo->server->mac_signing_key, |
3463 | response, ntlm_session_key, */ | 3534 | response, ntlm_session_key,*/ |
3464 | kfree(v2_response); | 3535 | kfree(v2_response); |
3465 | /* BB Put dummy sig in SessSetup PDU? */ | 3536 | /* BB Put dummy sig in SessSetup PDU? */ |
3466 | } else { | 3537 | } else { |