diff options
author | Jeff Layton <jlayton@redhat.com> | 2009-06-02 06:55:20 -0400 |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2009-06-02 11:45:40 -0400 |
commit | 50b64e3b77d569c217a48e078cd565dbd6462ad0 (patch) | |
tree | 2001150788641aad1f4824046d336f0b5d4dd32c /fs | |
parent | b96d31a62f714566fa6420851b3bb3615c796322 (diff) |
cifs: fix IPv6 address length check
For IPv6 the userspace mount helper sends an address in the "ip="
option. This check fails if the length is > 35 characters. I have no
idea where the magic 35 character limit came from, but it's clearly not
enough for IPv6. Fix it by making it use the INET6_ADDRSTRLEN #define.
While we're at it, use the same #define for the address length in SPNEGO
upcalls.
Reported-by: Charles R. Anderson <cra@wpi.edu>
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/cifs/cifs_spnego.c | 6 | ||||
-rw-r--r-- | fs/cifs/connect.c | 4 |
2 files changed, 5 insertions, 5 deletions
diff --git a/fs/cifs/cifs_spnego.c b/fs/cifs/cifs_spnego.c index 67bf93a40d2e..4a4581cb2b5e 100644 --- a/fs/cifs/cifs_spnego.c +++ b/fs/cifs/cifs_spnego.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/string.h> | 23 | #include <linux/string.h> |
24 | #include <keys/user-type.h> | 24 | #include <keys/user-type.h> |
25 | #include <linux/key-type.h> | 25 | #include <linux/key-type.h> |
26 | #include <linux/inet.h> | ||
26 | #include "cifsglob.h" | 27 | #include "cifsglob.h" |
27 | #include "cifs_spnego.h" | 28 | #include "cifs_spnego.h" |
28 | #include "cifs_debug.h" | 29 | #include "cifs_debug.h" |
@@ -73,9 +74,6 @@ struct key_type cifs_spnego_key_type = { | |||
73 | * strlen(";sec=ntlmsspi") */ | 74 | * strlen(";sec=ntlmsspi") */ |
74 | #define MAX_MECH_STR_LEN 13 | 75 | #define MAX_MECH_STR_LEN 13 |
75 | 76 | ||
76 | /* max possible addr len eg FEDC:BA98:7654:3210:FEDC:BA98:7654:3210/128 */ | ||
77 | #define MAX_IPV6_ADDR_LEN 43 | ||
78 | |||
79 | /* strlen of "host=" */ | 77 | /* strlen of "host=" */ |
80 | #define HOST_KEY_LEN 5 | 78 | #define HOST_KEY_LEN 5 |
81 | 79 | ||
@@ -102,7 +100,7 @@ cifs_get_spnego_key(struct cifsSesInfo *sesInfo) | |||
102 | host=hostname sec=mechanism uid=0xFF user=username */ | 100 | host=hostname sec=mechanism uid=0xFF user=username */ |
103 | desc_len = MAX_VER_STR_LEN + | 101 | desc_len = MAX_VER_STR_LEN + |
104 | HOST_KEY_LEN + strlen(hostname) + | 102 | HOST_KEY_LEN + strlen(hostname) + |
105 | IP_KEY_LEN + MAX_IPV6_ADDR_LEN + | 103 | IP_KEY_LEN + INET6_ADDRSTRLEN + |
106 | MAX_MECH_STR_LEN + | 104 | MAX_MECH_STR_LEN + |
107 | UID_KEY_LEN + (sizeof(uid_t) * 2) + | 105 | UID_KEY_LEN + (sizeof(uid_t) * 2) + |
108 | USER_KEY_LEN + strlen(sesInfo->userName) + 1; | 106 | USER_KEY_LEN + strlen(sesInfo->userName) + 1; |
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 8ae563f028bc..74b5a87e9195 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <linux/namei.h> | 35 | #include <linux/namei.h> |
36 | #include <asm/uaccess.h> | 36 | #include <asm/uaccess.h> |
37 | #include <asm/processor.h> | 37 | #include <asm/processor.h> |
38 | #include <linux/inet.h> | ||
38 | #include <net/ipv6.h> | 39 | #include <net/ipv6.h> |
39 | #include "cifspdu.h" | 40 | #include "cifspdu.h" |
40 | #include "cifsglob.h" | 41 | #include "cifsglob.h" |
@@ -960,7 +961,8 @@ cifs_parse_mount_options(char *options, const char *devname, | |||
960 | } else if (strnicmp(data, "ip", 2) == 0) { | 961 | } else if (strnicmp(data, "ip", 2) == 0) { |
961 | if (!value || !*value) { | 962 | if (!value || !*value) { |
962 | vol->UNCip = NULL; | 963 | vol->UNCip = NULL; |
963 | } else if (strnlen(value, 35) < 35) { | 964 | } else if (strnlen(value, INET6_ADDRSTRLEN) < |
965 | INET6_ADDRSTRLEN) { | ||
964 | vol->UNCip = value; | 966 | vol->UNCip = value; |
965 | } else { | 967 | } else { |
966 | printk(KERN_WARNING "CIFS: ip address " | 968 | printk(KERN_WARNING "CIFS: ip address " |