connect.c 104 KB
Newer Older
Linus Torvalds's avatar
Linus Torvalds committed
1
2
3
/*
 *   fs/cifs/connect.c
 *
4
 *   Copyright (C) International Business Machines  Corp., 2002,2009
Linus Torvalds's avatar
Linus Torvalds committed
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 *   Author(s): Steve French (sfrench@us.ibm.com)
 *
 *   This library is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU Lesser General Public License as published
 *   by the Free Software Foundation; either version 2.1 of the License, or
 *   (at your option) any later version.
 *
 *   This library is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
 *   the GNU Lesser General Public License for more details.
 *
 *   You should have received a copy of the GNU Lesser General Public License
 *   along with this library; if not, write to the Free Software
Steve French's avatar
Steve French committed
19
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Linus Torvalds's avatar
Linus Torvalds committed
20
21
22
23
24
25
 */
#include <linux/fs.h>
#include <linux/net.h>
#include <linux/string.h>
#include <linux/list.h>
#include <linux/wait.h>
26
#include <linux/slab.h>
Linus Torvalds's avatar
Linus Torvalds committed
27
28
29
30
#include <linux/pagemap.h>
#include <linux/ctype.h>
#include <linux/utsname.h>
#include <linux/mempool.h>
31
#include <linux/delay.h>
32
#include <linux/completion.h>
33
#include <linux/kthread.h>
34
#include <linux/pagevec.h>
35
#include <linux/freezer.h>
36
#include <linux/namei.h>
Linus Torvalds's avatar
Linus Torvalds committed
37
38
#include <asm/uaccess.h>
#include <asm/processor.h>
39
#include <linux/inet.h>
40
#include <net/ipv6.h>
Linus Torvalds's avatar
Linus Torvalds committed
41
42
43
44
45
46
47
48
49
#include "cifspdu.h"
#include "cifsglob.h"
#include "cifsproto.h"
#include "cifs_unicode.h"
#include "cifs_debug.h"
#include "cifs_fs_sb.h"
#include "ntlmssp.h"
#include "nterr.h"
#include "rfc1002pdu.h"
50
#include "fscache.h"
Linus Torvalds's avatar
Linus Torvalds committed
51
52
53
54

#define CIFS_PORT 445
#define RFC1001_PORT 139

55
56
57
/* SMB echo "timeout" -- FIXME: tunable? */
#define SMB_ECHO_INTERVAL (60 * HZ)

Linus Torvalds's avatar
Linus Torvalds committed
58
59
extern mempool_t *cifs_req_poolp;

60
/* FIXME: should these be tunable? */
61
#define TLINK_ERROR_EXPIRE	(1 * HZ)
62
#define TLINK_IDLE_EXPIRE	(600 * HZ)
63

64
65
static int ip_connect(struct TCP_Server_Info *server);
static int generic_ip_connect(struct TCP_Server_Info *server);
66
static void tlink_rb_insert(struct rb_root *root, struct tcon_link *new_tlink);
67
static void cifs_prune_tlinks(struct work_struct *work);
Jeff Layton's avatar
Jeff Layton committed
68
69
static int cifs_setup_volume_info(struct smb_vol *volume_info, char *mount_data,
					const char *devname);
Linus Torvalds's avatar
Linus Torvalds committed
70

71
72
73
74
75
76
77
78
/*
 * cifs tcp session reconnection
 *
 * mark tcp session as reconnecting so temporarily locked
 * mark all smb sessions as reconnecting for tcp session
 * reconnect tcp session
 * wake up waiters on reconnection? - (not needed currently)
 */
