diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-01-23 11:59:49 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-01-23 11:59:49 -0500 |
commit | 7908b3ef6809e49c77d914342dfaa4b946476d7a (patch) | |
tree | 44af103c5457b4c2286400158dcfc18846a7c4f0 /fs | |
parent | dcd6c92267155e70a94b3927bce681ce74b80d1f (diff) | |
parent | acbbb76a26648dfae6fed0989879e40d75692bfc (diff) |
Merge git://git.samba.org/sfrench/cifs-2.6
* git://git.samba.org/sfrench/cifs-2.6:
CIFS: Rename *UCS* functions to *UTF16*
[CIFS] ACL and FSCACHE support no longer EXPERIMENTAL
[CIFS] Fix build break with multiuser patch when LANMAN disabled
cifs: warn about impending deprecation of legacy MultiuserMount code
cifs: fetch credentials out of keyring for non-krb5 auth multiuser mounts
cifs: sanitize username handling
keys: add a "logon" key type
cifs: lower default wsize when unix extensions are not used
cifs: better instrumentation for coalesce_t2
cifs: integer overflow in parse_dacl()
cifs: Fix sparse warning when calling cifs_strtoUCS
CIFS: Add descriptions to the brlock cache functions
Diffstat (limited to 'fs')
-rw-r--r-- | fs/cifs/Kconfig | 3 | ||||
-rw-r--r-- | fs/cifs/cifs_debug.c | 11 | ||||
-rw-r--r-- | fs/cifs/cifs_spnego.c | 10 | ||||
-rw-r--r-- | fs/cifs/cifs_unicode.c | 41 | ||||
-rw-r--r-- | fs/cifs/cifs_unicode.h | 20 | ||||
-rw-r--r-- | fs/cifs/cifsacl.c | 2 | ||||
-rw-r--r-- | fs/cifs/cifsencrypt.c | 21 | ||||
-rw-r--r-- | fs/cifs/cifsglob.h | 2 | ||||
-rw-r--r-- | fs/cifs/cifssmb.c | 162 | ||||
-rw-r--r-- | fs/cifs/connect.c | 305 | ||||
-rw-r--r-- | fs/cifs/readdir.c | 9 | ||||
-rw-r--r-- | fs/cifs/sess.c | 34 | ||||
-rw-r--r-- | fs/cifs/smbencrypt.c | 2 |
13 files changed, 421 insertions, 201 deletions
diff --git a/fs/cifs/Kconfig b/fs/cifs/Kconfig index f66cc1625150..0554b00a7b33 100644 --- a/fs/cifs/Kconfig +++ b/fs/cifs/Kconfig | |||
@@ -140,7 +140,6 @@ config CIFS_DFS_UPCALL | |||
140 | 140 | ||
141 | config CIFS_FSCACHE | 141 | config CIFS_FSCACHE |
142 | bool "Provide CIFS client caching support (EXPERIMENTAL)" | 142 | bool "Provide CIFS client caching support (EXPERIMENTAL)" |
143 | depends on EXPERIMENTAL | ||
144 | depends on CIFS=m && FSCACHE || CIFS=y && FSCACHE=y | 143 | depends on CIFS=m && FSCACHE || CIFS=y && FSCACHE=y |
145 | help | 144 | help |
146 | Makes CIFS FS-Cache capable. Say Y here if you want your CIFS data | 145 | Makes CIFS FS-Cache capable. Say Y here if you want your CIFS data |
@@ -149,7 +148,7 @@ config CIFS_FSCACHE | |||
149 | 148 | ||
150 | config CIFS_ACL | 149 | config CIFS_ACL |
151 | bool "Provide CIFS ACL support (EXPERIMENTAL)" | 150 | bool "Provide CIFS ACL support (EXPERIMENTAL)" |
152 | depends on EXPERIMENTAL && CIFS_XATTR && KEYS | 151 | depends on CIFS_XATTR && KEYS |
153 | help | 152 | help |
154 | Allows to fetch CIFS/NTFS ACL from the server. The DACL blob | 153 | Allows to fetch CIFS/NTFS ACL from the server. The DACL blob |
155 | is handed over to the application/caller. | 154 | is handed over to the application/caller. |
diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c index 84e8c0724704..24b3dfc05282 100644 --- a/fs/cifs/cifs_debug.c +++ b/fs/cifs/cifs_debug.c | |||
@@ -676,14 +676,23 @@ static ssize_t cifs_multiuser_mount_proc_write(struct file *file, | |||
676 | { | 676 | { |
677 | char c; | 677 | char c; |
678 | int rc; | 678 | int rc; |
679 | static bool warned; | ||
679 | 680 | ||
680 | rc = get_user(c, buffer); | 681 | rc = get_user(c, buffer); |
681 | if (rc) | 682 | if (rc) |
682 | return rc; | 683 | return rc; |
683 | if (c == '0' || c == 'n' || c == 'N') | 684 | if (c == '0' || c == 'n' || c == 'N') |
684 | multiuser_mount = 0; | 685 | multiuser_mount = 0; |
685 | else if (c == '1' || c == 'y' || c == 'Y') | 686 | else if (c == '1' || c == 'y' || c == 'Y') { |
686 | multiuser_mount = 1; | 687 | multiuser_mount = 1; |
688 | if (!warned) { | ||
689 | warned = true; | ||
690 | printk(KERN_WARNING "CIFS VFS: The legacy multiuser " | ||
691 | "mount code is scheduled to be deprecated in " | ||
692 | "3.5. Please switch to using the multiuser " | ||
693 | "mount option."); | ||
694 | } | ||
695 | } | ||
687 | 696 | ||
688 | return count; | 697 | return count; |
689 | } | 698 | } |
diff --git a/fs/cifs/cifs_spnego.c b/fs/cifs/cifs_spnego.c index 2272fd5fe5b7..e622863b292f 100644 --- a/fs/cifs/cifs_spnego.c +++ b/fs/cifs/cifs_spnego.c | |||
@@ -113,9 +113,11 @@ cifs_get_spnego_key(struct cifs_ses *sesInfo) | |||
113 | MAX_MECH_STR_LEN + | 113 | MAX_MECH_STR_LEN + |
114 | UID_KEY_LEN + (sizeof(uid_t) * 2) + | 114 | UID_KEY_LEN + (sizeof(uid_t) * 2) + |
115 | CREDUID_KEY_LEN + (sizeof(uid_t) * 2) + | 115 | CREDUID_KEY_LEN + (sizeof(uid_t) * 2) + |
116 | USER_KEY_LEN + strlen(sesInfo->user_name) + | ||
117 | PID_KEY_LEN + (sizeof(pid_t) * 2) + 1; | 116 | PID_KEY_LEN + (sizeof(pid_t) * 2) + 1; |
118 | 117 | ||
118 | if (sesInfo->user_name) | ||
119 | desc_len += USER_KEY_LEN + strlen(sesInfo->user_name); | ||
120 | |||
119 | spnego_key = ERR_PTR(-ENOMEM); | 121 | spnego_key = ERR_PTR(-ENOMEM); |
120 | description = kzalloc(desc_len, GFP_KERNEL); | 122 | description = kzalloc(desc_len, GFP_KERNEL); |
121 | if (description == NULL) | 123 | if (description == NULL) |
@@ -152,8 +154,10 @@ cifs_get_spnego_key(struct cifs_ses *sesInfo) | |||
152 | dp = description + strlen(description); | 154 | dp = description + strlen(description); |
153 | sprintf(dp, ";creduid=0x%x", sesInfo->cred_uid); | 155 | sprintf(dp, ";creduid=0x%x", sesInfo->cred_uid); |
154 | 156 | ||
155 | dp = description + strlen(description); | 157 | if (sesInfo->user_name) { |
156 | sprintf(dp, ";user=%s", sesInfo->user_name); | 158 | dp = description + strlen(description); |
159 | sprintf(dp, ";user=%s", sesInfo->user_name); | ||
160 | } | ||
157 | 161 | ||
158 | dp = description + strlen(description); | 162 | dp = description + strlen(description); |
159 | sprintf(dp, ";pid=0x%x", current->pid); | 163 | sprintf(dp, ";pid=0x%x", current->pid); |
diff --git a/fs/cifs/cifs_unicode.c b/fs/cifs/cifs_unicode.c index 1b2e180b018d..fbb9da951843 100644 --- a/fs/cifs/cifs_unicode.c +++ b/fs/cifs/cifs_unicode.c | |||
@@ -27,17 +27,17 @@ | |||
27 | #include "cifs_debug.h" | 27 | #include "cifs_debug.h" |
28 | 28 | ||
29 | /* | 29 | /* |
30 | * cifs_ucs2_bytes - how long will a string be after conversion? | 30 | * cifs_utf16_bytes - how long will a string be after conversion? |
31 | * @ucs - pointer to input string | 31 | * @utf16 - pointer to input string |
32 | * @maxbytes - don't go past this many bytes of input string | 32 | * @maxbytes - don't go past this many bytes of input string |
33 | * @codepage - destination codepage | 33 | * @codepage - destination codepage |
34 | * | 34 | * |
35 | * Walk a ucs2le string and return the number of bytes that the string will | 35 | * Walk a utf16le string and return the number of bytes that the string will |
36 | * be after being converted to the given charset, not including any null | 36 | * be after being converted to the given charset, not including any null |
37 | * termination required. Don't walk past maxbytes in the source buffer. | 37 | * termination required. Don't walk past maxbytes in the source buffer. |
38 | */ | 38 | */ |
39 | int | 39 | int |
40 | cifs_ucs2_bytes(const __le16 *from, int maxbytes, | 40 | cifs_utf16_bytes(const __le16 *from, int maxbytes, |
41 | const struct nls_table *codepage) | 41 | const struct nls_table *codepage) |
42 | { | 42 | { |
43 | int i; | 43 | int i; |
@@ -122,7 +122,7 @@ cp_convert: | |||
122 | } | 122 | } |
123 | 123 | ||
124 | /* | 124 | /* |
125 | * cifs_from_ucs2 - convert utf16le string to local charset | 125 | * cifs_from_utf16 - convert utf16le string to local charset |
126 | * @to - destination buffer | 126 | * @to - destination buffer |
127 | * @from - source buffer | 127 | * @from - source buffer |
128 | * @tolen - destination buffer size (in bytes) | 128 | * @tolen - destination buffer size (in bytes) |
@@ -130,7 +130,7 @@ cp_convert: | |||
130 | * @codepage - codepage to which characters should be converted | 130 | * @codepage - codepage to which characters should be converted |
131 | * @mapchar - should characters be remapped according to the mapchars option? | 131 | * @mapchar - should characters be remapped according to the mapchars option? |
132 | * | 132 | * |
133 | * Convert a little-endian ucs2le string (as sent by the server) to a string | 133 | * Convert a little-endian utf16le string (as sent by the server) to a string |
134 | * in the provided codepage. The tolen and fromlen parameters are to ensure | 134 | * in the provided codepage. The tolen and fromlen parameters are to ensure |
135 | * that the code doesn't walk off of the end of the buffer (which is always | 135 | * that the code doesn't walk off of the end of the buffer (which is always |
136 | * a danger if the alignment of the source buffer is off). The destination | 136 | * a danger if the alignment of the source buffer is off). The destination |
@@ -139,12 +139,12 @@ cp_convert: | |||
139 | * null terminator). | 139 | * null terminator). |
140 | * | 140 | * |
141 | * Note that some windows versions actually send multiword UTF-16 characters | 141 | * Note that some windows versions actually send multiword UTF-16 characters |
142 | * instead of straight UCS-2. The linux nls routines however aren't able to | 142 | * instead of straight UTF16-2. The linux nls routines however aren't able to |
143 | * deal with those characters properly. In the event that we get some of | 143 | * deal with those characters properly. In the event that we get some of |
144 | * those characters, they won't be translated properly. | 144 | * those characters, they won't be translated properly. |
145 | */ | 145 | */ |
146 | int | 146 | int |
147 | cifs_from_ucs2(char *to, const __le16 *from, int tolen, int fromlen, | 147 | cifs_from_utf16(char *to, const __le16 *from, int tolen, int fromlen, |
148 | const struct nls_table *codepage, bool mapchar) | 148 | const struct nls_table *codepage, bool mapchar) |
149 | { | 149 | { |
150 | int i, charlen, safelen; | 150 | int i, charlen, safelen; |
@@ -190,13 +190,13 @@ cifs_from_ucs2(char *to, const __le16 *from, int tolen, int fromlen, | |||
190 | } | 190 | } |
191 | 191 | ||
192 | /* | 192 | /* |
193 | * NAME: cifs_strtoUCS() | 193 | * NAME: cifs_strtoUTF16() |
194 | * | 194 | * |
195 | * FUNCTION: Convert character string to unicode string | 195 | * FUNCTION: Convert character string to unicode string |
196 | * | 196 | * |
197 | */ | 197 | */ |
198 | int | 198 | int |
199 | cifs_strtoUCS(__le16 *to, const char *from, int len, | 199 | cifs_strtoUTF16(__le16 *to, const char *from, int len, |
200 | const struct nls_table *codepage) | 200 | const struct nls_table *codepage) |
201 | { | 201 | { |
202 | int charlen; | 202 | int charlen; |
@@ -206,7 +206,7 @@ cifs_strtoUCS(__le16 *to, const char *from, int len, | |||
206 | for (i = 0; len && *from; i++, from += charlen, len -= charlen) { | 206 | for (i = 0; len && *from; i++, from += charlen, len -= charlen) { |
207 | charlen = codepage->char2uni(from, len, &wchar_to); | 207 | charlen = codepage->char2uni(from, len, &wchar_to); |
208 | if (charlen < 1) { | 208 | if (charlen < 1) { |
209 | cERROR(1, "strtoUCS: char2uni of 0x%x returned %d", | 209 | cERROR(1, "strtoUTF16: char2uni of 0x%x returned %d", |
210 | *from, charlen); | 210 | *from, charlen); |
211 | /* A question mark */ | 211 | /* A question mark */ |
212 | wchar_to = 0x003f; | 212 | wchar_to = 0x003f; |
@@ -220,7 +220,8 @@ cifs_strtoUCS(__le16 *to, const char *from, int len, | |||
220 | } | 220 | } |
221 | 221 | ||
222 | /* | 222 | /* |
223 | * cifs_strndup_from_ucs - copy a string from wire format to the local codepage | 223 | * cifs_strndup_from_utf16 - copy a string from wire format to the local |
224 | * codepage | ||
224 | * @src - source string | 225 | * @src - source string |
225 | * @maxlen - don't walk past this many bytes in the source string | 226 | * @maxlen - don't walk past this many bytes in the source string |
226 | * @is_unicode - is this a unicode string? | 227 | * @is_unicode - is this a unicode string? |
@@ -231,19 +232,19 @@ cifs_strtoUCS(__le16 *to, const char *from, int len, | |||
231 | * error. | 232 | * error. |
232 | */ | 233 | */ |
233 | char * | 234 | char * |
234 | cifs_strndup_from_ucs(const char *src, const int maxlen, const bool is_unicode, | 235 | cifs_strndup_from_utf16(const char *src, const int maxlen, |
235 | const struct nls_table *codepage) | 236 | const bool is_unicode, const struct nls_table *codepage) |
236 | { | 237 | { |
237 | int len; | 238 | int len; |
238 | char *dst; | 239 | char *dst; |
239 | 240 | ||
240 | if (is_unicode) { | 241 | if (is_unicode) { |
241 | len = cifs_ucs2_bytes((__le16 *) src, maxlen, codepage); | 242 | len = cifs_utf16_bytes((__le16 *) src, maxlen, codepage); |
242 | len += nls_nullsize(codepage); | 243 | len += nls_nullsize(codepage); |
243 | dst = kmalloc(len, GFP_KERNEL); | 244 | dst = kmalloc(len, GFP_KERNEL); |
244 | if (!dst) | 245 | if (!dst) |
245 | return NULL; | 246 | return NULL; |
246 | cifs_from_ucs2(dst, (__le16 *) src, len, maxlen, codepage, | 247 | cifs_from_utf16(dst, (__le16 *) src, len, maxlen, codepage, |
247 | false); | 248 | false); |
248 | } else { | 249 | } else { |
249 | len = strnlen(src, maxlen); | 250 | len = strnlen(src, maxlen); |
@@ -264,7 +265,7 @@ cifs_strndup_from_ucs(const char *src, const int maxlen, const bool is_unicode, | |||
264 | * names are little endian 16 bit Unicode on the wire | 265 | * names are little endian 16 bit Unicode on the wire |
265 | */ | 266 | */ |
266 | int | 267 | int |
267 | cifsConvertToUCS(__le16 *target, const char *source, int srclen, | 268 | cifsConvertToUTF16(__le16 *target, const char *source, int srclen, |
268 | const struct nls_table *cp, int mapChars) | 269 | const struct nls_table *cp, int mapChars) |
269 | { | 270 | { |
270 | int i, j, charlen; | 271 | int i, j, charlen; |
@@ -273,7 +274,7 @@ cifsConvertToUCS(__le16 *target, const char *source, int srclen, | |||
273 | wchar_t tmp; | 274 | wchar_t tmp; |
274 | 275 | ||
275 | if (!mapChars) | 276 | if (!mapChars) |
276 | return cifs_strtoUCS(target, source, PATH_MAX, cp); | 277 | return cifs_strtoUTF16(target, source, PATH_MAX, cp); |
277 | 278 | ||
278 | for (i = 0, j = 0; i < srclen; j++) { | 279 | for (i = 0, j = 0; i < srclen; j++) { |
279 | src_char = source[i]; | 280 | src_char = source[i]; |
@@ -281,7 +282,7 @@ cifsConvertToUCS(__le16 *target, const char *source, int srclen, | |||
281 | switch (src_char) { | 282 | switch (src_char) { |
282 | case 0: | 283 | case 0: |
283 | put_unaligned(0, &target[j]); | 284 | put_unaligned(0, &target[j]); |
284 | goto ctoUCS_out; | 285 | goto ctoUTF16_out; |
285 | case ':': | 286 | case ':': |
286 | dst_char = cpu_to_le16(UNI_COLON); | 287 | dst_char = cpu_to_le16(UNI_COLON); |
287 | break; | 288 | break; |
@@ -326,7 +327,7 @@ cifsConvertToUCS(__le16 *target, const char *source, int srclen, | |||
326 | put_unaligned(dst_char, &target[j]); | 327 | put_unaligned(dst_char, &target[j]); |
327 | } | 328 | } |
328 | 329 | ||
329 | ctoUCS_out: | 330 | ctoUTF16_out: |
330 | return i; | 331 | return i; |
331 | } | 332 | } |
332 | 333 | ||
diff --git a/fs/cifs/cifs_unicode.h b/fs/cifs/cifs_unicode.h index 6d02fd560566..a513a546700b 100644 --- a/fs/cifs/cifs_unicode.h +++ b/fs/cifs/cifs_unicode.h | |||
@@ -74,16 +74,16 @@ extern const struct UniCaseRange CifsUniLowerRange[]; | |||
74 | #endif /* UNIUPR_NOLOWER */ | 74 | #endif /* UNIUPR_NOLOWER */ |
75 | 75 | ||
76 | #ifdef __KERNEL__ | 76 | #ifdef __KERNEL__ |
77 | int cifs_from_ucs2(char *to, const __le16 *from, int tolen, int fromlen, | 77 | int cifs_from_utf16(char *to, const __le16 *from, int tolen, int fromlen, |
78 | const struct nls_table *codepage, bool mapchar); | 78 | const struct nls_table *codepage, bool mapchar); |
79 | int cifs_ucs2_bytes(const __le16 *from, int maxbytes, | 79 | int cifs_utf16_bytes(const __le16 *from, int maxbytes, |
80 | const struct nls_table *codepage); | 80 | const struct nls_table *codepage); |
81 | int cifs_strtoUCS(__le16 *, const char *, int, const struct nls_table *); | 81 | int cifs_strtoUTF16(__le16 *, const char *, int, const struct nls_table *); |
82 | char *cifs_strndup_from_ucs(const char *src, const int maxlen, | 82 | char *cifs_strndup_from_utf16(const char *src, const int maxlen, |
83 | const bool is_unicode, | 83 | const bool is_unicode, |
84 | const struct nls_table *codepage); | 84 | const struct nls_table *codepage); |
85 | extern int cifsConvertToUCS(__le16 *target, const char *source, int maxlen, | 85 | extern int cifsConvertToUTF16(__le16 *target, const char *source, int maxlen, |
86 | const struct nls_table *cp, int mapChars); | 86 | const struct nls_table *cp, int mapChars); |
87 | 87 | ||
88 | #endif | 88 | #endif |
89 | 89 | ||
diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c index 72ddf23ef6f7..c1b254487388 100644 --- a/fs/cifs/cifsacl.c +++ b/fs/cifs/cifsacl.c | |||
@@ -909,6 +909,8 @@ static void parse_dacl(struct cifs_acl *pdacl, char *end_of_acl, | |||
909 | umode_t group_mask = S_IRWXG; | 909 | umode_t group_mask = S_IRWXG; |
910 | umode_t other_mask = S_IRWXU | S_IRWXG | S_IRWXO; | 910 | umode_t other_mask = S_IRWXU | S_IRWXG | S_IRWXO; |
911 | 911 | ||
912 | if (num_aces > ULONG_MAX / sizeof(struct cifs_ace *)) | ||
913 | return; | ||
912 | ppace = kmalloc(num_aces * sizeof(struct cifs_ace *), | 914 | ppace = kmalloc(num_aces * sizeof(struct cifs_ace *), |
913 | GFP_KERNEL); | 915 | GFP_KERNEL); |
914 | if (!ppace) { | 916 | if (!ppace) { |
diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c index 5d9b9acc5fce..63c460e503b6 100644 --- a/fs/cifs/cifsencrypt.c +++ b/fs/cifs/cifsencrypt.c | |||
@@ -327,7 +327,7 @@ build_avpair_blob(struct cifs_ses *ses, const struct nls_table *nls_cp) | |||
327 | attrptr->type = cpu_to_le16(NTLMSSP_AV_NB_DOMAIN_NAME); | 327 | attrptr->type = cpu_to_le16(NTLMSSP_AV_NB_DOMAIN_NAME); |
328 | attrptr->length = cpu_to_le16(2 * dlen); | 328 | attrptr->length = cpu_to_le16(2 * dlen); |
329 | blobptr = (unsigned char *)attrptr + sizeof(struct ntlmssp2_name); | 329 | blobptr = (unsigned char *)attrptr + sizeof(struct ntlmssp2_name); |
330 | cifs_strtoUCS((__le16 *)blobptr, ses->domainName, dlen, nls_cp); | 330 | cifs_strtoUTF16((__le16 *)blobptr, ses->domainName, dlen, nls_cp); |
331 | 331 | ||
332 | return 0; | 332 | return 0; |
333 | } | 333 | } |
@@ -376,7 +376,7 @@ find_domain_name(struct cifs_ses *ses, const struct nls_table *nls_cp) | |||
376 | kmalloc(attrsize + 1, GFP_KERNEL); | 376 | kmalloc(attrsize + 1, GFP_KERNEL); |
377 | if (!ses->domainName) | 377 | if (!ses->domainName) |
378 | return -ENOMEM; | 378 | return -ENOMEM; |
379 | cifs_from_ucs2(ses->domainName, | 379 | cifs_from_utf16(ses->domainName, |
380 | (__le16 *)blobptr, attrsize, attrsize, | 380 | (__le16 *)blobptr, attrsize, attrsize, |
381 | nls_cp, false); | 381 | nls_cp, false); |
382 | break; | 382 | break; |
@@ -420,15 +420,20 @@ static int calc_ntlmv2_hash(struct cifs_ses *ses, char *ntlmv2_hash, | |||
420 | } | 420 | } |
421 | 421 | ||
422 | /* convert ses->user_name to unicode and uppercase */ | 422 | /* convert ses->user_name to unicode and uppercase */ |
423 | len = strlen(ses->user_name); | 423 | len = ses->user_name ? strlen(ses->user_name) : 0; |
424 | user = kmalloc(2 + (len * 2), GFP_KERNEL); | 424 | user = kmalloc(2 + (len * 2), GFP_KERNEL); |
425 | if (user == NULL) { | 425 | if (user == NULL) { |
426 | cERROR(1, "calc_ntlmv2_hash: user mem alloc failure\n"); | 426 | cERROR(1, "calc_ntlmv2_hash: user mem alloc failure\n"); |
427 | rc = -ENOMEM; | 427 | rc = -ENOMEM; |
428 | return rc; | 428 | return rc; |
429 | } | 429 | } |
430 | len = cifs_strtoUCS((__le16 *)user, ses->user_name, len, nls_cp); | 430 | |
431 | UniStrupr(user); | 431 | if (len) { |
432 | len = cifs_strtoUTF16((__le16 *)user, ses->user_name, len, nls_cp); | ||
433 | UniStrupr(user); | ||
434 | } else { | ||
435 | memset(user, '\0', 2); | ||
436 | } | ||
432 | 437 | ||
433 | rc = crypto_shash_update(&ses->server->secmech.sdeschmacmd5->shash, | 438 | rc = crypto_shash_update(&ses->server->secmech.sdeschmacmd5->shash, |
434 | (char *)user, 2 * len); | 439 | (char *)user, 2 * len); |
@@ -448,8 +453,8 @@ static int calc_ntlmv2_hash(struct cifs_ses *ses, char *ntlmv2_hash, | |||
448 | rc = -ENOMEM; | 453 | rc = -ENOMEM; |
449 | return rc; | 454 | return rc; |
450 | } | 455 | } |
451 | len = cifs_strtoUCS((__le16 *)domain, ses->domainName, len, | 456 | len = cifs_strtoUTF16((__le16 *)domain, ses->domainName, len, |
452 | nls_cp); | 457 | nls_cp); |
453 | rc = | 458 | rc = |
454 | crypto_shash_update(&ses->server->secmech.sdeschmacmd5->shash, | 459 | crypto_shash_update(&ses->server->secmech.sdeschmacmd5->shash, |
455 | (char *)domain, 2 * len); | 460 | (char *)domain, 2 * len); |
@@ -468,7 +473,7 @@ static int calc_ntlmv2_hash(struct cifs_ses *ses, char *ntlmv2_hash, | |||
468 | rc = -ENOMEM; | 473 | rc = -ENOMEM; |
469 | return rc; | 474 | return rc; |
470 | } | 475 | } |
471 | len = cifs_strtoUCS((__le16 *)server, ses->serverName, len, | 476 | len = cifs_strtoUTF16((__le16 *)server, ses->serverName, len, |
472 | nls_cp); | 477 | nls_cp); |
473 | rc = | 478 | rc = |
474 | crypto_shash_update(&ses->server->secmech.sdeschmacmd5->shash, | 479 | crypto_shash_update(&ses->server->secmech.sdeschmacmd5->shash, |
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index ba53c1c6c6cc..76e7d8b6da17 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h | |||
@@ -879,6 +879,8 @@ require use of the stronger protocol */ | |||
879 | #define CIFSSEC_MASK 0xB70B7 /* current flags supported if weak */ | 879 | #define CIFSSEC_MASK 0xB70B7 /* current flags supported if weak */ |
880 | #endif /* UPCALL */ | 880 | #endif /* UPCALL */ |
881 | #else /* do not allow weak pw hash */ | 881 | #else /* do not allow weak pw hash */ |
882 | #define CIFSSEC_MUST_LANMAN 0 | ||
883 | #define CIFSSEC_MUST_PLNTXT 0 | ||
882 | #ifdef CONFIG_CIFS_UPCALL | 884 | #ifdef CONFIG_CIFS_UPCALL |
883 | #define CIFSSEC_MASK 0x8F08F /* flags supported if no weak allowed */ | 885 | #define CIFSSEC_MASK 0x8F08F /* flags supported if no weak allowed */ |
884 | #else | 886 | #else |
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index 6600aa2d2ef3..8b7794c31591 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c | |||
@@ -821,8 +821,8 @@ PsxDelete: | |||
821 | 821 | ||
822 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 822 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
823 | name_len = | 823 | name_len = |
824 | cifsConvertToUCS((__le16 *) pSMB->FileName, fileName, | 824 | cifsConvertToUTF16((__le16 *) pSMB->FileName, fileName, |
825 | PATH_MAX, nls_codepage, remap); | 825 | PATH_MAX, nls_codepage, remap); |
826 | name_len++; /* trailing null */ | 826 | name_len++; /* trailing null */ |
827 | name_len *= 2; | 827 | name_len *= 2; |
828 | } else { /* BB add path length overrun check */ | 828 | } else { /* BB add path length overrun check */ |
@@ -893,8 +893,8 @@ DelFileRetry: | |||
893 | 893 | ||
894 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 894 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
895 | name_len = | 895 | name_len = |
896 | cifsConvertToUCS((__le16 *) pSMB->fileName, fileName, | 896 | cifsConvertToUTF16((__le16 *) pSMB->fileName, fileName, |
897 | PATH_MAX, nls_codepage, remap); | 897 | PATH_MAX, nls_codepage, remap); |
898 | name_len++; /* trailing null */ | 898 | name_len++; /* trailing null */ |
899 | name_len *= 2; | 899 | name_len *= 2; |
900 | } else { /* BB improve check for buffer overruns BB */ | 900 | } else { /* BB improve check for buffer overruns BB */ |
@@ -938,8 +938,8 @@ RmDirRetry: | |||
938 | return rc; | 938 | return rc; |
939 | 939 | ||
940 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 940 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
941 | name_len = cifsConvertToUCS((__le16 *) pSMB->DirName, dirName, | 941 | name_len = cifsConvertToUTF16((__le16 *) pSMB->DirName, dirName, |
942 | PATH_MAX, nls_codepage, remap); | 942 | PATH_MAX, nls_codepage, remap); |
943 | name_len++; /* trailing null */ | 943 | name_len++; /* trailing null */ |
944 | name_len *= 2; | 944 | name_len *= 2; |
945 | } else { /* BB improve check for buffer overruns BB */ | 945 | } else { /* BB improve check for buffer overruns BB */ |
@@ -981,8 +981,8 @@ MkDirRetry: | |||
981 | return rc; | 981 | return rc; |
982 | 982 | ||
983 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 983 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
984 | name_len = cifsConvertToUCS((__le16 *) pSMB->DirName, name, | 984 | name_len = cifsConvertToUTF16((__le16 *) pSMB->DirName, name, |
985 | PATH_MAX, nls_codepage, remap); | 985 | PATH_MAX, nls_codepage, remap); |
986 | name_len++; /* trailing null */ | 986 | name_len++; /* trailing null */ |
987 | name_len *= 2; | 987 | name_len *= 2; |
988 | } else { /* BB improve check for buffer overruns BB */ | 988 | } else { /* BB improve check for buffer overruns BB */ |
@@ -1030,8 +1030,8 @@ PsxCreat: | |||
1030 | 1030 | ||
1031 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 1031 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
1032 | name_len = | 1032 | name_len = |
1033 | cifsConvertToUCS((__le16 *) pSMB->FileName, name, | 1033 | cifsConvertToUTF16((__le16 *) pSMB->FileName, name, |
1034 | PATH_MAX, nls_codepage, remap); | 1034 | PATH_MAX, nls_codepage, remap); |
1035 | name_len++; /* trailing null */ | 1035 | name_len++; /* trailing null */ |
1036 | name_len *= 2; | 1036 | name_len *= 2; |
1037 | } else { /* BB improve the check for buffer overruns BB */ | 1037 | } else { /* BB improve the check for buffer overruns BB */ |
@@ -1197,8 +1197,8 @@ OldOpenRetry: | |||
1197 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 1197 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
1198 | count = 1; /* account for one byte pad to word boundary */ | 1198 | count = 1; /* account for one byte pad to word boundary */ |
1199 | name_len = | 1199 | name_len = |
1200 | cifsConvertToUCS((__le16 *) (pSMB->fileName + 1), | 1200 | cifsConvertToUTF16((__le16 *) (pSMB->fileName + 1), |
1201 | fileName, PATH_MAX, nls_codepage, remap); | 1201 | fileName, PATH_MAX, nls_codepage, remap); |
1202 | name_len++; /* trailing null */ | 1202 | name_len++; /* trailing null */ |
1203 | name_len *= 2; | 1203 | name_len *= 2; |
1204 | } else { /* BB improve check for buffer overruns BB */ | 1204 | } else { /* BB improve check for buffer overruns BB */ |
@@ -1304,8 +1304,8 @@ openRetry: | |||
1304 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 1304 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
1305 | count = 1; /* account for one byte pad to word boundary */ | 1305 | count = 1; /* account for one byte pad to word boundary */ |
1306 | name_len = | 1306 | name_len = |
1307 | cifsConvertToUCS((__le16 *) (pSMB->fileName + 1), | 1307 | cifsConvertToUTF16((__le16 *) (pSMB->fileName + 1), |
1308 | fileName, PATH_MAX, nls_codepage, remap); | 1308 | fileName, PATH_MAX, nls_codepage, remap); |
1309 | name_len++; /* trailing null */ | 1309 | name_len++; /* trailing null */ |
1310 | name_len *= 2; | 1310 | name_len *= 2; |
1311 | pSMB->NameLength = cpu_to_le16(name_len); | 1311 | pSMB->NameLength = cpu_to_le16(name_len); |
@@ -2649,16 +2649,16 @@ renameRetry: | |||
2649 | 2649 | ||
2650 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 2650 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
2651 | name_len = | 2651 | name_len = |
2652 | cifsConvertToUCS((__le16 *) pSMB->OldFileName, fromName, | 2652 | cifsConvertToUTF16((__le16 *) pSMB->OldFileName, fromName, |
2653 | PATH_MAX, nls_codepage, remap); | 2653 | PATH_MAX, nls_codepage, remap); |
2654 | name_len++; /* trailing null */ | 2654 | name_len++; /* trailing null */ |
2655 | name_len *= 2; | 2655 | name_len *= 2; |
2656 | pSMB->OldFileName[name_len] = 0x04; /* pad */ | 2656 | pSMB->OldFileName[name_len] = 0x04; /* pad */ |
2657 | /* protocol requires ASCII signature byte on Unicode string */ | 2657 | /* protocol requires ASCII signature byte on Unicode string */ |
2658 | pSMB->OldFileName[name_len + 1] = 0x00; | 2658 | pSMB->OldFileName[name_len + 1] = 0x00; |
2659 | name_len2 = | 2659 | name_len2 = |
2660 | cifsConvertToUCS((__le16 *)&pSMB->OldFileName[name_len + 2], | 2660 | cifsConvertToUTF16((__le16 *)&pSMB->OldFileName[name_len+2], |
2661 | toName, PATH_MAX, nls_codepage, remap); | 2661 | toName, PATH_MAX, nls_codepage, remap); |
2662 | name_len2 += 1 /* trailing null */ + 1 /* Signature word */ ; | 2662 | name_len2 += 1 /* trailing null */ + 1 /* Signature word */ ; |
2663 | name_len2 *= 2; /* convert to bytes */ | 2663 | name_len2 *= 2; /* convert to bytes */ |
2664 | } else { /* BB improve the check for buffer overruns BB */ | 2664 | } else { /* BB improve the check for buffer overruns BB */ |
@@ -2738,10 +2738,12 @@ int CIFSSMBRenameOpenFile(const int xid, struct cifs_tcon *pTcon, | |||
2738 | /* unicode only call */ | 2738 | /* unicode only call */ |
2739 | if (target_name == NULL) { | 2739 | if (target_name == NULL) { |
2740 | sprintf(dummy_string, "cifs%x", pSMB->hdr.Mid); | 2740 | sprintf(dummy_string, "cifs%x", pSMB->hdr.Mid); |
2741 | len_of_str = cifsConvertToUCS((__le16 *)rename_info->target_name, | 2741 | len_of_str = |
2742 | cifsConvertToUTF16((__le16 *)rename_info->target_name, | ||
2742 | dummy_string, 24, nls_codepage, remap); | 2743 | dummy_string, 24, nls_codepage, remap); |
2743 | } else { | 2744 | } else { |
2744 | len_of_str = cifsConvertToUCS((__le16 *)rename_info->target_name, | 2745 | len_of_str = |
2746 | cifsConvertToUTF16((__le16 *)rename_info->target_name, | ||
2745 | target_name, PATH_MAX, nls_codepage, | 2747 | target_name, PATH_MAX, nls_codepage, |
2746 | remap); | 2748 | remap); |
2747 | } | 2749 | } |
@@ -2795,17 +2797,17 @@ copyRetry: | |||
2795 | pSMB->Flags = cpu_to_le16(flags & COPY_TREE); | 2797 | pSMB->Flags = cpu_to_le16(flags & COPY_TREE); |
2796 | 2798 | ||
2797 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 2799 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
2798 | name_len = cifsConvertToUCS((__le16 *) pSMB->OldFileName, | 2800 | name_len = cifsConvertToUTF16((__le16 *) pSMB->OldFileName, |
2799 | fromName, PATH_MAX, nls_codepage, | 2801 | fromName, PATH_MAX, nls_codepage, |
2800 | remap); | 2802 | remap); |
2801 | name_len++; /* trailing null */ | 2803 | name_len++; /* trailing null */ |
2802 | name_len *= 2; | 2804 | name_len *= 2; |
2803 | pSMB->OldFileName[name_len] = 0x04; /* pad */ | 2805 | pSMB->OldFileName[name_len] = 0x04; /* pad */ |
2804 | /* protocol requires ASCII signature byte on Unicode string */ | 2806 | /* protocol requires ASCII signature byte on Unicode string */ |
2805 | pSMB->OldFileName[name_len + 1] = 0x00; | 2807 | pSMB->OldFileName[name_len + 1] = 0x00; |
2806 | name_len2 = | 2808 | name_len2 = |
2807 | cifsConvertToUCS((__le16 *)&pSMB->OldFileName[name_len + 2], | 2809 | cifsConvertToUTF16((__le16 *)&pSMB->OldFileName[name_len+2], |
2808 | toName, PATH_MAX, nls_codepage, remap); | 2810 | toName, PATH_MAX, nls_codepage, remap); |
2809 | name_len2 += 1 /* trailing null */ + 1 /* Signature word */ ; | 2811 | name_len2 += 1 /* trailing null */ + 1 /* Signature word */ ; |
2810 | name_len2 *= 2; /* convert to bytes */ | 2812 | name_len2 *= 2; /* convert to bytes */ |
2811 | } else { /* BB improve the check for buffer overruns BB */ | 2813 | } else { /* BB improve the check for buffer overruns BB */ |
@@ -2861,9 +2863,9 @@ createSymLinkRetry: | |||
2861 | 2863 | ||
2862 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 2864 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
2863 | name_len = | 2865 | name_len = |
2864 | cifs_strtoUCS((__le16 *) pSMB->FileName, fromName, PATH_MAX | 2866 | cifs_strtoUTF16((__le16 *) pSMB->FileName, fromName, |
2865 | /* find define for this maxpathcomponent */ | 2867 | /* find define for this maxpathcomponent */ |
2866 | , nls_codepage); | 2868 | PATH_MAX, nls_codepage); |
2867 | name_len++; /* trailing null */ | 2869 | name_len++; /* trailing null */ |
2868 | name_len *= 2; | 2870 | name_len *= 2; |
2869 | 2871 | ||
@@ -2885,9 +2887,9 @@ createSymLinkRetry: | |||
2885 | data_offset = (char *) (&pSMB->hdr.Protocol) + offset; | 2887 | data_offset = (char *) (&pSMB->hdr.Protocol) + offset; |
2886 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 2888 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
2887 | name_len_target = | 2889 | name_len_target = |
2888 | cifs_strtoUCS((__le16 *) data_offset, toName, PATH_MAX | 2890 | cifs_strtoUTF16((__le16 *) data_offset, toName, PATH_MAX |
2889 | /* find define for this maxpathcomponent */ | 2891 | /* find define for this maxpathcomponent */ |
2890 | , nls_codepage); | 2892 | , nls_codepage); |
2891 | name_len_target++; /* trailing null */ | 2893 | name_len_target++; /* trailing null */ |
2892 | name_len_target *= 2; | 2894 | name_len_target *= 2; |
2893 | } else { /* BB improve the check for buffer overruns BB */ | 2895 | } else { /* BB improve the check for buffer overruns BB */ |
@@ -2949,8 +2951,8 @@ createHardLinkRetry: | |||
2949 | return rc; | 2951 | return rc; |
2950 | 2952 | ||
2951 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 2953 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
2952 | name_len = cifsConvertToUCS((__le16 *) pSMB->FileName, toName, | 2954 | name_len = cifsConvertToUTF16((__le16 *) pSMB->FileName, toName, |
2953 | PATH_MAX, nls_codepage, remap); | 2955 | PATH_MAX, nls_codepage, remap); |
2954 | name_len++; /* trailing null */ | 2956 | name_len++; /* trailing null */ |
2955 | name_len *= 2; | 2957 | name_len *= 2; |
2956 | 2958 | ||
@@ -2972,8 +2974,8 @@ createHardLinkRetry: | |||
2972 | data_offset = (char *) (&pSMB->hdr.Protocol) + offset; | 2974 | data_offset = (char *) (&pSMB->hdr.Protocol) + offset; |
2973 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 2975 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
2974 | name_len_target = | 2976 | name_len_target = |
2975 | cifsConvertToUCS((__le16 *) data_offset, fromName, PATH_MAX, | 2977 | cifsConvertToUTF16((__le16 *) data_offset, fromName, |
2976 | nls_codepage, remap); | 2978 | PATH_MAX, nls_codepage, remap); |
2977 | name_len_target++; /* trailing null */ | 2979 | name_len_target++; /* trailing null */ |
2978 | name_len_target *= 2; | 2980 | name_len_target *= 2; |
2979 | } else { /* BB improve the check for buffer overruns BB */ | 2981 | } else { /* BB improve the check for buffer overruns BB */ |
@@ -3042,8 +3044,8 @@ winCreateHardLinkRetry: | |||
3042 | 3044 | ||
3043 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 3045 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
3044 | name_len = | 3046 | name_len = |
3045 | cifsConvertToUCS((__le16 *) pSMB->OldFileName, fromName, | 3047 | cifsConvertToUTF16((__le16 *) pSMB->OldFileName, fromName, |
3046 | PATH_MAX, nls_codepage, remap); | 3048 | PATH_MAX, nls_codepage, remap); |
3047 | name_len++; /* trailing null */ | 3049 | name_len++; /* trailing null */ |
3048 | name_len *= 2; | 3050 | name_len *= 2; |
3049 | 3051 | ||
@@ -3051,8 +3053,8 @@ winCreateHardLinkRetry: | |||
3051 | pSMB->OldFileName[name_len] = 0x04; | 3053 | pSMB->OldFileName[name_len] = 0x04; |
3052 | pSMB->OldFileName[name_len + 1] = 0x00; /* pad */ | 3054 | pSMB->OldFileName[name_len + 1] = 0x00; /* pad */ |
3053 | name_len2 = | 3055 | name_len2 = |
3054 | cifsConvertToUCS((__le16 *)&pSMB->OldFileName[name_len + 2], | 3056 | cifsConvertToUTF16((__le16 *)&pSMB->OldFileName[name_len+2], |
3055 | toName, PATH_MAX, nls_codepage, remap); | 3057 | toName, PATH_MAX, nls_codepage, remap); |
3056 | name_len2 += 1 /* trailing null */ + 1 /* Signature word */ ; | 3058 | name_len2 += 1 /* trailing null */ + 1 /* Signature word */ ; |
3057 | name_len2 *= 2; /* convert to bytes */ | 3059 | name_len2 *= 2; /* convert to bytes */ |
3058 | } else { /* BB improve the check for buffer overruns BB */ | 3060 | } else { /* BB improve the check for buffer overruns BB */ |
@@ -3108,8 +3110,8 @@ querySymLinkRetry: | |||
3108 | 3110 | ||
3109 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 3111 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
3110 | name_len = | 3112 | name_len = |
3111 | cifs_strtoUCS((__le16 *) pSMB->FileName, searchName, | 3113 | cifs_strtoUTF16((__le16 *) pSMB->FileName, searchName, |
3112 | PATH_MAX, nls_codepage); | 3114 | PATH_MAX, nls_codepage); |
3113 | name_len++; /* trailing null */ | 3115 | name_len++; /* trailing null */ |
3114 | name_len *= 2; | 3116 | name_len *= 2; |
3115 | } else { /* BB improve the check for buffer overruns BB */ | 3117 | } else { /* BB improve the check for buffer overruns BB */ |
@@ -3166,8 +3168,8 @@ querySymLinkRetry: | |||
3166 | is_unicode = false; | 3168 | is_unicode = false; |
3167 | 3169 | ||
3168 | /* BB FIXME investigate remapping reserved chars here */ | 3170 | /* BB FIXME investigate remapping reserved chars here */ |
3169 | *symlinkinfo = cifs_strndup_from_ucs(data_start, count, | 3171 | *symlinkinfo = cifs_strndup_from_utf16(data_start, |
3170 | is_unicode, nls_codepage); | 3172 | count, is_unicode, nls_codepage); |
3171 | if (!*symlinkinfo) | 3173 | if (!*symlinkinfo) |
3172 | rc = -ENOMEM; | 3174 | rc = -ENOMEM; |
3173 | } | 3175 | } |
@@ -3450,8 +3452,9 @@ queryAclRetry: | |||
3450 | 3452 | ||
3451 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 3453 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
3452 | name_len = | 3454 | name_len = |
3453 | cifsConvertToUCS((__le16 *) pSMB->FileName, searchName, | 3455 | cifsConvertToUTF16((__le16 *) pSMB->FileName, |
3454 | PATH_MAX, nls_codepage, remap); | 3456 | searchName, PATH_MAX, nls_codepage, |
3457 | remap); | ||
3455 | name_len++; /* trailing null */ | 3458 | name_len++; /* trailing null */ |
3456 | name_len *= 2; | 3459 | name_len *= 2; |
3457 | pSMB->FileName[name_len] = 0; | 3460 | pSMB->FileName[name_len] = 0; |
@@ -3537,8 +3540,8 @@ setAclRetry: | |||
3537 | return rc; | 3540 | return rc; |
3538 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 3541 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
3539 | name_len = | 3542 | name_len = |
3540 | cifsConvertToUCS((__le16 *) pSMB->FileName, fileName, | 3543 | cifsConvertToUTF16((__le16 *) pSMB->FileName, fileName, |
3541 | PATH_MAX, nls_codepage, remap); | 3544 | PATH_MAX, nls_codepage, remap); |
3542 | name_len++; /* trailing null */ | 3545 | name_len++; /* trailing null */ |
3543 | name_len *= 2; | 3546 | name_len *= 2; |
3544 | } else { /* BB improve the check for buffer overruns BB */ | 3547 | } else { /* BB improve the check for buffer overruns BB */ |
@@ -3948,8 +3951,9 @@ QInfRetry: | |||
3948 | 3951 | ||
3949 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 3952 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
3950 | name_len = | 3953 | name_len = |
3951 | cifsConvertToUCS((__le16 *) pSMB->FileName, searchName, | 3954 | cifsConvertToUTF16((__le16 *) pSMB->FileName, |
3952 | PATH_MAX, nls_codepage, remap); | 3955 | searchName, PATH_MAX, nls_codepage, |
3956 | remap); | ||
3953 | name_len++; /* trailing null */ | 3957 | name_len++; /* trailing null */ |
3954 | name_len *= 2; | 3958 | name_len *= 2; |
3955 | } else { | 3959 | } else { |
@@ -4086,8 +4090,8 @@ QPathInfoRetry: | |||
4086 | 4090 | ||
4087 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 4091 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
4088 | name_len = | 4092 | name_len = |
4089 | cifsConvertToUCS((__le16 *) pSMB->FileName, searchName, | 4093 | cifsConvertToUTF16((__le16 *) pSMB->FileName, searchName, |
4090 | PATH_MAX, nls_codepage, remap); | 4094 | PATH_MAX, nls_codepage, remap); |
4091 | name_len++; /* trailing null */ | 4095 | name_len++; /* trailing null */ |
4092 | name_len *= 2; | 4096 | name_len *= 2; |
4093 | } else { /* BB improve the check for buffer overruns BB */ | 4097 | } else { /* BB improve the check for buffer overruns BB */ |
@@ -4255,8 +4259,8 @@ UnixQPathInfoRetry: | |||
4255 | 4259 | ||
4256 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 4260 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
4257 | name_len = | 4261 | name_len = |
4258 | cifsConvertToUCS((__le16 *) pSMB->FileName, searchName, | 4262 | cifsConvertToUTF16((__le16 *) pSMB->FileName, searchName, |
4259 | PATH_MAX, nls_codepage, remap); | 4263 | PATH_MAX, nls_codepage, remap); |
4260 | name_len++; /* trailing null */ | 4264 | name_len++; /* trailing null */ |
4261 | name_len *= 2; | 4265 | name_len *= 2; |
4262 | } else { /* BB improve the check for buffer overruns BB */ | 4266 | } else { /* BB improve the check for buffer overruns BB */ |
@@ -4344,8 +4348,8 @@ findFirstRetry: | |||
4344 | 4348 | ||
4345 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 4349 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
4346 | name_len = | 4350 | name_len = |
4347 | cifsConvertToUCS((__le16 *) pSMB->FileName, searchName, | 4351 | cifsConvertToUTF16((__le16 *) pSMB->FileName, searchName, |
4348 | PATH_MAX, nls_codepage, remap); | 4352 | PATH_MAX, nls_codepage, remap); |
4349 | /* We can not add the asterik earlier in case | 4353 | /* We can not add the asterik earlier in case |
4350 | it got remapped to 0xF03A as if it were part of the | 4354 | it got remapped to 0xF03A as if it were part of the |
4351 | directory name instead of a wildcard */ | 4355 | directory name instead of a wildcard */ |
@@ -4656,8 +4660,9 @@ GetInodeNumberRetry: | |||
4656 | 4660 | ||
4657 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 4661 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
4658 | name_len = | 4662 | name_len = |
4659 | cifsConvertToUCS((__le16 *) pSMB->FileName, searchName, | 4663 | cifsConvertToUTF16((__le16 *) pSMB->FileName, |
4660 | PATH_MAX, nls_codepage, remap); | 4664 | searchName, PATH_MAX, nls_codepage, |
4665 | remap); | ||
4661 | name_len++; /* trailing null */ | 4666 | name_len++; /* trailing null */ |
4662 | name_len *= 2; | 4667 | name_len *= 2; |
4663 | } else { /* BB improve the check for buffer overruns BB */ | 4668 | } else { /* BB improve the check for buffer overruns BB */ |
@@ -4794,9 +4799,9 @@ parse_DFS_referrals(TRANSACTION2_GET_DFS_REFER_RSP *pSMBr, | |||
4794 | rc = -ENOMEM; | 4799 | rc = -ENOMEM; |
4795 | goto parse_DFS_referrals_exit; | 4800 | goto parse_DFS_referrals_exit; |
4796 | } | 4801 | } |
4797 | cifsConvertToUCS((__le16 *) tmp, searchName, | 4802 | cifsConvertToUTF16((__le16 *) tmp, searchName, |
4798 | PATH_MAX, nls_codepage, remap); | 4803 | PATH_MAX, nls_codepage, remap); |
4799 | node->path_consumed = cifs_ucs2_bytes(tmp, | 4804 | node->path_consumed = cifs_utf16_bytes(tmp, |
4800 | le16_to_cpu(pSMBr->PathConsumed), | 4805 | le16_to_cpu(pSMBr->PathConsumed), |
4801 | nls_codepage); | 4806 | nls_codepage); |
4802 | kfree(tmp); | 4807 | kfree(tmp); |
@@ -4809,8 +4814,8 @@ parse_DFS_referrals(TRANSACTION2_GET_DFS_REFER_RSP *pSMBr, | |||
4809 | /* copy DfsPath */ | 4814 | /* copy DfsPath */ |
4810 | temp = (char *)ref + le16_to_cpu(ref->DfsPathOffset); | 4815 | temp = (char *)ref + le16_to_cpu(ref->DfsPathOffset); |
4811 | max_len = data_end - temp; | 4816 | max_len = data_end - temp; |
4812 | node->path_name = cifs_strndup_from_ucs(temp, max_len, | 4817 | node->path_name = cifs_strndup_from_utf16(temp, max_len, |
4813 | is_unicode, nls_codepage); | 4818 | is_unicode, nls_codepage); |
4814 | if (!node->path_name) { | 4819 | if (!node->path_name) { |
4815 | rc = -ENOMEM; | 4820 | rc = -ENOMEM; |
4816 | goto parse_DFS_referrals_exit; | 4821 | goto parse_DFS_referrals_exit; |
@@ -4819,8 +4824,8 @@ parse_DFS_referrals(TRANSACTION2_GET_DFS_REFER_RSP *pSMBr, | |||
4819 | /* copy link target UNC */ | 4824 | /* copy link target UNC */ |
4820 | temp = (char *)ref + le16_to_cpu(ref->NetworkAddressOffset); | 4825 | temp = (char *)ref + le16_to_cpu(ref->NetworkAddressOffset); |
4821 | max_len = data_end - temp; | 4826 | max_len = data_end - temp; |
4822 | node->node_name = cifs_strndup_from_ucs(temp, max_len, | 4827 | node->node_name = cifs_strndup_from_utf16(temp, max_len, |
4823 | is_unicode, nls_codepage); | 4828 | is_unicode, nls_codepage); |
4824 | if (!node->node_name) | 4829 | if (!node->node_name) |
4825 | rc = -ENOMEM; | 4830 | rc = -ENOMEM; |
4826 | } | 4831 | } |
@@ -4873,8 +4878,9 @@ getDFSRetry: | |||
4873 | if (ses->capabilities & CAP_UNICODE) { | 4878 | if (ses->capabilities & CAP_UNICODE) { |
4874 | pSMB->hdr.Flags2 |= SMBFLG2_UNICODE; | 4879 | pSMB->hdr.Flags2 |= SMBFLG2_UNICODE; |
4875 | name_len = | 4880 | name_len = |
4876 | cifsConvertToUCS((__le16 *) pSMB->RequestFileName, | 4881 | cifsConvertToUTF16((__le16 *) pSMB->RequestFileName, |
4877 | searchName, PATH_MAX, nls_codepage, remap); | 4882 | searchName, PATH_MAX, nls_codepage, |
4883 | remap); | ||
4878 | name_len++; /* trailing null */ | 4884 | name_len++; /* trailing null */ |
4879 | name_len *= 2; | 4885 | name_len *= 2; |
4880 | } else { /* BB improve the check for buffer overruns BB */ | 4886 | } else { /* BB improve the check for buffer overruns BB */ |
@@ -5506,8 +5512,8 @@ SetEOFRetry: | |||
5506 | 5512 | ||
5507 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 5513 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
5508 | name_len = | 5514 | name_len = |
5509 | cifsConvertToUCS((__le16 *) pSMB->FileName, fileName, | 5515 | cifsConvertToUTF16((__le16 *) pSMB->FileName, fileName, |
5510 | PATH_MAX, nls_codepage, remap); | 5516 | PATH_MAX, nls_codepage, remap); |
5511 | name_len++; /* trailing null */ | 5517 | name_len++; /* trailing null */ |
5512 | name_len *= 2; | 5518 | name_len *= 2; |
5513 | } else { /* BB improve the check for buffer overruns BB */ | 5519 | } else { /* BB improve the check for buffer overruns BB */ |
@@ -5796,8 +5802,8 @@ SetTimesRetry: | |||
5796 | 5802 | ||
5797 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 5803 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
5798 | name_len = | 5804 | name_len = |
5799 | cifsConvertToUCS((__le16 *) pSMB->FileName, fileName, | 5805 | cifsConvertToUTF16((__le16 *) pSMB->FileName, fileName, |
5800 | PATH_MAX, nls_codepage, remap); | 5806 | PATH_MAX, nls_codepage, remap); |
5801 | name_len++; /* trailing null */ | 5807 | name_len++; /* trailing null */ |
5802 | name_len *= 2; | 5808 | name_len *= 2; |
5803 | } else { /* BB improve the check for buffer overruns BB */ | 5809 | } else { /* BB improve the check for buffer overruns BB */ |
@@ -5877,8 +5883,8 @@ SetAttrLgcyRetry: | |||
5877 | 5883 | ||
5878 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 5884 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
5879 | name_len = | 5885 | name_len = |
5880 | ConvertToUCS((__le16 *) pSMB->fileName, fileName, | 5886 | ConvertToUTF16((__le16 *) pSMB->fileName, fileName, |
5881 | PATH_MAX, nls_codepage); | 5887 | PATH_MAX, nls_codepage); |
5882 | name_len++; /* trailing null */ | 5888 | name_len++; /* trailing null */ |
5883 | name_len *= 2; | 5889 | name_len *= 2; |
5884 | } else { /* BB improve the check for buffer overruns BB */ | 5890 | } else { /* BB improve the check for buffer overruns BB */ |
@@ -6030,8 +6036,8 @@ setPermsRetry: | |||
6030 | 6036 | ||
6031 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 6037 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
6032 | name_len = | 6038 | name_len = |
6033 | cifsConvertToUCS((__le16 *) pSMB->FileName, fileName, | 6039 | cifsConvertToUTF16((__le16 *) pSMB->FileName, fileName, |
6034 | PATH_MAX, nls_codepage, remap); | 6040 | PATH_MAX, nls_codepage, remap); |
6035 | name_len++; /* trailing null */ | 6041 | name_len++; /* trailing null */ |
6036 | name_len *= 2; | 6042 | name_len *= 2; |
6037 | } else { /* BB improve the check for buffer overruns BB */ | 6043 | } else { /* BB improve the check for buffer overruns BB */ |
@@ -6123,8 +6129,8 @@ QAllEAsRetry: | |||
6123 | 6129 | ||
6124 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 6130 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
6125 | list_len = | 6131 | list_len = |
6126 | cifsConvertToUCS((__le16 *) pSMB->FileName, searchName, | 6132 | cifsConvertToUTF16((__le16 *) pSMB->FileName, searchName, |
6127 | PATH_MAX, nls_codepage, remap); | 6133 | PATH_MAX, nls_codepage, remap); |
6128 | list_len++; /* trailing null */ | 6134 | list_len++; /* trailing null */ |
6129 | list_len *= 2; | 6135 | list_len *= 2; |
6130 | } else { /* BB improve the check for buffer overruns BB */ | 6136 | } else { /* BB improve the check for buffer overruns BB */ |
@@ -6301,8 +6307,8 @@ SetEARetry: | |||
6301 | 6307 | ||
6302 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 6308 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
6303 | name_len = | 6309 | name_len = |
6304 | cifsConvertToUCS((__le16 *) pSMB->FileName, fileName, | 6310 | cifsConvertToUTF16((__le16 *) pSMB->FileName, fileName, |
6305 | PATH_MAX, nls_codepage, remap); | 6311 | PATH_MAX, nls_codepage, remap); |
6306 | name_len++; /* trailing null */ | 6312 | name_len++; /* trailing null */ |
6307 | name_len *= 2; | 6313 | name_len *= 2; |
6308 | } else { /* BB improve the check for buffer overruns BB */ | 6314 | } else { /* BB improve the check for buffer overruns BB */ |
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 4666780f315d..986709a8d903 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include <asm/processor.h> | 38 | #include <asm/processor.h> |
39 | #include <linux/inet.h> | 39 | #include <linux/inet.h> |
40 | #include <linux/module.h> | 40 | #include <linux/module.h> |
41 | #include <keys/user-type.h> | ||
41 | #include <net/ipv6.h> | 42 | #include <net/ipv6.h> |
42 | #include "cifspdu.h" | 43 | #include "cifspdu.h" |
43 | #include "cifsglob.h" | 44 | #include "cifsglob.h" |
@@ -225,74 +226,90 @@ static int check2ndT2(struct smb_hdr *pSMB) | |||
225 | 226 | ||
226 | static int coalesce_t2(struct smb_hdr *psecond, struct smb_hdr *pTargetSMB) | 227 | static int coalesce_t2(struct smb_hdr *psecond, struct smb_hdr *pTargetSMB) |
227 | { | 228 | { |
228 | struct smb_t2_rsp *pSMB2 = (struct smb_t2_rsp *)psecond; | 229 | struct smb_t2_rsp *pSMBs = (struct smb_t2_rsp *)psecond; |
229 | struct smb_t2_rsp *pSMBt = (struct smb_t2_rsp *)pTargetSMB; | 230 | struct smb_t2_rsp *pSMBt = (struct smb_t2_rsp *)pTargetSMB; |
230 | char *data_area_of_target; | 231 | char *data_area_of_tgt; |
231 | char *data_area_of_buf2; | 232 | char *data_area_of_src; |
232 | int remaining; | 233 | int remaining; |
233 | unsigned int byte_count, total_in_buf; | 234 | unsigned int byte_count, total_in_tgt; |
234 | __u16 total_data_size, total_in_buf2; | 235 | __u16 tgt_total_cnt, src_total_cnt, total_in_src; |
235 | 236 | ||
236 | total_data_size = get_unaligned_le16(&pSMBt->t2_rsp.TotalDataCount); | 237 | src_total_cnt = get_unaligned_le16(&pSMBs->t2_rsp.TotalDataCount); |
238 | tgt_total_cnt = get_unaligned_le16(&pSMBt->t2_rsp.TotalDataCount); | ||
237 | 239 | ||
238 | if (total_data_size != | 240 | if (tgt_total_cnt != src_total_cnt) |
239 | get_unaligned_le16(&pSMB2->t2_rsp.TotalDataCount)) | 241 | cFYI(1, "total data count of primary and secondary t2 differ " |
240 | cFYI(1, "total data size of primary and secondary t2 differ"); | 242 | "source=%hu target=%hu", src_total_cnt, tgt_total_cnt); |
241 | 243 | ||
242 | total_in_buf = get_unaligned_le16(&pSMBt->t2_rsp.DataCount); | 244 | total_in_tgt = get_unaligned_le16(&pSMBt->t2_rsp.DataCount); |
243 | 245 | ||
244 | remaining = total_data_size - total_in_buf; | 246 | remaining = tgt_total_cnt - total_in_tgt; |
245 | 247 | ||
246 | if (remaining < 0) | 248 | if (remaining < 0) { |
249 | cFYI(1, "Server sent too much data. tgt_total_cnt=%hu " | ||
250 | "total_in_tgt=%hu", tgt_total_cnt, total_in_tgt); | ||
247 | return -EPROTO; | 251 | return -EPROTO; |
252 | } | ||
248 | 253 | ||
249 | if (remaining == 0) /* nothing to do, ignore */ | 254 | if (remaining == 0) { |
255 | /* nothing to do, ignore */ | ||
256 | cFYI(1, "no more data remains"); | ||
250 | return 0; | 257 | return 0; |
258 | } | ||
251 | 259 | ||
252 | total_in_buf2 = get_unaligned_le16(&pSMB2->t2_rsp.DataCount); | 260 | total_in_src = get_unaligned_le16(&pSMBs->t2_rsp.DataCount); |
253 | if (remaining < total_in_buf2) { | 261 | if (remaining < total_in_src) |
254 | cFYI(1, "transact2 2nd response contains too much data"); | 262 | cFYI(1, "transact2 2nd response contains too much data"); |
255 | } | ||
256 | 263 | ||
257 | /* find end of first SMB data area */ | 264 | /* find end of first SMB data area */ |
258 | data_area_of_target = (char *)&pSMBt->hdr.Protocol + | 265 | data_area_of_tgt = (char *)&pSMBt->hdr.Protocol + |
259 | get_unaligned_le16(&pSMBt->t2_rsp.DataOffset); | 266 | get_unaligned_le16(&pSMBt->t2_rsp.DataOffset); |
260 | /* validate target area */ | ||
261 | 267 | ||
262 | data_area_of_buf2 = (char *)&pSMB2->hdr.Protocol + | 268 | /* validate target area */ |
263 | get_unaligned_le16(&pSMB2->t2_rsp.DataOffset); | 269 | data_area_of_src = (char *)&pSMBs->hdr.Protocol + |
270 | get_unaligned_le16(&pSMBs->t2_rsp.DataOffset); | ||
264 | 271 | ||
265 | data_area_of_target += total_in_buf; | 272 | data_area_of_tgt += total_in_tgt; |
266 | 273 | ||
267 | /* copy second buffer into end of first buffer */ | 274 | total_in_tgt += total_in_src; |
268 | total_in_buf += total_in_buf2; | ||
269 | /* is the result too big for the field? */ | 275 | /* is the result too big for the field? */ |
270 | if (total_in_buf > USHRT_MAX) | 276 | if (total_in_tgt > USHRT_MAX) { |
277 | cFYI(1, "coalesced DataCount too large (%u)", total_in_tgt); | ||
271 | return -EPROTO; | 278 | return -EPROTO; |
272 | put_unaligned_le16(total_in_buf, &pSMBt->t2_rsp.DataCount); | 279 | } |
280 | put_unaligned_le16(total_in_tgt, &pSMBt->t2_rsp.DataCount); | ||
273 | 281 | ||
274 | /* fix up the BCC */ | 282 | /* fix up the BCC */ |
275 | byte_count = get_bcc(pTargetSMB); | 283 | byte_count = get_bcc(pTargetSMB); |
276 | byte_count += total_in_buf2; | 284 | byte_count += total_in_src; |
277 | /* is the result too big for the field? */ | 285 | /* is the result too big for the field? */ |
278 | if (byte_count > USHRT_MAX) | 286 | if (byte_count > USHRT_MAX) { |
287 | cFYI(1, "coalesced BCC too large (%u)", byte_count); | ||
279 | return -EPROTO; | 288 | return -EPROTO; |
289 | } | ||
280 | put_bcc(byte_count, pTargetSMB); | 290 | put_bcc(byte_count, pTargetSMB); |
281 | 291 | ||
282 | byte_count = be32_to_cpu(pTargetSMB->smb_buf_length); | 292 | byte_count = be32_to_cpu(pTargetSMB->smb_buf_length); |
283 | byte_count += total_in_buf2; | 293 | byte_count += total_in_src; |
284 | /* don't allow buffer to overflow */ | 294 | /* don't allow buffer to overflow */ |
285 | if (byte_count > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) | 295 | if (byte_count > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) { |
296 | cFYI(1, "coalesced BCC exceeds buffer size (%u)", byte_count); | ||
286 | return -ENOBUFS; | 297 | return -ENOBUFS; |
298 | } | ||
287 | pTargetSMB->smb_buf_length = cpu_to_be32(byte_count); | 299 | pTargetSMB->smb_buf_length = cpu_to_be32(byte_count); |
288 | 300 | ||
289 | memcpy(data_area_of_target, data_area_of_buf2, total_in_buf2); | 301 | /* copy second buffer into end of first buffer */ |
302 | memcpy(data_area_of_tgt, data_area_of_src, total_in_src); | ||
290 | 303 | ||
291 | if (remaining == total_in_buf2) { | 304 | if (remaining != total_in_src) { |
292 | cFYI(1, "found the last secondary response"); | 305 | /* more responses to go */ |
293 | return 0; /* we are done */ | 306 | cFYI(1, "waiting for more secondary responses"); |
294 | } else /* more responses to go */ | ||
295 | return 1; | 307 | return 1; |
308 | } | ||
309 | |||
310 | /* we are done */ | ||
311 | cFYI(1, "found the last secondary response"); | ||
312 | return 0; | ||
296 | } | 313 | } |
297 | 314 | ||
298 | static void | 315 | static void |
@@ -1578,11 +1595,14 @@ cifs_parse_mount_options(const char *mountdata, const char *devname, | |||
1578 | } | 1595 | } |
1579 | } | 1596 | } |
1580 | 1597 | ||
1581 | if (vol->multiuser && !(vol->secFlg & CIFSSEC_MAY_KRB5)) { | 1598 | #ifndef CONFIG_KEYS |
1582 | cERROR(1, "Multiuser mounts currently require krb5 " | 1599 | /* Muliuser mounts require CONFIG_KEYS support */ |
1583 | "authentication!"); | 1600 | if (vol->multiuser) { |
1601 | cERROR(1, "Multiuser mounts require kernels with " | ||
1602 | "CONFIG_KEYS enabled."); | ||
1584 | goto cifs_parse_mount_err; | 1603 | goto cifs_parse_mount_err; |
1585 | } | 1604 | } |
1605 | #endif | ||
1586 | 1606 | ||
1587 | if (vol->UNCip == NULL) | 1607 | if (vol->UNCip == NULL) |
1588 | vol->UNCip = &vol->UNC[2]; | 1608 | vol->UNCip = &vol->UNC[2]; |
@@ -1981,10 +2001,16 @@ static int match_session(struct cifs_ses *ses, struct smb_vol *vol) | |||
1981 | return 0; | 2001 | return 0; |
1982 | break; | 2002 | break; |
1983 | default: | 2003 | default: |
2004 | /* NULL username means anonymous session */ | ||
2005 | if (ses->user_name == NULL) { | ||
2006 | if (!vol->nullauth) | ||
2007 | return 0; | ||
2008 | break; | ||
2009 | } | ||
2010 | |||
1984 | /* anything else takes username/password */ | 2011 | /* anything else takes username/password */ |
1985 | if (ses->user_name == NULL) | 2012 | if (strncmp(ses->user_name, |
1986 | return 0; | 2013 | vol->username ? vol->username : "", |
1987 | if (strncmp(ses->user_name, vol->username, | ||
1988 | MAX_USERNAME_SIZE)) | 2014 | MAX_USERNAME_SIZE)) |
1989 | return 0; | 2015 | return 0; |
1990 | if (strlen(vol->username) != 0 && | 2016 | if (strlen(vol->username) != 0 && |
@@ -2039,6 +2065,132 @@ cifs_put_smb_ses(struct cifs_ses *ses) | |||
2039 | cifs_put_tcp_session(server); | 2065 | cifs_put_tcp_session(server); |
2040 | } | 2066 | } |
2041 | 2067 | ||
2068 | #ifdef CONFIG_KEYS | ||
2069 | |||
2070 | /* strlen("cifs:a:") + INET6_ADDRSTRLEN + 1 */ | ||
2071 | #define CIFSCREDS_DESC_SIZE (7 + INET6_ADDRSTRLEN + 1) | ||
2072 | |||
2073 | /* Populate username and pw fields from keyring if possible */ | ||
2074 | static int | ||
2075 | cifs_set_cifscreds(struct smb_vol *vol, struct cifs_ses *ses) | ||
2076 | { | ||
2077 | int rc = 0; | ||
2078 | char *desc, *delim, *payload; | ||
2079 | ssize_t len; | ||
2080 | struct key *key; | ||
2081 | struct TCP_Server_Info *server = ses->server; | ||
2082 | struct sockaddr_in *sa; | ||
2083 | struct sockaddr_in6 *sa6; | ||
2084 | struct user_key_payload *upayload; | ||
2085 | |||
2086 | desc = kmalloc(CIFSCREDS_DESC_SIZE, GFP_KERNEL); | ||
2087 | if (!desc) | ||
2088 | return -ENOMEM; | ||
2089 | |||
2090 | /* try to find an address key first */ | ||
2091 | switch (server->dstaddr.ss_family) { | ||
2092 | case AF_INET: | ||
2093 | sa = (struct sockaddr_in *)&server->dstaddr; | ||
2094 | sprintf(desc, "cifs:a:%pI4", &sa->sin_addr.s_addr); | ||
2095 | break; | ||
2096 | case AF_INET6: | ||
2097 | sa6 = (struct sockaddr_in6 *)&server->dstaddr; | ||
2098 | sprintf(desc, "cifs:a:%pI6c", &sa6->sin6_addr.s6_addr); | ||
2099 | break; | ||
2100 | default: | ||
2101 | cFYI(1, "Bad ss_family (%hu)", server->dstaddr.ss_family); | ||
2102 | rc = -EINVAL; | ||
2103 | goto out_err; | ||
2104 | } | ||
2105 | |||
2106 | cFYI(1, "%s: desc=%s", __func__, desc); | ||
2107 | key = request_key(&key_type_logon, desc, ""); | ||
2108 | if (IS_ERR(key)) { | ||
2109 | if (!ses->domainName) { | ||
2110 | cFYI(1, "domainName is NULL"); | ||
2111 | rc = PTR_ERR(key); | ||
2112 | goto out_err; | ||
2113 | } | ||
2114 | |||
2115 | /* didn't work, try to find a domain key */ | ||
2116 | sprintf(desc, "cifs:d:%s", ses->domainName); | ||
2117 | cFYI(1, "%s: desc=%s", __func__, desc); | ||
2118 | key = request_key(&key_type_logon, desc, ""); | ||
2119 | if (IS_ERR(key)) { | ||
2120 | rc = PTR_ERR(key); | ||
2121 | goto out_err; | ||
2122 | } | ||
2123 | } | ||
2124 | |||
2125 | down_read(&key->sem); | ||
2126 | upayload = key->payload.data; | ||
2127 | if (IS_ERR_OR_NULL(upayload)) { | ||
2128 | rc = PTR_ERR(key); | ||
2129 | goto out_key_put; | ||
2130 | } | ||
2131 | |||
2132 | /* find first : in payload */ | ||
2133 | payload = (char *)upayload->data; | ||
2134 | delim = strnchr(payload, upayload->datalen, ':'); | ||
2135 | cFYI(1, "payload=%s", payload); | ||
2136 | if (!delim) { | ||
2137 | cFYI(1, "Unable to find ':' in payload (datalen=%d)", | ||
2138 | upayload->datalen); | ||
2139 | rc = -EINVAL; | ||
2140 | goto out_key_put; | ||
2141 | } | ||
2142 | |||
2143 | len = delim - payload; | ||
2144 | if (len > MAX_USERNAME_SIZE || len <= 0) { | ||
2145 | cFYI(1, "Bad value from username search (len=%ld)", len); | ||
2146 | rc = -EINVAL; | ||
2147 | goto out_key_put; | ||
2148 | } | ||
2149 | |||
2150 | vol->username = kstrndup(payload, len, GFP_KERNEL); | ||
2151 | if (!vol->username) { | ||
2152 | cFYI(1, "Unable to allocate %ld bytes for username", len); | ||
2153 | rc = -ENOMEM; | ||
2154 | goto out_key_put; | ||
2155 | } | ||
2156 | cFYI(1, "%s: username=%s", __func__, vol->username); | ||
2157 | |||
2158 | len = key->datalen - (len + 1); | ||
2159 | if (len > MAX_PASSWORD_SIZE || len <= 0) { | ||
2160 | cFYI(1, "Bad len for password search (len=%ld)", len); | ||
2161 | rc = -EINVAL; | ||
2162 | kfree(vol->username); | ||
2163 | vol->username = NULL; | ||
2164 | goto out_key_put; | ||
2165 | } | ||
2166 | |||
2167 | ++delim; | ||
2168 | vol->password = kstrndup(delim, len, GFP_KERNEL); | ||
2169 | if (!vol->password) { | ||
2170 | cFYI(1, "Unable to allocate %ld bytes for password", len); | ||
2171 | rc = -ENOMEM; | ||
2172 | kfree(vol->username); | ||
2173 | vol->username = NULL; | ||
2174 | goto out_key_put; | ||
2175 | } | ||
2176 | |||
2177 | out_key_put: | ||
2178 | up_read(&key->sem); | ||
2179 | key_put(key); | ||
2180 | out_err: | ||
2181 | kfree(desc); | ||
2182 | cFYI(1, "%s: returning %d", __func__, rc); | ||
2183 | return rc; | ||
2184 | } | ||
2185 | #else /* ! CONFIG_KEYS */ | ||
2186 | static inline int | ||
2187 | cifs_set_cifscreds(struct smb_vol *vol __attribute__((unused)), | ||
2188 | struct cifs_ses *ses __attribute__((unused))) | ||
2189 | { | ||
2190 | return -ENOSYS; | ||
2191 | } | ||
2192 | #endif /* CONFIG_KEYS */ | ||
2193 | |||
2042 | static bool warned_on_ntlm; /* globals init to false automatically */ | 2194 | static bool warned_on_ntlm; /* globals init to false automatically */ |
2043 | 2195 | ||
2044 | static struct cifs_ses * | 2196 | static struct cifs_ses * |
@@ -2914,18 +3066,33 @@ void cifs_setup_cifs_sb(struct smb_vol *pvolume_info, | |||
2914 | #define CIFS_DEFAULT_IOSIZE (1024 * 1024) | 3066 | #define CIFS_DEFAULT_IOSIZE (1024 * 1024) |
2915 | 3067 | ||
2916 | /* | 3068 | /* |
2917 | * Windows only supports a max of 60k reads. Default to that when posix | 3069 | * Windows only supports a max of 60kb reads and 65535 byte writes. Default to |
2918 | * extensions aren't in force. | 3070 | * those values when posix extensions aren't in force. In actuality here, we |
3071 | * use 65536 to allow for a write that is a multiple of 4k. Most servers seem | ||
3072 | * to be ok with the extra byte even though Windows doesn't send writes that | ||
3073 | * are that large. | ||
3074 | * | ||
3075 | * Citation: | ||
3076 | * | ||
3077 | * http://blogs.msdn.com/b/openspecification/archive/2009/04/10/smb-maximum-transmit-buffer-size-and-performance-tuning.aspx | ||
2919 | */ | 3078 | */ |
2920 | #define CIFS_DEFAULT_NON_POSIX_RSIZE (60 * 1024) | 3079 | #define CIFS_DEFAULT_NON_POSIX_RSIZE (60 * 1024) |
3080 | #define CIFS_DEFAULT_NON_POSIX_WSIZE (65536) | ||
2921 | 3081 | ||
2922 | static unsigned int | 3082 | static unsigned int |
2923 | cifs_negotiate_wsize(struct cifs_tcon *tcon, struct smb_vol *pvolume_info) | 3083 | cifs_negotiate_wsize(struct cifs_tcon *tcon, struct smb_vol *pvolume_info) |
2924 | { | 3084 | { |
2925 | __u64 unix_cap = le64_to_cpu(tcon->fsUnixInfo.Capability); | 3085 | __u64 unix_cap = le64_to_cpu(tcon->fsUnixInfo.Capability); |
2926 | struct TCP_Server_Info *server = tcon->ses->server; | 3086 | struct TCP_Server_Info *server = tcon->ses->server; |
2927 | unsigned int wsize = pvolume_info->wsize ? pvolume_info->wsize : | 3087 | unsigned int wsize; |
2928 | CIFS_DEFAULT_IOSIZE; | 3088 | |
3089 | /* start with specified wsize, or default */ | ||
3090 | if (pvolume_info->wsize) | ||
3091 | wsize = pvolume_info->wsize; | ||
3092 | else if (tcon->unix_ext && (unix_cap & CIFS_UNIX_LARGE_WRITE_CAP)) | ||
3093 | wsize = CIFS_DEFAULT_IOSIZE; | ||
3094 | else | ||
3095 | wsize = CIFS_DEFAULT_NON_POSIX_WSIZE; | ||
2929 | 3096 | ||
2930 | /* can server support 24-bit write sizes? (via UNIX extensions) */ | 3097 | /* can server support 24-bit write sizes? (via UNIX extensions) */ |
2931 | if (!tcon->unix_ext || !(unix_cap & CIFS_UNIX_LARGE_WRITE_CAP)) | 3098 | if (!tcon->unix_ext || !(unix_cap & CIFS_UNIX_LARGE_WRITE_CAP)) |
@@ -3136,10 +3303,9 @@ cifs_setup_volume_info(struct smb_vol *volume_info, char *mount_data, | |||
3136 | return -EINVAL; | 3303 | return -EINVAL; |
3137 | 3304 | ||
3138 | if (volume_info->nullauth) { | 3305 | if (volume_info->nullauth) { |
3139 | cFYI(1, "null user"); | 3306 | cFYI(1, "Anonymous login"); |
3140 | volume_info->username = kzalloc(1, GFP_KERNEL); | 3307 | kfree(volume_info->username); |
3141 | if (volume_info->username == NULL) | 3308 | volume_info->username = NULL; |
3142 | return -ENOMEM; | ||
3143 | } else if (volume_info->username) { | 3309 | } else if (volume_info->username) { |
3144 | /* BB fixme parse for domain name here */ | 3310 | /* BB fixme parse for domain name here */ |
3145 | cFYI(1, "Username: %s", volume_info->username); | 3311 | cFYI(1, "Username: %s", volume_info->username); |
@@ -3478,7 +3644,7 @@ CIFSTCon(unsigned int xid, struct cifs_ses *ses, | |||
3478 | if (ses->capabilities & CAP_UNICODE) { | 3644 | if (ses->capabilities & CAP_UNICODE) { |
3479 | smb_buffer->Flags2 |= SMBFLG2_UNICODE; | 3645 | smb_buffer->Flags2 |= SMBFLG2_UNICODE; |
3480 | length = | 3646 | length = |
3481 | cifs_strtoUCS((__le16 *) bcc_ptr, tree, | 3647 | cifs_strtoUTF16((__le16 *) bcc_ptr, tree, |
3482 | 6 /* max utf8 char length in bytes */ * | 3648 | 6 /* max utf8 char length in bytes */ * |
3483 | (/* server len*/ + 256 /* share len */), nls_codepage); | 3649 | (/* server len*/ + 256 /* share len */), nls_codepage); |
3484 | bcc_ptr += 2 * length; /* convert num 16 bit words to bytes */ | 3650 | bcc_ptr += 2 * length; /* convert num 16 bit words to bytes */ |
@@ -3533,7 +3699,7 @@ CIFSTCon(unsigned int xid, struct cifs_ses *ses, | |||
3533 | 3699 | ||
3534 | /* mostly informational -- no need to fail on error here */ | 3700 | /* mostly informational -- no need to fail on error here */ |
3535 | kfree(tcon->nativeFileSystem); | 3701 | kfree(tcon->nativeFileSystem); |
3536 | tcon->nativeFileSystem = cifs_strndup_from_ucs(bcc_ptr, | 3702 | tcon->nativeFileSystem = cifs_strndup_from_utf16(bcc_ptr, |
3537 | bytes_left, is_unicode, | 3703 | bytes_left, is_unicode, |
3538 | nls_codepage); | 3704 | nls_codepage); |
3539 | 3705 | ||
@@ -3657,16 +3823,38 @@ int cifs_setup_session(unsigned int xid, struct cifs_ses *ses, | |||
3657 | return rc; | 3823 | return rc; |
3658 | } | 3824 | } |
3659 | 3825 | ||
3826 | static int | ||
3827 | cifs_set_vol_auth(struct smb_vol *vol, struct cifs_ses *ses) | ||
3828 | { | ||
3829 | switch (ses->server->secType) { | ||
3830 | case Kerberos: | ||
3831 | vol->secFlg = CIFSSEC_MUST_KRB5; | ||
3832 | return 0; | ||
3833 | case NTLMv2: | ||
3834 | vol->secFlg = CIFSSEC_MUST_NTLMV2; | ||
3835 | break; | ||
3836 | case NTLM: | ||
3837 | vol->secFlg = CIFSSEC_MUST_NTLM; | ||
3838 | break; | ||
3839 | case RawNTLMSSP: | ||
3840 | vol->secFlg = CIFSSEC_MUST_NTLMSSP; | ||
3841 | break; | ||
3842 | case LANMAN: | ||
3843 | vol->secFlg = CIFSSEC_MUST_LANMAN; | ||
3844 | break; | ||
3845 | } | ||
3846 | |||
3847 | return cifs_set_cifscreds(vol, ses); | ||
3848 | } | ||
3849 | |||
3660 | static struct cifs_tcon * | 3850 | static struct cifs_tcon * |
3661 | cifs_construct_tcon(struct cifs_sb_info *cifs_sb, uid_t fsuid) | 3851 | cifs_construct_tcon(struct cifs_sb_info *cifs_sb, uid_t fsuid) |
3662 | { | 3852 | { |
3853 | int rc; | ||
3663 | struct cifs_tcon *master_tcon = cifs_sb_master_tcon(cifs_sb); | 3854 | struct cifs_tcon *master_tcon = cifs_sb_master_tcon(cifs_sb); |
3664 | struct cifs_ses *ses; | 3855 | struct cifs_ses *ses; |
3665 | struct cifs_tcon *tcon = NULL; | 3856 | struct cifs_tcon *tcon = NULL; |
3666 | struct smb_vol *vol_info; | 3857 | struct smb_vol *vol_info; |
3667 | char username[28]; /* big enough for "krb50x" + hex of ULONG_MAX 6+16 */ | ||
3668 | /* We used to have this as MAX_USERNAME which is */ | ||
3669 | /* way too big now (256 instead of 32) */ | ||
3670 | 3858 | ||
3671 | vol_info = kzalloc(sizeof(*vol_info), GFP_KERNEL); | 3859 | vol_info = kzalloc(sizeof(*vol_info), GFP_KERNEL); |
3672 | if (vol_info == NULL) { | 3860 | if (vol_info == NULL) { |
@@ -3674,8 +3862,6 @@ cifs_construct_tcon(struct cifs_sb_info *cifs_sb, uid_t fsuid) | |||
3674 | goto out; | 3862 | goto out; |
3675 | } | 3863 | } |
3676 | 3864 | ||
3677 | snprintf(username, sizeof(username), "krb50x%x", fsuid); | ||
3678 | vol_info->username = username; | ||
3679 | vol_info->local_nls = cifs_sb->local_nls; | 3865 | vol_info->local_nls = cifs_sb->local_nls; |
3680 | vol_info->linux_uid = fsuid; | 3866 | vol_info->linux_uid = fsuid; |
3681 | vol_info->cred_uid = fsuid; | 3867 | vol_info->cred_uid = fsuid; |
@@ -3685,8 +3871,11 @@ cifs_construct_tcon(struct cifs_sb_info *cifs_sb, uid_t fsuid) | |||
3685 | vol_info->local_lease = master_tcon->local_lease; | 3871 | vol_info->local_lease = master_tcon->local_lease; |
3686 | vol_info->no_linux_ext = !master_tcon->unix_ext; | 3872 | vol_info->no_linux_ext = !master_tcon->unix_ext; |
3687 | 3873 | ||
3688 | /* FIXME: allow for other secFlg settings */ | 3874 | rc = cifs_set_vol_auth(vol_info, master_tcon->ses); |
3689 | vol_info->secFlg = CIFSSEC_MUST_KRB5; | 3875 | if (rc) { |
3876 | tcon = ERR_PTR(rc); | ||
3877 | goto out; | ||
3878 | } | ||
3690 | 3879 | ||
3691 | /* get a reference for the same TCP session */ | 3880 | /* get a reference for the same TCP session */ |
3692 | spin_lock(&cifs_tcp_ses_lock); | 3881 | spin_lock(&cifs_tcp_ses_lock); |
@@ -3709,6 +3898,8 @@ cifs_construct_tcon(struct cifs_sb_info *cifs_sb, uid_t fsuid) | |||
3709 | if (ses->capabilities & CAP_UNIX) | 3898 | if (ses->capabilities & CAP_UNIX) |
3710 | reset_cifs_unix_caps(0, tcon, NULL, vol_info); | 3899 | reset_cifs_unix_caps(0, tcon, NULL, vol_info); |
3711 | out: | 3900 | out: |
3901 | kfree(vol_info->username); | ||
3902 | kfree(vol_info->password); | ||
3712 | kfree(vol_info); | 3903 | kfree(vol_info); |
3713 | 3904 | ||
3714 | return tcon; | 3905 | return tcon; |
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c index a090bbe6ee29..e2bbc683e018 100644 --- a/fs/cifs/readdir.c +++ b/fs/cifs/readdir.c | |||
@@ -647,10 +647,11 @@ static int cifs_filldir(char *find_entry, struct file *file, filldir_t filldir, | |||
647 | 647 | ||
648 | name.name = scratch_buf; | 648 | name.name = scratch_buf; |
649 | name.len = | 649 | name.len = |
650 | cifs_from_ucs2((char *)name.name, (__le16 *)de.name, | 650 | cifs_from_utf16((char *)name.name, (__le16 *)de.name, |
651 | UNICODE_NAME_MAX, | 651 | UNICODE_NAME_MAX, |
652 | min(de.namelen, (size_t)max_len), nlt, | 652 | min_t(size_t, de.namelen, |
653 | cifs_sb->mnt_cifs_flags & | 653 | (size_t)max_len), nlt, |
654 | cifs_sb->mnt_cifs_flags & | ||
654 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 655 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
655 | name.len -= nls_nullsize(nlt); | 656 | name.len -= nls_nullsize(nlt); |
656 | } else { | 657 | } else { |
diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c index 4ec3ee9d72cc..d85efad5765f 100644 --- a/fs/cifs/sess.c +++ b/fs/cifs/sess.c | |||
@@ -167,16 +167,16 @@ unicode_oslm_strings(char **pbcc_area, const struct nls_table *nls_cp) | |||
167 | int bytes_ret = 0; | 167 | int bytes_ret = 0; |
168 | 168 | ||
169 | /* Copy OS version */ | 169 | /* Copy OS version */ |
170 | bytes_ret = cifs_strtoUCS((__le16 *)bcc_ptr, "Linux version ", 32, | 170 | bytes_ret = cifs_strtoUTF16((__le16 *)bcc_ptr, "Linux version ", 32, |
171 | nls_cp); | 171 | nls_cp); |
172 | bcc_ptr += 2 * bytes_ret; | 172 | bcc_ptr += 2 * bytes_ret; |
173 | bytes_ret = cifs_strtoUCS((__le16 *) bcc_ptr, init_utsname()->release, | 173 | bytes_ret = cifs_strtoUTF16((__le16 *) bcc_ptr, init_utsname()->release, |
174 | 32, nls_cp); | 174 | 32, nls_cp); |
175 | bcc_ptr += 2 * bytes_ret; | 175 | bcc_ptr += 2 * bytes_ret; |
176 | bcc_ptr += 2; /* trailing null */ | 176 | bcc_ptr += 2; /* trailing null */ |
177 | 177 | ||
178 | bytes_ret = cifs_strtoUCS((__le16 *) bcc_ptr, CIFS_NETWORK_OPSYS, | 178 | bytes_ret = cifs_strtoUTF16((__le16 *) bcc_ptr, CIFS_NETWORK_OPSYS, |
179 | 32, nls_cp); | 179 | 32, nls_cp); |
180 | bcc_ptr += 2 * bytes_ret; | 180 | bcc_ptr += 2 * bytes_ret; |
181 | bcc_ptr += 2; /* trailing null */ | 181 | bcc_ptr += 2; /* trailing null */ |
182 | 182 | ||
@@ -197,8 +197,8 @@ static void unicode_domain_string(char **pbcc_area, struct cifs_ses *ses, | |||
197 | *(bcc_ptr+1) = 0; | 197 | *(bcc_ptr+1) = 0; |
198 | bytes_ret = 0; | 198 | bytes_ret = 0; |
199 | } else | 199 | } else |
200 | bytes_ret = cifs_strtoUCS((__le16 *) bcc_ptr, ses->domainName, | 200 | bytes_ret = cifs_strtoUTF16((__le16 *) bcc_ptr, ses->domainName, |
201 | 256, nls_cp); | 201 | 256, nls_cp); |
202 | bcc_ptr += 2 * bytes_ret; | 202 | bcc_ptr += 2 * bytes_ret; |
203 | bcc_ptr += 2; /* account for null terminator */ | 203 | bcc_ptr += 2; /* account for null terminator */ |
204 | 204 | ||
@@ -226,8 +226,8 @@ static void unicode_ssetup_strings(char **pbcc_area, struct cifs_ses *ses, | |||
226 | *bcc_ptr = 0; | 226 | *bcc_ptr = 0; |
227 | *(bcc_ptr+1) = 0; | 227 | *(bcc_ptr+1) = 0; |
228 | } else { | 228 | } else { |
229 | bytes_ret = cifs_strtoUCS((__le16 *) bcc_ptr, ses->user_name, | 229 | bytes_ret = cifs_strtoUTF16((__le16 *) bcc_ptr, ses->user_name, |
230 | MAX_USERNAME_SIZE, nls_cp); | 230 | MAX_USERNAME_SIZE, nls_cp); |
231 | } | 231 | } |
232 | bcc_ptr += 2 * bytes_ret; | 232 | bcc_ptr += 2 * bytes_ret; |
233 | bcc_ptr += 2; /* account for null termination */ | 233 | bcc_ptr += 2; /* account for null termination */ |
@@ -287,7 +287,7 @@ decode_unicode_ssetup(char **pbcc_area, int bleft, struct cifs_ses *ses, | |||
287 | cFYI(1, "bleft %d", bleft); | 287 | cFYI(1, "bleft %d", bleft); |
288 | 288 | ||
289 | kfree(ses->serverOS); | 289 | kfree(ses->serverOS); |
290 | ses->serverOS = cifs_strndup_from_ucs(data, bleft, true, nls_cp); | 290 | ses->serverOS = cifs_strndup_from_utf16(data, bleft, true, nls_cp); |
291 | cFYI(1, "serverOS=%s", ses->serverOS); | 291 | cFYI(1, "serverOS=%s", ses->serverOS); |
292 | len = (UniStrnlen((wchar_t *) data, bleft / 2) * 2) + 2; | 292 | len = (UniStrnlen((wchar_t *) data, bleft / 2) * 2) + 2; |
293 | data += len; | 293 | data += len; |
@@ -296,7 +296,7 @@ decode_unicode_ssetup(char **pbcc_area, int bleft, struct cifs_ses *ses, | |||
296 | return; | 296 | return; |
297 | 297 | ||
298 | kfree(ses->serverNOS); | 298 | kfree(ses->serverNOS); |
299 | ses->serverNOS = cifs_strndup_from_ucs(data, bleft, true, nls_cp); | 299 | ses->serverNOS = cifs_strndup_from_utf16(data, bleft, true, nls_cp); |
300 | cFYI(1, "serverNOS=%s", ses->serverNOS); | 300 | cFYI(1, "serverNOS=%s", ses->serverNOS); |
301 | len = (UniStrnlen((wchar_t *) data, bleft / 2) * 2) + 2; | 301 | len = (UniStrnlen((wchar_t *) data, bleft / 2) * 2) + 2; |
302 | data += len; | 302 | data += len; |
@@ -305,7 +305,7 @@ decode_unicode_ssetup(char **pbcc_area, int bleft, struct cifs_ses *ses, | |||
305 | return; | 305 | return; |
306 | 306 | ||
307 | kfree(ses->serverDomain); | 307 | kfree(ses->serverDomain); |
308 | ses->serverDomain = cifs_strndup_from_ucs(data, bleft, true, nls_cp); | 308 | ses->serverDomain = cifs_strndup_from_utf16(data, bleft, true, nls_cp); |
309 | cFYI(1, "serverDomain=%s", ses->serverDomain); | 309 | cFYI(1, "serverDomain=%s", ses->serverDomain); |
310 | 310 | ||
311 | return; | 311 | return; |
@@ -502,8 +502,8 @@ static int build_ntlmssp_auth_blob(unsigned char *pbuffer, | |||
502 | tmp += 2; | 502 | tmp += 2; |
503 | } else { | 503 | } else { |
504 | int len; | 504 | int len; |
505 | len = cifs_strtoUCS((__le16 *)tmp, ses->domainName, | 505 | len = cifs_strtoUTF16((__le16 *)tmp, ses->domainName, |
506 | MAX_USERNAME_SIZE, nls_cp); | 506 | MAX_USERNAME_SIZE, nls_cp); |
507 | len *= 2; /* unicode is 2 bytes each */ | 507 | len *= 2; /* unicode is 2 bytes each */ |
508 | sec_blob->DomainName.BufferOffset = cpu_to_le32(tmp - pbuffer); | 508 | sec_blob->DomainName.BufferOffset = cpu_to_le32(tmp - pbuffer); |
509 | sec_blob->DomainName.Length = cpu_to_le16(len); | 509 | sec_blob->DomainName.Length = cpu_to_le16(len); |
@@ -518,8 +518,8 @@ static int build_ntlmssp_auth_blob(unsigned char *pbuffer, | |||
518 | tmp += 2; | 518 | tmp += 2; |
519 | } else { | 519 | } else { |
520 | int len; | 520 | int len; |
521 | len = cifs_strtoUCS((__le16 *)tmp, ses->user_name, | 521 | len = cifs_strtoUTF16((__le16 *)tmp, ses->user_name, |
522 | MAX_USERNAME_SIZE, nls_cp); | 522 | MAX_USERNAME_SIZE, nls_cp); |
523 | len *= 2; /* unicode is 2 bytes each */ | 523 | len *= 2; /* unicode is 2 bytes each */ |
524 | sec_blob->UserName.BufferOffset = cpu_to_le32(tmp - pbuffer); | 524 | sec_blob->UserName.BufferOffset = cpu_to_le32(tmp - pbuffer); |
525 | sec_blob->UserName.Length = cpu_to_le16(len); | 525 | sec_blob->UserName.Length = cpu_to_le16(len); |
diff --git a/fs/cifs/smbencrypt.c b/fs/cifs/smbencrypt.c index 80d850881938..d5cd9aa7eacc 100644 --- a/fs/cifs/smbencrypt.c +++ b/fs/cifs/smbencrypt.c | |||
@@ -213,7 +213,7 @@ E_md4hash(const unsigned char *passwd, unsigned char *p16, | |||
213 | 213 | ||
214 | /* Password cannot be longer than 128 characters */ | 214 | /* Password cannot be longer than 128 characters */ |
215 | if (passwd) /* Password must be converted to NT unicode */ | 215 | if (passwd) /* Password must be converted to NT unicode */ |
216 | len = cifs_strtoUCS(wpwd, passwd, 128, codepage); | 216 | len = cifs_strtoUTF16(wpwd, passwd, 128, codepage); |
217 | else { | 217 | else { |
218 | len = 0; | 218 | len = 0; |
219 | *wpwd = 0; /* Ensure string is null terminated */ | 219 | *wpwd = 0; /* Ensure string is null terminated */ |