diff options
Diffstat (limited to 'fs/cifs')
-rw-r--r-- | fs/cifs/CHANGES | 3 | ||||
-rw-r--r-- | fs/cifs/cifs_dfs_ref.c | 25 | ||||
-rw-r--r-- | fs/cifs/cifsfs.c | 66 | ||||
-rw-r--r-- | fs/cifs/cifsfs.h | 2 | ||||
-rw-r--r-- | fs/cifs/cifspdu.h | 2 | ||||
-rw-r--r-- | fs/cifs/dns_resolve.c | 62 |
6 files changed, 104 insertions, 56 deletions
diff --git a/fs/cifs/CHANGES b/fs/cifs/CHANGES index 05c9da6181c3..8355e918fddf 100644 --- a/fs/cifs/CHANGES +++ b/fs/cifs/CHANGES | |||
@@ -1,3 +1,6 @@ | |||
1 | Version 1.53 | ||
2 | ------------ | ||
3 | |||
1 | Version 1.52 | 4 | Version 1.52 |
2 | ------------ | 5 | ------------ |
3 | Fix oops on second mount to server when null auth is used. | 6 | Fix oops on second mount to server when null auth is used. |
diff --git a/fs/cifs/cifs_dfs_ref.c b/fs/cifs/cifs_dfs_ref.c index 95024c066d89..f6fdecf6598c 100644 --- a/fs/cifs/cifs_dfs_ref.c +++ b/fs/cifs/cifs_dfs_ref.c | |||
@@ -93,15 +93,11 @@ static char *cifs_get_share_name(const char *node_name) | |||
93 | /* find sharename end */ | 93 | /* find sharename end */ |
94 | pSep++; | 94 | pSep++; |
95 | pSep = memchr(UNC+(pSep-UNC), '\\', len-(pSep-UNC)); | 95 | pSep = memchr(UNC+(pSep-UNC), '\\', len-(pSep-UNC)); |
96 | if (!pSep) { | 96 | if (pSep) { |
97 | cERROR(1, ("%s:2 cant find share name in node name: %s", | 97 | /* trim path up to sharename end |
98 | __func__, node_name)); | 98 | * now we have share name in UNC */ |
99 | kfree(UNC); | 99 | *pSep = 0; |
100 | return NULL; | ||
101 | } | 100 | } |
102 | /* trim path up to sharename end | ||
103 | * * now we have share name in UNC */ | ||
104 | *pSep = 0; | ||
105 | 101 | ||
106 | return UNC; | 102 | return UNC; |
107 | } | 103 | } |
@@ -188,7 +184,7 @@ static char *compose_mount_options(const char *sb_mountdata, | |||
188 | tkn_e = strchr(tkn_e+1, '\\'); | 184 | tkn_e = strchr(tkn_e+1, '\\'); |
189 | if (tkn_e) { | 185 | if (tkn_e) { |
190 | strcat(mountdata, ",prefixpath="); | 186 | strcat(mountdata, ",prefixpath="); |
191 | strcat(mountdata, tkn_e); | 187 | strcat(mountdata, tkn_e+1); |
192 | } | 188 | } |
193 | } | 189 | } |
194 | 190 | ||
@@ -244,7 +240,8 @@ static char *build_full_dfs_path_from_dentry(struct dentry *dentry) | |||
244 | return NULL; | 240 | return NULL; |
245 | 241 | ||
246 | if (cifs_sb->tcon->Flags & SMB_SHARE_IS_IN_DFS) { | 242 | if (cifs_sb->tcon->Flags & SMB_SHARE_IS_IN_DFS) { |
247 | /* we should use full path name to correct working with DFS */ | 243 | int i; |
244 | /* we should use full path name for correct working with DFS */ | ||
248 | l_max_len = strnlen(cifs_sb->tcon->treeName, MAX_TREE_SIZE+1) + | 245 | l_max_len = strnlen(cifs_sb->tcon->treeName, MAX_TREE_SIZE+1) + |
249 | strnlen(search_path, MAX_PATHCONF) + 1; | 246 | strnlen(search_path, MAX_PATHCONF) + 1; |
250 | tmp_path = kmalloc(l_max_len, GFP_KERNEL); | 247 | tmp_path = kmalloc(l_max_len, GFP_KERNEL); |
@@ -253,8 +250,14 @@ static char *build_full_dfs_path_from_dentry(struct dentry *dentry) | |||
253 | return NULL; | 250 | return NULL; |
254 | } | 251 | } |
255 | strncpy(tmp_path, cifs_sb->tcon->treeName, l_max_len); | 252 | strncpy(tmp_path, cifs_sb->tcon->treeName, l_max_len); |
256 | strcat(tmp_path, search_path); | ||
257 | tmp_path[l_max_len-1] = 0; | 253 | tmp_path[l_max_len-1] = 0; |
254 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS) | ||
255 | for (i = 0; i < l_max_len; i++) { | ||
256 | if (tmp_path[i] == '\\') | ||
257 | tmp_path[i] = '/'; | ||
258 | } | ||
259 | strncat(tmp_path, search_path, l_max_len - strlen(tmp_path)); | ||
260 | |||
258 | full_path = tmp_path; | 261 | full_path = tmp_path; |
259 | kfree(search_path); | 262 | kfree(search_path); |
260 | } else { | 263 | } else { |
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 39c2cbdface7..68f1cdf6aed7 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c | |||
@@ -222,50 +222,50 @@ static int | |||
222 | cifs_statfs(struct dentry *dentry, struct kstatfs *buf) | 222 | cifs_statfs(struct dentry *dentry, struct kstatfs *buf) |
223 | { | 223 | { |
224 | struct super_block *sb = dentry->d_sb; | 224 | struct super_block *sb = dentry->d_sb; |
225 | int xid; | 225 | struct cifs_sb_info *cifs_sb = CIFS_SB(sb); |
226 | struct cifsTconInfo *tcon = cifs_sb->tcon; | ||
226 | int rc = -EOPNOTSUPP; | 227 | int rc = -EOPNOTSUPP; |
227 | struct cifs_sb_info *cifs_sb; | 228 | int xid; |
228 | struct cifsTconInfo *pTcon; | ||
229 | 229 | ||
230 | xid = GetXid(); | 230 | xid = GetXid(); |
231 | 231 | ||
232 | cifs_sb = CIFS_SB(sb); | ||
233 | pTcon = cifs_sb->tcon; | ||
234 | |||
235 | buf->f_type = CIFS_MAGIC_NUMBER; | 232 | buf->f_type = CIFS_MAGIC_NUMBER; |
236 | 233 | ||
237 | /* instead could get the real value via SMB_QUERY_FS_ATTRIBUTE_INFO */ | 234 | /* |
238 | buf->f_namelen = PATH_MAX; /* PATH_MAX may be too long - it would | 235 | * PATH_MAX may be too long - it would presumably be total path, |
239 | presumably be total path, but note | 236 | * but note that some servers (includinng Samba 3) have a shorter |
240 | that some servers (includinng Samba 3) | 237 | * maximum path. |
241 | have a shorter maximum path */ | 238 | * |
239 | * Instead could get the real value via SMB_QUERY_FS_ATTRIBUTE_INFO. | ||
240 | */ | ||
241 | buf->f_namelen = PATH_MAX; | ||
242 | buf->f_files = 0; /* undefined */ | 242 | buf->f_files = 0; /* undefined */ |
243 | buf->f_ffree = 0; /* unlimited */ | 243 | buf->f_ffree = 0; /* unlimited */ |
244 | 244 | ||
245 | /* BB we could add a second check for a QFS Unix capability bit */ | 245 | /* |
246 | /* BB FIXME check CIFS_POSIX_EXTENSIONS Unix cap first FIXME BB */ | 246 | * We could add a second check for a QFS Unix capability bit |
247 | if ((pTcon->ses->capabilities & CAP_UNIX) && (CIFS_POSIX_EXTENSIONS & | 247 | */ |
248 | le64_to_cpu(pTcon->fsUnixInfo.Capability))) | 248 | if ((tcon->ses->capabilities & CAP_UNIX) && |
249 | rc = CIFSSMBQFSPosixInfo(xid, pTcon, buf); | 249 | (CIFS_POSIX_EXTENSIONS & le64_to_cpu(tcon->fsUnixInfo.Capability))) |
250 | 250 | rc = CIFSSMBQFSPosixInfo(xid, tcon, buf); | |
251 | /* Only need to call the old QFSInfo if failed | 251 | |
252 | on newer one */ | 252 | /* |
253 | if (rc) | 253 | * Only need to call the old QFSInfo if failed on newer one, |
254 | if (pTcon->ses->capabilities & CAP_NT_SMBS) | 254 | * e.g. by OS/2. |
255 | rc = CIFSSMBQFSInfo(xid, pTcon, buf); /* not supported by OS2 */ | 255 | **/ |
256 | 256 | if (rc && (tcon->ses->capabilities & CAP_NT_SMBS)) | |
257 | /* Some old Windows servers also do not support level 103, retry with | 257 | rc = CIFSSMBQFSInfo(xid, tcon, buf); |
258 | older level one if old server failed the previous call or we | 258 | |
259 | bypassed it because we detected that this was an older LANMAN sess */ | 259 | /* |
260 | * Some old Windows servers also do not support level 103, retry with | ||
261 | * older level one if old server failed the previous call or we | ||
262 | * bypassed it because we detected that this was an older LANMAN sess | ||
263 | */ | ||
260 | if (rc) | 264 | if (rc) |
261 | rc = SMBOldQFSInfo(xid, pTcon, buf); | 265 | rc = SMBOldQFSInfo(xid, tcon, buf); |
262 | /* int f_type; | 266 | |
263 | __fsid_t f_fsid; | ||
264 | int f_namelen; */ | ||
265 | /* BB get from info in tcon struct at mount time call to QFSAttrInfo */ | ||
266 | FreeXid(xid); | 267 | FreeXid(xid); |
267 | return 0; /* always return success? what if volume is no | 268 | return 0; |
268 | longer available? */ | ||
269 | } | 269 | } |
270 | 270 | ||
271 | static int cifs_permission(struct inode *inode, int mask, struct nameidata *nd) | 271 | static int cifs_permission(struct inode *inode, int mask, struct nameidata *nd) |
diff --git a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h index e1dd9f32e1d7..503f6aa734af 100644 --- a/fs/cifs/cifsfs.h +++ b/fs/cifs/cifsfs.h | |||
@@ -110,5 +110,5 @@ extern int cifs_ioctl(struct inode *inode, struct file *filep, | |||
110 | extern const struct export_operations cifs_export_ops; | 110 | extern const struct export_operations cifs_export_ops; |
111 | #endif /* EXPERIMENTAL */ | 111 | #endif /* EXPERIMENTAL */ |
112 | 112 | ||
113 | #define CIFS_VERSION "1.52" | 113 | #define CIFS_VERSION "1.53" |
114 | #endif /* _CIFSFS_H */ | 114 | #endif /* _CIFSFS_H */ |
diff --git a/fs/cifs/cifspdu.h b/fs/cifs/cifspdu.h index 9f49c2f3582c..a0d26b540d4e 100644 --- a/fs/cifs/cifspdu.h +++ b/fs/cifs/cifspdu.h | |||
@@ -2050,7 +2050,7 @@ typedef struct { | |||
2050 | to 0xFFFF00 */ | 2050 | to 0xFFFF00 */ |
2051 | #define CIFS_UNIX_LARGE_WRITE_CAP 0x00000080 | 2051 | #define CIFS_UNIX_LARGE_WRITE_CAP 0x00000080 |
2052 | #define CIFS_UNIX_TRANSPORT_ENCRYPTION_CAP 0x00000100 /* can do SPNEGO crypt */ | 2052 | #define CIFS_UNIX_TRANSPORT_ENCRYPTION_CAP 0x00000100 /* can do SPNEGO crypt */ |
2053 | #define CIFS_UNIX_TRANPSORT_ENCRYPTION_MANDATORY_CAP 0x00000200 /* must do */ | 2053 | #define CIFS_UNIX_TRANSPORT_ENCRYPTION_MANDATORY_CAP 0x00000200 /* must do */ |
2054 | #define CIFS_UNIX_PROXY_CAP 0x00000400 /* Proxy cap: 0xACE ioctl and | 2054 | #define CIFS_UNIX_PROXY_CAP 0x00000400 /* Proxy cap: 0xACE ioctl and |
2055 | QFS PROXY call */ | 2055 | QFS PROXY call */ |
2056 | #ifdef CONFIG_CIFS_POSIX | 2056 | #ifdef CONFIG_CIFS_POSIX |
diff --git a/fs/cifs/dns_resolve.c b/fs/cifs/dns_resolve.c index 7cc86c418182..939e256f8497 100644 --- a/fs/cifs/dns_resolve.c +++ b/fs/cifs/dns_resolve.c | |||
@@ -55,6 +55,32 @@ struct key_type key_type_dns_resolver = { | |||
55 | .match = user_match, | 55 | .match = user_match, |
56 | }; | 56 | }; |
57 | 57 | ||
58 | /* Checks if supplied name is IP address | ||
59 | * returns: | ||
60 | * 1 - name is IP | ||
61 | * 0 - name is not IP | ||
62 | */ | ||
63 | static int is_ip(const char *name) | ||
64 | { | ||
65 | int rc; | ||
66 | struct sockaddr_in sin_server; | ||
67 | struct sockaddr_in6 sin_server6; | ||
68 | |||
69 | rc = cifs_inet_pton(AF_INET, name, | ||
70 | &sin_server.sin_addr.s_addr); | ||
71 | |||
72 | if (rc <= 0) { | ||
73 | /* not ipv4 address, try ipv6 */ | ||
74 | rc = cifs_inet_pton(AF_INET6, name, | ||
75 | &sin_server6.sin6_addr.in6_u); | ||
76 | if (rc > 0) | ||
77 | return 1; | ||
78 | } else { | ||
79 | return 1; | ||
80 | } | ||
81 | /* we failed translating address */ | ||
82 | return 0; | ||
83 | } | ||
58 | 84 | ||
59 | /* Resolves server name to ip address. | 85 | /* Resolves server name to ip address. |
60 | * input: | 86 | * input: |
@@ -67,8 +93,9 @@ int | |||
67 | dns_resolve_server_name_to_ip(const char *unc, char **ip_addr) | 93 | dns_resolve_server_name_to_ip(const char *unc, char **ip_addr) |
68 | { | 94 | { |
69 | int rc = -EAGAIN; | 95 | int rc = -EAGAIN; |
70 | struct key *rkey; | 96 | struct key *rkey = ERR_PTR(-EAGAIN); |
71 | char *name; | 97 | char *name; |
98 | char *data = NULL; | ||
72 | int len; | 99 | int len; |
73 | 100 | ||
74 | if (!ip_addr || !unc) | 101 | if (!ip_addr || !unc) |
@@ -97,26 +124,41 @@ dns_resolve_server_name_to_ip(const char *unc, char **ip_addr) | |||
97 | memcpy(name, unc+2, len); | 124 | memcpy(name, unc+2, len); |
98 | name[len] = 0; | 125 | name[len] = 0; |
99 | 126 | ||
127 | if (is_ip(name)) { | ||
128 | cFYI(1, ("%s: it is IP, skipping dns upcall: %s", | ||
129 | __func__, name)); | ||
130 | data = name; | ||
131 | goto skip_upcall; | ||
132 | } | ||
133 | |||
100 | rkey = request_key(&key_type_dns_resolver, name, ""); | 134 | rkey = request_key(&key_type_dns_resolver, name, ""); |
101 | if (!IS_ERR(rkey)) { | 135 | if (!IS_ERR(rkey)) { |
102 | len = strlen(rkey->payload.data); | 136 | data = rkey->payload.data; |
103 | *ip_addr = kmalloc(len+1, GFP_KERNEL); | 137 | cFYI(1, ("%s: resolved: %s to %s", __func__, |
104 | if (*ip_addr) { | ||
105 | memcpy(*ip_addr, rkey->payload.data, len); | ||
106 | (*ip_addr)[len] = '\0'; | ||
107 | cFYI(1, ("%s: resolved: %s to %s", __func__, | ||
108 | rkey->description, | 138 | rkey->description, |
109 | *ip_addr | 139 | *ip_addr |
110 | )); | 140 | )); |
141 | } else { | ||
142 | cERROR(1, ("%s: unable to resolve: %s", __func__, name)); | ||
143 | goto out; | ||
144 | } | ||
145 | |||
146 | skip_upcall: | ||
147 | if (data) { | ||
148 | len = strlen(data); | ||
149 | *ip_addr = kmalloc(len+1, GFP_KERNEL); | ||
150 | if (*ip_addr) { | ||
151 | memcpy(*ip_addr, data, len); | ||
152 | (*ip_addr)[len] = '\0'; | ||
111 | rc = 0; | 153 | rc = 0; |
112 | } else { | 154 | } else { |
113 | rc = -ENOMEM; | 155 | rc = -ENOMEM; |
114 | } | 156 | } |
115 | key_put(rkey); | 157 | if (!IS_ERR(rkey)) |
116 | } else { | 158 | key_put(rkey); |
117 | cERROR(1, ("%s: unable to resolve: %s", __func__, name)); | ||
118 | } | 159 | } |
119 | 160 | ||
161 | out: | ||
120 | kfree(name); | 162 | kfree(name); |
121 | return rc; | 163 | return rc; |
122 | } | 164 | } |