79
static int
Linus Torvalds's avatar
Linus Torvalds committed
80
81
82
cifs_reconnect(struct TCP_Server_Info *server)
{
	int rc = 0;
83
	struct list_head *tmp, *tmp2;
84
85
	struct cifs_ses *ses;
	struct cifs_tcon *tcon;
Steve French's avatar
Steve French committed
86
	struct mid_q_entry *mid_entry;
87
	struct list_head retry_list;
88

Linus Torvalds's avatar
Linus Torvalds committed
89
	spin_lock(&GlobalMid_Lock);
90
	if (server->tcpStatus == CifsExiting) {
Steve French's avatar
Steve French committed
91
		/* the demux thread will exit normally
Linus Torvalds's avatar
Linus Torvalds committed
92
93
94
95
96
97
98
99
		next time through the loop */
		spin_unlock(&GlobalMid_Lock);
		return rc;
	} else
		server->tcpStatus = CifsNeedReconnect;
	spin_unlock(&GlobalMid_Lock);
	server->maxBuf = 0;

100
	cFYI(1, "Reconnecting tcp session");
Linus Torvalds's avatar
Linus Torvalds committed
101
102
103

	/* before reconnecting the tcp session, mark the smb session (uid)
		and the tid bad so they are not used until reconnected */
104
	cFYI(1, "%s: marking sessions and tcons for reconnect", __func__);
105
	spin_lock(&cifs_tcp_ses_lock);
106
	list_for_each(tmp, &server->smb_ses_list) {
107
		ses = list_entry(tmp, struct cifs_ses, smb_ses_list);
108
109
		ses->need_reconnect = true;
		ses->ipc_tid = 0;
110
		list_for_each(tmp2, &ses->tcon_list) {
111
			tcon = list_entry(tmp2, struct cifs_tcon, tcon_list);
112
			tcon->need_reconnect = true;
Linus Torvalds's avatar
Linus Torvalds committed
113
114
		}
	}
115
	spin_unlock(&cifs_tcp_ses_lock);
116

Linus Torvalds's avatar
Linus Torvalds committed
117
	/* do not want to be sending data on a socket we are freeing */
118
	cFYI(1, "%s: tearing down socket", __func__);
Jeff Layton's avatar
Jeff Layton committed
119
	mutex_lock(&server->srv_mutex);
Steve French's avatar
Steve French committed
120
	if (server->ssocket) {
121
122
		cFYI(1, "State: 0x%x Flags: 0x%lx", server->ssocket->state,
			server->ssocket->flags);
123
		kernel_sock_shutdown(server->ssocket, SHUT_WR);
124
		cFYI(1, "Post shutdown state: 0x%x Flags: 0x%lx",
Steve French's avatar
Steve French committed
125
			server->ssocket->state,
126
			server->ssocket->flags);
Linus Torvalds's avatar
Linus Torvalds committed
127
128
129
		sock_release(server->ssocket);
		server->ssocket = NULL;
	}
130
131
	server->sequence_number = 0;
	server->session_estab = false;
132
133
134
	kfree(server->session_key.response);
	server->session_key.response = NULL;
	server->session_key.len = 0;
135
	server->lstrp = jiffies;
136
	mutex_unlock(&server->srv_mutex);
Linus Torvalds's avatar
Linus Torvalds committed
137

138
	/* mark submitted MIDs for retry and issue callback */
139
140
	INIT_LIST_HEAD(&retry_list);
	cFYI(1, "%s: moving mids to private list", __func__);
Linus Torvalds's avatar
Linus Torvalds committed
141
	spin_lock(&GlobalMid_Lock);
142
143
144
	list_for_each_safe(tmp, tmp2, &server->pending_mid_q) {
		mid_entry = list_entry(tmp, struct mid_q_entry, qhead);
		if (mid_entry->midState == MID_REQUEST_SUBMITTED)
145
			mid_entry->midState = MID_RETRY_NEEDED;
146
147
148
149
150
151
152
		list_move(&mid_entry->qhead, &retry_list);
	}
	spin_unlock(&GlobalMid_Lock);

	cFYI(1, "%s: issuing mid callbacks", __func__);
	list_for_each_safe(tmp, tmp2, &retry_list) {
		mid_entry = list_entry(tmp, struct mid_q_entry, qhead);
153
154
		list_del_init(&mid_entry->qhead);
		mid_entry->callback(mid_entry);
Linus Torvalds's avatar
Linus Torvalds committed
155
156
	}

157
	do {
158
		try_to_freeze();
159
160
161

		/* we should try only the port we connected to before */
		rc = generic_ip_connect(server);
Steve French's avatar
Steve French committed
162
		if (rc) {
163
			cFYI(1, "reconnect error %d", rc);
164
			msleep(3000);
Linus Torvalds's avatar
Linus Torvalds committed
165
166
167
		} else {
			atomic_inc(&tcpSesReconnectCount);
			spin_lock(&GlobalMid_Lock);
168
			if (server->tcpStatus != CifsExiting)
169
				server->tcpStatus = CifsNeedNegotiate;
Steve French's avatar
Steve French committed
170
			spin_unlock(&GlobalMid_Lock);
Linus Torvalds's avatar
Linus Torvalds committed
171
		}
172
	} while (server->tcpStatus == CifsNeedReconnect);
173

Linus Torvalds's avatar
Linus Torvalds committed
174
175
176
	return rc;
}

Steve French's avatar
Steve French committed
177
/*
178
179
180
181
182
183
	return codes:
		0 	not a transact2, or all data present
		>0 	transact2 with that much data missing
		-EINVAL = invalid transact2

 */
Steve French's avatar
Steve French committed
184
static int check2ndT2(struct smb_hdr *pSMB, unsigned int maxBufSize)
185
{
Steve French's avatar
Steve French committed
186
	struct smb_t2_rsp *pSMBt;
187
	int remaining;
188
	__u16 total_data_size, data_in_this_rsp;
189

Steve French's avatar
Steve French committed
190
	if (pSMB->Command != SMB_COM_TRANSACTION2)
191
192
		return 0;

Steve French's avatar
Steve French committed
193
194
195
	/* check for plausible wct, bcc and t2 data and parm sizes */
	/* check for parm and data offset going beyond end of smb */
	if (pSMB->WordCount != 10) { /* coalesce_t2 depends on this */
196
		cFYI(1, "invalid transact2 word count");
197
198
199
200
201
		return -EINVAL;
	}

	pSMBt = (struct smb_t2_rsp *)pSMB;

202
203
	total_data_size = get_unaligned_le16(&pSMBt->t2_rsp.TotalDataCount);
	data_in_this_rsp = get_unaligned_le16(&pSMBt->t2_rsp.DataCount);
204

205
	if (total_data_size == data_in_this_rsp)
206
		return 0;
207
	else if (total_data_size < data_in_this_rsp) {
208
209
		cFYI(1, "total data %d smaller than data in frame %d",
			total_data_size, data_in_this_rsp);
210
211
		return -EINVAL;
	}
212
213
214
215
216
217
218
219
220
221
222

	remaining = total_data_size - data_in_this_rsp;

	cFYI(1, "missing %d bytes from transact2, check next response",
		remaining);
	if (total_data_size > maxBufSize) {
		cERROR(1, "TotalDataSize %d is over maximum buffer %d",
			total_data_size, maxBufSize);
		return -EINVAL;
	}
	return remaining;
223
224
}

