diff options
-rw-r--r-- | fs/cifs/cifsglob.h | 7 | ||||
-rw-r--r-- | fs/cifs/connect.c | 12 | ||||
-rw-r--r-- | fs/cifs/sess.c | 10 | ||||
-rw-r--r-- | include/uapi/linux/cifs/cifs_mount.h | 25 |
4 files changed, 38 insertions, 16 deletions
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index ec6c3fbb29eb..633bbc5e8801 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h | |||
@@ -28,6 +28,7 @@ | |||
28 | #include "cifsacl.h" | 28 | #include "cifsacl.h" |
29 | #include <crypto/internal/hash.h> | 29 | #include <crypto/internal/hash.h> |
30 | #include <linux/scatterlist.h> | 30 | #include <linux/scatterlist.h> |
31 | #include <uapi/linux/cifs/cifs_mount.h> | ||
31 | #ifdef CONFIG_CIFS_SMB2 | 32 | #ifdef CONFIG_CIFS_SMB2 |
32 | #include "smb2pdu.h" | 33 | #include "smb2pdu.h" |
33 | #endif | 34 | #endif |
@@ -41,12 +42,8 @@ | |||
41 | #define MAX_SES_INFO 2 | 42 | #define MAX_SES_INFO 2 |
42 | #define MAX_TCON_INFO 4 | 43 | #define MAX_TCON_INFO 4 |
43 | 44 | ||
44 | #define MAX_TREE_SIZE (2 + MAX_SERVER_SIZE + 1 + MAX_SHARE_SIZE + 1) | 45 | #define MAX_TREE_SIZE (2 + MAX_SERVER_SIZE + 1 + CIFS_MAX_SHARE_LEN + 1) |
45 | #define MAX_SERVER_SIZE 15 | 46 | #define MAX_SERVER_SIZE 15 |
46 | #define MAX_SHARE_SIZE 80 | ||
47 | #define CIFS_MAX_DOMAINNAME_LEN 256 /* max domain name length */ | ||
48 | #define MAX_USERNAME_SIZE 256 /* reasonable maximum for current servers */ | ||
49 | #define MAX_PASSWORD_SIZE 512 /* max for windows seems to be 256 wide chars */ | ||
50 | 47 | ||
51 | #define CIFS_MIN_RCV_POOL 4 | 48 | #define CIFS_MIN_RCV_POOL 4 |
52 | 49 | ||
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 37950c65453c..b1bab99be83b 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c | |||
@@ -1577,8 +1577,8 @@ cifs_parse_mount_options(const char *mountdata, const char *devname, | |||
1577 | if (string == NULL) | 1577 | if (string == NULL) |
1578 | goto out_nomem; | 1578 | goto out_nomem; |
1579 | 1579 | ||
1580 | if (strnlen(string, MAX_USERNAME_SIZE) > | 1580 | if (strnlen(string, CIFS_MAX_USERNAME_LEN) > |
1581 | MAX_USERNAME_SIZE) { | 1581 | CIFS_MAX_USERNAME_LEN) { |
1582 | printk(KERN_WARNING "CIFS: username too long\n"); | 1582 | printk(KERN_WARNING "CIFS: username too long\n"); |
1583 | goto cifs_parse_mount_err; | 1583 | goto cifs_parse_mount_err; |
1584 | } | 1584 | } |
@@ -2223,13 +2223,13 @@ static int match_session(struct cifs_ses *ses, struct smb_vol *vol) | |||
2223 | /* anything else takes username/password */ | 2223 | /* anything else takes username/password */ |
2224 | if (strncmp(ses->user_name, | 2224 | if (strncmp(ses->user_name, |
2225 | vol->username ? vol->username : "", | 2225 | vol->username ? vol->username : "", |
2226 | MAX_USERNAME_SIZE)) | 2226 | CIFS_MAX_USERNAME_LEN)) |
2227 | return 0; | 2227 | return 0; |
2228 | if (strlen(vol->username) != 0 && | 2228 | if (strlen(vol->username) != 0 && |
2229 | ses->password != NULL && | 2229 | ses->password != NULL && |
2230 | strncmp(ses->password, | 2230 | strncmp(ses->password, |
2231 | vol->password ? vol->password : "", | 2231 | vol->password ? vol->password : "", |
2232 | MAX_PASSWORD_SIZE)) | 2232 | CIFS_MAX_PASSWORD_LEN)) |
2233 | return 0; | 2233 | return 0; |
2234 | } | 2234 | } |
2235 | return 1; | 2235 | return 1; |
@@ -2354,7 +2354,7 @@ cifs_set_cifscreds(struct smb_vol *vol, struct cifs_ses *ses) | |||
2354 | } | 2354 | } |
2355 | 2355 | ||
2356 | len = delim - payload; | 2356 | len = delim - payload; |
2357 | if (len > MAX_USERNAME_SIZE || len <= 0) { | 2357 | if (len > CIFS_MAX_USERNAME_LEN || len <= 0) { |
2358 | cifs_dbg(FYI, "Bad value from username search (len=%zd)\n", | 2358 | cifs_dbg(FYI, "Bad value from username search (len=%zd)\n", |
2359 | len); | 2359 | len); |
2360 | rc = -EINVAL; | 2360 | rc = -EINVAL; |
@@ -2371,7 +2371,7 @@ cifs_set_cifscreds(struct smb_vol *vol, struct cifs_ses *ses) | |||
2371 | cifs_dbg(FYI, "%s: username=%s\n", __func__, vol->username); | 2371 | cifs_dbg(FYI, "%s: username=%s\n", __func__, vol->username); |
2372 | 2372 | ||
2373 | len = key->datalen - (len + 1); | 2373 | len = key->datalen - (len + 1); |
2374 | if (len > MAX_PASSWORD_SIZE || len <= 0) { | 2374 | if (len > CIFS_MAX_PASSWORD_LEN || len <= 0) { |
2375 | cifs_dbg(FYI, "Bad len for password search (len=%zd)\n", len); | 2375 | cifs_dbg(FYI, "Bad len for password search (len=%zd)\n", len); |
2376 | rc = -EINVAL; | 2376 | rc = -EINVAL; |
2377 | kfree(vol->username); | 2377 | kfree(vol->username); |
diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c index 08dd37bb23aa..a0a62db0f575 100644 --- a/fs/cifs/sess.c +++ b/fs/cifs/sess.c | |||
@@ -226,7 +226,7 @@ static void unicode_ssetup_strings(char **pbcc_area, struct cifs_ses *ses, | |||
226 | *(bcc_ptr+1) = 0; | 226 | *(bcc_ptr+1) = 0; |
227 | } else { | 227 | } else { |
228 | bytes_ret = cifs_strtoUTF16((__le16 *) bcc_ptr, ses->user_name, | 228 | bytes_ret = cifs_strtoUTF16((__le16 *) bcc_ptr, ses->user_name, |
229 | MAX_USERNAME_SIZE, nls_cp); | 229 | CIFS_MAX_USERNAME_LEN, nls_cp); |
230 | } | 230 | } |
231 | bcc_ptr += 2 * bytes_ret; | 231 | bcc_ptr += 2 * bytes_ret; |
232 | bcc_ptr += 2; /* account for null termination */ | 232 | bcc_ptr += 2; /* account for null termination */ |
@@ -246,8 +246,8 @@ static void ascii_ssetup_strings(char **pbcc_area, struct cifs_ses *ses, | |||
246 | /* BB what about null user mounts - check that we do this BB */ | 246 | /* BB what about null user mounts - check that we do this BB */ |
247 | /* copy user */ | 247 | /* copy user */ |
248 | if (ses->user_name != NULL) { | 248 | if (ses->user_name != NULL) { |
249 | strncpy(bcc_ptr, ses->user_name, MAX_USERNAME_SIZE); | 249 | strncpy(bcc_ptr, ses->user_name, CIFS_MAX_USERNAME_LEN); |
250 | bcc_ptr += strnlen(ses->user_name, MAX_USERNAME_SIZE); | 250 | bcc_ptr += strnlen(ses->user_name, CIFS_MAX_USERNAME_LEN); |
251 | } | 251 | } |
252 | /* else null user mount */ | 252 | /* else null user mount */ |
253 | *bcc_ptr = 0; | 253 | *bcc_ptr = 0; |
@@ -501,7 +501,7 @@ int build_ntlmssp_auth_blob(unsigned char *pbuffer, | |||
501 | } else { | 501 | } else { |
502 | int len; | 502 | int len; |
503 | len = cifs_strtoUTF16((__le16 *)tmp, ses->domainName, | 503 | len = cifs_strtoUTF16((__le16 *)tmp, ses->domainName, |
504 | MAX_USERNAME_SIZE, nls_cp); | 504 | CIFS_MAX_USERNAME_LEN, nls_cp); |
505 | len *= 2; /* unicode is 2 bytes each */ | 505 | len *= 2; /* unicode is 2 bytes each */ |
506 | sec_blob->DomainName.BufferOffset = cpu_to_le32(tmp - pbuffer); | 506 | sec_blob->DomainName.BufferOffset = cpu_to_le32(tmp - pbuffer); |
507 | sec_blob->DomainName.Length = cpu_to_le16(len); | 507 | sec_blob->DomainName.Length = cpu_to_le16(len); |
@@ -517,7 +517,7 @@ int build_ntlmssp_auth_blob(unsigned char *pbuffer, | |||
517 | } else { | 517 | } else { |
518 | int len; | 518 | int len; |
519 | len = cifs_strtoUTF16((__le16 *)tmp, ses->user_name, | 519 | len = cifs_strtoUTF16((__le16 *)tmp, ses->user_name, |
520 | MAX_USERNAME_SIZE, nls_cp); | 520 | CIFS_MAX_USERNAME_LEN, nls_cp); |
521 | len *= 2; /* unicode is 2 bytes each */ | 521 | len *= 2; /* unicode is 2 bytes each */ |
522 | sec_blob->UserName.BufferOffset = cpu_to_le32(tmp - pbuffer); | 522 | sec_blob->UserName.BufferOffset = cpu_to_le32(tmp - pbuffer); |
523 | sec_blob->UserName.Length = cpu_to_le16(len); | 523 | sec_blob->UserName.Length = cpu_to_le16(len); |
diff --git a/include/uapi/linux/cifs/cifs_mount.h b/include/uapi/linux/cifs/cifs_mount.h new file mode 100644 index 000000000000..19063fef6219 --- /dev/null +++ b/include/uapi/linux/cifs/cifs_mount.h | |||
@@ -0,0 +1,25 @@ | |||
1 | /* | ||
2 | * include/uapi/linux/cifs/cifs_mount.h | ||
3 | * | ||
4 | * Author(s): Scott Lovenberg (scott.lovenberg@gmail.com) | ||
5 | * | ||
6 | * This library is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU Lesser General Public License as published | ||
8 | * by the Free Software Foundation; either version 2.1 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This library is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See | ||
14 | * the GNU Lesser General Public License for more details. | ||
15 | */ | ||
16 | #ifndef _CIFS_MOUNT_H | ||
17 | #define _CIFS_MOUNT_H | ||
18 | |||
19 | /* Max string lengths for cifs mounting options. */ | ||
20 | #define CIFS_MAX_DOMAINNAME_LEN 256 /* max fully qualified domain name */ | ||
21 | #define CIFS_MAX_USERNAME_LEN 256 /* reasonable max for current servers */ | ||
22 | #define CIFS_MAX_PASSWORD_LEN 512 /* Windows max seems to be 256 wide chars */ | ||
23 | #define CIFS_MAX_SHARE_LEN 80 | ||
24 | |||
25 | #endif /* _CIFS_MOUNT_H */ | ||