diff options
Diffstat (limited to 'fs/cifs/connect.c')
-rw-r--r-- | fs/cifs/connect.c | 1262 |
1 files changed, 693 insertions, 569 deletions
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 0a1b8bd1dfcb..4af3588c1a96 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * fs/cifs/connect.c | 2 | * fs/cifs/connect.c |
3 | * | 3 | * |
4 | * Copyright (C) International Business Machines Corp., 2002,2006 | 4 | * Copyright (C) International Business Machines Corp., 2002,2007 |
5 | * Author(s): Steve French (sfrench@us.ibm.com) | 5 | * Author(s): Steve French (sfrench@us.ibm.com) |
6 | * | 6 | * |
7 | * This library is free software; you can redistribute it and/or modify | 7 | * This library is free software; you can redistribute it and/or modify |
@@ -16,7 +16,7 @@ | |||
16 | * | 16 | * |
17 | * You should have received a copy of the GNU Lesser General Public License | 17 | * You should have received a copy of the GNU Lesser General Public License |
18 | * along with this library; if not, write to the Free Software | 18 | * along with this library; if not, write to the Free Software |
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
20 | */ | 20 | */ |
21 | #include <linux/fs.h> | 21 | #include <linux/fs.h> |
22 | #include <linux/net.h> | 22 | #include <linux/net.h> |
@@ -85,6 +85,7 @@ struct smb_vol { | |||
85 | unsigned direct_io:1; | 85 | unsigned direct_io:1; |
86 | unsigned remap:1; /* set to remap seven reserved chars in filenames */ | 86 | unsigned remap:1; /* set to remap seven reserved chars in filenames */ |
87 | unsigned posix_paths:1; /* unset to not ask for posix pathnames. */ | 87 | unsigned posix_paths:1; /* unset to not ask for posix pathnames. */ |
88 | unsigned no_linux_ext:1; | ||
88 | unsigned sfu_emul:1; | 89 | unsigned sfu_emul:1; |
89 | unsigned nullauth:1; /* attempt to authenticate with null user */ | 90 | unsigned nullauth:1; /* attempt to authenticate with null user */ |
90 | unsigned nocase; /* request case insensitive filenames */ | 91 | unsigned nocase; /* request case insensitive filenames */ |
@@ -93,20 +94,20 @@ struct smb_vol { | |||
93 | unsigned int wsize; | 94 | unsigned int wsize; |
94 | unsigned int sockopt; | 95 | unsigned int sockopt; |
95 | unsigned short int port; | 96 | unsigned short int port; |
96 | char * prepath; | 97 | char *prepath; |
97 | }; | 98 | }; |
98 | 99 | ||
99 | static int ipv4_connect(struct sockaddr_in *psin_server, | 100 | static int ipv4_connect(struct sockaddr_in *psin_server, |
100 | struct socket **csocket, | 101 | struct socket **csocket, |
101 | char * netb_name, | 102 | char *netb_name, |
102 | char * server_netb_name); | 103 | char *server_netb_name); |
103 | static int ipv6_connect(struct sockaddr_in6 *psin_server, | 104 | static int ipv6_connect(struct sockaddr_in6 *psin_server, |
104 | struct socket **csocket); | 105 | struct socket **csocket); |
105 | 106 | ||
106 | 107 | ||
107 | /* | 108 | /* |
108 | * cifs tcp session reconnection | 109 | * cifs tcp session reconnection |
109 | * | 110 | * |
110 | * mark tcp session as reconnecting so temporarily locked | 111 | * mark tcp session as reconnecting so temporarily locked |
111 | * mark all smb sessions as reconnecting for tcp session | 112 | * mark all smb sessions as reconnecting for tcp session |
112 | * reconnect tcp session | 113 | * reconnect tcp session |
@@ -120,11 +121,11 @@ cifs_reconnect(struct TCP_Server_Info *server) | |||
120 | struct list_head *tmp; | 121 | struct list_head *tmp; |
121 | struct cifsSesInfo *ses; | 122 | struct cifsSesInfo *ses; |
122 | struct cifsTconInfo *tcon; | 123 | struct cifsTconInfo *tcon; |
123 | struct mid_q_entry * mid_entry; | 124 | struct mid_q_entry *mid_entry; |
124 | 125 | ||
125 | spin_lock(&GlobalMid_Lock); | 126 | spin_lock(&GlobalMid_Lock); |
126 | if( kthread_should_stop() ) { | 127 | if ( kthread_should_stop() ) { |
127 | /* the demux thread will exit normally | 128 | /* the demux thread will exit normally |
128 | next time through the loop */ | 129 | next time through the loop */ |
129 | spin_unlock(&GlobalMid_Lock); | 130 | spin_unlock(&GlobalMid_Lock); |
130 | return rc; | 131 | return rc; |
@@ -150,18 +151,19 @@ cifs_reconnect(struct TCP_Server_Info *server) | |||
150 | } | 151 | } |
151 | list_for_each(tmp, &GlobalTreeConnectionList) { | 152 | list_for_each(tmp, &GlobalTreeConnectionList) { |
152 | tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); | 153 | tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); |
153 | if((tcon) && (tcon->ses) && (tcon->ses->server == server)) { | 154 | if ((tcon) && (tcon->ses) && (tcon->ses->server == server)) { |
154 | tcon->tidStatus = CifsNeedReconnect; | 155 | tcon->tidStatus = CifsNeedReconnect; |
155 | } | 156 | } |
156 | } | 157 | } |
157 | read_unlock(&GlobalSMBSeslock); | 158 | read_unlock(&GlobalSMBSeslock); |
158 | /* do not want to be sending data on a socket we are freeing */ | 159 | /* do not want to be sending data on a socket we are freeing */ |
159 | down(&server->tcpSem); | 160 | down(&server->tcpSem); |
160 | if(server->ssocket) { | 161 | if (server->ssocket) { |
161 | cFYI(1,("State: 0x%x Flags: 0x%lx", server->ssocket->state, | 162 | cFYI(1, ("State: 0x%x Flags: 0x%lx", server->ssocket->state, |
162 | server->ssocket->flags)); | 163 | server->ssocket->flags)); |
163 | server->ssocket->ops->shutdown(server->ssocket,SEND_SHUTDOWN); | 164 | server->ssocket->ops->shutdown(server->ssocket, SEND_SHUTDOWN); |
164 | cFYI(1,("Post shutdown state: 0x%x Flags: 0x%lx", server->ssocket->state, | 165 | cFYI(1, ("Post shutdown state: 0x%x Flags: 0x%lx", |
166 | server->ssocket->state, | ||
165 | server->ssocket->flags)); | 167 | server->ssocket->flags)); |
166 | sock_release(server->ssocket); | 168 | sock_release(server->ssocket); |
167 | server->ssocket = NULL; | 169 | server->ssocket = NULL; |
@@ -172,8 +174,8 @@ cifs_reconnect(struct TCP_Server_Info *server) | |||
172 | mid_entry = list_entry(tmp, struct | 174 | mid_entry = list_entry(tmp, struct |
173 | mid_q_entry, | 175 | mid_q_entry, |
174 | qhead); | 176 | qhead); |
175 | if(mid_entry) { | 177 | if (mid_entry) { |
176 | if(mid_entry->midState == MID_REQUEST_SUBMITTED) { | 178 | if (mid_entry->midState == MID_REQUEST_SUBMITTED) { |
177 | /* Mark other intransit requests as needing | 179 | /* Mark other intransit requests as needing |
178 | retry so we do not immediately mark the | 180 | retry so we do not immediately mark the |
179 | session bad again (ie after we reconnect | 181 | session bad again (ie after we reconnect |
@@ -183,29 +185,29 @@ cifs_reconnect(struct TCP_Server_Info *server) | |||
183 | } | 185 | } |
184 | } | 186 | } |
185 | spin_unlock(&GlobalMid_Lock); | 187 | spin_unlock(&GlobalMid_Lock); |
186 | up(&server->tcpSem); | 188 | up(&server->tcpSem); |
187 | 189 | ||
188 | while ( (!kthread_should_stop()) && (server->tcpStatus != CifsGood)) | 190 | while ( (!kthread_should_stop()) && (server->tcpStatus != CifsGood)) { |
189 | { | ||
190 | try_to_freeze(); | 191 | try_to_freeze(); |
191 | if(server->protocolType == IPV6) { | 192 | if (server->protocolType == IPV6) { |
192 | rc = ipv6_connect(&server->addr.sockAddr6,&server->ssocket); | 193 | rc = ipv6_connect(&server->addr.sockAddr6, |
194 | &server->ssocket); | ||
193 | } else { | 195 | } else { |
194 | rc = ipv4_connect(&server->addr.sockAddr, | 196 | rc = ipv4_connect(&server->addr.sockAddr, |
195 | &server->ssocket, | 197 | &server->ssocket, |
196 | server->workstation_RFC1001_name, | 198 | server->workstation_RFC1001_name, |
197 | server->server_RFC1001_name); | 199 | server->server_RFC1001_name); |
198 | } | 200 | } |
199 | if(rc) { | 201 | if (rc) { |
200 | cFYI(1,("reconnect error %d",rc)); | 202 | cFYI(1, ("reconnect error %d", rc)); |
201 | msleep(3000); | 203 | msleep(3000); |
202 | } else { | 204 | } else { |
203 | atomic_inc(&tcpSesReconnectCount); | 205 | atomic_inc(&tcpSesReconnectCount); |
204 | spin_lock(&GlobalMid_Lock); | 206 | spin_lock(&GlobalMid_Lock); |
205 | if( !kthread_should_stop() ) | 207 | if ( !kthread_should_stop() ) |
206 | server->tcpStatus = CifsGood; | 208 | server->tcpStatus = CifsGood; |
207 | server->sequence_number = 0; | 209 | server->sequence_number = 0; |
208 | spin_unlock(&GlobalMid_Lock); | 210 | spin_unlock(&GlobalMid_Lock); |
209 | /* atomic_set(&server->inFlight,0);*/ | 211 | /* atomic_set(&server->inFlight,0);*/ |
210 | wake_up(&server->response_q); | 212 | wake_up(&server->response_q); |
211 | } | 213 | } |
@@ -213,27 +215,27 @@ cifs_reconnect(struct TCP_Server_Info *server) | |||
213 | return rc; | 215 | return rc; |
214 | } | 216 | } |
215 | 217 | ||
216 | /* | 218 | /* |
217 | return codes: | 219 | return codes: |
218 | 0 not a transact2, or all data present | 220 | 0 not a transact2, or all data present |
219 | >0 transact2 with that much data missing | 221 | >0 transact2 with that much data missing |
220 | -EINVAL = invalid transact2 | 222 | -EINVAL = invalid transact2 |
221 | 223 | ||
222 | */ | 224 | */ |
223 | static int check2ndT2(struct smb_hdr * pSMB, unsigned int maxBufSize) | 225 | static int check2ndT2(struct smb_hdr *pSMB, unsigned int maxBufSize) |
224 | { | 226 | { |
225 | struct smb_t2_rsp * pSMBt; | 227 | struct smb_t2_rsp *pSMBt; |
226 | int total_data_size; | 228 | int total_data_size; |
227 | int data_in_this_rsp; | 229 | int data_in_this_rsp; |
228 | int remaining; | 230 | int remaining; |
229 | 231 | ||
230 | if(pSMB->Command != SMB_COM_TRANSACTION2) | 232 | if (pSMB->Command != SMB_COM_TRANSACTION2) |
231 | return 0; | 233 | return 0; |
232 | 234 | ||
233 | /* check for plausible wct, bcc and t2 data and parm sizes */ | 235 | /* check for plausible wct, bcc and t2 data and parm sizes */ |
234 | /* check for parm and data offset going beyond end of smb */ | 236 | /* check for parm and data offset going beyond end of smb */ |
235 | if(pSMB->WordCount != 10) { /* coalesce_t2 depends on this */ | 237 | if (pSMB->WordCount != 10) { /* coalesce_t2 depends on this */ |
236 | cFYI(1,("invalid transact2 word count")); | 238 | cFYI(1, ("invalid transact2 word count")); |
237 | return -EINVAL; | 239 | return -EINVAL; |
238 | } | 240 | } |
239 | 241 | ||
@@ -244,25 +246,25 @@ static int check2ndT2(struct smb_hdr * pSMB, unsigned int maxBufSize) | |||
244 | 246 | ||
245 | remaining = total_data_size - data_in_this_rsp; | 247 | remaining = total_data_size - data_in_this_rsp; |
246 | 248 | ||
247 | if(remaining == 0) | 249 | if (remaining == 0) |
248 | return 0; | 250 | return 0; |
249 | else if(remaining < 0) { | 251 | else if (remaining < 0) { |
250 | cFYI(1,("total data %d smaller than data in frame %d", | 252 | cFYI(1, ("total data %d smaller than data in frame %d", |
251 | total_data_size, data_in_this_rsp)); | 253 | total_data_size, data_in_this_rsp)); |
252 | return -EINVAL; | 254 | return -EINVAL; |
253 | } else { | 255 | } else { |
254 | cFYI(1,("missing %d bytes from transact2, check next response", | 256 | cFYI(1, ("missing %d bytes from transact2, check next response", |
255 | remaining)); | 257 | remaining)); |
256 | if(total_data_size > maxBufSize) { | 258 | if (total_data_size > maxBufSize) { |
257 | cERROR(1,("TotalDataSize %d is over maximum buffer %d", | 259 | cERROR(1, ("TotalDataSize %d is over maximum buffer %d", |
258 | total_data_size,maxBufSize)); | 260 | total_data_size, maxBufSize)); |
259 | return -EINVAL; | 261 | return -EINVAL; |
260 | } | 262 | } |
261 | return remaining; | 263 | return remaining; |
262 | } | 264 | } |
263 | } | 265 | } |
264 | 266 | ||
265 | static int coalesce_t2(struct smb_hdr * psecond, struct smb_hdr *pTargetSMB) | 267 | static int coalesce_t2(struct smb_hdr *psecond, struct smb_hdr *pTargetSMB) |
266 | { | 268 | { |
267 | struct smb_t2_rsp *pSMB2 = (struct smb_t2_rsp *)psecond; | 269 | struct smb_t2_rsp *pSMB2 = (struct smb_t2_rsp *)psecond; |
268 | struct smb_t2_rsp *pSMBt = (struct smb_t2_rsp *)pTargetSMB; | 270 | struct smb_t2_rsp *pSMBt = (struct smb_t2_rsp *)pTargetSMB; |
@@ -270,43 +272,43 @@ static int coalesce_t2(struct smb_hdr * psecond, struct smb_hdr *pTargetSMB) | |||
270 | int total_in_buf; | 272 | int total_in_buf; |
271 | int remaining; | 273 | int remaining; |
272 | int total_in_buf2; | 274 | int total_in_buf2; |
273 | char * data_area_of_target; | 275 | char *data_area_of_target; |
274 | char * data_area_of_buf2; | 276 | char *data_area_of_buf2; |
275 | __u16 byte_count; | 277 | __u16 byte_count; |
276 | 278 | ||
277 | total_data_size = le16_to_cpu(pSMBt->t2_rsp.TotalDataCount); | 279 | total_data_size = le16_to_cpu(pSMBt->t2_rsp.TotalDataCount); |
278 | 280 | ||
279 | if(total_data_size != le16_to_cpu(pSMB2->t2_rsp.TotalDataCount)) { | 281 | if (total_data_size != le16_to_cpu(pSMB2->t2_rsp.TotalDataCount)) { |
280 | cFYI(1,("total data sizes of primary and secondary t2 differ")); | 282 | cFYI(1, ("total data size of primary and secondary t2 differ")); |
281 | } | 283 | } |
282 | 284 | ||
283 | total_in_buf = le16_to_cpu(pSMBt->t2_rsp.DataCount); | 285 | total_in_buf = le16_to_cpu(pSMBt->t2_rsp.DataCount); |
284 | 286 | ||
285 | remaining = total_data_size - total_in_buf; | 287 | remaining = total_data_size - total_in_buf; |
286 | 288 | ||
287 | if(remaining < 0) | 289 | if (remaining < 0) |
288 | return -EINVAL; | 290 | return -EINVAL; |
289 | 291 | ||
290 | if(remaining == 0) /* nothing to do, ignore */ | 292 | if (remaining == 0) /* nothing to do, ignore */ |
291 | return 0; | 293 | return 0; |
292 | 294 | ||
293 | total_in_buf2 = le16_to_cpu(pSMB2->t2_rsp.DataCount); | 295 | total_in_buf2 = le16_to_cpu(pSMB2->t2_rsp.DataCount); |
294 | if(remaining < total_in_buf2) { | 296 | if (remaining < total_in_buf2) { |
295 | cFYI(1,("transact2 2nd response contains too much data")); | 297 | cFYI(1, ("transact2 2nd response contains too much data")); |
296 | } | 298 | } |
297 | 299 | ||
298 | /* find end of first SMB data area */ | 300 | /* find end of first SMB data area */ |
299 | data_area_of_target = (char *)&pSMBt->hdr.Protocol + | 301 | data_area_of_target = (char *)&pSMBt->hdr.Protocol + |
300 | le16_to_cpu(pSMBt->t2_rsp.DataOffset); | 302 | le16_to_cpu(pSMBt->t2_rsp.DataOffset); |
301 | /* validate target area */ | 303 | /* validate target area */ |
302 | 304 | ||
303 | data_area_of_buf2 = (char *) &pSMB2->hdr.Protocol + | 305 | data_area_of_buf2 = (char *) &pSMB2->hdr.Protocol + |
304 | le16_to_cpu(pSMB2->t2_rsp.DataOffset); | 306 | le16_to_cpu(pSMB2->t2_rsp.DataOffset); |
305 | 307 | ||
306 | data_area_of_target += total_in_buf; | 308 | data_area_of_target += total_in_buf; |
307 | 309 | ||
308 | /* copy second buffer into end of first buffer */ | 310 | /* copy second buffer into end of first buffer */ |
309 | memcpy(data_area_of_target,data_area_of_buf2,total_in_buf2); | 311 | memcpy(data_area_of_target, data_area_of_buf2, total_in_buf2); |
310 | total_in_buf += total_in_buf2; | 312 | total_in_buf += total_in_buf2; |
311 | pSMBt->t2_rsp.DataCount = cpu_to_le16(total_in_buf); | 313 | pSMBt->t2_rsp.DataCount = cpu_to_le16(total_in_buf); |
312 | byte_count = le16_to_cpu(BCC_LE(pTargetSMB)); | 314 | byte_count = le16_to_cpu(BCC_LE(pTargetSMB)); |
@@ -317,11 +319,11 @@ static int coalesce_t2(struct smb_hdr * psecond, struct smb_hdr *pTargetSMB) | |||
317 | byte_count += total_in_buf2; | 319 | byte_count += total_in_buf2; |
318 | 320 | ||
319 | /* BB also add check that we are not beyond maximum buffer size */ | 321 | /* BB also add check that we are not beyond maximum buffer size */ |
320 | 322 | ||
321 | pTargetSMB->smb_buf_length = byte_count; | 323 | pTargetSMB->smb_buf_length = byte_count; |
322 | 324 | ||
323 | if(remaining == total_in_buf2) { | 325 | if (remaining == total_in_buf2) { |
324 | cFYI(1,("found the last secondary response")); | 326 | cFYI(1, ("found the last secondary response")); |
325 | return 0; /* we are done */ | 327 | return 0; /* we are done */ |
326 | } else /* more responses to go */ | 328 | } else /* more responses to go */ |
327 | return 1; | 329 | return 1; |
@@ -348,16 +350,15 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) | |||
348 | int isMultiRsp; | 350 | int isMultiRsp; |
349 | int reconnect; | 351 | int reconnect; |
350 | 352 | ||
351 | allow_signal(SIGKILL); | ||
352 | current->flags |= PF_MEMALLOC; | 353 | current->flags |= PF_MEMALLOC; |
353 | server->tsk = current; /* save process info to wake at shutdown */ | 354 | server->tsk = current; /* save process info to wake at shutdown */ |
354 | cFYI(1, ("Demultiplex PID: %d", current->pid)); | 355 | cFYI(1, ("Demultiplex PID: %d", current->pid)); |
355 | write_lock(&GlobalSMBSeslock); | 356 | write_lock(&GlobalSMBSeslock); |
356 | atomic_inc(&tcpSesAllocCount); | 357 | atomic_inc(&tcpSesAllocCount); |
357 | length = tcpSesAllocCount.counter; | 358 | length = tcpSesAllocCount.counter; |
358 | write_unlock(&GlobalSMBSeslock); | 359 | write_unlock(&GlobalSMBSeslock); |
359 | complete(&cifsd_complete); | 360 | complete(&cifsd_complete); |
360 | if(length > 1) { | 361 | if (length > 1) { |
361 | mempool_resize(cifs_req_poolp, | 362 | mempool_resize(cifs_req_poolp, |
362 | length + cifs_min_rcv, | 363 | length + cifs_min_rcv, |
363 | GFP_KERNEL); | 364 | GFP_KERNEL); |
@@ -426,10 +427,10 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) | |||
426 | break; | 427 | break; |
427 | } | 428 | } |
428 | if (!try_to_freeze() && (length == -EINTR)) { | 429 | if (!try_to_freeze() && (length == -EINTR)) { |
429 | cFYI(1,("cifsd thread killed")); | 430 | cFYI(1, ("cifsd thread killed")); |
430 | break; | 431 | break; |
431 | } | 432 | } |
432 | cFYI(1,("Reconnect after unexpected peek error %d", | 433 | cFYI(1, ("Reconnect after unexpected peek error %d", |
433 | length)); | 434 | length)); |
434 | cifs_reconnect(server); | 435 | cifs_reconnect(server); |
435 | csocket = server->ssocket; | 436 | csocket = server->ssocket; |
@@ -453,26 +454,26 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) | |||
453 | with the most common, zero, as regular data */ | 454 | with the most common, zero, as regular data */ |
454 | temp = *((char *) smb_buffer); | 455 | temp = *((char *) smb_buffer); |
455 | 456 | ||
456 | /* Note that FC 1001 length is big endian on the wire, | 457 | /* Note that FC 1001 length is big endian on the wire, |
457 | but we convert it here so it is always manipulated | 458 | but we convert it here so it is always manipulated |
458 | as host byte order */ | 459 | as host byte order */ |
459 | pdu_length = ntohl(smb_buffer->smb_buf_length); | 460 | pdu_length = ntohl(smb_buffer->smb_buf_length); |
460 | smb_buffer->smb_buf_length = pdu_length; | 461 | smb_buffer->smb_buf_length = pdu_length; |
461 | 462 | ||
462 | cFYI(1,("rfc1002 length 0x%x)", pdu_length+4)); | 463 | cFYI(1, ("rfc1002 length 0x%x", pdu_length+4)); |
463 | 464 | ||
464 | if (temp == (char) RFC1002_SESSION_KEEP_ALIVE) { | 465 | if (temp == (char) RFC1002_SESSION_KEEP_ALIVE) { |
465 | continue; | 466 | continue; |
466 | } else if (temp == (char)RFC1002_POSITIVE_SESSION_RESPONSE) { | 467 | } else if (temp == (char)RFC1002_POSITIVE_SESSION_RESPONSE) { |
467 | cFYI(1,("Good RFC 1002 session rsp")); | 468 | cFYI(1, ("Good RFC 1002 session rsp")); |
468 | continue; | 469 | continue; |
469 | } else if (temp == (char)RFC1002_NEGATIVE_SESSION_RESPONSE) { | 470 | } else if (temp == (char)RFC1002_NEGATIVE_SESSION_RESPONSE) { |
470 | /* we get this from Windows 98 instead of | 471 | /* we get this from Windows 98 instead of |
471 | an error on SMB negprot response */ | 472 | an error on SMB negprot response */ |
472 | cFYI(1,("Negative RFC1002 Session Response Error 0x%x)", | 473 | cFYI(1, ("Negative RFC1002 Session Response Error 0x%x)", |
473 | pdu_length)); | 474 | pdu_length)); |
474 | if(server->tcpStatus == CifsNew) { | 475 | if (server->tcpStatus == CifsNew) { |
475 | /* if nack on negprot (rather than | 476 | /* if nack on negprot (rather than |
476 | ret of smb negprot error) reconnecting | 477 | ret of smb negprot error) reconnecting |
477 | not going to help, ret error to mount */ | 478 | not going to help, ret error to mount */ |
478 | break; | 479 | break; |
@@ -482,10 +483,10 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) | |||
482 | msleep(1000); | 483 | msleep(1000); |
483 | /* always try 445 first on reconnect | 484 | /* always try 445 first on reconnect |
484 | since we get NACK on some if we ever | 485 | since we get NACK on some if we ever |
485 | connected to port 139 (the NACK is | 486 | connected to port 139 (the NACK is |
486 | since we do not begin with RFC1001 | 487 | since we do not begin with RFC1001 |
487 | session initialize frame) */ | 488 | session initialize frame) */ |
488 | server->addr.sockAddr.sin_port = | 489 | server->addr.sockAddr.sin_port = |
489 | htons(CIFS_PORT); | 490 | htons(CIFS_PORT); |
490 | cifs_reconnect(server); | 491 | cifs_reconnect(server); |
491 | csocket = server->ssocket; | 492 | csocket = server->ssocket; |
@@ -493,7 +494,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) | |||
493 | continue; | 494 | continue; |
494 | } | 495 | } |
495 | } else if (temp != (char) 0) { | 496 | } else if (temp != (char) 0) { |
496 | cERROR(1,("Unknown RFC 1002 frame")); | 497 | cERROR(1, ("Unknown RFC 1002 frame")); |
497 | cifs_dump_mem(" Received Data: ", (char *)smb_buffer, | 498 | cifs_dump_mem(" Received Data: ", (char *)smb_buffer, |
498 | length); | 499 | length); |
499 | cifs_reconnect(server); | 500 | cifs_reconnect(server); |
@@ -502,7 +503,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) | |||
502 | } | 503 | } |
503 | 504 | ||
504 | /* else we have an SMB response */ | 505 | /* else we have an SMB response */ |
505 | if((pdu_length > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) || | 506 | if ((pdu_length > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) || |
506 | (pdu_length < sizeof (struct smb_hdr) - 1 - 4)) { | 507 | (pdu_length < sizeof (struct smb_hdr) - 1 - 4)) { |
507 | cERROR(1, ("Invalid size SMB length %d pdu_length %d", | 508 | cERROR(1, ("Invalid size SMB length %d pdu_length %d", |
508 | length, pdu_length+4)); | 509 | length, pdu_length+4)); |
@@ -510,12 +511,12 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) | |||
510 | csocket = server->ssocket; | 511 | csocket = server->ssocket; |
511 | wake_up(&server->response_q); | 512 | wake_up(&server->response_q); |
512 | continue; | 513 | continue; |
513 | } | 514 | } |
514 | 515 | ||
515 | /* else length ok */ | 516 | /* else length ok */ |
516 | reconnect = 0; | 517 | reconnect = 0; |
517 | 518 | ||
518 | if(pdu_length > MAX_CIFS_SMALL_BUFFER_SIZE - 4) { | 519 | if (pdu_length > MAX_CIFS_SMALL_BUFFER_SIZE - 4) { |
519 | isLargeBuf = TRUE; | 520 | isLargeBuf = TRUE; |
520 | memcpy(bigbuf, smallbuf, 4); | 521 | memcpy(bigbuf, smallbuf, 4); |
521 | smb_buffer = bigbuf; | 522 | smb_buffer = bigbuf; |
@@ -523,11 +524,11 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) | |||
523 | length = 0; | 524 | length = 0; |
524 | iov.iov_base = 4 + (char *)smb_buffer; | 525 | iov.iov_base = 4 + (char *)smb_buffer; |
525 | iov.iov_len = pdu_length; | 526 | iov.iov_len = pdu_length; |
526 | for (total_read = 0; total_read < pdu_length; | 527 | for (total_read = 0; total_read < pdu_length; |
527 | total_read += length) { | 528 | total_read += length) { |
528 | length = kernel_recvmsg(csocket, &smb_msg, &iov, 1, | 529 | length = kernel_recvmsg(csocket, &smb_msg, &iov, 1, |
529 | pdu_length - total_read, 0); | 530 | pdu_length - total_read, 0); |
530 | if( kthread_should_stop() || | 531 | if ( kthread_should_stop() || |
531 | (length == -EINTR)) { | 532 | (length == -EINTR)) { |
532 | /* then will exit */ | 533 | /* then will exit */ |
533 | reconnect = 2; | 534 | reconnect = 2; |
@@ -535,19 +536,19 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) | |||
535 | } else if (server->tcpStatus == CifsNeedReconnect) { | 536 | } else if (server->tcpStatus == CifsNeedReconnect) { |
536 | cifs_reconnect(server); | 537 | cifs_reconnect(server); |
537 | csocket = server->ssocket; | 538 | csocket = server->ssocket; |
538 | /* Reconnect wakes up rspns q */ | 539 | /* Reconnect wakes up rspns q */ |
539 | /* Now we will reread sock */ | 540 | /* Now we will reread sock */ |
540 | reconnect = 1; | 541 | reconnect = 1; |
541 | break; | 542 | break; |
542 | } else if ((length == -ERESTARTSYS) || | 543 | } else if ((length == -ERESTARTSYS) || |
543 | (length == -EAGAIN)) { | 544 | (length == -EAGAIN)) { |
544 | msleep(1); /* minimum sleep to prevent looping, | 545 | msleep(1); /* minimum sleep to prevent looping, |
545 | allowing socket to clear and app | 546 | allowing socket to clear and app |
546 | threads to set tcpStatus | 547 | threads to set tcpStatus |
547 | CifsNeedReconnect if server hung*/ | 548 | CifsNeedReconnect if server hung*/ |
548 | continue; | 549 | continue; |
549 | } else if (length <= 0) { | 550 | } else if (length <= 0) { |
550 | cERROR(1,("Received no data, expecting %d", | 551 | cERROR(1, ("Received no data, expecting %d", |
551 | pdu_length - total_read)); | 552 | pdu_length - total_read)); |
552 | cifs_reconnect(server); | 553 | cifs_reconnect(server); |
553 | csocket = server->ssocket; | 554 | csocket = server->ssocket; |
@@ -555,13 +556,13 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) | |||
555 | break; | 556 | break; |
556 | } | 557 | } |
557 | } | 558 | } |
558 | if(reconnect == 2) | 559 | if (reconnect == 2) |
559 | break; | 560 | break; |
560 | else if(reconnect == 1) | 561 | else if (reconnect == 1) |
561 | continue; | 562 | continue; |
562 | 563 | ||
563 | length += 4; /* account for rfc1002 hdr */ | 564 | length += 4; /* account for rfc1002 hdr */ |
564 | 565 | ||
565 | 566 | ||
566 | dump_smb(smb_buffer, length); | 567 | dump_smb(smb_buffer, length); |
567 | if (checkSMB(smb_buffer, smb_buffer->Mid, total_read+4)) { | 568 | if (checkSMB(smb_buffer, smb_buffer->Mid, total_read+4)) { |
@@ -575,28 +576,28 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) | |||
575 | list_for_each(tmp, &server->pending_mid_q) { | 576 | list_for_each(tmp, &server->pending_mid_q) { |
576 | mid_entry = list_entry(tmp, struct mid_q_entry, qhead); | 577 | mid_entry = list_entry(tmp, struct mid_q_entry, qhead); |
577 | 578 | ||
578 | if ((mid_entry->mid == smb_buffer->Mid) && | 579 | if ((mid_entry->mid == smb_buffer->Mid) && |
579 | (mid_entry->midState == MID_REQUEST_SUBMITTED) && | 580 | (mid_entry->midState == MID_REQUEST_SUBMITTED) && |
580 | (mid_entry->command == smb_buffer->Command)) { | 581 | (mid_entry->command == smb_buffer->Command)) { |
581 | if(check2ndT2(smb_buffer,server->maxBuf) > 0) { | 582 | if (check2ndT2(smb_buffer,server->maxBuf) > 0) { |
582 | /* We have a multipart transact2 resp */ | 583 | /* We have a multipart transact2 resp */ |
583 | isMultiRsp = TRUE; | 584 | isMultiRsp = TRUE; |
584 | if(mid_entry->resp_buf) { | 585 | if (mid_entry->resp_buf) { |
585 | /* merge response - fix up 1st*/ | 586 | /* merge response - fix up 1st*/ |
586 | if(coalesce_t2(smb_buffer, | 587 | if (coalesce_t2(smb_buffer, |
587 | mid_entry->resp_buf)) { | 588 | mid_entry->resp_buf)) { |
588 | mid_entry->multiRsp = 1; | 589 | mid_entry->multiRsp = 1; |
589 | break; | 590 | break; |
590 | } else { | 591 | } else { |
591 | /* all parts received */ | 592 | /* all parts received */ |
592 | mid_entry->multiEnd = 1; | 593 | mid_entry->multiEnd = 1; |
593 | goto multi_t2_fnd; | 594 | goto multi_t2_fnd; |
594 | } | 595 | } |
595 | } else { | 596 | } else { |
596 | if(!isLargeBuf) { | 597 | if (!isLargeBuf) { |
597 | cERROR(1,("1st trans2 resp needs bigbuf")); | 598 | cERROR(1,("1st trans2 resp needs bigbuf")); |
598 | /* BB maybe we can fix this up, switch | 599 | /* BB maybe we can fix this up, switch |
599 | to already allocated large buffer? */ | 600 | to already allocated large buffer? */ |
600 | } else { | 601 | } else { |
601 | /* Have first buffer */ | 602 | /* Have first buffer */ |
602 | mid_entry->resp_buf = | 603 | mid_entry->resp_buf = |
@@ -606,9 +607,9 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) | |||
606 | } | 607 | } |
607 | } | 608 | } |
608 | break; | 609 | break; |
609 | } | 610 | } |
610 | mid_entry->resp_buf = smb_buffer; | 611 | mid_entry->resp_buf = smb_buffer; |
611 | if(isLargeBuf) | 612 | if (isLargeBuf) |
612 | mid_entry->largeBuf = 1; | 613 | mid_entry->largeBuf = 1; |
613 | else | 614 | else |
614 | mid_entry->largeBuf = 0; | 615 | mid_entry->largeBuf = 0; |
@@ -628,24 +629,25 @@ multi_t2_fnd: | |||
628 | spin_unlock(&GlobalMid_Lock); | 629 | spin_unlock(&GlobalMid_Lock); |
629 | if (task_to_wake) { | 630 | if (task_to_wake) { |
630 | /* Was previous buf put in mpx struct for multi-rsp? */ | 631 | /* Was previous buf put in mpx struct for multi-rsp? */ |
631 | if(!isMultiRsp) { | 632 | if (!isMultiRsp) { |
632 | /* smb buffer will be freed by user thread */ | 633 | /* smb buffer will be freed by user thread */ |
633 | if(isLargeBuf) { | 634 | if (isLargeBuf) { |
634 | bigbuf = NULL; | 635 | bigbuf = NULL; |
635 | } else | 636 | } else |
636 | smallbuf = NULL; | 637 | smallbuf = NULL; |
637 | } | 638 | } |
638 | wake_up_process(task_to_wake); | 639 | wake_up_process(task_to_wake); |
639 | } else if ((is_valid_oplock_break(smb_buffer, server) == FALSE) | 640 | } else if ((is_valid_oplock_break(smb_buffer, server) == FALSE) |
640 | && (isMultiRsp == FALSE)) { | 641 | && (isMultiRsp == FALSE)) { |
641 | cERROR(1, ("No task to wake, unknown frame rcvd! NumMids %d", midCount.counter)); | 642 | cERROR(1, ("No task to wake, unknown frame received! " |
642 | cifs_dump_mem("Received Data is: ",(char *)smb_buffer, | 643 | "NumMids %d", midCount.counter)); |
644 | cifs_dump_mem("Received Data is: ", (char *)smb_buffer, | ||
643 | sizeof(struct smb_hdr)); | 645 | sizeof(struct smb_hdr)); |
644 | #ifdef CONFIG_CIFS_DEBUG2 | 646 | #ifdef CONFIG_CIFS_DEBUG2 |
645 | cifs_dump_detail(smb_buffer); | 647 | cifs_dump_detail(smb_buffer); |
646 | cifs_dump_mids(server); | 648 | cifs_dump_mids(server); |
647 | #endif /* CIFS_DEBUG2 */ | 649 | #endif /* CIFS_DEBUG2 */ |
648 | 650 | ||
649 | } | 651 | } |
650 | } /* end while !EXITING */ | 652 | } /* end while !EXITING */ |
651 | 653 | ||
@@ -655,12 +657,12 @@ multi_t2_fnd: | |||
655 | /* check if we have blocked requests that need to free */ | 657 | /* check if we have blocked requests that need to free */ |
656 | /* Note that cifs_max_pending is normally 50, but | 658 | /* Note that cifs_max_pending is normally 50, but |
657 | can be set at module install time to as little as two */ | 659 | can be set at module install time to as little as two */ |
658 | if(atomic_read(&server->inFlight) >= cifs_max_pending) | 660 | if (atomic_read(&server->inFlight) >= cifs_max_pending) |
659 | atomic_set(&server->inFlight, cifs_max_pending - 1); | 661 | atomic_set(&server->inFlight, cifs_max_pending - 1); |
660 | /* We do not want to set the max_pending too low or we | 662 | /* We do not want to set the max_pending too low or we |
661 | could end up with the counter going negative */ | 663 | could end up with the counter going negative */ |
662 | spin_unlock(&GlobalMid_Lock); | 664 | spin_unlock(&GlobalMid_Lock); |
663 | /* Although there should not be any requests blocked on | 665 | /* Although there should not be any requests blocked on |
664 | this queue it can not hurt to be paranoid and try to wake up requests | 666 | this queue it can not hurt to be paranoid and try to wake up requests |
665 | that may haven been blocked when more than 50 at time were on the wire | 667 | that may haven been blocked when more than 50 at time were on the wire |
666 | to the same server - they now will see the session is in exit state | 668 | to the same server - they now will see the session is in exit state |
@@ -668,8 +670,8 @@ multi_t2_fnd: | |||
668 | wake_up_all(&server->request_q); | 670 | wake_up_all(&server->request_q); |
669 | /* give those requests time to exit */ | 671 | /* give those requests time to exit */ |
670 | msleep(125); | 672 | msleep(125); |
671 | 673 | ||
672 | if(server->ssocket) { | 674 | if (server->ssocket) { |
673 | sock_release(csocket); | 675 | sock_release(csocket); |
674 | server->ssocket = NULL; | 676 | server->ssocket = NULL; |
675 | } | 677 | } |
@@ -709,10 +711,10 @@ multi_t2_fnd: | |||
709 | list_for_each(tmp, &server->pending_mid_q) { | 711 | list_for_each(tmp, &server->pending_mid_q) { |
710 | mid_entry = list_entry(tmp, struct mid_q_entry, qhead); | 712 | mid_entry = list_entry(tmp, struct mid_q_entry, qhead); |
711 | if (mid_entry->midState == MID_REQUEST_SUBMITTED) { | 713 | if (mid_entry->midState == MID_REQUEST_SUBMITTED) { |
712 | cFYI(1, | 714 | cFYI(1, ("Clearing Mid 0x%x - waking up ", |
713 | ("Clearing Mid 0x%x - waking up ",mid_entry->mid)); | 715 | mid_entry->mid)); |
714 | task_to_wake = mid_entry->tsk; | 716 | task_to_wake = mid_entry->tsk; |
715 | if(task_to_wake) { | 717 | if (task_to_wake) { |
716 | wake_up_process(task_to_wake); | 718 | wake_up_process(task_to_wake); |
717 | } | 719 | } |
718 | } | 720 | } |
@@ -724,7 +726,7 @@ multi_t2_fnd: | |||
724 | } | 726 | } |
725 | 727 | ||
726 | if (!list_empty(&server->pending_mid_q)) { | 728 | if (!list_empty(&server->pending_mid_q)) { |
727 | /* mpx threads have not exited yet give them | 729 | /* mpx threads have not exited yet give them |
728 | at least the smb send timeout time for long ops */ | 730 | at least the smb send timeout time for long ops */ |
729 | /* due to delays on oplock break requests, we need | 731 | /* due to delays on oplock break requests, we need |
730 | to wait at least 45 seconds before giving up | 732 | to wait at least 45 seconds before giving up |
@@ -742,7 +744,7 @@ multi_t2_fnd: | |||
742 | 744 | ||
743 | /* last chance to mark ses pointers invalid | 745 | /* last chance to mark ses pointers invalid |
744 | if there are any pointing to this (e.g | 746 | if there are any pointing to this (e.g |
745 | if a crazy root user tried to kill cifsd | 747 | if a crazy root user tried to kill cifsd |
746 | kernel thread explicitly this might happen) */ | 748 | kernel thread explicitly this might happen) */ |
747 | list_for_each(tmp, &GlobalSMBSessionList) { | 749 | list_for_each(tmp, &GlobalSMBSessionList) { |
748 | ses = list_entry(tmp, struct cifsSesInfo, | 750 | ses = list_entry(tmp, struct cifsSesInfo, |
@@ -754,17 +756,18 @@ multi_t2_fnd: | |||
754 | write_unlock(&GlobalSMBSeslock); | 756 | write_unlock(&GlobalSMBSeslock); |
755 | 757 | ||
756 | kfree(server); | 758 | kfree(server); |
757 | if(length > 0) { | 759 | if (length > 0) { |
758 | mempool_resize(cifs_req_poolp, | 760 | mempool_resize(cifs_req_poolp, |
759 | length + cifs_min_rcv, | 761 | length + cifs_min_rcv, |
760 | GFP_KERNEL); | 762 | GFP_KERNEL); |
761 | } | 763 | } |
762 | 764 | ||
763 | return 0; | 765 | return 0; |
764 | } | 766 | } |
765 | 767 | ||
766 | static int | 768 | static int |
767 | cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | 769 | cifs_parse_mount_options(char *options, const char *devname, |
770 | struct smb_vol *vol) | ||
768 | { | 771 | { |
769 | char *value; | 772 | char *value; |
770 | char *data; | 773 | char *data; |
@@ -772,15 +775,15 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
772 | char separator[2]; | 775 | char separator[2]; |
773 | 776 | ||
774 | separator[0] = ','; | 777 | separator[0] = ','; |
775 | separator[1] = 0; | 778 | separator[1] = 0; |
776 | 779 | ||
777 | if (Local_System_Name[0] != 0) | 780 | if (Local_System_Name[0] != 0) |
778 | memcpy(vol->source_rfc1001_name, Local_System_Name,15); | 781 | memcpy(vol->source_rfc1001_name, Local_System_Name, 15); |
779 | else { | 782 | else { |
780 | char *nodename = utsname()->nodename; | 783 | char *nodename = utsname()->nodename; |
781 | int n = strnlen(nodename,15); | 784 | int n = strnlen(nodename, 15); |
782 | memset(vol->source_rfc1001_name,0x20,15); | 785 | memset(vol->source_rfc1001_name, 0x20, 15); |
783 | for(i=0 ; i < n ; i++) { | 786 | for (i = 0; i < n; i++) { |
784 | /* does not have to be perfect mapping since field is | 787 | /* does not have to be perfect mapping since field is |
785 | informational, only used for servers that do not support | 788 | informational, only used for servers that do not support |
786 | port 445 and it can be overridden at mount time */ | 789 | port 445 and it can be overridden at mount time */ |
@@ -805,31 +808,32 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
805 | if (!options) | 808 | if (!options) |
806 | return 1; | 809 | return 1; |
807 | 810 | ||
808 | if(strncmp(options,"sep=",4) == 0) { | 811 | if (strncmp(options, "sep=", 4) == 0) { |
809 | if(options[4] != 0) { | 812 | if (options[4] != 0) { |
810 | separator[0] = options[4]; | 813 | separator[0] = options[4]; |
811 | options += 5; | 814 | options += 5; |
812 | } else { | 815 | } else { |
813 | cFYI(1,("Null separator not allowed")); | 816 | cFYI(1, ("Null separator not allowed")); |
814 | } | 817 | } |
815 | } | 818 | } |
816 | 819 | ||
817 | while ((data = strsep(&options, separator)) != NULL) { | 820 | while ((data = strsep(&options, separator)) != NULL) { |
818 | if (!*data) | 821 | if (!*data) |
819 | continue; | 822 | continue; |
820 | if ((value = strchr(data, '=')) != NULL) | 823 | if ((value = strchr(data, '=')) != NULL) |
821 | *value++ = '\0'; | 824 | *value++ = '\0'; |
822 | 825 | ||
823 | if (strnicmp(data, "user_xattr",10) == 0) {/*parse before user*/ | 826 | /* Have to parse this before we parse for "user" */ |
827 | if (strnicmp(data, "user_xattr", 10) == 0) { | ||
824 | vol->no_xattr = 0; | 828 | vol->no_xattr = 0; |
825 | } else if (strnicmp(data, "nouser_xattr",12) == 0) { | 829 | } else if (strnicmp(data, "nouser_xattr", 12) == 0) { |
826 | vol->no_xattr = 1; | 830 | vol->no_xattr = 1; |
827 | } else if (strnicmp(data, "user", 4) == 0) { | 831 | } else if (strnicmp(data, "user", 4) == 0) { |
828 | if (!value) { | 832 | if (!value) { |
829 | printk(KERN_WARNING | 833 | printk(KERN_WARNING |
830 | "CIFS: invalid or missing username\n"); | 834 | "CIFS: invalid or missing username\n"); |
831 | return 1; /* needs_arg; */ | 835 | return 1; /* needs_arg; */ |
832 | } else if(!*value) { | 836 | } else if (!*value) { |
833 | /* null user, ie anonymous, authentication */ | 837 | /* null user, ie anonymous, authentication */ |
834 | vol->nullauth = 1; | 838 | vol->nullauth = 1; |
835 | } | 839 | } |
@@ -843,12 +847,12 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
843 | if (!value) { | 847 | if (!value) { |
844 | vol->password = NULL; | 848 | vol->password = NULL; |
845 | continue; | 849 | continue; |
846 | } else if(value[0] == 0) { | 850 | } else if (value[0] == 0) { |
847 | /* check if string begins with double comma | 851 | /* check if string begins with double comma |
848 | since that would mean the password really | 852 | since that would mean the password really |
849 | does start with a comma, and would not | 853 | does start with a comma, and would not |
850 | indicate an empty string */ | 854 | indicate an empty string */ |
851 | if(value[1] != separator[0]) { | 855 | if (value[1] != separator[0]) { |
852 | vol->password = NULL; | 856 | vol->password = NULL; |
853 | continue; | 857 | continue; |
854 | } | 858 | } |
@@ -857,7 +861,7 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
857 | /* removed password length check, NTLM passwords | 861 | /* removed password length check, NTLM passwords |
858 | can be arbitrarily long */ | 862 | can be arbitrarily long */ |
859 | 863 | ||
860 | /* if comma in password, the string will be | 864 | /* if comma in password, the string will be |
861 | prematurely null terminated. Commas in password are | 865 | prematurely null terminated. Commas in password are |
862 | specified across the cifs mount interface by a double | 866 | specified across the cifs mount interface by a double |
863 | comma ie ,, and a comma used as in other cases ie ',' | 867 | comma ie ,, and a comma used as in other cases ie ',' |
@@ -867,18 +871,18 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
867 | /* NB: password legally can have multiple commas and | 871 | /* NB: password legally can have multiple commas and |
868 | the only illegal character in a password is null */ | 872 | the only illegal character in a password is null */ |
869 | 873 | ||
870 | if ((value[temp_len] == 0) && | 874 | if ((value[temp_len] == 0) && |
871 | (value[temp_len+1] == separator[0])) { | 875 | (value[temp_len+1] == separator[0])) { |
872 | /* reinsert comma */ | 876 | /* reinsert comma */ |
873 | value[temp_len] = separator[0]; | 877 | value[temp_len] = separator[0]; |
874 | temp_len+=2; /* move after the second comma */ | 878 | temp_len += 2; /* move after second comma */ |
875 | while(value[temp_len] != 0) { | 879 | while (value[temp_len] != 0) { |
876 | if (value[temp_len] == separator[0]) { | 880 | if (value[temp_len] == separator[0]) { |
877 | if (value[temp_len+1] == | 881 | if (value[temp_len+1] == |
878 | separator[0]) { | 882 | separator[0]) { |
879 | /* skip second comma */ | 883 | /* skip second comma */ |
880 | temp_len++; | 884 | temp_len++; |
881 | } else { | 885 | } else { |
882 | /* single comma indicating start | 886 | /* single comma indicating start |
883 | of next parm */ | 887 | of next parm */ |
884 | break; | 888 | break; |
@@ -886,24 +890,25 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
886 | } | 890 | } |
887 | temp_len++; | 891 | temp_len++; |
888 | } | 892 | } |
889 | if(value[temp_len] == 0) { | 893 | if (value[temp_len] == 0) { |
890 | options = NULL; | 894 | options = NULL; |
891 | } else { | 895 | } else { |
892 | value[temp_len] = 0; | 896 | value[temp_len] = 0; |
893 | /* point option to start of next parm */ | 897 | /* point option to start of next parm */ |
894 | options = value + temp_len + 1; | 898 | options = value + temp_len + 1; |
895 | } | 899 | } |
896 | /* go from value to value + temp_len condensing | 900 | /* go from value to value + temp_len condensing |
897 | double commas to singles. Note that this ends up | 901 | double commas to singles. Note that this ends up |
898 | allocating a few bytes too many, which is ok */ | 902 | allocating a few bytes too many, which is ok */ |
899 | vol->password = kzalloc(temp_len, GFP_KERNEL); | 903 | vol->password = kzalloc(temp_len, GFP_KERNEL); |
900 | if(vol->password == NULL) { | 904 | if (vol->password == NULL) { |
901 | printk("CIFS: no memory for pass\n"); | 905 | printk(KERN_WARNING "CIFS: no memory " |
906 | "for password\n"); | ||
902 | return 1; | 907 | return 1; |
903 | } | 908 | } |
904 | for(i=0,j=0;i<temp_len;i++,j++) { | 909 | for (i = 0, j = 0; i < temp_len; i++, j++) { |
905 | vol->password[j] = value[i]; | 910 | vol->password[j] = value[i]; |
906 | if(value[i] == separator[0] | 911 | if (value[i] == separator[0] |
907 | && value[i+1] == separator[0]) { | 912 | && value[i+1] == separator[0]) { |
908 | /* skip second comma */ | 913 | /* skip second comma */ |
909 | i++; | 914 | i++; |
@@ -912,8 +917,9 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
912 | vol->password[j] = 0; | 917 | vol->password[j] = 0; |
913 | } else { | 918 | } else { |
914 | vol->password = kzalloc(temp_len+1, GFP_KERNEL); | 919 | vol->password = kzalloc(temp_len+1, GFP_KERNEL); |
915 | if(vol->password == NULL) { | 920 | if (vol->password == NULL) { |
916 | printk("CIFS: no memory for pass\n"); | 921 | printk(KERN_WARNING "CIFS: no memory " |
922 | "for password\n"); | ||
917 | return 1; | 923 | return 1; |
918 | } | 924 | } |
919 | strcpy(vol->password, value); | 925 | strcpy(vol->password, value); |
@@ -924,20 +930,21 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
924 | } else if (strnlen(value, 35) < 35) { | 930 | } else if (strnlen(value, 35) < 35) { |
925 | vol->UNCip = value; | 931 | vol->UNCip = value; |
926 | } else { | 932 | } else { |
927 | printk(KERN_WARNING "CIFS: ip address too long\n"); | 933 | printk(KERN_WARNING "CIFS: ip address " |
934 | "too long\n"); | ||
928 | return 1; | 935 | return 1; |
929 | } | 936 | } |
930 | } else if (strnicmp(data, "sec", 3) == 0) { | 937 | } else if (strnicmp(data, "sec", 3) == 0) { |
931 | if (!value || !*value) { | 938 | if (!value || !*value) { |
932 | cERROR(1,("no security value specified")); | 939 | cERROR(1, ("no security value specified")); |
933 | continue; | 940 | continue; |
934 | } else if (strnicmp(value, "krb5i", 5) == 0) { | 941 | } else if (strnicmp(value, "krb5i", 5) == 0) { |
935 | vol->secFlg |= CIFSSEC_MAY_KRB5 | | 942 | vol->secFlg |= CIFSSEC_MAY_KRB5 | |
936 | CIFSSEC_MUST_SIGN; | 943 | CIFSSEC_MUST_SIGN; |
937 | } else if (strnicmp(value, "krb5p", 5) == 0) { | 944 | } else if (strnicmp(value, "krb5p", 5) == 0) { |
938 | /* vol->secFlg |= CIFSSEC_MUST_SEAL | | 945 | /* vol->secFlg |= CIFSSEC_MUST_SEAL | |
939 | CIFSSEC_MAY_KRB5; */ | 946 | CIFSSEC_MAY_KRB5; */ |
940 | cERROR(1,("Krb5 cifs privacy not supported")); | 947 | cERROR(1, ("Krb5 cifs privacy not supported")); |
941 | return 1; | 948 | return 1; |
942 | } else if (strnicmp(value, "krb5", 4) == 0) { | 949 | } else if (strnicmp(value, "krb5", 4) == 0) { |
943 | vol->secFlg |= CIFSSEC_MAY_KRB5; | 950 | vol->secFlg |= CIFSSEC_MAY_KRB5; |
@@ -957,33 +964,34 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
957 | vol->secFlg |= CIFSSEC_MAY_NTLMV2; | 964 | vol->secFlg |= CIFSSEC_MAY_NTLMV2; |
958 | #ifdef CONFIG_CIFS_WEAK_PW_HASH | 965 | #ifdef CONFIG_CIFS_WEAK_PW_HASH |
959 | } else if (strnicmp(value, "lanman", 6) == 0) { | 966 | } else if (strnicmp(value, "lanman", 6) == 0) { |
960 | vol->secFlg |= CIFSSEC_MAY_LANMAN; | 967 | vol->secFlg |= CIFSSEC_MAY_LANMAN; |
961 | #endif | 968 | #endif |
962 | } else if (strnicmp(value, "none", 4) == 0) { | 969 | } else if (strnicmp(value, "none", 4) == 0) { |
963 | vol->nullauth = 1; | 970 | vol->nullauth = 1; |
964 | } else { | 971 | } else { |
965 | cERROR(1,("bad security option: %s", value)); | 972 | cERROR(1, ("bad security option: %s", value)); |
966 | return 1; | 973 | return 1; |
967 | } | 974 | } |
968 | } else if ((strnicmp(data, "unc", 3) == 0) | 975 | } else if ((strnicmp(data, "unc", 3) == 0) |
969 | || (strnicmp(data, "target", 6) == 0) | 976 | || (strnicmp(data, "target", 6) == 0) |
970 | || (strnicmp(data, "path", 4) == 0)) { | 977 | || (strnicmp(data, "path", 4) == 0)) { |
971 | if (!value || !*value) { | 978 | if (!value || !*value) { |
972 | printk(KERN_WARNING | 979 | printk(KERN_WARNING "CIFS: invalid path to " |
973 | "CIFS: invalid path to network resource\n"); | 980 | "network resource\n"); |
974 | return 1; /* needs_arg; */ | 981 | return 1; /* needs_arg; */ |
975 | } | 982 | } |
976 | if ((temp_len = strnlen(value, 300)) < 300) { | 983 | if ((temp_len = strnlen(value, 300)) < 300) { |
977 | vol->UNC = kmalloc(temp_len+1,GFP_KERNEL); | 984 | vol->UNC = kmalloc(temp_len+1, GFP_KERNEL); |
978 | if (vol->UNC == NULL) | 985 | if (vol->UNC == NULL) |
979 | return 1; | 986 | return 1; |
980 | strcpy(vol->UNC,value); | 987 | strcpy(vol->UNC, value); |
981 | if (strncmp(vol->UNC, "//", 2) == 0) { | 988 | if (strncmp(vol->UNC, "//", 2) == 0) { |
982 | vol->UNC[0] = '\\'; | 989 | vol->UNC[0] = '\\'; |
983 | vol->UNC[1] = '\\'; | 990 | vol->UNC[1] = '\\'; |
984 | } else if (strncmp(vol->UNC, "\\\\", 2) != 0) { | 991 | } else if (strncmp(vol->UNC, "\\\\", 2) != 0) { |
985 | printk(KERN_WARNING | 992 | printk(KERN_WARNING |
986 | "CIFS: UNC Path does not begin with // or \\\\ \n"); | 993 | "CIFS: UNC Path does not begin " |
994 | "with // or \\\\ \n"); | ||
987 | return 1; | 995 | return 1; |
988 | } | 996 | } |
989 | } else { | 997 | } else { |
@@ -1002,43 +1010,47 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
1002 | vol->domainname = value; | 1010 | vol->domainname = value; |
1003 | cFYI(1, ("Domain name set")); | 1011 | cFYI(1, ("Domain name set")); |
1004 | } else { | 1012 | } else { |
1005 | printk(KERN_WARNING "CIFS: domain name too long\n"); | 1013 | printk(KERN_WARNING "CIFS: domain name too " |
1014 | "long\n"); | ||
1006 | return 1; | 1015 | return 1; |
1007 | } | 1016 | } |
1008 | } else if (strnicmp(data, "prefixpath", 10) == 0) { | 1017 | } else if (strnicmp(data, "prefixpath", 10) == 0) { |
1009 | if (!value || !*value) { | 1018 | if (!value || !*value) { |
1010 | printk(KERN_WARNING | 1019 | printk(KERN_WARNING |
1011 | "CIFS: invalid path prefix\n"); | 1020 | "CIFS: invalid path prefix\n"); |
1012 | return 1; /* needs_arg; */ | 1021 | return 1; /* needs_argument */ |
1013 | } | 1022 | } |
1014 | if ((temp_len = strnlen(value, 1024)) < 1024) { | 1023 | if ((temp_len = strnlen(value, 1024)) < 1024) { |
1015 | if (value[0] != '/') | 1024 | if (value[0] != '/') |
1016 | temp_len++; /* missing leading slash */ | 1025 | temp_len++; /* missing leading slash */ |
1017 | vol->prepath = kmalloc(temp_len+1,GFP_KERNEL); | 1026 | vol->prepath = kmalloc(temp_len+1, GFP_KERNEL); |
1018 | if (vol->prepath == NULL) | 1027 | if (vol->prepath == NULL) |
1019 | return 1; | 1028 | return 1; |
1020 | if (value[0] != '/') { | 1029 | if (value[0] != '/') { |
1021 | vol->prepath[0] = '/'; | 1030 | vol->prepath[0] = '/'; |
1022 | strcpy(vol->prepath+1,value); | 1031 | strcpy(vol->prepath+1, value); |
1023 | } else | 1032 | } else |
1024 | strcpy(vol->prepath,value); | 1033 | strcpy(vol->prepath, value); |
1025 | cFYI(1,("prefix path %s",vol->prepath)); | 1034 | cFYI(1, ("prefix path %s", vol->prepath)); |
1026 | } else { | 1035 | } else { |
1027 | printk(KERN_WARNING "CIFS: prefix too long\n"); | 1036 | printk(KERN_WARNING "CIFS: prefix too long\n"); |
1028 | return 1; | 1037 | return 1; |
1029 | } | 1038 | } |
1030 | } else if (strnicmp(data, "iocharset", 9) == 0) { | 1039 | } else if (strnicmp(data, "iocharset", 9) == 0) { |
1031 | if (!value || !*value) { | 1040 | if (!value || !*value) { |
1032 | printk(KERN_WARNING "CIFS: invalid iocharset specified\n"); | 1041 | printk(KERN_WARNING "CIFS: invalid iocharset " |
1042 | "specified\n"); | ||
1033 | return 1; /* needs_arg; */ | 1043 | return 1; /* needs_arg; */ |
1034 | } | 1044 | } |
1035 | if (strnlen(value, 65) < 65) { | 1045 | if (strnlen(value, 65) < 65) { |
1036 | if (strnicmp(value,"default",7)) | 1046 | if (strnicmp(value, "default", 7)) |
1037 | vol->iocharset = value; | 1047 | vol->iocharset = value; |
1038 | /* if iocharset not set load_nls_default used by caller */ | 1048 | /* if iocharset not set then load_nls_default |
1039 | cFYI(1, ("iocharset set to %s",value)); | 1049 | is used by caller */ |
1050 | cFYI(1, ("iocharset set to %s", value)); | ||
1040 | } else { | 1051 | } else { |
1041 | printk(KERN_WARNING "CIFS: iocharset name too long.\n"); | 1052 | printk(KERN_WARNING "CIFS: iocharset name " |
1053 | "too long.\n"); | ||
1042 | return 1; | 1054 | return 1; |
1043 | } | 1055 | } |
1044 | } else if (strnicmp(data, "uid", 3) == 0) { | 1056 | } else if (strnicmp(data, "uid", 3) == 0) { |
@@ -1090,54 +1102,59 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
1090 | } | 1102 | } |
1091 | } else if (strnicmp(data, "netbiosname", 4) == 0) { | 1103 | } else if (strnicmp(data, "netbiosname", 4) == 0) { |
1092 | if (!value || !*value || (*value == ' ')) { | 1104 | if (!value || !*value || (*value == ' ')) { |
1093 | cFYI(1,("invalid (empty) netbiosname specified")); | 1105 | cFYI(1, ("invalid (empty) netbiosname")); |
1094 | } else { | 1106 | } else { |
1095 | memset(vol->source_rfc1001_name,0x20,15); | 1107 | memset(vol->source_rfc1001_name, 0x20, 15); |
1096 | for(i=0;i<15;i++) { | 1108 | for (i = 0; i < 15; i++) { |
1097 | /* BB are there cases in which a comma can be | 1109 | /* BB are there cases in which a comma can be |
1098 | valid in this workstation netbios name (and need | 1110 | valid in this workstation netbios name (and need |
1099 | special handling)? */ | 1111 | special handling)? */ |
1100 | 1112 | ||
1101 | /* We do not uppercase netbiosname for user */ | 1113 | /* We do not uppercase netbiosname for user */ |
1102 | if (value[i]==0) | 1114 | if (value[i] == 0) |
1103 | break; | 1115 | break; |
1104 | else | 1116 | else |
1105 | vol->source_rfc1001_name[i] = value[i]; | 1117 | vol->source_rfc1001_name[i] = |
1118 | value[i]; | ||
1106 | } | 1119 | } |
1107 | /* The string has 16th byte zero still from | 1120 | /* The string has 16th byte zero still from |
1108 | set at top of the function */ | 1121 | set at top of the function */ |
1109 | if ((i==15) && (value[i] != 0)) | 1122 | if ((i == 15) && (value[i] != 0)) |
1110 | printk(KERN_WARNING "CIFS: netbiosname longer than 15 truncated.\n"); | 1123 | printk(KERN_WARNING "CIFS: netbiosname" |
1124 | " longer than 15 truncated.\n"); | ||
1111 | } | 1125 | } |
1112 | } else if (strnicmp(data, "servern", 7) == 0) { | 1126 | } else if (strnicmp(data, "servern", 7) == 0) { |
1113 | /* servernetbiosname specified override *SMBSERVER */ | 1127 | /* servernetbiosname specified override *SMBSERVER */ |
1114 | if (!value || !*value || (*value == ' ')) { | 1128 | if (!value || !*value || (*value == ' ')) { |
1115 | cFYI(1,("empty server netbiosname specified")); | 1129 | cFYI(1, ("empty server netbiosname specified")); |
1116 | } else { | 1130 | } else { |
1117 | /* last byte, type, is 0x20 for servr type */ | 1131 | /* last byte, type, is 0x20 for servr type */ |
1118 | memset(vol->target_rfc1001_name,0x20,16); | 1132 | memset(vol->target_rfc1001_name, 0x20, 16); |
1119 | 1133 | ||
1120 | for(i=0;i<15;i++) { | 1134 | for (i = 0; i < 15; i++) { |
1121 | /* BB are there cases in which a comma can be | 1135 | /* BB are there cases in which a comma can be |
1122 | valid in this workstation netbios name (and need | 1136 | valid in this workstation netbios name |
1123 | special handling)? */ | 1137 | (and need special handling)? */ |
1124 | 1138 | ||
1125 | /* user or mount helper must uppercase netbiosname */ | 1139 | /* user or mount helper must uppercase |
1126 | if (value[i]==0) | 1140 | the netbiosname */ |
1141 | if (value[i] == 0) | ||
1127 | break; | 1142 | break; |
1128 | else | 1143 | else |
1129 | vol->target_rfc1001_name[i] = value[i]; | 1144 | vol->target_rfc1001_name[i] = |
1145 | value[i]; | ||
1130 | } | 1146 | } |
1131 | /* The string has 16th byte zero still from | 1147 | /* The string has 16th byte zero still from |
1132 | set at top of the function */ | 1148 | set at top of the function */ |
1133 | if ((i==15) && (value[i] != 0)) | 1149 | if ((i == 15) && (value[i] != 0)) |
1134 | printk(KERN_WARNING "CIFS: server netbiosname longer than 15 truncated.\n"); | 1150 | printk(KERN_WARNING "CIFS: server net" |
1151 | "biosname longer than 15 truncated.\n"); | ||
1135 | } | 1152 | } |
1136 | } else if (strnicmp(data, "credentials", 4) == 0) { | 1153 | } else if (strnicmp(data, "credentials", 4) == 0) { |
1137 | /* ignore */ | 1154 | /* ignore */ |
1138 | } else if (strnicmp(data, "version", 3) == 0) { | 1155 | } else if (strnicmp(data, "version", 3) == 0) { |
1139 | /* ignore */ | 1156 | /* ignore */ |
1140 | } else if (strnicmp(data, "guest",5) == 0) { | 1157 | } else if (strnicmp(data, "guest", 5) == 0) { |
1141 | /* ignore */ | 1158 | /* ignore */ |
1142 | } else if (strnicmp(data, "rw", 2) == 0) { | 1159 | } else if (strnicmp(data, "rw", 2) == 0) { |
1143 | vol->rw = TRUE; | 1160 | vol->rw = TRUE; |
@@ -1149,11 +1166,11 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
1149 | (strnicmp(data, "noauto", 6) == 0) || | 1166 | (strnicmp(data, "noauto", 6) == 0) || |
1150 | (strnicmp(data, "dev", 3) == 0)) { | 1167 | (strnicmp(data, "dev", 3) == 0)) { |
1151 | /* The mount tool or mount.cifs helper (if present) | 1168 | /* The mount tool or mount.cifs helper (if present) |
1152 | uses these opts to set flags, and the flags are read | 1169 | uses these opts to set flags, and the flags are read |
1153 | by the kernel vfs layer before we get here (ie | 1170 | by the kernel vfs layer before we get here (ie |
1154 | before read super) so there is no point trying to | 1171 | before read super) so there is no point trying to |
1155 | parse these options again and set anything and it | 1172 | parse these options again and set anything and it |
1156 | is ok to just ignore them */ | 1173 | is ok to just ignore them */ |
1157 | continue; | 1174 | continue; |
1158 | } else if (strnicmp(data, "ro", 2) == 0) { | 1175 | } else if (strnicmp(data, "ro", 2) == 0) { |
1159 | vol->rw = FALSE; | 1176 | vol->rw = FALSE; |
@@ -1169,26 +1186,31 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
1169 | vol->remap = 1; | 1186 | vol->remap = 1; |
1170 | } else if (strnicmp(data, "nomapchars", 10) == 0) { | 1187 | } else if (strnicmp(data, "nomapchars", 10) == 0) { |
1171 | vol->remap = 0; | 1188 | vol->remap = 0; |
1172 | } else if (strnicmp(data, "sfu", 3) == 0) { | 1189 | } else if (strnicmp(data, "sfu", 3) == 0) { |
1173 | vol->sfu_emul = 1; | 1190 | vol->sfu_emul = 1; |
1174 | } else if (strnicmp(data, "nosfu", 5) == 0) { | 1191 | } else if (strnicmp(data, "nosfu", 5) == 0) { |
1175 | vol->sfu_emul = 0; | 1192 | vol->sfu_emul = 0; |
1176 | } else if (strnicmp(data, "posixpaths", 10) == 0) { | 1193 | } else if (strnicmp(data, "posixpaths", 10) == 0) { |
1177 | vol->posix_paths = 1; | 1194 | vol->posix_paths = 1; |
1178 | } else if (strnicmp(data, "noposixpaths", 12) == 0) { | 1195 | } else if (strnicmp(data, "noposixpaths", 12) == 0) { |
1179 | vol->posix_paths = 0; | 1196 | vol->posix_paths = 0; |
1180 | } else if ((strnicmp(data, "nocase", 6) == 0) || | 1197 | } else if (strnicmp(data, "nounix", 6) == 0) { |
1198 | vol->no_linux_ext = 1; | ||
1199 | } else if (strnicmp(data, "nolinux", 7) == 0) { | ||
1200 | vol->no_linux_ext = 1; | ||
1201 | } else if ((strnicmp(data, "nocase", 6) == 0) || | ||
1181 | (strnicmp(data, "ignorecase", 10) == 0)) { | 1202 | (strnicmp(data, "ignorecase", 10) == 0)) { |
1182 | vol->nocase = 1; | 1203 | vol->nocase = 1; |
1183 | } else if (strnicmp(data, "brl", 3) == 0) { | 1204 | } else if (strnicmp(data, "brl", 3) == 0) { |
1184 | vol->nobrl = 0; | 1205 | vol->nobrl = 0; |
1185 | } else if ((strnicmp(data, "nobrl", 5) == 0) || | 1206 | } else if ((strnicmp(data, "nobrl", 5) == 0) || |
1186 | (strnicmp(data, "nolock", 6) == 0)) { | 1207 | (strnicmp(data, "nolock", 6) == 0)) { |
1187 | vol->nobrl = 1; | 1208 | vol->nobrl = 1; |
1188 | /* turn off mandatory locking in mode | 1209 | /* turn off mandatory locking in mode |
1189 | if remote locking is turned off since the | 1210 | if remote locking is turned off since the |
1190 | local vfs will do advisory */ | 1211 | local vfs will do advisory */ |
1191 | if(vol->file_mode == (S_IALLUGO & ~(S_ISUID | S_IXGRP))) | 1212 | if (vol->file_mode == |
1213 | (S_IALLUGO & ~(S_ISUID | S_IXGRP))) | ||
1192 | vol->file_mode = S_IALLUGO; | 1214 | vol->file_mode = S_IALLUGO; |
1193 | } else if (strnicmp(data, "setuids", 7) == 0) { | 1215 | } else if (strnicmp(data, "setuids", 7) == 0) { |
1194 | vol->setuids = 1; | 1216 | vol->setuids = 1; |
@@ -1202,55 +1224,61 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
1202 | vol->intr = 0; | 1224 | vol->intr = 0; |
1203 | } else if (strnicmp(data, "intr", 4) == 0) { | 1225 | } else if (strnicmp(data, "intr", 4) == 0) { |
1204 | vol->intr = 1; | 1226 | vol->intr = 1; |
1205 | } else if (strnicmp(data, "serverino",7) == 0) { | 1227 | } else if (strnicmp(data, "serverino", 7) == 0) { |
1206 | vol->server_ino = 1; | 1228 | vol->server_ino = 1; |
1207 | } else if (strnicmp(data, "noserverino",9) == 0) { | 1229 | } else if (strnicmp(data, "noserverino", 9) == 0) { |
1208 | vol->server_ino = 0; | 1230 | vol->server_ino = 0; |
1209 | } else if (strnicmp(data, "cifsacl",7) == 0) { | 1231 | } else if (strnicmp(data, "cifsacl", 7) == 0) { |
1210 | vol->cifs_acl = 1; | 1232 | vol->cifs_acl = 1; |
1211 | } else if (strnicmp(data, "nocifsacl", 9) == 0) { | 1233 | } else if (strnicmp(data, "nocifsacl", 9) == 0) { |
1212 | vol->cifs_acl = 0; | 1234 | vol->cifs_acl = 0; |
1213 | } else if (strnicmp(data, "acl",3) == 0) { | 1235 | } else if (strnicmp(data, "acl", 3) == 0) { |
1214 | vol->no_psx_acl = 0; | 1236 | vol->no_psx_acl = 0; |
1215 | } else if (strnicmp(data, "noacl",5) == 0) { | 1237 | } else if (strnicmp(data, "noacl", 5) == 0) { |
1216 | vol->no_psx_acl = 1; | 1238 | vol->no_psx_acl = 1; |
1217 | } else if (strnicmp(data, "sign",4) == 0) { | 1239 | } else if (strnicmp(data, "sign", 4) == 0) { |
1218 | vol->secFlg |= CIFSSEC_MUST_SIGN; | 1240 | vol->secFlg |= CIFSSEC_MUST_SIGN; |
1219 | /* } else if (strnicmp(data, "seal",4) == 0) { | 1241 | /* } else if (strnicmp(data, "seal",4) == 0) { |
1220 | vol->secFlg |= CIFSSEC_MUST_SEAL; */ | 1242 | vol->secFlg |= CIFSSEC_MUST_SEAL; */ |
1221 | } else if (strnicmp(data, "direct",6) == 0) { | 1243 | } else if (strnicmp(data, "direct", 6) == 0) { |
1222 | vol->direct_io = 1; | 1244 | vol->direct_io = 1; |
1223 | } else if (strnicmp(data, "forcedirectio",13) == 0) { | 1245 | } else if (strnicmp(data, "forcedirectio", 13) == 0) { |
1224 | vol->direct_io = 1; | 1246 | vol->direct_io = 1; |
1225 | } else if (strnicmp(data, "in6_addr",8) == 0) { | 1247 | } else if (strnicmp(data, "in6_addr", 8) == 0) { |
1226 | if (!value || !*value) { | 1248 | if (!value || !*value) { |
1227 | vol->in6_addr = NULL; | 1249 | vol->in6_addr = NULL; |
1228 | } else if (strnlen(value, 49) == 48) { | 1250 | } else if (strnlen(value, 49) == 48) { |
1229 | vol->in6_addr = value; | 1251 | vol->in6_addr = value; |
1230 | } else { | 1252 | } else { |
1231 | printk(KERN_WARNING "CIFS: ip v6 address not 48 characters long\n"); | 1253 | printk(KERN_WARNING "CIFS: ip v6 address not " |
1254 | "48 characters long\n"); | ||
1232 | return 1; | 1255 | return 1; |
1233 | } | 1256 | } |
1234 | } else if (strnicmp(data, "noac", 4) == 0) { | 1257 | } else if (strnicmp(data, "noac", 4) == 0) { |
1235 | printk(KERN_WARNING "CIFS: Mount option noac not supported. Instead set /proc/fs/cifs/LookupCacheEnabled to 0\n"); | 1258 | printk(KERN_WARNING "CIFS: Mount option noac not " |
1259 | "supported. Instead set " | ||
1260 | "/proc/fs/cifs/LookupCacheEnabled to 0\n"); | ||
1236 | } else | 1261 | } else |
1237 | printk(KERN_WARNING "CIFS: Unknown mount option %s\n",data); | 1262 | printk(KERN_WARNING "CIFS: Unknown mount option %s\n", |
1263 | data); | ||
1238 | } | 1264 | } |
1239 | if (vol->UNC == NULL) { | 1265 | if (vol->UNC == NULL) { |
1240 | if (devname == NULL) { | 1266 | if (devname == NULL) { |
1241 | printk(KERN_WARNING "CIFS: Missing UNC name for mount target\n"); | 1267 | printk(KERN_WARNING "CIFS: Missing UNC name for mount " |
1268 | "target\n"); | ||
1242 | return 1; | 1269 | return 1; |
1243 | } | 1270 | } |
1244 | if ((temp_len = strnlen(devname, 300)) < 300) { | 1271 | if ((temp_len = strnlen(devname, 300)) < 300) { |
1245 | vol->UNC = kmalloc(temp_len+1,GFP_KERNEL); | 1272 | vol->UNC = kmalloc(temp_len+1, GFP_KERNEL); |
1246 | if (vol->UNC == NULL) | 1273 | if (vol->UNC == NULL) |
1247 | return 1; | 1274 | return 1; |
1248 | strcpy(vol->UNC,devname); | 1275 | strcpy(vol->UNC, devname); |
1249 | if (strncmp(vol->UNC, "//", 2) == 0) { | 1276 | if (strncmp(vol->UNC, "//", 2) == 0) { |
1250 | vol->UNC[0] = '\\'; | 1277 | vol->UNC[0] = '\\'; |
1251 | vol->UNC[1] = '\\'; | 1278 | vol->UNC[1] = '\\'; |
1252 | } else if (strncmp(vol->UNC, "\\\\", 2) != 0) { | 1279 | } else if (strncmp(vol->UNC, "\\\\", 2) != 0) { |
1253 | printk(KERN_WARNING "CIFS: UNC Path does not begin with // or \\\\ \n"); | 1280 | printk(KERN_WARNING "CIFS: UNC Path does not " |
1281 | "begin with // or \\\\ \n"); | ||
1254 | return 1; | 1282 | return 1; |
1255 | } | 1283 | } |
1256 | } else { | 1284 | } else { |
@@ -1258,14 +1286,14 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
1258 | return 1; | 1286 | return 1; |
1259 | } | 1287 | } |
1260 | } | 1288 | } |
1261 | if(vol->UNCip == NULL) | 1289 | if (vol->UNCip == NULL) |
1262 | vol->UNCip = &vol->UNC[2]; | 1290 | vol->UNCip = &vol->UNC[2]; |
1263 | 1291 | ||
1264 | return 0; | 1292 | return 0; |
1265 | } | 1293 | } |
1266 | 1294 | ||
1267 | static struct cifsSesInfo * | 1295 | static struct cifsSesInfo * |
1268 | cifs_find_tcp_session(struct in_addr * target_ip_addr, | 1296 | cifs_find_tcp_session(struct in_addr *target_ip_addr, |
1269 | struct in6_addr *target_ip6_addr, | 1297 | struct in6_addr *target_ip6_addr, |
1270 | char *userName, struct TCP_Server_Info **psrvTcp) | 1298 | char *userName, struct TCP_Server_Info **psrvTcp) |
1271 | { | 1299 | { |
@@ -1277,19 +1305,25 @@ cifs_find_tcp_session(struct in_addr * target_ip_addr, | |||
1277 | list_for_each(tmp, &GlobalSMBSessionList) { | 1305 | list_for_each(tmp, &GlobalSMBSessionList) { |
1278 | ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList); | 1306 | ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList); |
1279 | if (ses->server) { | 1307 | if (ses->server) { |
1280 | if((target_ip_addr && | 1308 | if ((target_ip_addr && |
1281 | (ses->server->addr.sockAddr.sin_addr.s_addr | 1309 | (ses->server->addr.sockAddr.sin_addr.s_addr |
1282 | == target_ip_addr->s_addr)) || (target_ip6_addr | 1310 | == target_ip_addr->s_addr)) || (target_ip6_addr |
1283 | && memcmp(&ses->server->addr.sockAddr6.sin6_addr, | 1311 | && memcmp(&ses->server->addr.sockAddr6.sin6_addr, |
1284 | target_ip6_addr,sizeof(*target_ip6_addr)))){ | 1312 | target_ip6_addr, sizeof(*target_ip6_addr)))) { |
1285 | /* BB lock server and tcp session and increment use count here?? */ | 1313 | /* BB lock server and tcp session and increment |
1286 | *psrvTcp = ses->server; /* found a match on the TCP session */ | 1314 | use count here?? */ |
1315 | |||
1316 | /* found a match on the TCP session */ | ||
1317 | *psrvTcp = ses->server; | ||
1318 | |||
1287 | /* BB check if reconnection needed */ | 1319 | /* BB check if reconnection needed */ |
1288 | if (strncmp | 1320 | if (strncmp |
1289 | (ses->userName, userName, | 1321 | (ses->userName, userName, |
1290 | MAX_USERNAME_SIZE) == 0){ | 1322 | MAX_USERNAME_SIZE) == 0){ |
1291 | read_unlock(&GlobalSMBSeslock); | 1323 | read_unlock(&GlobalSMBSeslock); |
1292 | return ses; /* found exact match on both tcp and SMB sessions */ | 1324 | /* Found exact match on both TCP and |
1325 | SMB sessions */ | ||
1326 | return ses; | ||
1293 | } | 1327 | } |
1294 | } | 1328 | } |
1295 | } | 1329 | } |
@@ -1320,7 +1354,8 @@ find_unc(__be32 new_target_ip_addr, char *uncName, char *userName) | |||
1320 | /* BB lock tcon, server and tcp session and increment use count here? */ | 1354 | /* BB lock tcon, server and tcp session and increment use count here? */ |
1321 | /* found a match on the TCP session */ | 1355 | /* found a match on the TCP session */ |
1322 | /* BB check if reconnection needed */ | 1356 | /* BB check if reconnection needed */ |
1323 | cFYI(1,("IP match, old UNC: %s new: %s", | 1357 | cFYI(1, |
1358 | ("IP match, old UNC: %s new: %s", | ||
1324 | tcon->treeName, uncName)); | 1359 | tcon->treeName, uncName)); |
1325 | if (strncmp | 1360 | if (strncmp |
1326 | (tcon->treeName, uncName, | 1361 | (tcon->treeName, uncName, |
@@ -1355,11 +1390,11 @@ connect_to_dfs_path(int xid, struct cifsSesInfo *pSesInfo, | |||
1355 | unsigned int num_referrals; | 1390 | unsigned int num_referrals; |
1356 | int rc = 0; | 1391 | int rc = 0; |
1357 | 1392 | ||
1358 | rc = get_dfs_path(xid, pSesInfo,old_path, nls_codepage, | 1393 | rc = get_dfs_path(xid, pSesInfo, old_path, nls_codepage, |
1359 | &num_referrals, &referrals, remap); | 1394 | &num_referrals, &referrals, remap); |
1360 | 1395 | ||
1361 | /* BB Add in code to: if valid refrl, if not ip address contact | 1396 | /* BB Add in code to: if valid refrl, if not ip address contact |
1362 | the helper that resolves tcp names, mount to it, try to | 1397 | the helper that resolves tcp names, mount to it, try to |
1363 | tcon to it unmount it if fail */ | 1398 | tcon to it unmount it if fail */ |
1364 | 1399 | ||
1365 | kfree(referrals); | 1400 | kfree(referrals); |
@@ -1368,10 +1403,9 @@ connect_to_dfs_path(int xid, struct cifsSesInfo *pSesInfo, | |||
1368 | } | 1403 | } |
1369 | 1404 | ||
1370 | int | 1405 | int |
1371 | get_dfs_path(int xid, struct cifsSesInfo *pSesInfo, | 1406 | get_dfs_path(int xid, struct cifsSesInfo *pSesInfo, const char *old_path, |
1372 | const char *old_path, const struct nls_table *nls_codepage, | 1407 | const struct nls_table *nls_codepage, unsigned int *pnum_referrals, |
1373 | unsigned int *pnum_referrals, | 1408 | unsigned char **preferrals, int remap) |
1374 | unsigned char ** preferrals, int remap) | ||
1375 | { | 1409 | { |
1376 | char *temp_unc; | 1410 | char *temp_unc; |
1377 | int rc = 0; | 1411 | int rc = 0; |
@@ -1380,7 +1414,8 @@ get_dfs_path(int xid, struct cifsSesInfo *pSesInfo, | |||
1380 | 1414 | ||
1381 | if (pSesInfo->ipc_tid == 0) { | 1415 | if (pSesInfo->ipc_tid == 0) { |
1382 | temp_unc = kmalloc(2 /* for slashes */ + | 1416 | temp_unc = kmalloc(2 /* for slashes */ + |
1383 | strnlen(pSesInfo->serverName,SERVER_NAME_LEN_WITH_NULL * 2) | 1417 | strnlen(pSesInfo->serverName, |
1418 | SERVER_NAME_LEN_WITH_NULL * 2) | ||
1384 | + 1 + 4 /* slash IPC$ */ + 2, | 1419 | + 1 + 4 /* slash IPC$ */ + 2, |
1385 | GFP_KERNEL); | 1420 | GFP_KERNEL); |
1386 | if (temp_unc == NULL) | 1421 | if (temp_unc == NULL) |
@@ -1391,7 +1426,7 @@ get_dfs_path(int xid, struct cifsSesInfo *pSesInfo, | |||
1391 | strcpy(temp_unc + 2 + strlen(pSesInfo->serverName), "\\IPC$"); | 1426 | strcpy(temp_unc + 2 + strlen(pSesInfo->serverName), "\\IPC$"); |
1392 | rc = CIFSTCon(xid, pSesInfo, temp_unc, NULL, nls_codepage); | 1427 | rc = CIFSTCon(xid, pSesInfo, temp_unc, NULL, nls_codepage); |
1393 | cFYI(1, | 1428 | cFYI(1, |
1394 | ("CIFS Tcon rc = %d ipc_tid = %d", rc,pSesInfo->ipc_tid)); | 1429 | ("CIFS Tcon rc = %d ipc_tid = %d", rc, pSesInfo->ipc_tid)); |
1395 | kfree(temp_unc); | 1430 | kfree(temp_unc); |
1396 | } | 1431 | } |
1397 | if (rc == 0) | 1432 | if (rc == 0) |
@@ -1402,62 +1437,63 @@ get_dfs_path(int xid, struct cifsSesInfo *pSesInfo, | |||
1402 | } | 1437 | } |
1403 | 1438 | ||
1404 | /* See RFC1001 section 14 on representation of Netbios names */ | 1439 | /* See RFC1001 section 14 on representation of Netbios names */ |
1405 | static void rfc1002mangle(char * target,char * source, unsigned int length) | 1440 | static void rfc1002mangle(char *target, char *source, unsigned int length) |
1406 | { | 1441 | { |
1407 | unsigned int i,j; | 1442 | unsigned int i, j; |
1408 | 1443 | ||
1409 | for(i=0,j=0;i<(length);i++) { | 1444 | for (i = 0, j = 0; i < (length); i++) { |
1410 | /* mask a nibble at a time and encode */ | 1445 | /* mask a nibble at a time and encode */ |
1411 | target[j] = 'A' + (0x0F & (source[i] >> 4)); | 1446 | target[j] = 'A' + (0x0F & (source[i] >> 4)); |
1412 | target[j+1] = 'A' + (0x0F & source[i]); | 1447 | target[j+1] = 'A' + (0x0F & source[i]); |
1413 | j+=2; | 1448 | j += 2; |
1414 | } | 1449 | } |
1415 | 1450 | ||
1416 | } | 1451 | } |
1417 | 1452 | ||
1418 | 1453 | ||
1419 | static int | 1454 | static int |
1420 | ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket, | 1455 | ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket, |
1421 | char * netbios_name, char * target_name) | 1456 | char *netbios_name, char *target_name) |
1422 | { | 1457 | { |
1423 | int rc = 0; | 1458 | int rc = 0; |
1424 | int connected = 0; | 1459 | int connected = 0; |
1425 | __be16 orig_port = 0; | 1460 | __be16 orig_port = 0; |
1426 | 1461 | ||
1427 | if(*csocket == NULL) { | 1462 | if (*csocket == NULL) { |
1428 | rc = sock_create_kern(PF_INET, SOCK_STREAM, IPPROTO_TCP, csocket); | 1463 | rc = sock_create_kern(PF_INET, SOCK_STREAM, |
1464 | IPPROTO_TCP, csocket); | ||
1429 | if (rc < 0) { | 1465 | if (rc < 0) { |
1430 | cERROR(1, ("Error %d creating socket",rc)); | 1466 | cERROR(1, ("Error %d creating socket", rc)); |
1431 | *csocket = NULL; | 1467 | *csocket = NULL; |
1432 | return rc; | 1468 | return rc; |
1433 | } else { | 1469 | } else { |
1434 | /* BB other socket options to set KEEPALIVE, NODELAY? */ | 1470 | /* BB other socket options to set KEEPALIVE, NODELAY? */ |
1435 | cFYI(1,("Socket created")); | 1471 | cFYI(1, ("Socket created")); |
1436 | (*csocket)->sk->sk_allocation = GFP_NOFS; | 1472 | (*csocket)->sk->sk_allocation = GFP_NOFS; |
1437 | } | 1473 | } |
1438 | } | 1474 | } |
1439 | 1475 | ||
1440 | psin_server->sin_family = AF_INET; | 1476 | psin_server->sin_family = AF_INET; |
1441 | if(psin_server->sin_port) { /* user overrode default port */ | 1477 | if (psin_server->sin_port) { /* user overrode default port */ |
1442 | rc = (*csocket)->ops->connect(*csocket, | 1478 | rc = (*csocket)->ops->connect(*csocket, |
1443 | (struct sockaddr *) psin_server, | 1479 | (struct sockaddr *) psin_server, |
1444 | sizeof (struct sockaddr_in),0); | 1480 | sizeof (struct sockaddr_in), 0); |
1445 | if (rc >= 0) | 1481 | if (rc >= 0) |
1446 | connected = 1; | 1482 | connected = 1; |
1447 | } | 1483 | } |
1448 | 1484 | ||
1449 | if(!connected) { | 1485 | if (!connected) { |
1450 | /* save original port so we can retry user specified port | 1486 | /* save original port so we can retry user specified port |
1451 | later if fall back ports fail this time */ | 1487 | later if fall back ports fail this time */ |
1452 | orig_port = psin_server->sin_port; | 1488 | orig_port = psin_server->sin_port; |
1453 | 1489 | ||
1454 | /* do not retry on the same port we just failed on */ | 1490 | /* do not retry on the same port we just failed on */ |
1455 | if(psin_server->sin_port != htons(CIFS_PORT)) { | 1491 | if (psin_server->sin_port != htons(CIFS_PORT)) { |
1456 | psin_server->sin_port = htons(CIFS_PORT); | 1492 | psin_server->sin_port = htons(CIFS_PORT); |
1457 | 1493 | ||
1458 | rc = (*csocket)->ops->connect(*csocket, | 1494 | rc = (*csocket)->ops->connect(*csocket, |
1459 | (struct sockaddr *) psin_server, | 1495 | (struct sockaddr *) psin_server, |
1460 | sizeof (struct sockaddr_in),0); | 1496 | sizeof (struct sockaddr_in), 0); |
1461 | if (rc >= 0) | 1497 | if (rc >= 0) |
1462 | connected = 1; | 1498 | connected = 1; |
1463 | } | 1499 | } |
@@ -1465,60 +1501,63 @@ ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket, | |||
1465 | if (!connected) { | 1501 | if (!connected) { |
1466 | psin_server->sin_port = htons(RFC1001_PORT); | 1502 | psin_server->sin_port = htons(RFC1001_PORT); |
1467 | rc = (*csocket)->ops->connect(*csocket, (struct sockaddr *) | 1503 | rc = (*csocket)->ops->connect(*csocket, (struct sockaddr *) |
1468 | psin_server, sizeof (struct sockaddr_in),0); | 1504 | psin_server, |
1469 | if (rc >= 0) | 1505 | sizeof (struct sockaddr_in), 0); |
1506 | if (rc >= 0) | ||
1470 | connected = 1; | 1507 | connected = 1; |
1471 | } | 1508 | } |
1472 | 1509 | ||
1473 | /* give up here - unless we want to retry on different | 1510 | /* give up here - unless we want to retry on different |
1474 | protocol families some day */ | 1511 | protocol families some day */ |
1475 | if (!connected) { | 1512 | if (!connected) { |
1476 | if(orig_port) | 1513 | if (orig_port) |
1477 | psin_server->sin_port = orig_port; | 1514 | psin_server->sin_port = orig_port; |
1478 | cFYI(1,("Error %d connecting to server via ipv4",rc)); | 1515 | cFYI(1, ("Error %d connecting to server via ipv4", rc)); |
1479 | sock_release(*csocket); | 1516 | sock_release(*csocket); |
1480 | *csocket = NULL; | 1517 | *csocket = NULL; |
1481 | return rc; | 1518 | return rc; |
1482 | } | 1519 | } |
1483 | /* Eventually check for other socket options to change from | 1520 | /* Eventually check for other socket options to change from |
1484 | the default. sock_setsockopt not used because it expects | 1521 | the default. sock_setsockopt not used because it expects |
1485 | user space buffer */ | 1522 | user space buffer */ |
1486 | cFYI(1,("sndbuf %d rcvbuf %d rcvtimeo 0x%lx",(*csocket)->sk->sk_sndbuf, | 1523 | cFYI(1, ("sndbuf %d rcvbuf %d rcvtimeo 0x%lx", |
1524 | (*csocket)->sk->sk_sndbuf, | ||
1487 | (*csocket)->sk->sk_rcvbuf, (*csocket)->sk->sk_rcvtimeo)); | 1525 | (*csocket)->sk->sk_rcvbuf, (*csocket)->sk->sk_rcvtimeo)); |
1488 | (*csocket)->sk->sk_rcvtimeo = 7 * HZ; | 1526 | (*csocket)->sk->sk_rcvtimeo = 7 * HZ; |
1489 | /* make the bufsizes depend on wsize/rsize and max requests */ | 1527 | /* make the bufsizes depend on wsize/rsize and max requests */ |
1490 | if((*csocket)->sk->sk_sndbuf < (200 * 1024)) | 1528 | if ((*csocket)->sk->sk_sndbuf < (200 * 1024)) |
1491 | (*csocket)->sk->sk_sndbuf = 200 * 1024; | 1529 | (*csocket)->sk->sk_sndbuf = 200 * 1024; |
1492 | if((*csocket)->sk->sk_rcvbuf < (140 * 1024)) | 1530 | if ((*csocket)->sk->sk_rcvbuf < (140 * 1024)) |
1493 | (*csocket)->sk->sk_rcvbuf = 140 * 1024; | 1531 | (*csocket)->sk->sk_rcvbuf = 140 * 1024; |
1494 | 1532 | ||
1495 | /* send RFC1001 sessinit */ | 1533 | /* send RFC1001 sessinit */ |
1496 | if(psin_server->sin_port == htons(RFC1001_PORT)) { | 1534 | if (psin_server->sin_port == htons(RFC1001_PORT)) { |
1497 | /* some servers require RFC1001 sessinit before sending | 1535 | /* some servers require RFC1001 sessinit before sending |
1498 | negprot - BB check reconnection in case where second | 1536 | negprot - BB check reconnection in case where second |
1499 | sessinit is sent but no second negprot */ | 1537 | sessinit is sent but no second negprot */ |
1500 | struct rfc1002_session_packet * ses_init_buf; | 1538 | struct rfc1002_session_packet *ses_init_buf; |
1501 | struct smb_hdr * smb_buf; | 1539 | struct smb_hdr *smb_buf; |
1502 | ses_init_buf = kzalloc(sizeof(struct rfc1002_session_packet), GFP_KERNEL); | 1540 | ses_init_buf = kzalloc(sizeof(struct rfc1002_session_packet), |
1503 | if(ses_init_buf) { | 1541 | GFP_KERNEL); |
1542 | if (ses_init_buf) { | ||
1504 | ses_init_buf->trailer.session_req.called_len = 32; | 1543 | ses_init_buf->trailer.session_req.called_len = 32; |
1505 | if(target_name && (target_name[0] != 0)) { | 1544 | if (target_name && (target_name[0] != 0)) { |
1506 | rfc1002mangle(ses_init_buf->trailer.session_req.called_name, | 1545 | rfc1002mangle(ses_init_buf->trailer.session_req.called_name, |
1507 | target_name, 16); | 1546 | target_name, 16); |
1508 | } else { | 1547 | } else { |
1509 | rfc1002mangle(ses_init_buf->trailer.session_req.called_name, | 1548 | rfc1002mangle(ses_init_buf->trailer.session_req.called_name, |
1510 | DEFAULT_CIFS_CALLED_NAME,16); | 1549 | DEFAULT_CIFS_CALLED_NAME, 16); |
1511 | } | 1550 | } |
1512 | 1551 | ||
1513 | ses_init_buf->trailer.session_req.calling_len = 32; | 1552 | ses_init_buf->trailer.session_req.calling_len = 32; |
1514 | /* calling name ends in null (byte 16) from old smb | 1553 | /* calling name ends in null (byte 16) from old smb |
1515 | convention. */ | 1554 | convention. */ |
1516 | if(netbios_name && (netbios_name[0] !=0)) { | 1555 | if (netbios_name && (netbios_name[0] != 0)) { |
1517 | rfc1002mangle(ses_init_buf->trailer.session_req.calling_name, | 1556 | rfc1002mangle(ses_init_buf->trailer.session_req.calling_name, |
1518 | netbios_name,16); | 1557 | netbios_name, 16); |
1519 | } else { | 1558 | } else { |
1520 | rfc1002mangle(ses_init_buf->trailer.session_req.calling_name, | 1559 | rfc1002mangle(ses_init_buf->trailer.session_req.calling_name, |
1521 | "LINUX_CIFS_CLNT",16); | 1560 | "LINUX_CIFS_CLNT", 16); |
1522 | } | 1561 | } |
1523 | ses_init_buf->trailer.session_req.scope1 = 0; | 1562 | ses_init_buf->trailer.session_req.scope1 = 0; |
1524 | ses_init_buf->trailer.session_req.scope2 = 0; | 1563 | ses_init_buf->trailer.session_req.scope2 = 0; |
@@ -1528,20 +1567,20 @@ ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket, | |||
1528 | rc = smb_send(*csocket, smb_buf, 0x44, | 1567 | rc = smb_send(*csocket, smb_buf, 0x44, |
1529 | (struct sockaddr *)psin_server); | 1568 | (struct sockaddr *)psin_server); |
1530 | kfree(ses_init_buf); | 1569 | kfree(ses_init_buf); |
1531 | msleep(1); /* RFC1001 layer in at least one server | 1570 | msleep(1); /* RFC1001 layer in at least one server |
1532 | requires very short break before negprot | 1571 | requires very short break before negprot |
1533 | presumably because not expecting negprot | 1572 | presumably because not expecting negprot |
1534 | to follow so fast. This is a simple | 1573 | to follow so fast. This is a simple |
1535 | solution that works without | 1574 | solution that works without |
1536 | complicating the code and causes no | 1575 | complicating the code and causes no |
1537 | significant slowing down on mount | 1576 | significant slowing down on mount |
1538 | for everyone else */ | 1577 | for everyone else */ |
1539 | } | 1578 | } |
1540 | /* else the negprot may still work without this | 1579 | /* else the negprot may still work without this |
1541 | even though malloc failed */ | 1580 | even though malloc failed */ |
1542 | 1581 | ||
1543 | } | 1582 | } |
1544 | 1583 | ||
1545 | return rc; | 1584 | return rc; |
1546 | } | 1585 | } |
1547 | 1586 | ||
@@ -1552,41 +1591,42 @@ ipv6_connect(struct sockaddr_in6 *psin_server, struct socket **csocket) | |||
1552 | int connected = 0; | 1591 | int connected = 0; |
1553 | __be16 orig_port = 0; | 1592 | __be16 orig_port = 0; |
1554 | 1593 | ||
1555 | if(*csocket == NULL) { | 1594 | if (*csocket == NULL) { |
1556 | rc = sock_create_kern(PF_INET6, SOCK_STREAM, IPPROTO_TCP, csocket); | 1595 | rc = sock_create_kern(PF_INET6, SOCK_STREAM, |
1596 | IPPROTO_TCP, csocket); | ||
1557 | if (rc < 0) { | 1597 | if (rc < 0) { |
1558 | cERROR(1, ("Error %d creating ipv6 socket",rc)); | 1598 | cERROR(1, ("Error %d creating ipv6 socket", rc)); |
1559 | *csocket = NULL; | 1599 | *csocket = NULL; |
1560 | return rc; | 1600 | return rc; |
1561 | } else { | 1601 | } else { |
1562 | /* BB other socket options to set KEEPALIVE, NODELAY? */ | 1602 | /* BB other socket options to set KEEPALIVE, NODELAY? */ |
1563 | cFYI(1,("ipv6 Socket created")); | 1603 | cFYI(1, ("ipv6 Socket created")); |
1564 | (*csocket)->sk->sk_allocation = GFP_NOFS; | 1604 | (*csocket)->sk->sk_allocation = GFP_NOFS; |
1565 | } | 1605 | } |
1566 | } | 1606 | } |
1567 | 1607 | ||
1568 | psin_server->sin6_family = AF_INET6; | 1608 | psin_server->sin6_family = AF_INET6; |
1569 | 1609 | ||
1570 | if(psin_server->sin6_port) { /* user overrode default port */ | 1610 | if (psin_server->sin6_port) { /* user overrode default port */ |
1571 | rc = (*csocket)->ops->connect(*csocket, | 1611 | rc = (*csocket)->ops->connect(*csocket, |
1572 | (struct sockaddr *) psin_server, | 1612 | (struct sockaddr *) psin_server, |
1573 | sizeof (struct sockaddr_in6),0); | 1613 | sizeof (struct sockaddr_in6), 0); |
1574 | if (rc >= 0) | 1614 | if (rc >= 0) |
1575 | connected = 1; | 1615 | connected = 1; |
1576 | } | 1616 | } |
1577 | 1617 | ||
1578 | if(!connected) { | 1618 | if (!connected) { |
1579 | /* save original port so we can retry user specified port | 1619 | /* save original port so we can retry user specified port |
1580 | later if fall back ports fail this time */ | 1620 | later if fall back ports fail this time */ |
1581 | 1621 | ||
1582 | orig_port = psin_server->sin6_port; | 1622 | orig_port = psin_server->sin6_port; |
1583 | /* do not retry on the same port we just failed on */ | 1623 | /* do not retry on the same port we just failed on */ |
1584 | if(psin_server->sin6_port != htons(CIFS_PORT)) { | 1624 | if (psin_server->sin6_port != htons(CIFS_PORT)) { |
1585 | psin_server->sin6_port = htons(CIFS_PORT); | 1625 | psin_server->sin6_port = htons(CIFS_PORT); |
1586 | 1626 | ||
1587 | rc = (*csocket)->ops->connect(*csocket, | 1627 | rc = (*csocket)->ops->connect(*csocket, |
1588 | (struct sockaddr *) psin_server, | 1628 | (struct sockaddr *) psin_server, |
1589 | sizeof (struct sockaddr_in6),0); | 1629 | sizeof (struct sockaddr_in6), 0); |
1590 | if (rc >= 0) | 1630 | if (rc >= 0) |
1591 | connected = 1; | 1631 | connected = 1; |
1592 | } | 1632 | } |
@@ -1594,31 +1634,31 @@ ipv6_connect(struct sockaddr_in6 *psin_server, struct socket **csocket) | |||
1594 | if (!connected) { | 1634 | if (!connected) { |
1595 | psin_server->sin6_port = htons(RFC1001_PORT); | 1635 | psin_server->sin6_port = htons(RFC1001_PORT); |
1596 | rc = (*csocket)->ops->connect(*csocket, (struct sockaddr *) | 1636 | rc = (*csocket)->ops->connect(*csocket, (struct sockaddr *) |
1597 | psin_server, sizeof (struct sockaddr_in6),0); | 1637 | psin_server, sizeof (struct sockaddr_in6), 0); |
1598 | if (rc >= 0) | 1638 | if (rc >= 0) |
1599 | connected = 1; | 1639 | connected = 1; |
1600 | } | 1640 | } |
1601 | 1641 | ||
1602 | /* give up here - unless we want to retry on different | 1642 | /* give up here - unless we want to retry on different |
1603 | protocol families some day */ | 1643 | protocol families some day */ |
1604 | if (!connected) { | 1644 | if (!connected) { |
1605 | if(orig_port) | 1645 | if (orig_port) |
1606 | psin_server->sin6_port = orig_port; | 1646 | psin_server->sin6_port = orig_port; |
1607 | cFYI(1,("Error %d connecting to server via ipv6",rc)); | 1647 | cFYI(1, ("Error %d connecting to server via ipv6", rc)); |
1608 | sock_release(*csocket); | 1648 | sock_release(*csocket); |
1609 | *csocket = NULL; | 1649 | *csocket = NULL; |
1610 | return rc; | 1650 | return rc; |
1611 | } | 1651 | } |
1612 | /* Eventually check for other socket options to change from | 1652 | /* Eventually check for other socket options to change from |
1613 | the default. sock_setsockopt not used because it expects | 1653 | the default. sock_setsockopt not used because it expects |
1614 | user space buffer */ | 1654 | user space buffer */ |
1615 | (*csocket)->sk->sk_rcvtimeo = 7 * HZ; | 1655 | (*csocket)->sk->sk_rcvtimeo = 7 * HZ; |
1616 | 1656 | ||
1617 | return rc; | 1657 | return rc; |
1618 | } | 1658 | } |
1619 | 1659 | ||
1620 | void reset_cifs_unix_caps(int xid, struct cifsTconInfo * tcon, | 1660 | void reset_cifs_unix_caps(int xid, struct cifsTconInfo *tcon, |
1621 | struct super_block * sb, struct smb_vol * vol_info) | 1661 | struct super_block *sb, struct smb_vol *vol_info) |
1622 | { | 1662 | { |
1623 | /* if we are reconnecting then should we check to see if | 1663 | /* if we are reconnecting then should we check to see if |
1624 | * any requested capabilities changed locally e.g. via | 1664 | * any requested capabilities changed locally e.g. via |
@@ -1630,65 +1670,87 @@ void reset_cifs_unix_caps(int xid, struct cifsTconInfo * tcon, | |||
1630 | * What if we wanted to mount the server share twice once with | 1670 | * What if we wanted to mount the server share twice once with |
1631 | * and once without posixacls or posix paths? */ | 1671 | * and once without posixacls or posix paths? */ |
1632 | __u64 saved_cap = le64_to_cpu(tcon->fsUnixInfo.Capability); | 1672 | __u64 saved_cap = le64_to_cpu(tcon->fsUnixInfo.Capability); |
1633 | 1673 | ||
1634 | 1674 | if (vol_info && vol_info->no_linux_ext) { | |
1635 | if(!CIFSSMBQFSUnixInfo(xid, tcon)) { | 1675 | tcon->fsUnixInfo.Capability = 0; |
1676 | tcon->unix_ext = 0; /* Unix Extensions disabled */ | ||
1677 | cFYI(1, ("Linux protocol extensions disabled")); | ||
1678 | return; | ||
1679 | } else if (vol_info) | ||
1680 | tcon->unix_ext = 1; /* Unix Extensions supported */ | ||
1681 | |||
1682 | if (tcon->unix_ext == 0) { | ||
1683 | cFYI(1, ("Unix extensions disabled so not set on reconnect")); | ||
1684 | return; | ||
1685 | } | ||
1686 | |||
1687 | if (!CIFSSMBQFSUnixInfo(xid, tcon)) { | ||
1636 | __u64 cap = le64_to_cpu(tcon->fsUnixInfo.Capability); | 1688 | __u64 cap = le64_to_cpu(tcon->fsUnixInfo.Capability); |
1637 | 1689 | ||
1638 | /* check for reconnect case in which we do not | 1690 | /* check for reconnect case in which we do not |
1639 | want to change the mount behavior if we can avoid it */ | 1691 | want to change the mount behavior if we can avoid it */ |
1640 | if(vol_info == NULL) { | 1692 | if (vol_info == NULL) { |
1641 | /* turn off POSIX ACL and PATHNAMES if not set | 1693 | /* turn off POSIX ACL and PATHNAMES if not set |
1642 | originally at mount time */ | 1694 | originally at mount time */ |
1643 | if ((saved_cap & CIFS_UNIX_POSIX_ACL_CAP) == 0) | 1695 | if ((saved_cap & CIFS_UNIX_POSIX_ACL_CAP) == 0) |
1644 | cap &= ~CIFS_UNIX_POSIX_ACL_CAP; | 1696 | cap &= ~CIFS_UNIX_POSIX_ACL_CAP; |
1645 | if ((saved_cap & CIFS_UNIX_POSIX_PATHNAMES_CAP) == 0) | 1697 | if ((saved_cap & CIFS_UNIX_POSIX_PATHNAMES_CAP) == 0) |
1646 | cap &= ~CIFS_UNIX_POSIX_PATHNAMES_CAP; | 1698 | cap &= ~CIFS_UNIX_POSIX_PATHNAMES_CAP; |
1647 | |||
1648 | |||
1649 | |||
1650 | |||
1651 | } | 1699 | } |
1652 | 1700 | ||
1653 | cap &= CIFS_UNIX_CAP_MASK; | 1701 | cap &= CIFS_UNIX_CAP_MASK; |
1654 | if(vol_info && vol_info->no_psx_acl) | 1702 | if (vol_info && vol_info->no_psx_acl) |
1655 | cap &= ~CIFS_UNIX_POSIX_ACL_CAP; | 1703 | cap &= ~CIFS_UNIX_POSIX_ACL_CAP; |
1656 | else if(CIFS_UNIX_POSIX_ACL_CAP & cap) { | 1704 | else if (CIFS_UNIX_POSIX_ACL_CAP & cap) { |
1657 | cFYI(1,("negotiated posix acl support")); | 1705 | cFYI(1, ("negotiated posix acl support")); |
1658 | if(sb) | 1706 | if (sb) |
1659 | sb->s_flags |= MS_POSIXACL; | 1707 | sb->s_flags |= MS_POSIXACL; |
1660 | } | 1708 | } |
1661 | 1709 | ||
1662 | if(vol_info && vol_info->posix_paths == 0) | 1710 | if (vol_info && vol_info->posix_paths == 0) |
1663 | cap &= ~CIFS_UNIX_POSIX_PATHNAMES_CAP; | 1711 | cap &= ~CIFS_UNIX_POSIX_PATHNAMES_CAP; |
1664 | else if(cap & CIFS_UNIX_POSIX_PATHNAMES_CAP) { | 1712 | else if (cap & CIFS_UNIX_POSIX_PATHNAMES_CAP) { |
1665 | cFYI(1,("negotiate posix pathnames")); | 1713 | cFYI(1, ("negotiate posix pathnames")); |
1666 | if(sb) | 1714 | if (sb) |
1667 | CIFS_SB(sb)->mnt_cifs_flags |= | 1715 | CIFS_SB(sb)->mnt_cifs_flags |= |
1668 | CIFS_MOUNT_POSIX_PATHS; | 1716 | CIFS_MOUNT_POSIX_PATHS; |
1669 | } | 1717 | } |
1670 | 1718 | ||
1671 | /* We might be setting the path sep back to a different | 1719 | /* We might be setting the path sep back to a different |
1672 | form if we are reconnecting and the server switched its | 1720 | form if we are reconnecting and the server switched its |
1673 | posix path capability for this share */ | 1721 | posix path capability for this share */ |
1674 | if(sb && (CIFS_SB(sb)->prepathlen > 0)) | 1722 | if (sb && (CIFS_SB(sb)->prepathlen > 0)) |
1675 | CIFS_SB(sb)->prepath[0] = CIFS_DIR_SEP(CIFS_SB(sb)); | 1723 | CIFS_SB(sb)->prepath[0] = CIFS_DIR_SEP(CIFS_SB(sb)); |
1676 | 1724 | ||
1677 | cFYI(1,("Negotiate caps 0x%x",(int)cap)); | 1725 | if (sb && (CIFS_SB(sb)->rsize > 127 * 1024)) { |
1726 | if ((cap & CIFS_UNIX_LARGE_READ_CAP) == 0) { | ||
1727 | CIFS_SB(sb)->rsize = 127 * 1024; | ||
1728 | #ifdef CONFIG_CIFS_DEBUG2 | ||
1729 | cFYI(1, ("larger reads not supported by srv")); | ||
1730 | #endif | ||
1731 | } | ||
1732 | } | ||
1733 | |||
1734 | |||
1735 | cFYI(1, ("Negotiate caps 0x%x", (int)cap)); | ||
1678 | #ifdef CONFIG_CIFS_DEBUG2 | 1736 | #ifdef CONFIG_CIFS_DEBUG2 |
1679 | if(cap & CIFS_UNIX_FCNTL_CAP) | 1737 | if (cap & CIFS_UNIX_FCNTL_CAP) |
1680 | cFYI(1,("FCNTL cap")); | 1738 | cFYI(1, ("FCNTL cap")); |
1681 | if(cap & CIFS_UNIX_EXTATTR_CAP) | 1739 | if (cap & CIFS_UNIX_EXTATTR_CAP) |
1682 | cFYI(1,("EXTATTR cap")); | 1740 | cFYI(1, ("EXTATTR cap")); |
1683 | if(cap & CIFS_UNIX_POSIX_PATHNAMES_CAP) | 1741 | if (cap & CIFS_UNIX_POSIX_PATHNAMES_CAP) |
1684 | cFYI(1,("POSIX path cap")); | 1742 | cFYI(1, ("POSIX path cap")); |
1685 | if(cap & CIFS_UNIX_XATTR_CAP) | 1743 | if (cap & CIFS_UNIX_XATTR_CAP) |
1686 | cFYI(1,("XATTR cap")); | 1744 | cFYI(1, ("XATTR cap")); |
1687 | if(cap & CIFS_UNIX_POSIX_ACL_CAP) | 1745 | if (cap & CIFS_UNIX_POSIX_ACL_CAP) |
1688 | cFYI(1,("POSIX ACL cap")); | 1746 | cFYI(1, ("POSIX ACL cap")); |
1747 | if (cap & CIFS_UNIX_LARGE_READ_CAP) | ||
1748 | cFYI(1, ("very large read cap")); | ||
1749 | if (cap & CIFS_UNIX_LARGE_WRITE_CAP) | ||
1750 | cFYI(1, ("very large write cap")); | ||
1689 | #endif /* CIFS_DEBUG2 */ | 1751 | #endif /* CIFS_DEBUG2 */ |
1690 | if (CIFSSMBSetFSUnixInfo(xid, tcon, cap)) { | 1752 | if (CIFSSMBSetFSUnixInfo(xid, tcon, cap)) { |
1691 | cFYI(1,("setting capabilities failed")); | 1753 | cFYI(1, ("setting capabilities failed")); |
1692 | } | 1754 | } |
1693 | } | 1755 | } |
1694 | } | 1756 | } |
@@ -1712,8 +1774,8 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1712 | xid = GetXid(); | 1774 | xid = GetXid(); |
1713 | 1775 | ||
1714 | /* cFYI(1, ("Entering cifs_mount. Xid: %d with: %s", xid, mount_data)); */ | 1776 | /* cFYI(1, ("Entering cifs_mount. Xid: %d with: %s", xid, mount_data)); */ |
1715 | 1777 | ||
1716 | memset(&volume_info,0,sizeof(struct smb_vol)); | 1778 | memset(&volume_info, 0, sizeof(struct smb_vol)); |
1717 | if (cifs_parse_mount_options(mount_data, devname, &volume_info)) { | 1779 | if (cifs_parse_mount_options(mount_data, devname, &volume_info)) { |
1718 | kfree(volume_info.UNC); | 1780 | kfree(volume_info.UNC); |
1719 | kfree(volume_info.password); | 1781 | kfree(volume_info.password); |
@@ -1723,15 +1785,15 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1723 | } | 1785 | } |
1724 | 1786 | ||
1725 | if (volume_info.nullauth) { | 1787 | if (volume_info.nullauth) { |
1726 | cFYI(1,("null user")); | 1788 | cFYI(1, ("null user")); |
1727 | volume_info.username = NULL; | 1789 | volume_info.username = NULL; |
1728 | } else if (volume_info.username) { | 1790 | } else if (volume_info.username) { |
1729 | /* BB fixme parse for domain name here */ | 1791 | /* BB fixme parse for domain name here */ |
1730 | cFYI(1, ("Username: %s ", volume_info.username)); | 1792 | cFYI(1, ("Username: %s", volume_info.username)); |
1731 | } else { | 1793 | } else { |
1732 | cifserror("No username specified"); | 1794 | cifserror("No username specified"); |
1733 | /* In userspace mount helper we can get user name from alternate | 1795 | /* In userspace mount helper we can get user name from alternate |
1734 | locations such as env variables and files on disk */ | 1796 | locations such as env variables and files on disk */ |
1735 | kfree(volume_info.UNC); | 1797 | kfree(volume_info.UNC); |
1736 | kfree(volume_info.password); | 1798 | kfree(volume_info.password); |
1737 | kfree(volume_info.prepath); | 1799 | kfree(volume_info.prepath); |
@@ -1740,18 +1802,20 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1740 | } | 1802 | } |
1741 | 1803 | ||
1742 | if (volume_info.UNCip && volume_info.UNC) { | 1804 | if (volume_info.UNCip && volume_info.UNC) { |
1743 | rc = cifs_inet_pton(AF_INET, volume_info.UNCip,&sin_server.sin_addr.s_addr); | 1805 | rc = cifs_inet_pton(AF_INET, volume_info.UNCip, |
1806 | &sin_server.sin_addr.s_addr); | ||
1744 | 1807 | ||
1745 | if(rc <= 0) { | 1808 | if (rc <= 0) { |
1746 | /* not ipv4 address, try ipv6 */ | 1809 | /* not ipv4 address, try ipv6 */ |
1747 | rc = cifs_inet_pton(AF_INET6,volume_info.UNCip,&sin_server6.sin6_addr.in6_u); | 1810 | rc = cifs_inet_pton(AF_INET6, volume_info.UNCip, |
1748 | if(rc > 0) | 1811 | &sin_server6.sin6_addr.in6_u); |
1812 | if (rc > 0) | ||
1749 | address_type = AF_INET6; | 1813 | address_type = AF_INET6; |
1750 | } else { | 1814 | } else { |
1751 | address_type = AF_INET; | 1815 | address_type = AF_INET; |
1752 | } | 1816 | } |
1753 | 1817 | ||
1754 | if(rc <= 0) { | 1818 | if (rc <= 0) { |
1755 | /* we failed translating address */ | 1819 | /* we failed translating address */ |
1756 | kfree(volume_info.UNC); | 1820 | kfree(volume_info.UNC); |
1757 | kfree(volume_info.password); | 1821 | kfree(volume_info.password); |
@@ -1763,9 +1827,10 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1763 | cFYI(1, ("UNC: %s ip: %s", volume_info.UNC, volume_info.UNCip)); | 1827 | cFYI(1, ("UNC: %s ip: %s", volume_info.UNC, volume_info.UNCip)); |
1764 | /* success */ | 1828 | /* success */ |
1765 | rc = 0; | 1829 | rc = 0; |
1766 | } else if (volume_info.UNCip){ | 1830 | } else if (volume_info.UNCip) { |
1767 | /* BB using ip addr as server name connect to the DFS root below */ | 1831 | /* BB using ip addr as server name to connect to the |
1768 | cERROR(1,("Connecting to DFS root not implemented yet")); | 1832 | DFS root below */ |
1833 | cERROR(1, ("Connecting to DFS root not implemented yet")); | ||
1769 | kfree(volume_info.UNC); | 1834 | kfree(volume_info.UNC); |
1770 | kfree(volume_info.password); | 1835 | kfree(volume_info.password); |
1771 | kfree(volume_info.prepath); | 1836 | kfree(volume_info.prepath); |
@@ -1773,7 +1838,8 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1773 | return -EINVAL; | 1838 | return -EINVAL; |
1774 | } else /* which servers DFS root would we conect to */ { | 1839 | } else /* which servers DFS root would we conect to */ { |
1775 | cERROR(1, | 1840 | cERROR(1, |
1776 | ("CIFS mount error: No UNC path (e.g. -o unc=//192.168.1.100/public) specified")); | 1841 | ("CIFS mount error: No UNC path (e.g. -o " |
1842 | "unc=//192.168.1.100/public) specified")); | ||
1777 | kfree(volume_info.UNC); | 1843 | kfree(volume_info.UNC); |
1778 | kfree(volume_info.password); | 1844 | kfree(volume_info.password); |
1779 | kfree(volume_info.prepath); | 1845 | kfree(volume_info.prepath); |
@@ -1782,13 +1848,14 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1782 | } | 1848 | } |
1783 | 1849 | ||
1784 | /* this is needed for ASCII cp to Unicode converts */ | 1850 | /* this is needed for ASCII cp to Unicode converts */ |
1785 | if(volume_info.iocharset == NULL) { | 1851 | if (volume_info.iocharset == NULL) { |
1786 | cifs_sb->local_nls = load_nls_default(); | 1852 | cifs_sb->local_nls = load_nls_default(); |
1787 | /* load_nls_default can not return null */ | 1853 | /* load_nls_default can not return null */ |
1788 | } else { | 1854 | } else { |
1789 | cifs_sb->local_nls = load_nls(volume_info.iocharset); | 1855 | cifs_sb->local_nls = load_nls(volume_info.iocharset); |
1790 | if(cifs_sb->local_nls == NULL) { | 1856 | if (cifs_sb->local_nls == NULL) { |
1791 | cERROR(1,("CIFS mount error: iocharset %s not found",volume_info.iocharset)); | 1857 | cERROR(1, ("CIFS mount error: iocharset %s not found", |
1858 | volume_info.iocharset)); | ||
1792 | kfree(volume_info.UNC); | 1859 | kfree(volume_info.UNC); |
1793 | kfree(volume_info.password); | 1860 | kfree(volume_info.password); |
1794 | kfree(volume_info.prepath); | 1861 | kfree(volume_info.prepath); |
@@ -1797,12 +1864,12 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1797 | } | 1864 | } |
1798 | } | 1865 | } |
1799 | 1866 | ||
1800 | if(address_type == AF_INET) | 1867 | if (address_type == AF_INET) |
1801 | existingCifsSes = cifs_find_tcp_session(&sin_server.sin_addr, | 1868 | existingCifsSes = cifs_find_tcp_session(&sin_server.sin_addr, |
1802 | NULL /* no ipv6 addr */, | 1869 | NULL /* no ipv6 addr */, |
1803 | volume_info.username, &srvTcp); | 1870 | volume_info.username, &srvTcp); |
1804 | else if(address_type == AF_INET6) { | 1871 | else if (address_type == AF_INET6) { |
1805 | cFYI(1,("looking for ipv6 address")); | 1872 | cFYI(1, ("looking for ipv6 address")); |
1806 | existingCifsSes = cifs_find_tcp_session(NULL /* no ipv4 addr */, | 1873 | existingCifsSes = cifs_find_tcp_session(NULL /* no ipv4 addr */, |
1807 | &sin_server6.sin6_addr, | 1874 | &sin_server6.sin6_addr, |
1808 | volume_info.username, &srvTcp); | 1875 | volume_info.username, &srvTcp); |
@@ -1814,26 +1881,25 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1814 | return -EINVAL; | 1881 | return -EINVAL; |
1815 | } | 1882 | } |
1816 | 1883 | ||
1817 | |||
1818 | if (srvTcp) { | 1884 | if (srvTcp) { |
1819 | cFYI(1, ("Existing tcp session with server found")); | 1885 | cFYI(1, ("Existing tcp session with server found")); |
1820 | } else { /* create socket */ | 1886 | } else { /* create socket */ |
1821 | if (volume_info.port) | 1887 | if (volume_info.port) |
1822 | sin_server.sin_port = htons(volume_info.port); | 1888 | sin_server.sin_port = htons(volume_info.port); |
1823 | else | 1889 | else |
1824 | sin_server.sin_port = 0; | 1890 | sin_server.sin_port = 0; |
1825 | if (address_type == AF_INET6) { | 1891 | if (address_type == AF_INET6) { |
1826 | cFYI(1,("attempting ipv6 connect")); | 1892 | cFYI(1, ("attempting ipv6 connect")); |
1827 | /* BB should we allow ipv6 on port 139? */ | 1893 | /* BB should we allow ipv6 on port 139? */ |
1828 | /* other OS never observed in Wild doing 139 with v6 */ | 1894 | /* other OS never observed in Wild doing 139 with v6 */ |
1829 | rc = ipv6_connect(&sin_server6,&csocket); | 1895 | rc = ipv6_connect(&sin_server6, &csocket); |
1830 | } else | 1896 | } else |
1831 | rc = ipv4_connect(&sin_server,&csocket, | 1897 | rc = ipv4_connect(&sin_server, &csocket, |
1832 | volume_info.source_rfc1001_name, | 1898 | volume_info.source_rfc1001_name, |
1833 | volume_info.target_rfc1001_name); | 1899 | volume_info.target_rfc1001_name); |
1834 | if (rc < 0) { | 1900 | if (rc < 0) { |
1835 | cERROR(1, | 1901 | cERROR(1, ("Error connecting to IPv4 socket. " |
1836 | ("Error connecting to IPv4 socket. Aborting operation")); | 1902 | "Aborting operation")); |
1837 | if (csocket != NULL) | 1903 | if (csocket != NULL) |
1838 | sock_release(csocket); | 1904 | sock_release(csocket); |
1839 | kfree(volume_info.UNC); | 1905 | kfree(volume_info.UNC); |
@@ -1854,8 +1920,9 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1854 | return rc; | 1920 | return rc; |
1855 | } else { | 1921 | } else { |
1856 | memset(srvTcp, 0, sizeof (struct TCP_Server_Info)); | 1922 | memset(srvTcp, 0, sizeof (struct TCP_Server_Info)); |
1857 | memcpy(&srvTcp->addr.sockAddr, &sin_server, sizeof (struct sockaddr_in)); | 1923 | memcpy(&srvTcp->addr.sockAddr, &sin_server, |
1858 | atomic_set(&srvTcp->inFlight,0); | 1924 | sizeof (struct sockaddr_in)); |
1925 | atomic_set(&srvTcp->inFlight, 0); | ||
1859 | /* BB Add code for ipv6 case too */ | 1926 | /* BB Add code for ipv6 case too */ |
1860 | srvTcp->ssocket = csocket; | 1927 | srvTcp->ssocket = csocket; |
1861 | srvTcp->protocolType = IPV4; | 1928 | srvTcp->protocolType = IPV4; |
@@ -1870,7 +1937,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1870 | srvTcp->tsk = kthread_run((void *)(void *)cifs_demultiplex_thread, srvTcp, "cifsd"); | 1937 | srvTcp->tsk = kthread_run((void *)(void *)cifs_demultiplex_thread, srvTcp, "cifsd"); |
1871 | if ( IS_ERR(srvTcp->tsk) ) { | 1938 | if ( IS_ERR(srvTcp->tsk) ) { |
1872 | rc = PTR_ERR(srvTcp->tsk); | 1939 | rc = PTR_ERR(srvTcp->tsk); |
1873 | cERROR(1,("error %d create cifsd thread", rc)); | 1940 | cERROR(1, ("error %d create cifsd thread", rc)); |
1874 | srvTcp->tsk = NULL; | 1941 | srvTcp->tsk = NULL; |
1875 | sock_release(csocket); | 1942 | sock_release(csocket); |
1876 | kfree(volume_info.UNC); | 1943 | kfree(volume_info.UNC); |
@@ -1881,8 +1948,10 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1881 | } | 1948 | } |
1882 | wait_for_completion(&cifsd_complete); | 1949 | wait_for_completion(&cifsd_complete); |
1883 | rc = 0; | 1950 | rc = 0; |
1884 | memcpy(srvTcp->workstation_RFC1001_name, volume_info.source_rfc1001_name,16); | 1951 | memcpy(srvTcp->workstation_RFC1001_name, |
1885 | memcpy(srvTcp->server_RFC1001_name, volume_info.target_rfc1001_name,16); | 1952 | volume_info.source_rfc1001_name, 16); |
1953 | memcpy(srvTcp->server_RFC1001_name, | ||
1954 | volume_info.target_rfc1001_name, 16); | ||
1886 | srvTcp->sequence_number = 0; | 1955 | srvTcp->sequence_number = 0; |
1887 | } | 1956 | } |
1888 | } | 1957 | } |
@@ -1903,16 +1972,17 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1903 | NIPQUAD(sin_server.sin_addr.s_addr)); | 1972 | NIPQUAD(sin_server.sin_addr.s_addr)); |
1904 | } | 1973 | } |
1905 | 1974 | ||
1906 | if (!rc){ | 1975 | if (!rc) { |
1907 | /* volume_info.password freed at unmount */ | 1976 | /* volume_info.password freed at unmount */ |
1908 | if (volume_info.password) | 1977 | if (volume_info.password) |
1909 | pSesInfo->password = volume_info.password; | 1978 | pSesInfo->password = volume_info.password; |
1910 | if (volume_info.username) | 1979 | if (volume_info.username) |
1911 | strncpy(pSesInfo->userName, | 1980 | strncpy(pSesInfo->userName, |
1912 | volume_info.username,MAX_USERNAME_SIZE); | 1981 | volume_info.username, |
1982 | MAX_USERNAME_SIZE); | ||
1913 | if (volume_info.domainname) { | 1983 | if (volume_info.domainname) { |
1914 | int len = strlen(volume_info.domainname); | 1984 | int len = strlen(volume_info.domainname); |
1915 | pSesInfo->domainName = | 1985 | pSesInfo->domainName = |
1916 | kmalloc(len + 1, GFP_KERNEL); | 1986 | kmalloc(len + 1, GFP_KERNEL); |
1917 | if (pSesInfo->domainName) | 1987 | if (pSesInfo->domainName) |
1918 | strcpy(pSesInfo->domainName, | 1988 | strcpy(pSesInfo->domainName, |
@@ -1922,46 +1992,48 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1922 | pSesInfo->overrideSecFlg = volume_info.secFlg; | 1992 | pSesInfo->overrideSecFlg = volume_info.secFlg; |
1923 | down(&pSesInfo->sesSem); | 1993 | down(&pSesInfo->sesSem); |
1924 | /* BB FIXME need to pass vol->secFlgs BB */ | 1994 | /* BB FIXME need to pass vol->secFlgs BB */ |
1925 | rc = cifs_setup_session(xid,pSesInfo, cifs_sb->local_nls); | 1995 | rc = cifs_setup_session(xid, pSesInfo, |
1996 | cifs_sb->local_nls); | ||
1926 | up(&pSesInfo->sesSem); | 1997 | up(&pSesInfo->sesSem); |
1927 | if (!rc) | 1998 | if (!rc) |
1928 | atomic_inc(&srvTcp->socketUseCount); | 1999 | atomic_inc(&srvTcp->socketUseCount); |
1929 | } else | 2000 | } else |
1930 | kfree(volume_info.password); | 2001 | kfree(volume_info.password); |
1931 | } | 2002 | } |
1932 | 2003 | ||
1933 | /* search for existing tcon to this server share */ | 2004 | /* search for existing tcon to this server share */ |
1934 | if (!rc) { | 2005 | if (!rc) { |
1935 | if (volume_info.rsize > CIFSMaxBufSize) { | 2006 | if (volume_info.rsize > CIFSMaxBufSize) { |
1936 | cERROR(1,("rsize %d too large, using MaxBufSize", | 2007 | cERROR(1, ("rsize %d too large, using MaxBufSize", |
1937 | volume_info.rsize)); | 2008 | volume_info.rsize)); |
1938 | cifs_sb->rsize = CIFSMaxBufSize; | 2009 | cifs_sb->rsize = CIFSMaxBufSize; |
1939 | } else if((volume_info.rsize) && (volume_info.rsize <= CIFSMaxBufSize)) | 2010 | } else if ((volume_info.rsize) && |
2011 | (volume_info.rsize <= CIFSMaxBufSize)) | ||
1940 | cifs_sb->rsize = volume_info.rsize; | 2012 | cifs_sb->rsize = volume_info.rsize; |
1941 | else /* default */ | 2013 | else /* default */ |
1942 | cifs_sb->rsize = CIFSMaxBufSize; | 2014 | cifs_sb->rsize = CIFSMaxBufSize; |
1943 | 2015 | ||
1944 | if (volume_info.wsize > PAGEVEC_SIZE * PAGE_CACHE_SIZE) { | 2016 | if (volume_info.wsize > PAGEVEC_SIZE * PAGE_CACHE_SIZE) { |
1945 | cERROR(1,("wsize %d too large using 4096 instead", | 2017 | cERROR(1, ("wsize %d too large, using 4096 instead", |
1946 | volume_info.wsize)); | 2018 | volume_info.wsize)); |
1947 | cifs_sb->wsize = 4096; | 2019 | cifs_sb->wsize = 4096; |
1948 | } else if (volume_info.wsize) | 2020 | } else if (volume_info.wsize) |
1949 | cifs_sb->wsize = volume_info.wsize; | 2021 | cifs_sb->wsize = volume_info.wsize; |
1950 | else | 2022 | else |
1951 | cifs_sb->wsize = | 2023 | cifs_sb->wsize = |
1952 | min_t(const int, PAGEVEC_SIZE * PAGE_CACHE_SIZE, | 2024 | min_t(const int, PAGEVEC_SIZE * PAGE_CACHE_SIZE, |
1953 | 127*1024); | 2025 | 127*1024); |
1954 | /* old default of CIFSMaxBufSize was too small now | 2026 | /* old default of CIFSMaxBufSize was too small now |
1955 | that SMB Write2 can send multiple pages in kvec. | 2027 | that SMB Write2 can send multiple pages in kvec. |
1956 | RFC1001 does not describe what happens when frame | 2028 | RFC1001 does not describe what happens when frame |
1957 | bigger than 128K is sent so use that as max in | 2029 | bigger than 128K is sent so use that as max in |
1958 | conjunction with 52K kvec constraint on arch with 4K | 2030 | conjunction with 52K kvec constraint on arch with 4K |
1959 | page size */ | 2031 | page size */ |
1960 | 2032 | ||
1961 | if (cifs_sb->rsize < 2048) { | 2033 | if (cifs_sb->rsize < 2048) { |
1962 | cifs_sb->rsize = 2048; | 2034 | cifs_sb->rsize = 2048; |
1963 | /* Windows ME may prefer this */ | 2035 | /* Windows ME may prefer this */ |
1964 | cFYI(1,("readsize set to minimum 2048")); | 2036 | cFYI(1, ("readsize set to minimum: 2048")); |
1965 | } | 2037 | } |
1966 | /* calculate prepath */ | 2038 | /* calculate prepath */ |
1967 | cifs_sb->prepath = volume_info.prepath; | 2039 | cifs_sb->prepath = volume_info.prepath; |
@@ -1969,14 +2041,14 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1969 | cifs_sb->prepathlen = strlen(cifs_sb->prepath); | 2041 | cifs_sb->prepathlen = strlen(cifs_sb->prepath); |
1970 | cifs_sb->prepath[0] = CIFS_DIR_SEP(cifs_sb); | 2042 | cifs_sb->prepath[0] = CIFS_DIR_SEP(cifs_sb); |
1971 | volume_info.prepath = NULL; | 2043 | volume_info.prepath = NULL; |
1972 | } else | 2044 | } else |
1973 | cifs_sb->prepathlen = 0; | 2045 | cifs_sb->prepathlen = 0; |
1974 | cifs_sb->mnt_uid = volume_info.linux_uid; | 2046 | cifs_sb->mnt_uid = volume_info.linux_uid; |
1975 | cifs_sb->mnt_gid = volume_info.linux_gid; | 2047 | cifs_sb->mnt_gid = volume_info.linux_gid; |
1976 | cifs_sb->mnt_file_mode = volume_info.file_mode; | 2048 | cifs_sb->mnt_file_mode = volume_info.file_mode; |
1977 | cifs_sb->mnt_dir_mode = volume_info.dir_mode; | 2049 | cifs_sb->mnt_dir_mode = volume_info.dir_mode; |
1978 | cFYI(1,("file mode: 0x%x dir mode: 0x%x", | 2050 | cFYI(1, ("file mode: 0x%x dir mode: 0x%x", |
1979 | cifs_sb->mnt_file_mode,cifs_sb->mnt_dir_mode)); | 2051 | cifs_sb->mnt_file_mode, cifs_sb->mnt_dir_mode)); |
1980 | 2052 | ||
1981 | if (volume_info.noperm) | 2053 | if (volume_info.noperm) |
1982 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_PERM; | 2054 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_PERM; |
@@ -1999,7 +2071,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1999 | if (volume_info.override_gid) | 2071 | if (volume_info.override_gid) |
2000 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_OVERR_GID; | 2072 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_OVERR_GID; |
2001 | if (volume_info.direct_io) { | 2073 | if (volume_info.direct_io) { |
2002 | cFYI(1,("mounting share using direct i/o")); | 2074 | cFYI(1, ("mounting share using direct i/o")); |
2003 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_DIRECT_IO; | 2075 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_DIRECT_IO; |
2004 | } | 2076 | } |
2005 | 2077 | ||
@@ -2010,7 +2082,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
2010 | cFYI(1, ("Found match on UNC path")); | 2082 | cFYI(1, ("Found match on UNC path")); |
2011 | /* we can have only one retry value for a connection | 2083 | /* we can have only one retry value for a connection |
2012 | to a share so for resources mounted more than once | 2084 | to a share so for resources mounted more than once |
2013 | to the same server share the last value passed in | 2085 | to the same server share the last value passed in |
2014 | for the retry flag is used */ | 2086 | for the retry flag is used */ |
2015 | tcon->retry = volume_info.retry; | 2087 | tcon->retry = volume_info.retry; |
2016 | tcon->nocase = volume_info.nocase; | 2088 | tcon->nocase = volume_info.nocase; |
@@ -2019,17 +2091,17 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
2019 | if (tcon == NULL) | 2091 | if (tcon == NULL) |
2020 | rc = -ENOMEM; | 2092 | rc = -ENOMEM; |
2021 | else { | 2093 | else { |
2022 | /* check for null share name ie connecting to | 2094 | /* check for null share name ie connecting to |
2023 | * dfs root */ | 2095 | * dfs root */ |
2024 | 2096 | ||
2025 | /* BB check if this works for exactly length | 2097 | /* BB check if this works for exactly length |
2026 | * three strings */ | 2098 | * three strings */ |
2027 | if ((strchr(volume_info.UNC + 3, '\\') == NULL) | 2099 | if ((strchr(volume_info.UNC + 3, '\\') == NULL) |
2028 | && (strchr(volume_info.UNC + 3, '/') == | 2100 | && (strchr(volume_info.UNC + 3, '/') == |
2029 | NULL)) { | 2101 | NULL)) { |
2030 | rc = connect_to_dfs_path(xid, pSesInfo, | 2102 | rc = connect_to_dfs_path(xid, pSesInfo, |
2031 | "", cifs_sb->local_nls, | 2103 | "", cifs_sb->local_nls, |
2032 | cifs_sb->mnt_cifs_flags & | 2104 | cifs_sb->mnt_cifs_flags & |
2033 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 2105 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
2034 | kfree(volume_info.UNC); | 2106 | kfree(volume_info.UNC); |
2035 | FreeXid(xid); | 2107 | FreeXid(xid); |
@@ -2038,7 +2110,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
2038 | /* BB Do we need to wrap sesSem around | 2110 | /* BB Do we need to wrap sesSem around |
2039 | * this TCon call and Unix SetFS as | 2111 | * this TCon call and Unix SetFS as |
2040 | * we do on SessSetup and reconnect? */ | 2112 | * we do on SessSetup and reconnect? */ |
2041 | rc = CIFSTCon(xid, pSesInfo, | 2113 | rc = CIFSTCon(xid, pSesInfo, |
2042 | volume_info.UNC, | 2114 | volume_info.UNC, |
2043 | tcon, cifs_sb->local_nls); | 2115 | tcon, cifs_sb->local_nls); |
2044 | cFYI(1, ("CIFS Tcon rc = %d", rc)); | 2116 | cFYI(1, ("CIFS Tcon rc = %d", rc)); |
@@ -2075,9 +2147,9 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
2075 | always wake up processes blocked in | 2147 | always wake up processes blocked in |
2076 | tcp in recv_mesg then we could remove the | 2148 | tcp in recv_mesg then we could remove the |
2077 | send_sig call */ | 2149 | send_sig call */ |
2078 | send_sig(SIGKILL,srvTcp->tsk,1); | 2150 | force_sig(SIGKILL, srvTcp->tsk); |
2079 | tsk = srvTcp->tsk; | 2151 | tsk = srvTcp->tsk; |
2080 | if(tsk) | 2152 | if (tsk) |
2081 | kthread_stop(tsk); | 2153 | kthread_stop(tsk); |
2082 | } | 2154 | } |
2083 | } | 2155 | } |
@@ -2086,15 +2158,17 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
2086 | tconInfoFree(tcon); | 2158 | tconInfoFree(tcon); |
2087 | if (existingCifsSes == NULL) { | 2159 | if (existingCifsSes == NULL) { |
2088 | if (pSesInfo) { | 2160 | if (pSesInfo) { |
2089 | if ((pSesInfo->server) && | 2161 | if ((pSesInfo->server) && |
2090 | (pSesInfo->status == CifsGood)) { | 2162 | (pSesInfo->status == CifsGood)) { |
2091 | int temp_rc; | 2163 | int temp_rc; |
2092 | temp_rc = CIFSSMBLogoff(xid, pSesInfo); | 2164 | temp_rc = CIFSSMBLogoff(xid, pSesInfo); |
2093 | /* if the socketUseCount is now zero */ | 2165 | /* if the socketUseCount is now zero */ |
2094 | if ((temp_rc == -ESHUTDOWN) && | 2166 | if ((temp_rc == -ESHUTDOWN) && |
2095 | (pSesInfo->server) && (pSesInfo->server->tsk)) { | 2167 | (pSesInfo->server) && |
2168 | (pSesInfo->server->tsk)) { | ||
2096 | struct task_struct *tsk; | 2169 | struct task_struct *tsk; |
2097 | send_sig(SIGKILL,pSesInfo->server->tsk,1); | 2170 | force_sig(SIGKILL, |
2171 | pSesInfo->server->tsk); | ||
2098 | tsk = pSesInfo->server->tsk; | 2172 | tsk = pSesInfo->server->tsk; |
2099 | if (tsk) | 2173 | if (tsk) |
2100 | kthread_stop(tsk); | 2174 | kthread_stop(tsk); |
@@ -2113,19 +2187,29 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
2113 | /* do not care if following two calls succeed - informational */ | 2187 | /* do not care if following two calls succeed - informational */ |
2114 | CIFSSMBQFSDeviceInfo(xid, tcon); | 2188 | CIFSSMBQFSDeviceInfo(xid, tcon); |
2115 | CIFSSMBQFSAttributeInfo(xid, tcon); | 2189 | CIFSSMBQFSAttributeInfo(xid, tcon); |
2116 | 2190 | ||
2117 | /* tell server which Unix caps we support */ | 2191 | /* tell server which Unix caps we support */ |
2118 | if (tcon->ses->capabilities & CAP_UNIX) | 2192 | if (tcon->ses->capabilities & CAP_UNIX) |
2193 | /* reset of caps checks mount to see if unix extensions | ||
2194 | disabled for just this mount */ | ||
2119 | reset_cifs_unix_caps(xid, tcon, sb, &volume_info); | 2195 | reset_cifs_unix_caps(xid, tcon, sb, &volume_info); |
2120 | 2196 | else | |
2197 | tcon->unix_ext = 0; /* server does not support them */ | ||
2198 | |||
2199 | if ((tcon->unix_ext == 0) && (cifs_sb->rsize > (1024 * 127))) { | ||
2200 | cifs_sb->rsize = 1024 * 127; | ||
2201 | #ifdef CONFIG_CIFS_DEBUG2 | ||
2202 | cFYI(1, ("no very large read support, rsize now 127K")); | ||
2203 | #endif | ||
2204 | } | ||
2121 | if (!(tcon->ses->capabilities & CAP_LARGE_WRITE_X)) | 2205 | if (!(tcon->ses->capabilities & CAP_LARGE_WRITE_X)) |
2122 | cifs_sb->wsize = min(cifs_sb->wsize, | 2206 | cifs_sb->wsize = min(cifs_sb->wsize, |
2123 | (tcon->ses->server->maxBuf - | 2207 | (tcon->ses->server->maxBuf - |
2124 | MAX_CIFS_HDR_SIZE)); | 2208 | MAX_CIFS_HDR_SIZE)); |
2125 | if (!(tcon->ses->capabilities & CAP_LARGE_READ_X)) | 2209 | if (!(tcon->ses->capabilities & CAP_LARGE_READ_X)) |
2126 | cifs_sb->rsize = min(cifs_sb->rsize, | 2210 | cifs_sb->rsize = min(cifs_sb->rsize, |
2127 | (tcon->ses->server->maxBuf - | 2211 | (tcon->ses->server->maxBuf - |
2128 | MAX_CIFS_HDR_SIZE)); | 2212 | MAX_CIFS_HDR_SIZE)); |
2129 | } | 2213 | } |
2130 | 2214 | ||
2131 | /* volume_info.password is freed above when existing session found | 2215 | /* volume_info.password is freed above when existing session found |
@@ -2178,7 +2262,8 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2178 | pSMB->req_no_secext.MaxBufferSize = cpu_to_le16(ses->server->maxBuf); | 2262 | pSMB->req_no_secext.MaxBufferSize = cpu_to_le16(ses->server->maxBuf); |
2179 | pSMB->req_no_secext.MaxMpxCount = cpu_to_le16(ses->server->maxReq); | 2263 | pSMB->req_no_secext.MaxMpxCount = cpu_to_le16(ses->server->maxReq); |
2180 | 2264 | ||
2181 | if(ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) | 2265 | if (ses->server->secMode & |
2266 | (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) | ||
2182 | smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; | 2267 | smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; |
2183 | 2268 | ||
2184 | capabilities = CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS | | 2269 | capabilities = CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS | |
@@ -2197,7 +2282,7 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2197 | } | 2282 | } |
2198 | pSMB->req_no_secext.Capabilities = cpu_to_le32(capabilities); | 2283 | pSMB->req_no_secext.Capabilities = cpu_to_le32(capabilities); |
2199 | 2284 | ||
2200 | pSMB->req_no_secext.CaseInsensitivePasswordLength = | 2285 | pSMB->req_no_secext.CaseInsensitivePasswordLength = |
2201 | cpu_to_le16(CIFS_SESS_KEY_SIZE); | 2286 | cpu_to_le16(CIFS_SESS_KEY_SIZE); |
2202 | 2287 | ||
2203 | pSMB->req_no_secext.CaseSensitivePasswordLength = | 2288 | pSMB->req_no_secext.CaseSensitivePasswordLength = |
@@ -2215,9 +2300,9 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2215 | } | 2300 | } |
2216 | if (user == NULL) | 2301 | if (user == NULL) |
2217 | bytes_returned = 0; /* skip null user */ | 2302 | bytes_returned = 0; /* skip null user */ |
2218 | else | 2303 | else |
2219 | bytes_returned = | 2304 | bytes_returned = |
2220 | cifs_strtoUCS((__le16 *) bcc_ptr, user, 100, | 2305 | cifs_strtoUCS((__le16 *) bcc_ptr, user, 100, |
2221 | nls_codepage); | 2306 | nls_codepage); |
2222 | /* convert number of 16 bit words to bytes */ | 2307 | /* convert number of 16 bit words to bytes */ |
2223 | bcc_ptr += 2 * bytes_returned; | 2308 | bcc_ptr += 2 * bytes_returned; |
@@ -2247,7 +2332,7 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2247 | bcc_ptr += 2 * bytes_returned; | 2332 | bcc_ptr += 2 * bytes_returned; |
2248 | bcc_ptr += 2; | 2333 | bcc_ptr += 2; |
2249 | } else { | 2334 | } else { |
2250 | if (user != NULL) { | 2335 | if (user != NULL) { |
2251 | strncpy(bcc_ptr, user, 200); | 2336 | strncpy(bcc_ptr, user, 200); |
2252 | bcc_ptr += strnlen(user, 200); | 2337 | bcc_ptr += strnlen(user, 200); |
2253 | } | 2338 | } |
@@ -2282,11 +2367,12 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2282 | __u16 action = le16_to_cpu(pSMBr->resp.Action); | 2367 | __u16 action = le16_to_cpu(pSMBr->resp.Action); |
2283 | __u16 blob_len = le16_to_cpu(pSMBr->resp.SecurityBlobLength); | 2368 | __u16 blob_len = le16_to_cpu(pSMBr->resp.SecurityBlobLength); |
2284 | if (action & GUEST_LOGIN) | 2369 | if (action & GUEST_LOGIN) |
2285 | cFYI(1, (" Guest login")); /* do we want to mark SesInfo struct ? */ | 2370 | cFYI(1, (" Guest login")); /* BB mark SesInfo struct? */ |
2286 | ses->Suid = smb_buffer_response->Uid; /* UID left in wire format (le) */ | 2371 | ses->Suid = smb_buffer_response->Uid; /* UID left in wire format |
2372 | (little endian) */ | ||
2287 | cFYI(1, ("UID = %d ", ses->Suid)); | 2373 | cFYI(1, ("UID = %d ", ses->Suid)); |
2288 | /* response can have either 3 or 4 word count - Samba sends 3 */ | 2374 | /* response can have either 3 or 4 word count - Samba sends 3 */ |
2289 | bcc_ptr = pByteArea(smb_buffer_response); | 2375 | bcc_ptr = pByteArea(smb_buffer_response); |
2290 | if ((pSMBr->resp.hdr.WordCount == 3) | 2376 | if ((pSMBr->resp.hdr.WordCount == 3) |
2291 | || ((pSMBr->resp.hdr.WordCount == 4) | 2377 | || ((pSMBr->resp.hdr.WordCount == 4) |
2292 | && (blob_len < pSMBr->resp.ByteCount))) { | 2378 | && (blob_len < pSMBr->resp.ByteCount))) { |
@@ -2296,8 +2382,10 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2296 | if (smb_buffer->Flags2 & SMBFLG2_UNICODE) { | 2382 | if (smb_buffer->Flags2 & SMBFLG2_UNICODE) { |
2297 | if ((long) (bcc_ptr) % 2) { | 2383 | if ((long) (bcc_ptr) % 2) { |
2298 | remaining_words = | 2384 | remaining_words = |
2299 | (BCC(smb_buffer_response) - 1) /2; | 2385 | (BCC(smb_buffer_response) - 1) / 2; |
2300 | bcc_ptr++; /* Unicode strings must be word aligned */ | 2386 | /* Unicode strings must be word |
2387 | aligned */ | ||
2388 | bcc_ptr++; | ||
2301 | } else { | 2389 | } else { |
2302 | remaining_words = | 2390 | remaining_words = |
2303 | BCC(smb_buffer_response) / 2; | 2391 | BCC(smb_buffer_response) / 2; |
@@ -2308,13 +2396,15 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2308 | /* We look for obvious messed up bcc or strings in response so we do not go off | 2396 | /* We look for obvious messed up bcc or strings in response so we do not go off |
2309 | the end since (at least) WIN2K and Windows XP have a major bug in not null | 2397 | the end since (at least) WIN2K and Windows XP have a major bug in not null |
2310 | terminating last Unicode string in response */ | 2398 | terminating last Unicode string in response */ |
2311 | if(ses->serverOS) | 2399 | if (ses->serverOS) |
2312 | kfree(ses->serverOS); | 2400 | kfree(ses->serverOS); |
2313 | ses->serverOS = kzalloc(2 * (len + 1), GFP_KERNEL); | 2401 | ses->serverOS = kzalloc(2 * (len + 1), |
2314 | if(ses->serverOS == NULL) | 2402 | GFP_KERNEL); |
2403 | if (ses->serverOS == NULL) | ||
2315 | goto sesssetup_nomem; | 2404 | goto sesssetup_nomem; |
2316 | cifs_strfromUCS_le(ses->serverOS, | 2405 | cifs_strfromUCS_le(ses->serverOS, |
2317 | (__le16 *)bcc_ptr, len,nls_codepage); | 2406 | (__le16 *)bcc_ptr, |
2407 | len, nls_codepage); | ||
2318 | bcc_ptr += 2 * (len + 1); | 2408 | bcc_ptr += 2 * (len + 1); |
2319 | remaining_words -= len + 1; | 2409 | remaining_words -= len + 1; |
2320 | ses->serverOS[2 * len] = 0; | 2410 | ses->serverOS[2 * len] = 0; |
@@ -2323,42 +2413,49 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2323 | len = UniStrnlen((wchar_t *)bcc_ptr, | 2413 | len = UniStrnlen((wchar_t *)bcc_ptr, |
2324 | remaining_words-1); | 2414 | remaining_words-1); |
2325 | kfree(ses->serverNOS); | 2415 | kfree(ses->serverNOS); |
2326 | ses->serverNOS = kzalloc(2 * (len + 1),GFP_KERNEL); | 2416 | ses->serverNOS = kzalloc(2 * (len + 1), |
2327 | if(ses->serverNOS == NULL) | 2417 | GFP_KERNEL); |
2418 | if (ses->serverNOS == NULL) | ||
2328 | goto sesssetup_nomem; | 2419 | goto sesssetup_nomem; |
2329 | cifs_strfromUCS_le(ses->serverNOS, | 2420 | cifs_strfromUCS_le(ses->serverNOS, |
2330 | (__le16 *)bcc_ptr,len,nls_codepage); | 2421 | (__le16 *)bcc_ptr, |
2422 | len, nls_codepage); | ||
2331 | bcc_ptr += 2 * (len + 1); | 2423 | bcc_ptr += 2 * (len + 1); |
2332 | ses->serverNOS[2 * len] = 0; | 2424 | ses->serverNOS[2 * len] = 0; |
2333 | ses->serverNOS[1 + (2 * len)] = 0; | 2425 | ses->serverNOS[1 + (2 * len)] = 0; |
2334 | if(strncmp(ses->serverNOS, | 2426 | if (strncmp(ses->serverNOS, |
2335 | "NT LAN Manager 4",16) == 0) { | 2427 | "NT LAN Manager 4", 16) == 0) { |
2336 | cFYI(1,("NT4 server")); | 2428 | cFYI(1, ("NT4 server")); |
2337 | ses->flags |= CIFS_SES_NT4; | 2429 | ses->flags |= CIFS_SES_NT4; |
2338 | } | 2430 | } |
2339 | remaining_words -= len + 1; | 2431 | remaining_words -= len + 1; |
2340 | if (remaining_words > 0) { | 2432 | if (remaining_words > 0) { |
2341 | len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words); | 2433 | len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words); |
2342 | /* last string is not always null terminated (for e.g. for Windows XP & 2000) */ | 2434 | /* last string is not always null terminated |
2343 | if(ses->serverDomain) | 2435 | (for e.g. for Windows XP & 2000) */ |
2436 | if (ses->serverDomain) | ||
2344 | kfree(ses->serverDomain); | 2437 | kfree(ses->serverDomain); |
2345 | ses->serverDomain = | 2438 | ses->serverDomain = |
2346 | kzalloc(2*(len+1),GFP_KERNEL); | 2439 | kzalloc(2*(len+1), |
2347 | if(ses->serverDomain == NULL) | 2440 | GFP_KERNEL); |
2441 | if (ses->serverDomain == NULL) | ||
2348 | goto sesssetup_nomem; | 2442 | goto sesssetup_nomem; |
2349 | cifs_strfromUCS_le(ses->serverDomain, | 2443 | cifs_strfromUCS_le(ses->serverDomain, |
2350 | (__le16 *)bcc_ptr,len,nls_codepage); | 2444 | (__le16 *)bcc_ptr, |
2445 | len, nls_codepage); | ||
2351 | bcc_ptr += 2 * (len + 1); | 2446 | bcc_ptr += 2 * (len + 1); |
2352 | ses->serverDomain[2*len] = 0; | 2447 | ses->serverDomain[2*len] = 0; |
2353 | ses->serverDomain[1+(2*len)] = 0; | 2448 | ses->serverDomain[1+(2*len)] = 0; |
2354 | } /* else no more room so create dummy domain string */ | 2449 | } else { /* else no more room so create |
2355 | else { | 2450 | dummy domain string */ |
2356 | if(ses->serverDomain) | 2451 | if (ses->serverDomain) |
2357 | kfree(ses->serverDomain); | 2452 | kfree(ses->serverDomain); |
2358 | ses->serverDomain = | 2453 | ses->serverDomain = |
2359 | kzalloc(2, GFP_KERNEL); | 2454 | kzalloc(2, GFP_KERNEL); |
2360 | } | 2455 | } |
2361 | } else { /* no room so create dummy domain and NOS string */ | 2456 | } else { /* no room so create dummy domain |
2457 | and NOS string */ | ||
2458 | |||
2362 | /* if these kcallocs fail not much we | 2459 | /* if these kcallocs fail not much we |
2363 | can do, but better to not fail the | 2460 | can do, but better to not fail the |
2364 | sesssetup itself */ | 2461 | sesssetup itself */ |
@@ -2375,19 +2472,22 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2375 | pByteArea(smb_buffer_response) | 2472 | pByteArea(smb_buffer_response) |
2376 | <= BCC(smb_buffer_response)) { | 2473 | <= BCC(smb_buffer_response)) { |
2377 | kfree(ses->serverOS); | 2474 | kfree(ses->serverOS); |
2378 | ses->serverOS = kzalloc(len + 1,GFP_KERNEL); | 2475 | ses->serverOS = kzalloc(len + 1, |
2379 | if(ses->serverOS == NULL) | 2476 | GFP_KERNEL); |
2477 | if (ses->serverOS == NULL) | ||
2380 | goto sesssetup_nomem; | 2478 | goto sesssetup_nomem; |
2381 | strncpy(ses->serverOS,bcc_ptr, len); | 2479 | strncpy(ses->serverOS, bcc_ptr, len); |
2382 | 2480 | ||
2383 | bcc_ptr += len; | 2481 | bcc_ptr += len; |
2384 | bcc_ptr[0] = 0; /* null terminate the string */ | 2482 | /* null terminate the string */ |
2483 | bcc_ptr[0] = 0; | ||
2385 | bcc_ptr++; | 2484 | bcc_ptr++; |
2386 | 2485 | ||
2387 | len = strnlen(bcc_ptr, 1024); | 2486 | len = strnlen(bcc_ptr, 1024); |
2388 | kfree(ses->serverNOS); | 2487 | kfree(ses->serverNOS); |
2389 | ses->serverNOS = kzalloc(len + 1,GFP_KERNEL); | 2488 | ses->serverNOS = kzalloc(len + 1, |
2390 | if(ses->serverNOS == NULL) | 2489 | GFP_KERNEL); |
2490 | if (ses->serverNOS == NULL) | ||
2391 | goto sesssetup_nomem; | 2491 | goto sesssetup_nomem; |
2392 | strncpy(ses->serverNOS, bcc_ptr, len); | 2492 | strncpy(ses->serverNOS, bcc_ptr, len); |
2393 | bcc_ptr += len; | 2493 | bcc_ptr += len; |
@@ -2395,23 +2495,27 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2395 | bcc_ptr++; | 2495 | bcc_ptr++; |
2396 | 2496 | ||
2397 | len = strnlen(bcc_ptr, 1024); | 2497 | len = strnlen(bcc_ptr, 1024); |
2398 | if(ses->serverDomain) | 2498 | if (ses->serverDomain) |
2399 | kfree(ses->serverDomain); | 2499 | kfree(ses->serverDomain); |
2400 | ses->serverDomain = kzalloc(len + 1,GFP_KERNEL); | 2500 | ses->serverDomain = kzalloc(len + 1, |
2401 | if(ses->serverDomain == NULL) | 2501 | GFP_KERNEL); |
2502 | if (ses->serverDomain == NULL) | ||
2402 | goto sesssetup_nomem; | 2503 | goto sesssetup_nomem; |
2403 | strncpy(ses->serverDomain, bcc_ptr, len); | 2504 | strncpy(ses->serverDomain, bcc_ptr, |
2505 | len); | ||
2404 | bcc_ptr += len; | 2506 | bcc_ptr += len; |
2405 | bcc_ptr[0] = 0; | 2507 | bcc_ptr[0] = 0; |
2406 | bcc_ptr++; | 2508 | bcc_ptr++; |
2407 | } else | 2509 | } else |
2408 | cFYI(1, | 2510 | cFYI(1, |
2409 | ("Variable field of length %d extends beyond end of smb ", | 2511 | ("Variable field of length %d " |
2512 | "extends beyond end of smb ", | ||
2410 | len)); | 2513 | len)); |
2411 | } | 2514 | } |
2412 | } else { | 2515 | } else { |
2413 | cERROR(1, | 2516 | cERROR(1, |
2414 | (" Security Blob Length extends beyond end of SMB")); | 2517 | (" Security Blob Length extends beyond " |
2518 | "end of SMB")); | ||
2415 | } | 2519 | } |
2416 | } else { | 2520 | } else { |
2417 | cERROR(1, | 2521 | cERROR(1, |
@@ -2430,7 +2534,7 @@ sesssetup_nomem: /* do not return an error on nomem for the info strings, | |||
2430 | 2534 | ||
2431 | static int | 2535 | static int |
2432 | CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, | 2536 | CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, |
2433 | struct cifsSesInfo *ses, int * pNTLMv2_flag, | 2537 | struct cifsSesInfo *ses, int *pNTLMv2_flag, |
2434 | const struct nls_table *nls_codepage) | 2538 | const struct nls_table *nls_codepage) |
2435 | { | 2539 | { |
2436 | struct smb_hdr *smb_buffer; | 2540 | struct smb_hdr *smb_buffer; |
@@ -2450,7 +2554,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, | |||
2450 | __u16 count; | 2554 | __u16 count; |
2451 | 2555 | ||
2452 | cFYI(1, ("In NTLMSSP sesssetup (negotiate)")); | 2556 | cFYI(1, ("In NTLMSSP sesssetup (negotiate)")); |
2453 | if(ses == NULL) | 2557 | if (ses == NULL) |
2454 | return -EINVAL; | 2558 | return -EINVAL; |
2455 | domain = ses->domainName; | 2559 | domain = ses->domainName; |
2456 | *pNTLMv2_flag = FALSE; | 2560 | *pNTLMv2_flag = FALSE; |
@@ -2474,7 +2578,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, | |||
2474 | pSMB->req.MaxBufferSize = cpu_to_le16(ses->server->maxBuf); | 2578 | pSMB->req.MaxBufferSize = cpu_to_le16(ses->server->maxBuf); |
2475 | pSMB->req.MaxMpxCount = cpu_to_le16(ses->server->maxReq); | 2579 | pSMB->req.MaxMpxCount = cpu_to_le16(ses->server->maxReq); |
2476 | 2580 | ||
2477 | if(ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) | 2581 | if (ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) |
2478 | smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; | 2582 | smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; |
2479 | 2583 | ||
2480 | capabilities = CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS | | 2584 | capabilities = CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS | |
@@ -2502,9 +2606,9 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, | |||
2502 | NTLMSSP_REQUEST_TARGET | NTLMSSP_NEGOTIATE_NTLM | | 2606 | NTLMSSP_REQUEST_TARGET | NTLMSSP_NEGOTIATE_NTLM | |
2503 | NTLMSSP_NEGOTIATE_56 | | 2607 | NTLMSSP_NEGOTIATE_56 | |
2504 | /* NTLMSSP_NEGOTIATE_ALWAYS_SIGN | */ NTLMSSP_NEGOTIATE_128; | 2608 | /* NTLMSSP_NEGOTIATE_ALWAYS_SIGN | */ NTLMSSP_NEGOTIATE_128; |
2505 | if(sign_CIFS_PDUs) | 2609 | if (sign_CIFS_PDUs) |
2506 | negotiate_flags |= NTLMSSP_NEGOTIATE_SIGN; | 2610 | negotiate_flags |= NTLMSSP_NEGOTIATE_SIGN; |
2507 | /* if(ntlmv2_support) | 2611 | /* if (ntlmv2_support) |
2508 | negotiate_flags |= NTLMSSP_NEGOTIATE_NTLMV2;*/ | 2612 | negotiate_flags |= NTLMSSP_NEGOTIATE_NTLMV2;*/ |
2509 | /* setup pointers to domain name and workstation name */ | 2613 | /* setup pointers to domain name and workstation name */ |
2510 | bcc_ptr += SecurityBlobLength; | 2614 | bcc_ptr += SecurityBlobLength; |
@@ -2574,11 +2678,11 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, | |||
2574 | __u16 blob_len = le16_to_cpu(pSMBr->resp.SecurityBlobLength); | 2678 | __u16 blob_len = le16_to_cpu(pSMBr->resp.SecurityBlobLength); |
2575 | 2679 | ||
2576 | if (action & GUEST_LOGIN) | 2680 | if (action & GUEST_LOGIN) |
2577 | cFYI(1, (" Guest login")); | 2681 | cFYI(1, (" Guest login")); |
2578 | /* Do we want to set anything in SesInfo struct when guest login? */ | 2682 | /* Do we want to set anything in SesInfo struct when guest login? */ |
2579 | 2683 | ||
2580 | bcc_ptr = pByteArea(smb_buffer_response); | 2684 | bcc_ptr = pByteArea(smb_buffer_response); |
2581 | /* response can have either 3 or 4 word count - Samba sends 3 */ | 2685 | /* response can have either 3 or 4 word count - Samba sends 3 */ |
2582 | 2686 | ||
2583 | SecurityBlob2 = (PCHALLENGE_MESSAGE) bcc_ptr; | 2687 | SecurityBlob2 = (PCHALLENGE_MESSAGE) bcc_ptr; |
2584 | if (SecurityBlob2->MessageType != NtLmChallenge) { | 2688 | if (SecurityBlob2->MessageType != NtLmChallenge) { |
@@ -2586,7 +2690,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, | |||
2586 | ("Unexpected NTLMSSP message type received %d", | 2690 | ("Unexpected NTLMSSP message type received %d", |
2587 | SecurityBlob2->MessageType)); | 2691 | SecurityBlob2->MessageType)); |
2588 | } else if (ses) { | 2692 | } else if (ses) { |
2589 | ses->Suid = smb_buffer_response->Uid; /* UID left in le format */ | 2693 | ses->Suid = smb_buffer_response->Uid; /* UID left in le format */ |
2590 | cFYI(1, ("UID = %d", ses->Suid)); | 2694 | cFYI(1, ("UID = %d", ses->Suid)); |
2591 | if ((pSMBr->resp.hdr.WordCount == 3) | 2695 | if ((pSMBr->resp.hdr.WordCount == 3) |
2592 | || ((pSMBr->resp.hdr.WordCount == 4) | 2696 | || ((pSMBr->resp.hdr.WordCount == 4) |
@@ -2604,18 +2708,18 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, | |||
2604 | memcpy(ses->server->cryptKey, | 2708 | memcpy(ses->server->cryptKey, |
2605 | SecurityBlob2->Challenge, | 2709 | SecurityBlob2->Challenge, |
2606 | CIFS_CRYPTO_KEY_SIZE); | 2710 | CIFS_CRYPTO_KEY_SIZE); |
2607 | if(SecurityBlob2->NegotiateFlags & | 2711 | if (SecurityBlob2->NegotiateFlags & |
2608 | cpu_to_le32(NTLMSSP_NEGOTIATE_NTLMV2)) | 2712 | cpu_to_le32(NTLMSSP_NEGOTIATE_NTLMV2)) |
2609 | *pNTLMv2_flag = TRUE; | 2713 | *pNTLMv2_flag = TRUE; |
2610 | 2714 | ||
2611 | if((SecurityBlob2->NegotiateFlags & | 2715 | if ((SecurityBlob2->NegotiateFlags & |
2612 | cpu_to_le32(NTLMSSP_NEGOTIATE_ALWAYS_SIGN)) | 2716 | cpu_to_le32(NTLMSSP_NEGOTIATE_ALWAYS_SIGN)) |
2613 | || (sign_CIFS_PDUs > 1)) | 2717 | || (sign_CIFS_PDUs > 1)) |
2614 | ses->server->secMode |= | 2718 | ses->server->secMode |= |
2615 | SECMODE_SIGN_REQUIRED; | 2719 | SECMODE_SIGN_REQUIRED; |
2616 | if ((SecurityBlob2->NegotiateFlags & | 2720 | if ((SecurityBlob2->NegotiateFlags & |
2617 | cpu_to_le32(NTLMSSP_NEGOTIATE_SIGN)) && (sign_CIFS_PDUs)) | 2721 | cpu_to_le32(NTLMSSP_NEGOTIATE_SIGN)) && (sign_CIFS_PDUs)) |
2618 | ses->server->secMode |= | 2722 | ses->server->secMode |= |
2619 | SECMODE_SIGN_ENABLED; | 2723 | SECMODE_SIGN_ENABLED; |
2620 | 2724 | ||
2621 | if (smb_buffer->Flags2 & SMBFLG2_UNICODE) { | 2725 | if (smb_buffer->Flags2 & SMBFLG2_UNICODE) { |
@@ -2623,7 +2727,8 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, | |||
2623 | remaining_words = | 2727 | remaining_words = |
2624 | (BCC(smb_buffer_response) | 2728 | (BCC(smb_buffer_response) |
2625 | - 1) / 2; | 2729 | - 1) / 2; |
2626 | bcc_ptr++; /* Unicode strings must be word aligned */ | 2730 | /* Must word align unicode strings */ |
2731 | bcc_ptr++; | ||
2627 | } else { | 2732 | } else { |
2628 | remaining_words = | 2733 | remaining_words = |
2629 | BCC | 2734 | BCC |
@@ -2635,7 +2740,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, | |||
2635 | /* We look for obvious messed up bcc or strings in response so we do not go off | 2740 | /* We look for obvious messed up bcc or strings in response so we do not go off |
2636 | the end since (at least) WIN2K and Windows XP have a major bug in not null | 2741 | the end since (at least) WIN2K and Windows XP have a major bug in not null |
2637 | terminating last Unicode string in response */ | 2742 | terminating last Unicode string in response */ |
2638 | if(ses->serverOS) | 2743 | if (ses->serverOS) |
2639 | kfree(ses->serverOS); | 2744 | kfree(ses->serverOS); |
2640 | ses->serverOS = | 2745 | ses->serverOS = |
2641 | kzalloc(2 * (len + 1), GFP_KERNEL); | 2746 | kzalloc(2 * (len + 1), GFP_KERNEL); |
@@ -2668,8 +2773,9 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, | |||
2668 | (2 * len)] = 0; | 2773 | (2 * len)] = 0; |
2669 | remaining_words -= len + 1; | 2774 | remaining_words -= len + 1; |
2670 | if (remaining_words > 0) { | 2775 | if (remaining_words > 0) { |
2671 | len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words); | 2776 | len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words); |
2672 | /* last string is not always null terminated (for e.g. for Windows XP & 2000) */ | 2777 | /* last string not always null terminated |
2778 | (for e.g. for Windows XP & 2000) */ | ||
2673 | kfree(ses->serverDomain); | 2779 | kfree(ses->serverDomain); |
2674 | ses->serverDomain = | 2780 | ses->serverDomain = |
2675 | kzalloc(2 * | 2781 | kzalloc(2 * |
@@ -2707,7 +2813,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, | |||
2707 | if (((long) bcc_ptr + len) - (long) | 2813 | if (((long) bcc_ptr + len) - (long) |
2708 | pByteArea(smb_buffer_response) | 2814 | pByteArea(smb_buffer_response) |
2709 | <= BCC(smb_buffer_response)) { | 2815 | <= BCC(smb_buffer_response)) { |
2710 | if(ses->serverOS) | 2816 | if (ses->serverOS) |
2711 | kfree(ses->serverOS); | 2817 | kfree(ses->serverOS); |
2712 | ses->serverOS = | 2818 | ses->serverOS = |
2713 | kzalloc(len + 1, | 2819 | kzalloc(len + 1, |
@@ -2734,18 +2840,20 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, | |||
2734 | ses->serverDomain = | 2840 | ses->serverDomain = |
2735 | kzalloc(len + 1, | 2841 | kzalloc(len + 1, |
2736 | GFP_KERNEL); | 2842 | GFP_KERNEL); |
2737 | strncpy(ses->serverDomain, bcc_ptr, len); | 2843 | strncpy(ses->serverDomain, |
2844 | bcc_ptr, len); | ||
2738 | bcc_ptr += len; | 2845 | bcc_ptr += len; |
2739 | bcc_ptr[0] = 0; | 2846 | bcc_ptr[0] = 0; |
2740 | bcc_ptr++; | 2847 | bcc_ptr++; |
2741 | } else | 2848 | } else |
2742 | cFYI(1, | 2849 | cFYI(1, |
2743 | ("Variable field of length %d extends beyond end of smb", | 2850 | ("field of length %d " |
2851 | "extends beyond end of smb", | ||
2744 | len)); | 2852 | len)); |
2745 | } | 2853 | } |
2746 | } else { | 2854 | } else { |
2747 | cERROR(1, | 2855 | cERROR(1, ("Security Blob Length extends beyond" |
2748 | (" Security Blob Length extends beyond end of SMB")); | 2856 | " end of SMB")); |
2749 | } | 2857 | } |
2750 | } else { | 2858 | } else { |
2751 | cERROR(1, ("No session structure passed in.")); | 2859 | cERROR(1, ("No session structure passed in.")); |
@@ -2784,7 +2892,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2784 | __u16 count; | 2892 | __u16 count; |
2785 | 2893 | ||
2786 | cFYI(1, ("In NTLMSSPSessSetup (Authenticate)")); | 2894 | cFYI(1, ("In NTLMSSPSessSetup (Authenticate)")); |
2787 | if(ses == NULL) | 2895 | if (ses == NULL) |
2788 | return -EINVAL; | 2896 | return -EINVAL; |
2789 | user = ses->userName; | 2897 | user = ses->userName; |
2790 | domain = ses->domainName; | 2898 | domain = ses->domainName; |
@@ -2809,7 +2917,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2809 | 2917 | ||
2810 | pSMB->req.hdr.Uid = ses->Suid; | 2918 | pSMB->req.hdr.Uid = ses->Suid; |
2811 | 2919 | ||
2812 | if(ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) | 2920 | if (ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) |
2813 | smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; | 2921 | smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; |
2814 | 2922 | ||
2815 | capabilities = CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS | | 2923 | capabilities = CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS | |
@@ -2833,13 +2941,13 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2833 | strncpy(SecurityBlob->Signature, NTLMSSP_SIGNATURE, 8); | 2941 | strncpy(SecurityBlob->Signature, NTLMSSP_SIGNATURE, 8); |
2834 | SecurityBlob->MessageType = NtLmAuthenticate; | 2942 | SecurityBlob->MessageType = NtLmAuthenticate; |
2835 | bcc_ptr += SecurityBlobLength; | 2943 | bcc_ptr += SecurityBlobLength; |
2836 | negotiate_flags = | 2944 | negotiate_flags = |
2837 | NTLMSSP_NEGOTIATE_UNICODE | NTLMSSP_REQUEST_TARGET | | 2945 | NTLMSSP_NEGOTIATE_UNICODE | NTLMSSP_REQUEST_TARGET | |
2838 | NTLMSSP_NEGOTIATE_NTLM | NTLMSSP_NEGOTIATE_TARGET_INFO | | 2946 | NTLMSSP_NEGOTIATE_NTLM | NTLMSSP_NEGOTIATE_TARGET_INFO | |
2839 | 0x80000000 | NTLMSSP_NEGOTIATE_128; | 2947 | 0x80000000 | NTLMSSP_NEGOTIATE_128; |
2840 | if(sign_CIFS_PDUs) | 2948 | if (sign_CIFS_PDUs) |
2841 | negotiate_flags |= /* NTLMSSP_NEGOTIATE_ALWAYS_SIGN |*/ NTLMSSP_NEGOTIATE_SIGN; | 2949 | negotiate_flags |= /* NTLMSSP_NEGOTIATE_ALWAYS_SIGN |*/ NTLMSSP_NEGOTIATE_SIGN; |
2842 | if(ntlmv2_flag) | 2950 | if (ntlmv2_flag) |
2843 | negotiate_flags |= NTLMSSP_NEGOTIATE_NTLMV2; | 2951 | negotiate_flags |= NTLMSSP_NEGOTIATE_NTLMV2; |
2844 | 2952 | ||
2845 | /* setup pointers to domain name and workstation name */ | 2953 | /* setup pointers to domain name and workstation name */ |
@@ -2903,13 +3011,17 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2903 | cpu_to_le16(len); | 3011 | cpu_to_le16(len); |
2904 | } | 3012 | } |
2905 | 3013 | ||
2906 | /* SecurityBlob->WorkstationName.Length = cifs_strtoUCS((__le16 *) bcc_ptr, "AMACHINE",64, nls_codepage); | 3014 | /* SecurityBlob->WorkstationName.Length = |
3015 | cifs_strtoUCS((__le16 *) bcc_ptr, "AMACHINE",64, nls_codepage); | ||
2907 | SecurityBlob->WorkstationName.Length *= 2; | 3016 | SecurityBlob->WorkstationName.Length *= 2; |
2908 | SecurityBlob->WorkstationName.MaximumLength = cpu_to_le16(SecurityBlob->WorkstationName.Length); | 3017 | SecurityBlob->WorkstationName.MaximumLength = |
2909 | SecurityBlob->WorkstationName.Buffer = cpu_to_le32(SecurityBlobLength); | 3018 | cpu_to_le16(SecurityBlob->WorkstationName.Length); |
3019 | SecurityBlob->WorkstationName.Buffer = | ||
3020 | cpu_to_le32(SecurityBlobLength); | ||
2910 | bcc_ptr += SecurityBlob->WorkstationName.Length; | 3021 | bcc_ptr += SecurityBlob->WorkstationName.Length; |
2911 | SecurityBlobLength += SecurityBlob->WorkstationName.Length; | 3022 | SecurityBlobLength += SecurityBlob->WorkstationName.Length; |
2912 | SecurityBlob->WorkstationName.Length = cpu_to_le16(SecurityBlob->WorkstationName.Length); */ | 3023 | SecurityBlob->WorkstationName.Length = |
3024 | cpu_to_le16(SecurityBlob->WorkstationName.Length); */ | ||
2913 | 3025 | ||
2914 | if ((long) bcc_ptr % 2) { | 3026 | if ((long) bcc_ptr % 2) { |
2915 | *bcc_ptr = 0; | 3027 | *bcc_ptr = 0; |
@@ -2995,17 +3107,20 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2995 | __u16 blob_len = | 3107 | __u16 blob_len = |
2996 | le16_to_cpu(pSMBr->resp.SecurityBlobLength); | 3108 | le16_to_cpu(pSMBr->resp.SecurityBlobLength); |
2997 | if (action & GUEST_LOGIN) | 3109 | if (action & GUEST_LOGIN) |
2998 | cFYI(1, (" Guest login")); /* BB do we want to set anything in SesInfo struct ? */ | 3110 | cFYI(1, (" Guest login")); /* BB Should we set anything |
2999 | /* if(SecurityBlob2->MessageType != NtLm??){ | 3111 | in SesInfo struct ? */ |
3000 | cFYI("Unexpected message type on auth response is %d ")); | 3112 | /* if (SecurityBlob2->MessageType != NtLm??) { |
3001 | } */ | 3113 | cFYI("Unexpected message type on auth response is %d")); |
3114 | } */ | ||
3115 | |||
3002 | if (ses) { | 3116 | if (ses) { |
3003 | cFYI(1, | 3117 | cFYI(1, |
3004 | ("Does UID on challenge %d match auth response UID %d ", | 3118 | ("Check challenge UID %d vs auth response UID %d", |
3005 | ses->Suid, smb_buffer_response->Uid)); | 3119 | ses->Suid, smb_buffer_response->Uid)); |
3006 | ses->Suid = smb_buffer_response->Uid; /* UID left in wire format */ | 3120 | /* UID left in wire format */ |
3007 | bcc_ptr = pByteArea(smb_buffer_response); | 3121 | ses->Suid = smb_buffer_response->Uid; |
3008 | /* response can have either 3 or 4 word count - Samba sends 3 */ | 3122 | bcc_ptr = pByteArea(smb_buffer_response); |
3123 | /* response can have either 3 or 4 word count - Samba sends 3 */ | ||
3009 | if ((pSMBr->resp.hdr.WordCount == 3) | 3124 | if ((pSMBr->resp.hdr.WordCount == 3) |
3010 | || ((pSMBr->resp.hdr.WordCount == 4) | 3125 | || ((pSMBr->resp.hdr.WordCount == 4) |
3011 | && (blob_len < | 3126 | && (blob_len < |
@@ -3035,7 +3150,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
3035 | /* We look for obvious messed up bcc or strings in response so we do not go off | 3150 | /* We look for obvious messed up bcc or strings in response so we do not go off |
3036 | the end since (at least) WIN2K and Windows XP have a major bug in not null | 3151 | the end since (at least) WIN2K and Windows XP have a major bug in not null |
3037 | terminating last Unicode string in response */ | 3152 | terminating last Unicode string in response */ |
3038 | if(ses->serverOS) | 3153 | if (ses->serverOS) |
3039 | kfree(ses->serverOS); | 3154 | kfree(ses->serverOS); |
3040 | ses->serverOS = | 3155 | ses->serverOS = |
3041 | kzalloc(2 * (len + 1), GFP_KERNEL); | 3156 | kzalloc(2 * (len + 1), GFP_KERNEL); |
@@ -3067,9 +3182,9 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
3067 | ses->serverNOS[1+(2*len)] = 0; | 3182 | ses->serverNOS[1+(2*len)] = 0; |
3068 | remaining_words -= len + 1; | 3183 | remaining_words -= len + 1; |
3069 | if (remaining_words > 0) { | 3184 | if (remaining_words > 0) { |
3070 | len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words); | 3185 | len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words); |
3071 | /* last string not always null terminated (e.g. for Windows XP & 2000) */ | 3186 | /* last string not always null terminated (e.g. for Windows XP & 2000) */ |
3072 | if(ses->serverDomain) | 3187 | if (ses->serverDomain) |
3073 | kfree(ses->serverDomain); | 3188 | kfree(ses->serverDomain); |
3074 | ses->serverDomain = | 3189 | ses->serverDomain = |
3075 | kzalloc(2 * | 3190 | kzalloc(2 * |
@@ -3097,12 +3212,12 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
3097 | = 0; | 3212 | = 0; |
3098 | } /* else no more room so create dummy domain string */ | 3213 | } /* else no more room so create dummy domain string */ |
3099 | else { | 3214 | else { |
3100 | if(ses->serverDomain) | 3215 | if (ses->serverDomain) |
3101 | kfree(ses->serverDomain); | 3216 | kfree(ses->serverDomain); |
3102 | ses->serverDomain = kzalloc(2,GFP_KERNEL); | 3217 | ses->serverDomain = kzalloc(2,GFP_KERNEL); |
3103 | } | 3218 | } |
3104 | } else { /* no room so create dummy domain and NOS string */ | 3219 | } else { /* no room so create dummy domain and NOS string */ |
3105 | if(ses->serverDomain) | 3220 | if (ses->serverDomain) |
3106 | kfree(ses->serverDomain); | 3221 | kfree(ses->serverDomain); |
3107 | ses->serverDomain = kzalloc(2, GFP_KERNEL); | 3222 | ses->serverDomain = kzalloc(2, GFP_KERNEL); |
3108 | kfree(ses->serverNOS); | 3223 | kfree(ses->serverNOS); |
@@ -3110,10 +3225,10 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
3110 | } | 3225 | } |
3111 | } else { /* ASCII */ | 3226 | } else { /* ASCII */ |
3112 | len = strnlen(bcc_ptr, 1024); | 3227 | len = strnlen(bcc_ptr, 1024); |
3113 | if (((long) bcc_ptr + len) - | 3228 | if (((long) bcc_ptr + len) - |
3114 | (long) pByteArea(smb_buffer_response) | 3229 | (long) pByteArea(smb_buffer_response) |
3115 | <= BCC(smb_buffer_response)) { | 3230 | <= BCC(smb_buffer_response)) { |
3116 | if(ses->serverOS) | 3231 | if (ses->serverOS) |
3117 | kfree(ses->serverOS); | 3232 | kfree(ses->serverOS); |
3118 | ses->serverOS = kzalloc(len + 1,GFP_KERNEL); | 3233 | ses->serverOS = kzalloc(len + 1,GFP_KERNEL); |
3119 | strncpy(ses->serverOS,bcc_ptr, len); | 3234 | strncpy(ses->serverOS,bcc_ptr, len); |
@@ -3124,28 +3239,35 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
3124 | 3239 | ||
3125 | len = strnlen(bcc_ptr, 1024); | 3240 | len = strnlen(bcc_ptr, 1024); |
3126 | kfree(ses->serverNOS); | 3241 | kfree(ses->serverNOS); |
3127 | ses->serverNOS = kzalloc(len+1,GFP_KERNEL); | 3242 | ses->serverNOS = kzalloc(len+1, |
3128 | strncpy(ses->serverNOS, bcc_ptr, len); | 3243 | GFP_KERNEL); |
3244 | strncpy(ses->serverNOS, | ||
3245 | bcc_ptr, len); | ||
3129 | bcc_ptr += len; | 3246 | bcc_ptr += len; |
3130 | bcc_ptr[0] = 0; | 3247 | bcc_ptr[0] = 0; |
3131 | bcc_ptr++; | 3248 | bcc_ptr++; |
3132 | 3249 | ||
3133 | len = strnlen(bcc_ptr, 1024); | 3250 | len = strnlen(bcc_ptr, 1024); |
3134 | if(ses->serverDomain) | 3251 | if (ses->serverDomain) |
3135 | kfree(ses->serverDomain); | 3252 | kfree(ses->serverDomain); |
3136 | ses->serverDomain = kzalloc(len+1,GFP_KERNEL); | 3253 | ses->serverDomain = |
3137 | strncpy(ses->serverDomain, bcc_ptr, len); | 3254 | kzalloc(len+1, |
3255 | GFP_KERNEL); | ||
3256 | strncpy(ses->serverDomain, | ||
3257 | bcc_ptr, len); | ||
3138 | bcc_ptr += len; | 3258 | bcc_ptr += len; |
3139 | bcc_ptr[0] = 0; | 3259 | bcc_ptr[0] = 0; |
3140 | bcc_ptr++; | 3260 | bcc_ptr++; |
3141 | } else | 3261 | } else |
3142 | cFYI(1, | 3262 | cFYI(1, |
3143 | ("Variable field of length %d extends beyond end of smb ", | 3263 | ("field of length %d " |
3264 | "extends beyond end of smb ", | ||
3144 | len)); | 3265 | len)); |
3145 | } | 3266 | } |
3146 | } else { | 3267 | } else { |
3147 | cERROR(1, | 3268 | cERROR(1, |
3148 | (" Security Blob Length extends beyond end of SMB")); | 3269 | (" Security Blob extends beyond end " |
3270 | "of SMB")); | ||
3149 | } | 3271 | } |
3150 | } else { | 3272 | } else { |
3151 | cERROR(1, ("No session structure passed in.")); | 3273 | cERROR(1, ("No session structure passed in.")); |
@@ -3197,7 +3319,7 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, | |||
3197 | pSMB->AndXCommand = 0xFF; | 3319 | pSMB->AndXCommand = 0xFF; |
3198 | pSMB->Flags = cpu_to_le16(TCON_EXTENDED_SECINFO); | 3320 | pSMB->Flags = cpu_to_le16(TCON_EXTENDED_SECINFO); |
3199 | bcc_ptr = &pSMB->Password[0]; | 3321 | bcc_ptr = &pSMB->Password[0]; |
3200 | if((ses->server->secMode) & SECMODE_USER) { | 3322 | if ((ses->server->secMode) & SECMODE_USER) { |
3201 | pSMB->PasswordLength = cpu_to_le16(1); /* minimum */ | 3323 | pSMB->PasswordLength = cpu_to_le16(1); /* minimum */ |
3202 | *bcc_ptr = 0; /* password is null byte */ | 3324 | *bcc_ptr = 0; /* password is null byte */ |
3203 | bcc_ptr++; /* skip password */ | 3325 | bcc_ptr++; /* skip password */ |
@@ -3211,7 +3333,7 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, | |||
3211 | by Samba (not sure whether other servers allow | 3333 | by Samba (not sure whether other servers allow |
3212 | NTLMv2 password here) */ | 3334 | NTLMv2 password here) */ |
3213 | #ifdef CONFIG_CIFS_WEAK_PW_HASH | 3335 | #ifdef CONFIG_CIFS_WEAK_PW_HASH |
3214 | if((extended_security & CIFSSEC_MAY_LANMAN) && | 3336 | if ((extended_security & CIFSSEC_MAY_LANMAN) && |
3215 | (ses->server->secType == LANMAN)) | 3337 | (ses->server->secType == LANMAN)) |
3216 | calc_lanman_hash(ses, bcc_ptr); | 3338 | calc_lanman_hash(ses, bcc_ptr); |
3217 | else | 3339 | else |
@@ -3221,14 +3343,14 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, | |||
3221 | bcc_ptr); | 3343 | bcc_ptr); |
3222 | 3344 | ||
3223 | bcc_ptr += CIFS_SESS_KEY_SIZE; | 3345 | bcc_ptr += CIFS_SESS_KEY_SIZE; |
3224 | if(ses->capabilities & CAP_UNICODE) { | 3346 | if (ses->capabilities & CAP_UNICODE) { |
3225 | /* must align unicode strings */ | 3347 | /* must align unicode strings */ |
3226 | *bcc_ptr = 0; /* null byte password */ | 3348 | *bcc_ptr = 0; /* null byte password */ |
3227 | bcc_ptr++; | 3349 | bcc_ptr++; |
3228 | } | 3350 | } |
3229 | } | 3351 | } |
3230 | 3352 | ||
3231 | if(ses->server->secMode & | 3353 | if (ses->server->secMode & |
3232 | (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) | 3354 | (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) |
3233 | smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; | 3355 | smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; |
3234 | 3356 | ||
@@ -3241,8 +3363,8 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, | |||
3241 | if (ses->capabilities & CAP_UNICODE) { | 3363 | if (ses->capabilities & CAP_UNICODE) { |
3242 | smb_buffer->Flags2 |= SMBFLG2_UNICODE; | 3364 | smb_buffer->Flags2 |= SMBFLG2_UNICODE; |
3243 | length = | 3365 | length = |
3244 | cifs_strtoUCS((__le16 *) bcc_ptr, tree, | 3366 | cifs_strtoUCS((__le16 *) bcc_ptr, tree, |
3245 | 6 /* max utf8 char length in bytes */ * | 3367 | 6 /* max utf8 char length in bytes */ * |
3246 | (/* server len*/ + 256 /* share len */), nls_codepage); | 3368 | (/* server len*/ + 256 /* share len */), nls_codepage); |
3247 | bcc_ptr += 2 * length; /* convert num 16 bit words to bytes */ | 3369 | bcc_ptr += 2 * length; /* convert num 16 bit words to bytes */ |
3248 | bcc_ptr += 2; /* skip trailing null */ | 3370 | bcc_ptr += 2; /* skip trailing null */ |
@@ -3266,8 +3388,8 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, | |||
3266 | tcon->tid = smb_buffer_response->Tid; | 3388 | tcon->tid = smb_buffer_response->Tid; |
3267 | bcc_ptr = pByteArea(smb_buffer_response); | 3389 | bcc_ptr = pByteArea(smb_buffer_response); |
3268 | length = strnlen(bcc_ptr, BCC(smb_buffer_response) - 2); | 3390 | length = strnlen(bcc_ptr, BCC(smb_buffer_response) - 2); |
3269 | /* skip service field (NB: this field is always ASCII) */ | 3391 | /* skip service field (NB: this field is always ASCII) */ |
3270 | bcc_ptr += length + 1; | 3392 | bcc_ptr += length + 1; |
3271 | strncpy(tcon->treeName, tree, MAX_TREE_SIZE); | 3393 | strncpy(tcon->treeName, tree, MAX_TREE_SIZE); |
3272 | if (smb_buffer->Flags2 & SMBFLG2_UNICODE) { | 3394 | if (smb_buffer->Flags2 & SMBFLG2_UNICODE) { |
3273 | length = UniStrnlen((wchar_t *) bcc_ptr, 512); | 3395 | length = UniStrnlen((wchar_t *) bcc_ptr, 512); |
@@ -3285,7 +3407,7 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, | |||
3285 | bcc_ptr[1] = 0; | 3407 | bcc_ptr[1] = 0; |
3286 | bcc_ptr += 2; | 3408 | bcc_ptr += 2; |
3287 | } | 3409 | } |
3288 | /* else do not bother copying these informational fields */ | 3410 | /* else do not bother copying these information fields*/ |
3289 | } else { | 3411 | } else { |
3290 | length = strnlen(bcc_ptr, 1024); | 3412 | length = strnlen(bcc_ptr, 1024); |
3291 | if ((bcc_ptr + length) - | 3413 | if ((bcc_ptr + length) - |
@@ -3297,9 +3419,9 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, | |||
3297 | strncpy(tcon->nativeFileSystem, bcc_ptr, | 3419 | strncpy(tcon->nativeFileSystem, bcc_ptr, |
3298 | length); | 3420 | length); |
3299 | } | 3421 | } |
3300 | /* else do not bother copying these informational fields */ | 3422 | /* else do not bother copying these information fields*/ |
3301 | } | 3423 | } |
3302 | if((smb_buffer_response->WordCount == 3) || | 3424 | if ((smb_buffer_response->WordCount == 3) || |
3303 | (smb_buffer_response->WordCount == 7)) | 3425 | (smb_buffer_response->WordCount == 7)) |
3304 | /* field is in same location */ | 3426 | /* field is in same location */ |
3305 | tcon->Flags = le16_to_cpu(pSMBr->OptionalSupport); | 3427 | tcon->Flags = le16_to_cpu(pSMBr->OptionalSupport); |
@@ -3307,7 +3429,7 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, | |||
3307 | tcon->Flags = 0; | 3429 | tcon->Flags = 0; |
3308 | cFYI(1, ("Tcon flags: 0x%x ", tcon->Flags)); | 3430 | cFYI(1, ("Tcon flags: 0x%x ", tcon->Flags)); |
3309 | } else if ((rc == 0) && tcon == NULL) { | 3431 | } else if ((rc == 0) && tcon == NULL) { |
3310 | /* all we need to save for IPC$ connection */ | 3432 | /* all we need to save for IPC$ connection */ |
3311 | ses->ipc_tid = smb_buffer_response->Tid; | 3433 | ses->ipc_tid = smb_buffer_response->Tid; |
3312 | } | 3434 | } |
3313 | 3435 | ||
@@ -3323,7 +3445,7 @@ cifs_umount(struct super_block *sb, struct cifs_sb_info *cifs_sb) | |||
3323 | int xid; | 3445 | int xid; |
3324 | struct cifsSesInfo *ses = NULL; | 3446 | struct cifsSesInfo *ses = NULL; |
3325 | struct task_struct *cifsd_task; | 3447 | struct task_struct *cifsd_task; |
3326 | char * tmp; | 3448 | char *tmp; |
3327 | 3449 | ||
3328 | xid = GetXid(); | 3450 | xid = GetXid(); |
3329 | 3451 | ||
@@ -3344,9 +3466,9 @@ cifs_umount(struct super_block *sb, struct cifs_sb_info *cifs_sb) | |||
3344 | FreeXid(xid); | 3466 | FreeXid(xid); |
3345 | return 0; | 3467 | return 0; |
3346 | } else if (rc == -ESHUTDOWN) { | 3468 | } else if (rc == -ESHUTDOWN) { |
3347 | cFYI(1,("Waking up socket by sending it signal")); | 3469 | cFYI(1, ("Waking up socket by sending signal")); |
3348 | if (cifsd_task) { | 3470 | if (cifsd_task) { |
3349 | send_sig(SIGKILL,cifsd_task,1); | 3471 | force_sig(SIGKILL, cifsd_task); |
3350 | kthread_stop(cifsd_task); | 3472 | kthread_stop(cifsd_task); |
3351 | } | 3473 | } |
3352 | rc = 0; | 3474 | rc = 0; |
@@ -3355,7 +3477,7 @@ cifs_umount(struct super_block *sb, struct cifs_sb_info *cifs_sb) | |||
3355 | } else | 3477 | } else |
3356 | cFYI(1, ("No session or bad tcon")); | 3478 | cFYI(1, ("No session or bad tcon")); |
3357 | } | 3479 | } |
3358 | 3480 | ||
3359 | cifs_sb->tcon = NULL; | 3481 | cifs_sb->tcon = NULL; |
3360 | tmp = cifs_sb->prepath; | 3482 | tmp = cifs_sb->prepath; |
3361 | cifs_sb->prepathlen = 0; | 3483 | cifs_sb->prepathlen = 0; |
@@ -3367,11 +3489,11 @@ cifs_umount(struct super_block *sb, struct cifs_sb_info *cifs_sb) | |||
3367 | sesInfoFree(ses); | 3489 | sesInfoFree(ses); |
3368 | 3490 | ||
3369 | FreeXid(xid); | 3491 | FreeXid(xid); |
3370 | return rc; /* BB check if we should always return zero here */ | 3492 | return rc; /* BB check if we should always return zero here */ |
3371 | } | 3493 | } |
3372 | 3494 | ||
3373 | int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo, | 3495 | int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo, |
3374 | struct nls_table * nls_info) | 3496 | struct nls_table *nls_info) |
3375 | { | 3497 | { |
3376 | int rc = 0; | 3498 | int rc = 0; |
3377 | char ntlm_session_key[CIFS_SESS_KEY_SIZE]; | 3499 | char ntlm_session_key[CIFS_SESS_KEY_SIZE]; |
@@ -3379,16 +3501,16 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo, | |||
3379 | int first_time = 0; | 3501 | int first_time = 0; |
3380 | 3502 | ||
3381 | /* what if server changes its buffer size after dropping the session? */ | 3503 | /* what if server changes its buffer size after dropping the session? */ |
3382 | if(pSesInfo->server->maxBuf == 0) /* no need to send on reconnect */ { | 3504 | if (pSesInfo->server->maxBuf == 0) /* no need to send on reconnect */ { |
3383 | rc = CIFSSMBNegotiate(xid, pSesInfo); | 3505 | rc = CIFSSMBNegotiate(xid, pSesInfo); |
3384 | if(rc == -EAGAIN) /* retry only once on 1st time connection */ { | 3506 | if (rc == -EAGAIN) /* retry only once on 1st time connection */ { |
3385 | rc = CIFSSMBNegotiate(xid, pSesInfo); | 3507 | rc = CIFSSMBNegotiate(xid, pSesInfo); |
3386 | if(rc == -EAGAIN) | 3508 | if (rc == -EAGAIN) |
3387 | rc = -EHOSTDOWN; | 3509 | rc = -EHOSTDOWN; |
3388 | } | 3510 | } |
3389 | if(rc == 0) { | 3511 | if (rc == 0) { |
3390 | spin_lock(&GlobalMid_Lock); | 3512 | spin_lock(&GlobalMid_Lock); |
3391 | if(pSesInfo->server->tcpStatus != CifsExiting) | 3513 | if (pSesInfo->server->tcpStatus != CifsExiting) |
3392 | pSesInfo->server->tcpStatus = CifsGood; | 3514 | pSesInfo->server->tcpStatus = CifsGood; |
3393 | else | 3515 | else |
3394 | rc = -EHOSTDOWN; | 3516 | rc = -EHOSTDOWN; |
@@ -3400,18 +3522,19 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo, | |||
3400 | if (!rc) { | 3522 | if (!rc) { |
3401 | pSesInfo->flags = 0; | 3523 | pSesInfo->flags = 0; |
3402 | pSesInfo->capabilities = pSesInfo->server->capabilities; | 3524 | pSesInfo->capabilities = pSesInfo->server->capabilities; |
3403 | if(linuxExtEnabled == 0) | 3525 | if (linuxExtEnabled == 0) |
3404 | pSesInfo->capabilities &= (~CAP_UNIX); | 3526 | pSesInfo->capabilities &= (~CAP_UNIX); |
3405 | /* pSesInfo->sequence_number = 0;*/ | 3527 | /* pSesInfo->sequence_number = 0;*/ |
3406 | cFYI(1,("Security Mode: 0x%x Capabilities: 0x%x TimeAdjust: %d", | 3528 | cFYI(1, |
3529 | ("Security Mode: 0x%x Capabilities: 0x%x TimeAdjust: %d", | ||
3407 | pSesInfo->server->secMode, | 3530 | pSesInfo->server->secMode, |
3408 | pSesInfo->server->capabilities, | 3531 | pSesInfo->server->capabilities, |
3409 | pSesInfo->server->timeAdj)); | 3532 | pSesInfo->server->timeAdj)); |
3410 | if(experimEnabled < 2) | 3533 | if (experimEnabled < 2) |
3411 | rc = CIFS_SessSetup(xid, pSesInfo, | 3534 | rc = CIFS_SessSetup(xid, pSesInfo, |
3412 | first_time, nls_info); | 3535 | first_time, nls_info); |
3413 | else if (extended_security | 3536 | else if (extended_security |
3414 | && (pSesInfo->capabilities | 3537 | && (pSesInfo->capabilities |
3415 | & CAP_EXTENDED_SECURITY) | 3538 | & CAP_EXTENDED_SECURITY) |
3416 | && (pSesInfo->server->secType == NTLMSSP)) { | 3539 | && (pSesInfo->server->secType == NTLMSSP)) { |
3417 | rc = -EOPNOTSUPP; | 3540 | rc = -EOPNOTSUPP; |
@@ -3424,21 +3547,22 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo, | |||
3424 | &ntlmv2_flag, | 3547 | &ntlmv2_flag, |
3425 | nls_info); | 3548 | nls_info); |
3426 | if (!rc) { | 3549 | if (!rc) { |
3427 | if(ntlmv2_flag) { | 3550 | if (ntlmv2_flag) { |
3428 | char * v2_response; | 3551 | char *v2_response; |
3429 | cFYI(1,("more secure NTLM ver2 hash")); | 3552 | cFYI(1, ("more secure NTLM ver2 hash")); |
3430 | if(CalcNTLMv2_partial_mac_key(pSesInfo, | 3553 | if (CalcNTLMv2_partial_mac_key(pSesInfo, |
3431 | nls_info)) { | 3554 | nls_info)) { |
3432 | rc = -ENOMEM; | 3555 | rc = -ENOMEM; |
3433 | goto ss_err_exit; | 3556 | goto ss_err_exit; |
3434 | } else | 3557 | } else |
3435 | v2_response = kmalloc(16 + 64 /* blob */, GFP_KERNEL); | 3558 | v2_response = kmalloc(16 + 64 /* blob */, GFP_KERNEL); |
3436 | if(v2_response) { | 3559 | if (v2_response) { |
3437 | CalcNTLMv2_response(pSesInfo,v2_response); | 3560 | CalcNTLMv2_response(pSesInfo, |
3438 | /* if(first_time) | 3561 | v2_response); |
3439 | cifs_calculate_ntlmv2_mac_key( | 3562 | /* if (first_time) |
3440 | pSesInfo->server->mac_signing_key, | 3563 | cifs_calculate_ntlmv2_mac_key( |
3441 | response, ntlm_session_key, */ | 3564 | pSesInfo->server->mac_signing_key, |
3565 | response, ntlm_session_key,*/ | ||
3442 | kfree(v2_response); | 3566 | kfree(v2_response); |
3443 | /* BB Put dummy sig in SessSetup PDU? */ | 3567 | /* BB Put dummy sig in SessSetup PDU? */ |
3444 | } else { | 3568 | } else { |
@@ -3451,9 +3575,9 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo, | |||
3451 | pSesInfo->server->cryptKey, | 3575 | pSesInfo->server->cryptKey, |
3452 | ntlm_session_key); | 3576 | ntlm_session_key); |
3453 | 3577 | ||
3454 | if(first_time) | 3578 | if (first_time) |
3455 | cifs_calculate_mac_key( | 3579 | cifs_calculate_mac_key( |
3456 | pSesInfo->server->mac_signing_key, | 3580 | &pSesInfo->server->mac_signing_key, |
3457 | ntlm_session_key, | 3581 | ntlm_session_key, |
3458 | pSesInfo->password); | 3582 | pSesInfo->password); |
3459 | } | 3583 | } |
@@ -3471,18 +3595,18 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo, | |||
3471 | pSesInfo->server->cryptKey, | 3595 | pSesInfo->server->cryptKey, |
3472 | ntlm_session_key); | 3596 | ntlm_session_key); |
3473 | 3597 | ||
3474 | if(first_time) | 3598 | if (first_time) |
3475 | cifs_calculate_mac_key( | 3599 | cifs_calculate_mac_key( |
3476 | pSesInfo->server->mac_signing_key, | 3600 | &pSesInfo->server->mac_signing_key, |
3477 | ntlm_session_key, pSesInfo->password); | 3601 | ntlm_session_key, pSesInfo->password); |
3478 | 3602 | ||
3479 | rc = CIFSSessSetup(xid, pSesInfo, | 3603 | rc = CIFSSessSetup(xid, pSesInfo, |
3480 | ntlm_session_key, nls_info); | 3604 | ntlm_session_key, nls_info); |
3481 | } | 3605 | } |
3482 | if (rc) { | 3606 | if (rc) { |
3483 | cERROR(1,("Send error in SessSetup = %d",rc)); | 3607 | cERROR(1, ("Send error in SessSetup = %d", rc)); |
3484 | } else { | 3608 | } else { |
3485 | cFYI(1,("CIFS Session Established successfully")); | 3609 | cFYI(1, ("CIFS Session Established successfully")); |
3486 | pSesInfo->status = CifsGood; | 3610 | pSesInfo->status = CifsGood; |
3487 | } | 3611 | } |
3488 | } | 3612 | } |