Steve French's avatar
Steve French committed
225
static int coalesce_t2(struct smb_hdr *psecond, struct smb_hdr *pTargetSMB)
226
227
228
{
	struct smb_t2_rsp *pSMB2 = (struct smb_t2_rsp *)psecond;
	struct smb_t2_rsp *pSMBt  = (struct smb_t2_rsp *)pTargetSMB;
Steve French's avatar
Steve French committed
229
230
	char *data_area_of_target;
	char *data_area_of_buf2;
231
	int remaining;
232
233
	unsigned int byte_count, total_in_buf;
	__u16 total_data_size, total_in_buf2;
234

235
	total_data_size = get_unaligned_le16(&pSMBt->t2_rsp.TotalDataCount);
236

237
238
	if (total_data_size !=
	    get_unaligned_le16(&pSMB2->t2_rsp.TotalDataCount))
239
		cFYI(1, "total data size of primary and secondary t2 differ");
240

241
	total_in_buf = get_unaligned_le16(&pSMBt->t2_rsp.DataCount);
242
243

	remaining = total_data_size - total_in_buf;
244

Steve French's avatar
Steve French committed
245
	if (remaining < 0)
246
		return -EPROTO;
247

Steve French's avatar
Steve French committed
248
	if (remaining == 0) /* nothing to do, ignore */
249
		return 0;
250

251
	total_in_buf2 = get_unaligned_le16(&pSMB2->t2_rsp.DataCount);
Steve French's avatar
Steve French committed
252
	if (remaining < total_in_buf2) {
253
		cFYI(1, "transact2 2nd response contains too much data");
254
255
256
	}

	/* find end of first SMB data area */
Steve French's avatar
Steve French committed
257
	data_area_of_target = (char *)&pSMBt->hdr.Protocol +
258
				get_unaligned_le16(&pSMBt->t2_rsp.DataOffset);
259
260
	/* validate target area */

261
262
	data_area_of_buf2 = (char *)&pSMB2->hdr.Protocol +
				get_unaligned_le16(&pSMB2->t2_rsp.DataOffset);
263
264
265
266
267

	data_area_of_target += total_in_buf;

	/* copy second buffer into end of first buffer */
	total_in_buf += total_in_buf2;
268
269
270
	/* is the result too big for the field? */
	if (total_in_buf > USHRT_MAX)
		return -EPROTO;
271
	put_unaligned_le16(total_in_buf, &pSMBt->t2_rsp.DataCount);
272
273

	/* fix up the BCC */
274
	byte_count = get_bcc(pTargetSMB);
275
	byte_count += total_in_buf2;
276
277
278
	/* is the result too big for the field? */
	if (byte_count > USHRT_MAX)
		return -EPROTO;
279
	put_bcc(byte_count, pTargetSMB);
280

281
	byte_count = be32_to_cpu(pTargetSMB->smb_buf_length);
282
	byte_count += total_in_buf2;
283
284
285
	/* don't allow buffer to overflow */
	if (byte_count > CIFSMaxBufSize)
		return -ENOBUFS;
286
	pTargetSMB->smb_buf_length = cpu_to_be32(byte_count);
287

288
289
	memcpy(data_area_of_target, data_area_of_buf2, total_in_buf2);

Steve French's avatar
Steve French committed
290
	if (remaining == total_in_buf2) {
291
		cFYI(1, "found the last secondary response");
292
293
294
295
296
		return 0; /* we are done */
	} else /* more responses to go */
		return 1;
}

297
298
299
300
301
302
303
static void
cifs_echo_request(struct work_struct *work)
{
	int rc;
	struct TCP_Server_Info *server = container_of(work,
					struct TCP_Server_Info, echo.work);

304
	/*
305
306
307
	 * We cannot send an echo until the NEGOTIATE_PROTOCOL request is
	 * done, which is indicated by maxBuf != 0. Also, no need to ping if
	 * we got a response recently
308
	 */
309
	if (server->maxBuf == 0 ||
310
	    time_before(jiffies, server->lstrp + SMB_ECHO_INTERVAL - HZ))
311
312
313
314
315
316
317
318
319
320
321
		goto requeue_echo;

	rc = CIFSSMBEcho(server);
	if (rc)
		cFYI(1, "Unable to send echo request to server: %s",
			server->hostname);

requeue_echo:
	queue_delayed_work(system_nrt_wq, &server->echo, SMB_ECHO_INTERVAL);
}

322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
static bool
allocate_buffers(char **bigbuf, char **smallbuf, unsigned int size,
		 bool is_large_buf)
{
	char *bbuf = *bigbuf, *sbuf = *smallbuf;

	if (bbuf == NULL) {
		bbuf = (char *)cifs_buf_get();
		if (!bbuf) {
			cERROR(1, "No memory for large SMB response");
			msleep(3000);
			/* retry will check if exiting */
			return false;
		}
	} else if (is_large_buf) {
		/* we are reusing a dirty large buf, clear its start */
		memset(bbuf, 0, size);
	}

	if (sbuf == NULL) {
		sbuf = (char *)cifs_small_buf_get();
		if (!sbuf) {
			cERROR(1, "No memory for SMB response");
			msleep(1000);
			/* retry will check if exiting */
			return false;
		}
		/* beginning of smb buffer is cleared in our buf_get */
	} else {
		/* if existing small buf clear beginning */
		memset(sbuf, 0, size);
	}

	*bigbuf = bbuf;
	*smallbuf = sbuf;

	return true;
}

361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
static int
read_from_socket(struct TCP_Server_Info *server, struct msghdr *smb_msg,
		 struct kvec *iov, unsigned int to_read,
		 unsigned int *ptotal_read, bool is_header_read)
{
	int length, rc = 0;
	unsigned int total_read;
	char *buf = iov->iov_base;

	for (total_read = 0; total_read < to_read; total_read += length) {
		length = kernel_recvmsg(server->ssocket, smb_msg, iov, 1,
					to_read - total_read, 0);
		if (server->tcpStatus == CifsExiting) {
			/* then will exit */
			rc = 2;
			break;
		} else if (server->tcpStatus == CifsNeedReconnect) {
			cifs_reconnect(server);
			/* Reconnect wakes up rspns q */
			/* Now we will reread sock */
			rc = 1;
			break;
		} else if (length == -ERESTARTSYS ||
			   length == -EAGAIN ||
			   length == -EINTR) {
			/*
			 * Minimum sleep to prevent looping, allowing socket
			 * to clear and app threads to set tcpStatus
			 * CifsNeedReconnect if server hung.
			 */
			usleep_range(1000, 2000);
			length = 0;
			if (!is_header_read)
				continue;
			/* Special handling for header read */
			if (total_read) {
				iov->iov_base = (to_read - total_read) +
						buf;
				iov->iov_len = to_read - total_read;
				smb_msg->msg_control = NULL;
				smb_msg->msg_controllen = 0;
				rc = 3;
			} else
				rc = 1;
			break;
		} else if (length <= 0) {
			cERROR(1, "Received no data, expecting %d",
			       to_read - total_read);
			cifs_reconnect(server);
			rc = 1;
			break;
		}
	}

	*ptotal_read = total_read;
	return rc;
}

419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
static bool
check_rfc1002_header(struct TCP_Server_Info *server, char *buf)
{
	char temp = *buf;
	unsigned int pdu_length = be32_to_cpu(
				((struct smb_hdr *)buf)->smb_buf_length);

	/*
	 * The first byte big endian of the length field,
	 * is actually not part of the length but the type
	 * with the most common, zero, as regular data.
	 */
	if (temp == (char) RFC1002_SESSION_KEEP_ALIVE) {
		return false;
	} else if (temp == (char)RFC1002_POSITIVE_SESSION_RESPONSE) {
		cFYI(1, "Good RFC 1002 session rsp");
		return false;
	} else if (temp == (char)RFC1002_NEGATIVE_SESSION_RESPONSE) {
		/*
		 * We get this from Windows 98 instead of an error on
		 * SMB negprot response.
		 */
		cFYI(1, "Negative RFC1002 Session Response Error 0x%x)",
			pdu_length);
		/* give server a second to clean up */
		msleep(1000);
		/*
		 * Always try 445 first on reconnect since we get NACK
		 * on some if we ever connected to port 139 (the NACK
		 * is since we do not begin with RFC1001 session
		 * initialize frame).
		 */
		cifs_set_port((struct sockaddr *)
				&server->dstaddr, CIFS_PORT);
		cifs_reconnect(server);
		wake_up(&server->response_q);
		return false;
	} else if (temp != (char) 0) {
		cERROR(1, "Unknown RFC 1002 frame");
		cifs_dump_mem(" Received Data: ", buf, 4);
		cifs_reconnect(server);
		return false;
	}

	/* else we have an SMB response */
	if ((pdu_length > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) ||
	    (pdu_length < sizeof(struct smb_hdr) - 1 - 4)) {
		cERROR(1, "Invalid size SMB length %d pdu_length %d",
		       4, pdu_length+4);
		cifs_reconnect(server);
		wake_up(&server->response_q);
		return false;
	}

	return true;
}

476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
static struct mid_q_entry *
find_cifs_mid(struct TCP_Server_Info *server, struct smb_hdr *buf,
	      int *length, bool is_large_buf, bool *is_multi_rsp, char **bigbuf)
{
	struct mid_q_entry *mid = NULL, *tmp_mid, *ret = NULL;

	spin_lock(&GlobalMid_Lock);
	list_for_each_entry_safe(mid, tmp_mid, &server->pending_mid_q, qhead) {
		if (mid->mid != buf->Mid ||
		    mid->midState != MID_REQUEST_SUBMITTED ||
		    mid->command != buf->Command)
			continue;

		if (*length == 0 && check2ndT2(buf, server->maxBuf) > 0) {
			/* We have a multipart transact2 resp */
			*is_multi_rsp = true;
			if (mid->resp_buf) {
				/* merge response - fix up 1st*/
				*length = coalesce_t2(buf, mid->resp_buf);
				if (*length > 0) {
					*length = 0;
					mid->multiRsp = true;
					break;
				}
				/* All parts received or packet is malformed. */
				mid->multiEnd = true;
				goto multi_t2_fnd;
			}
			if (!is_large_buf) {
				/*FIXME: switch to already allocated largebuf?*/
				cERROR(1, "1st trans2 resp needs bigbuf");
			} else {
				/* Have first buffer */
				mid->resp_buf = buf;
				mid->largeBuf = true;
				*bigbuf = NULL;
			}
			break;
		}
		mid->resp_buf = buf;
		mid->largeBuf = is_large_buf;
multi_t2_fnd:
		if (*length == 0)
			mid->midState = MID_RESPONSE_RECEIVED;
		else
			mid->midState = MID_RESPONSE_MALFORMED;
#ifdef CONFIG_CIFS_STATS2
		mid->when_received = jiffies;
#endif
		list_del_init(&mid->qhead);
		ret = mid;
		break;
	}
	spin_unlock(&GlobalMid_Lock);

	return ret;
}

534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
static void clean_demultiplex_info(struct TCP_Server_Info *server)
{
	int length;

	/* take it off the list, if it's not already */
	spin_lock(&cifs_tcp_ses_lock);
	list_del_init(&server->tcp_ses_list);
	spin_unlock(&cifs_tcp_ses_lock);

	spin_lock(&GlobalMid_Lock);
	server->tcpStatus = CifsExiting;
	spin_unlock(&GlobalMid_Lock);
	wake_up_all(&server->response_q);

	/*
	 * Check if we have blocked requests that need to free. Note that
	 * cifs_max_pending is normally 50, but can be set at module install
	 * time to as little as two.
	 */
	spin_lock(&GlobalMid_Lock);
	if (atomic_read(&server->inFlight) >= cifs_max_pending)
		atomic_set(&server->inFlight, cifs_max_pending - 1);
	/*
	 * We do not want to set the max_pending too low or we could end up
	 * with the counter going negative.
	 */
	spin_unlock(&GlobalMid_Lock);
	/*
	 * Although there should not be any requests blocked on this queue it
	 * can not hurt to be paranoid and try to wake up requests that may
	 * haven been blocked when more than 50 at time were on the wire to the
	 * same server - they now will see the session is in exit state and get
	 * out of SendReceive.
	 */
	wake_up_all(&server->request_q);
	/* give those requests time to exit */
	msleep(125);

	if (server->ssocket) {
		sock_release(server->ssocket);
		server->ssocket = NULL;
	}

	if (!list_empty(&server->pending_mid_q)) {
		struct list_head dispose_list;
		struct mid_q_entry *mid_entry;
		struct list_head *tmp, *tmp2;

		INIT_LIST_HEAD(&dispose_list);
		spin_lock(&GlobalMid_Lock);
		list_for_each_safe(tmp, tmp2, &server->pending_mid_q) {
			mid_entry = list_entry(tmp, struct mid_q_entry, qhead);
			cFYI(1, "Clearing mid 0x%x", mid_entry->mid);
			mid_entry->midState = MID_SHUTDOWN;
			list_move(&mid_entry->qhead, &dispose_list);
		}
		spin_unlock(&GlobalMid_Lock);

		/* now walk dispose list and issue callbacks */
		list_for_each_safe(tmp, tmp2, &dispose_list) {
			mid_entry = list_entry(tmp, struct mid_q_entry, qhead);
			cFYI(1, "Callback mid 0x%x", mid_entry->mid);
			list_del_init(&mid_entry->qhead);
			mid_entry->callback(mid_entry);
		}
		/* 1/8th of sec is more than enough time for them to exit */
		msleep(125);
	}

	if (!list_empty(&server->pending_mid_q)) {
		/*
		 * mpx threads have not exited yet give them at least the smb
		 * send timeout time for long ops.
		 *
		 * Due to delays on oplock break requests, we need to wait at
		 * least 45 seconds before giving up on a request getting a
		 * response and going ahead and killing cifsd.
		 */
		cFYI(1, "Wait for exit from demultiplex thread");
		msleep(46000);
		/*
		 * If threads still have not exited they are probably never
		 * coming home not much else we can do but free the memory.
		 */
	}

	kfree(server->hostname);
	kfree(server);

	length = atomic_dec_return(&tcpSesAllocCount);
	if (length > 0)
		mempool_resize(cifs_req_poolp, length + cifs_min_rcv,
				GFP_KERNEL);
}

Linus Torvalds's avatar
Linus Torvalds committed
629
static int
630
cifs_demultiplex_thread(void *p)
Linus Torvalds's avatar
Linus Torvalds committed
631
632
{
	int length;
633
	struct TCP_Server_Info *server = p;
Linus Torvalds's avatar
Linus Torvalds committed
634
	unsigned int pdu_length, total_read;
635
	char *buf = NULL, *bigbuf = NULL, *smallbuf = NULL;
Linus Torvalds's avatar
Linus Torvalds committed
636
637
638
639
640
	struct smb_hdr *smb_buffer = NULL;
	struct msghdr smb_msg;
	struct kvec iov;
	struct task_struct *task_to_wake = NULL;
	struct mid_q_entry *mid_entry;
641
	bool isLargeBuf = false;
642
	bool isMultiRsp = false;
643
	int rc;
Linus Torvalds's avatar
Linus Torvalds committed
644
645

	current->flags |= PF_MEMALLOC;
646
	cFYI(1, "Demultiplex PID: %d", task_pid_nr(current));
647
648
649

	length = atomic_inc_return(&tcpSesAllocCount);
	if (length > 1)
650
651
		mempool_resize(cifs_req_poolp, length + cifs_min_rcv,
				GFP_KERNEL);
Linus Torvalds's avatar
Linus Torvalds committed
652

653
	set_freezable();
654
	while (server->tcpStatus != CifsExiting) {
655
656
		if (try_to_freeze())
			continue;
657

658
659
660
		if (!allocate_buffers(&bigbuf, &smallbuf,
				      sizeof(struct smb_hdr), isLargeBuf))
			continue;
661

662
663
		isLargeBuf = false;
		isMultiRsp = false;
664
665
666
		smb_buffer = (struct smb_hdr *)smallbuf;
		buf = smallbuf;
		iov.iov_base = buf;
Linus Torvalds's avatar
Linus Torvalds committed
667
668
669
		iov.iov_len = 4;
		smb_msg.msg_control = NULL;
		smb_msg.msg_controllen = 0;
670
		pdu_length = 4; /* enough to get RFC1001 header */
671

672
incomplete_rcv:
673
		if (echo_retries > 0 && server->tcpStatus == CifsGood &&
674
675
676
677
678
679
680
681
682
683
		    time_after(jiffies, server->lstrp +
					(echo_retries * SMB_ECHO_INTERVAL))) {
			cERROR(1, "Server %s has not responded in %d seconds. "
				  "Reconnecting...", server->hostname,
				  (echo_retries * SMB_ECHO_INTERVAL / HZ));
			cifs_reconnect(server);
			wake_up(&server->response_q);
			continue;
		}

684
685
686
687
688
		rc = read_from_socket(server, &smb_msg, &iov, pdu_length,
				      &total_read, true /* header read */);
		if (rc == 3)
			goto incomplete_rcv;
		else if (rc == 2)
Linus Torvalds's avatar
Linus Torvalds committed
689
			break;
690
		else if (rc == 1)
Linus Torvalds's avatar
Linus Torvalds committed
691
692
			continue;

693
694
695
696
		/*
		 * The right amount was read from socket - 4 bytes,
		 * so we can now interpret the length field.
		 */
697

698
699
700
701
702
		/*
		 * Note that RFC 1001 length is big endian on the wire,
		 * but we convert it here so it is always manipulated
		 * as host byte order.
		 */
703
		pdu_length = be32_to_cpu(smb_buffer->smb_buf_length);
704

705
		cFYI(1, "rfc1002 length 0x%x", pdu_length+4);
706
		if (!check_rfc1002_header(server, buf))
Steve French's avatar
Steve French committed
707
			continue;
708
709

		/* else length ok */
Steve French's avatar
Steve French committed
710
		if (pdu_length > MAX_CIFS_SMALL_BUFFER_SIZE - 4) {
711
			isLargeBuf = true;
712
			memcpy(bigbuf, smallbuf, 4);
713
714
			smb_buffer = (struct smb_hdr *)bigbuf;
			buf = bigbuf;
715
		}
716

717
		iov.iov_base = 4 + buf;
718
		iov.iov_len = pdu_length;
719
720
721
		rc = read_from_socket(server, &smb_msg, &iov, pdu_length,
				      &total_read, false);
		if (rc == 2)
722
			break;
723
		else if (rc == 1)
724
			continue;
Linus Torvalds's avatar
Linus Torvalds committed
725

726
		total_read += 4; /* account for rfc1002 hdr */
727

728
		dump_smb(smb_buffer, total_read);
729
730
731
732
733
734
735
736
737
738
739
740

		/*
		 * We know that we received enough to get to the MID as we
		 * checked the pdu_length earlier. Now check to see
		 * if the rest of the header is OK. We borrow the length
		 * var for the rest of the loop to avoid a new stack var.
		 *
		 * 48 bytes is enough to display the header and a little bit
		 * into the payload for debugging purposes.
		 */
		length = checkSMB(smb_buffer, smb_buffer->Mid, total_read);
		if (length != 0)
741
742
			cifs_dump_mem("Bad SMB: ", buf,
				      min_t(unsigned int, total_read, 48));
Linus Torvalds's avatar
Linus Torvalds committed
743

744
745
		server->lstrp = jiffies;

746
747
		mid_entry = find_cifs_mid(server, smb_buffer, &length,
					  isLargeBuf, &isMultiRsp, &bigbuf);
748
		if (mid_entry != NULL) {
749
			mid_entry->callback(mid_entry);
750
			/* Was previous buf put in mpx struct for multi-rsp? */
Steve French's avatar
Steve French committed
751
			if (!isMultiRsp) {
752
				/* smb buffer will be freed by user thread */
753
				if (isLargeBuf)
754
					bigbuf = NULL;
755
				else
756
757
					smallbuf = NULL;
			}
758
759
760
		} else if (length != 0) {
			/* response sanity checks failed */
			continue;
761
762
		} else if (!is_valid_oplock_break(smb_buffer, server) &&
			   !isMultiRsp) {
763
			cERROR(1, "No task to wake, unknown frame received! "
764
				   "NumMids %d", atomic_read(&midCount));
765
			cifs_dump_mem("Received Data is: ", buf,
766
				      sizeof(struct smb_hdr));
767
768
769
770
#ifdef CONFIG_CIFS_DEBUG2
			cifs_dump_detail(smb_buffer);
			cifs_dump_mids(server);
#endif /* CIFS_DEBUG2 */
771

772
773
774
		}
	} /* end while !EXITING */

775
	/* buffer usually freed in free_mid - need to free it here on exit */
776
777
	cifs_buf_release(bigbuf);
	if (smallbuf) /* no sense logging a debug message if NULL */
778
		cifs_small_buf_release(smallbuf);
Linus Torvalds's avatar
Linus Torvalds committed
779

780
	task_to_wake = xchg(&server->tsk, NULL);
781
	clean_demultiplex_info(server);
782

783
784
785
786
787
788
789
790
791
792
	/* if server->tsk was NULL then wait for a signal before exiting */
	if (!task_to_wake) {
		set_current_state(TASK_INTERRUPTIBLE);
		while (!signal_pending(current)) {
			schedule();
			set_current_state(TASK_INTERRUPTIBLE);
		}
		set_current_state(TASK_RUNNING);
	}

793
	module_put_and_exit(0);
Linus Torvalds's avatar
Linus Torvalds committed
794
795
}

796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
/* extract the host portion of the UNC string */
static char *
extract_hostname(const char *unc)
{
	const char *src;
	char *dst, *delim;
	unsigned int len;

	/* skip double chars at beginning of string */
	/* BB: check validity of these bytes? */
	src = unc + 2;

	/* delimiter between hostname and sharename is always '\\' now */
	delim = strchr(src, '\\');
	if (!delim)
		return ERR_PTR(-EINVAL);

	len = delim - src;
	dst = kmalloc((len + 1), GFP_KERNEL);
	if (dst == NULL)
		return ERR_PTR(-ENOMEM);

	memcpy(dst, src, len);
	dst[len] = '\0';

	return dst;
}

Linus Torvalds's avatar
Linus Torvalds committed
824
static int
825
cifs_parse_mount_options(const char *mountdata, const char *devname,
826
			 struct smb_vol *vol)
Linus Torvalds's avatar
Linus Torvalds committed
827
{
828
	char *value, *data, *end;
829
	char *mountdata_copy = NULL, *options;
Linus Torvalds's avatar
Linus Torvalds committed
830
831
	unsigned int  temp_len, i, j;
	char separator[2];
832
833
834
835
	short int override_uid = -1;
	short int override_gid = -1;
	bool uid_specified = false;
	bool gid_specified = false;
Jeff Layton's avatar
Jeff Layton committed
836
	char *nodename = utsname()->nodename;
Linus Torvalds's avatar
Linus Torvalds committed
837
838

	separator[0] = ',';
839
	separator[1] = 0;
Linus Torvalds's avatar
Linus Torvalds committed
840

Jeff Layton's avatar
Jeff Layton committed
841
842
843
844
845
	/*
	 * does not have to be perfect mapping since field is
	 * informational, only used for servers that do not support
	 * port 445 and it can be overridden at mount time
	 */
846
847
	memset(vol->source_rfc1001_name, 0x20, RFC1001_NAME_LEN);
	for (i = 0; i < strnlen(nodename, RFC1001_NAME_LEN); i++)
Jeff Layton's avatar
Jeff Layton committed
848
849
		vol->source_rfc1001_name[i] = toupper(nodename[i]);

850
	vol->source_rfc1001_name[RFC1001_NAME_LEN] = 0;
851
852
853
	/* null target name indicates to use *SMBSERVR default called name
	   if we end up sending RFC1001 session initialize */
	vol->target_rfc1001_name[0] = 0;
854
855
	vol->cred_uid = current_uid();
	vol->linux_uid = current_uid();
856
	vol->linux_gid = current_gid();
857
858
859

	/* default to only allowing write access to owner of the mount */
	vol->dir_mode = vol->file_mode = S_IRUGO | S_IXUGO | S_IWUSR;
Linus Torvalds's avatar
Linus Torvalds committed
860
861

	/* vol->retry default is 0 (i.e. "soft" limited retry not hard retry) */
862
863
	/* default is always to request posix paths. */
	vol->posix_paths = 1;
864
865
	/* default to using server inode numbers where available */
	vol->server_ino = 1;
866

867
868
	vol->actimeo = CIFS_DEF_ACTIMEO;

869
870
871
872
873
874
	if (!mountdata)
		goto cifs_parse_mount_err;

	mountdata_copy = kstrndup(mountdata, PAGE_SIZE, GFP_KERNEL);
	if (!mountdata_copy)
		goto cifs_parse_mount_err;
Linus Torvalds's avatar
Linus Torvalds committed
875

876
	options = mountdata_copy;
877
	end = options + strlen(options);
878
	if (strncmp(options, "sep=", 4) == 0) {
Steve French's avatar
Steve French committed
879
		if (options[4] != 0) {
Linus Torvalds's avatar
Linus Torvalds committed
880
881
882
			separator[0] = options[4];
			options += 5;
		} else {
883
			cFYI(1, "Null separator not allowed");
Linus Torvalds's avatar
Linus Torvalds committed
884
885
		}
	}
886

Linus Torvalds's avatar
Linus Torvalds committed
887
888
889
890
891
892
	while ((data = strsep(&options, separator)) != NULL) {
		if (!*data)
			continue;
		if ((value = strchr(data, '=')) != NULL)
			*value++ = '\0';

893
894
		/* Have to parse this before we parse for "user" */
		if (strnicmp(data, "user_xattr", 10) == 0) {
Linus Torvalds's avatar
Linus Torvalds committed
895
			vol->no_xattr = 0;
896
		} else if (strnicmp(data, "nouser_xattr", 12) == 0) {
Linus Torvalds's avatar
Linus Torvalds committed
897
898
			vol->no_xattr = 1;
		} else if (strnicmp(data, "user", 4) == 0) {
899
			if (!value) {
Linus Torvalds's avatar
Linus Torvalds committed
900
901
				printk(KERN_WARNING
				       "CIFS: invalid or missing username\n");
902
				goto cifs_parse_mount_err;
Steve French's avatar
Steve French committed
903
			} else if (!*value) {
904
905
				/* null user, ie anonymous, authentication */
				vol->nullauth = 1;
Linus Torvalds's avatar
Linus Torvalds committed
906
			}
907
908
			if (strnlen(value, MAX_USERNAME_SIZE) <
						MAX_USERNAME_SIZE) {
909
910
911
912
913
914
				vol->username = kstrdup(value, GFP_KERNEL);
				if (!vol->username) {
					printk(KERN_WARNING "CIFS: no memory "
							    "for username\n");
					goto cifs_parse_mount_err;
				}
Linus Torvalds's avatar
Linus Torvalds committed
915
916
			} else {
				printk(KERN_WARNING "CIFS: username too long\n");
917
				goto cifs_parse_mount_err;
Linus Torvalds's avatar
Linus Torvalds committed
918
919
920
921
922
			}
		} else if (strnicmp(data, "pass", 4) == 0) {
			if (!value) {
				vol->password = NULL;
				continue;
Steve French's avatar
Steve French committed
923
			} else if (value[0] == 0) {
Linus Torvalds's avatar
Linus Torvalds committed
924
925
926
927
				/* check if string begins with double comma
				   since that would mean the password really
				   does start with a comma, and would not
				   indicate an empty string */
Steve French's avatar
Steve French committed
928
				if (value[1] != separator[0]) {
Linus Torvalds's avatar
Linus Torvalds committed
929
930
931
932
933
934
935
936
					vol->password = NULL;
					continue;
				}
			}
			temp_len = strlen(value);
			/* removed password length check, NTLM passwords
				can be arbitrarily long */

937
			/* if comma in password, the string will be
Linus Torvalds's avatar
Linus Torvalds committed
938
939
940
941
942
943
944
945
946
			prematurely null terminated.  Commas in password are
			specified across the cifs mount interface by a double
			comma ie ,, and a comma used as in other cases ie ','
			as a parameter delimiter/separator is single and due
			to the strsep above is temporarily zeroed. */

			/* NB: password legally can have multiple commas and
			the only illegal character in a password is null */

947
			if ((value[temp_len] == 0) &&
948
			    (value + temp_len < end) &&
949
			    (value[temp_len+1] == separator[0])) {
Linus Torvalds's avatar
Linus Torvalds committed
950
951
				/* reinsert comma */
				value[temp_len] = separator[0];
952
953
				temp_len += 2;  /* move after second comma */
				while (value[temp_len] != 0)  {
Linus Torvalds's avatar
Linus Torvalds committed
954
					if (value[temp_len] == separator[0]) {
955
						if (value[temp_len+1] ==
956
957
958
						     separator[0]) {
						/* skip second comma */
							temp_len++;
959
						} else {
Linus Torvalds's avatar
Linus Torvalds committed
960
961
962
963
964
965
966
						/* single comma indicating start
							 of next parm */
							break;
						}
					}
					temp_len++;
				}
Steve French's avatar
Steve French committed
967
				if (value[temp_len] == 0) {
Linus Torvalds's avatar
Linus Torvalds committed
968
969
970
971
972
973
					options = NULL;
				} else {
					value[temp_len] = 0;
					/* point option to start of next parm */
					options = value + temp_len + 1;
				}
974
				/* go from value to value + temp_len condensing
Linus Torvalds's avatar
Linus Torvalds committed
975
976
				double commas to singles. Note that this ends up
				allocating a few bytes too many, which is ok */
977
				vol->password = kzalloc(temp_len, GFP_KERNEL);
Steve French's avatar
Steve French committed
978
				if (vol->password == NULL) {
979
980
					printk(KERN_WARNING "CIFS: no memory "
							    "for password\n");
981
					goto cifs_parse_mount_err;
982
				}
983
				for (i = 0, j = 0; i < temp_len; i++, j++) {
Linus Torvalds's avatar
Linus Torvalds committed
984
					vol->password[j] = value[i];
Steve French's avatar
Steve French committed
985
					if (value[i] == separator[0]
986
						&& value[i+1] == separator[0]) {
Linus Torvalds's avatar
Linus Torvalds committed
987
988
989
990
991
992
						/* skip second comma */
						i++;
					}
				}
				vol->password[j] = 0;
			} else {
993
				vol->password = kzalloc(temp_len+1, GFP_KERNEL);
Steve French's avatar
Steve French committed
994
				if (vol->password == NULL) {
995
996
					printk(KERN_WARNING "CIFS: no memory "
							    "for password\n");
997
					goto cifs_parse_mount_err;
998
				}
Linus Torvalds's avatar
Linus Torvalds committed
999
1000
				strcpy(vol->password, value);
			}
1001
1002
		} else if (!strnicmp(data, "ip", 2) ||
			   !strnicmp(data, "addr", 4)) {
Linus Torvalds's avatar
Linus Torvalds committed
1003
1004
			if (!value || !*value) {
				vol->UNCip = NULL;
1005
1006
			} else if (strnlen(value, INET6_ADDRSTRLEN) <
							INET6_ADDRSTRLEN) {
1007
1008
1009
1010
1011
1012
				vol->UNCip = kstrdup(value, GFP_KERNEL);
				if (!vol->UNCip) {
					printk(KERN_WARNING "CIFS: no memory "
							    "for UNC IP\n");
					goto cifs_parse_mount_err;
				}
Linus Torvalds's avatar
Linus Torvalds committed
1013
			} else {
1014
1015
				printk(KERN_WARNING "CIFS: ip address "
						    "too long\n");
1016
				goto cifs_parse_mount_err;
Linus Torvalds's avatar
Linus Torvalds committed
1017
			}
1018
1019
		} else if (strnicmp(data, "sec", 3) == 0) {
			if (!value || !*value) {
1020
				cERROR(1, "no security value specified");
1021
1022
1023
				continue;
			} else if (strnicmp(value, "krb5i", 5) == 0) {
				vol->secFlg |= CIFSSEC_MAY_KRB5 |
1024
					CIFSSEC_MUST_SIGN;
1025
			} else if (strnicmp(value, "krb5p", 5) == 0) {
1026
1027
				/* vol->secFlg |= CIFSSEC_MUST_SEAL |
					CIFSSEC_MAY_KRB5; */
1028
				cERROR(1, "Krb5 cifs privacy not supported");
1029
				goto cifs_parse_mount_err;
1030
			} else if (strnicmp(value, "krb5", 4) == 0) {
1031
				vol->secFlg |= CIFSSEC_MAY_KRB5;
1032
1033
1034
1035
1036
			} else if (strnicmp(value, "ntlmsspi", 8) == 0) {
				vol->secFlg |= CIFSSEC_MAY_NTLMSSP |
					CIFSSEC_MUST_SIGN;
			} else if (strnicmp(value, "ntlmssp", 7) == 0) {
				vol->secFlg |= CIFSSEC_MAY_NTLMSSP;
1037
			} else if (strnicmp(value, "ntlmv2i", 7) == 0) {
1038
				vol->secFlg |= CIFSSEC_MAY_NTLMV2 |
1039
					CIFSSEC_MUST_SIGN;
1040
			} else if (strnicmp(value, "ntlmv2", 6) == 0) {
1041
				vol->secFlg |= CIFSSEC_MAY_NTLMV2;
1042
			} else if (strnicmp(value, "ntlmi", 5) == 0) {
1043
				vol->secFlg |= CIFSSEC_MAY_NTLM |
1044
					CIFSSEC_MUST_SIGN;
1045
1046
			} else if (strnicmp(value, "ntlm", 4) == 0) {
				/* ntlm is default so can be turned off too */
1047
				vol->secFlg |= CIFSSEC_MAY_NTLM;
1048
			} else if (strnicmp(value, "nontlm", 6) == 0) {
1049
				/* BB is there a better way to do this? */
1050
				vol->secFlg |= CIFSSEC_MAY_NTLMV2;
1051
1052
#ifdef CONFIG_CIFS_WEAK_PW_HASH
			} else if (strnicmp(value, "lanman", 6) == 0) {
1053
				vol->secFlg |= CIFSSEC_MAY_LANMAN;
1054
#endif
1055
			} else if (strnicmp(value, "none", 4) == 0) {
1056
				vol->nullauth = 1;
1057
			} else {
1058
				cERROR(1, "bad security option: %s", value);
1059
				goto cifs_parse_mount_err;
1060
			}
Steve French's avatar
Steve French committed
1061
1062
1063
1064
1065
1066
1067
1068
1069
		} else if (strnicmp(data, "vers", 3) == 0) {
			if (!value || !*value) {
				cERROR(1, "no protocol version specified"
					  " after vers= mount option");
			} else if ((strnicmp(value, "cifs", 4) == 0) ||
				   (strnicmp(value, "1", 1) == 0)) {
				/* this is the default */
				continue;
			}
Linus Torvalds's avatar
Linus Torvalds committed
1070
1071
1072
1073
		} else if ((strnicmp(data, "unc", 3) == 0)
			   || (strnicmp(data, "target", 6) == 0)
			   || (strnicmp(data, "path", 4) == 0)) {
			if (!value || !*value) {
1074
1075
				printk(KERN_WARNING "CIFS: invalid path to "
						    "network resource\n");
1076
				goto cifs_parse_mount_err;
Linus Torvalds's avatar
Linus Torvalds committed
1077
1078
			}
			if ((temp_len = strnlen(value, 300)) < 300) {
1079
				vol->UNC = kmalloc(temp_len+1, GFP_KERNEL);
1080
				if (vol->UNC == NULL)
1081
					goto cifs_parse_mount_err;
1082
				strcpy(vol->UNC, value);
Linus Torvalds's avatar
Linus Torvalds committed
1083
1084
1085
				if (strncmp(vol->UNC, "//", 2) == 0) {
					vol->UNC[0] = '\\';
					vol->UNC[1] = '\\';
1086
				} else if (strncmp(vol->UNC, "\\\\", 2) != 0) {
Linus Torvalds's avatar
Linus Torvalds committed
1087
					printk(KERN_WARNING
1088
1089
					       "CIFS: UNC Path does not begin "
					       "with // or \\\\ \n");
1090
					goto cifs_parse_mount_err;
Linus Torvalds's avatar
Linus Torvalds committed
1091
1092
1093
				}
			} else {
				printk(KERN_WARNING "CIFS: UNC name too long\n");
1094
				goto cifs_parse_mount_err;
Linus Torvalds's avatar
Linus Torvalds committed
1095
1096
1097
1098
1099
			}
		} else if ((strnicmp(data, "domain", 3) == 0)
			   || (strnicmp(data, "workgroup", 5) == 0)) {
			if (!value || !*value) {
				printk(KERN_WARNING "CIFS: invalid domain name\n");
1100
				goto cifs_parse_mount_err;
Linus Torvalds's avatar
Linus Torvalds committed
1101
1102
1103
			}
			/* BB are there cases in which a comma can be valid in
			a domain name and need special handling? */
1104
			if (strnlen(value, 256) < 256) {
1105
1106
1107
1108
1109
1110
				vol->domainname = kstrdup(value, GFP_KERNEL);
				if (!vol->domainname) {
					printk(KERN_WARNING "CIFS: no memory "
							    "for domainname\n");
					goto cifs_parse_mount_err;
				}
1111
				cFYI(1, "Domain name set");