hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/fs/cifs/cifssmb.c
....@@ -42,8 +42,12 @@
4242 #include "cifsproto.h"
4343 #include "cifs_unicode.h"
4444 #include "cifs_debug.h"
45
+#include "smb2proto.h"
4546 #include "fscache.h"
4647 #include "smbdirect.h"
48
+#ifdef CONFIG_CIFS_DFS_UPCALL
49
+#include "dfs_cache.h"
50
+#endif
4751
4852 #ifdef CONFIG_CIFS_POSIX
4953 static struct {
....@@ -109,6 +113,8 @@
109113
110114 mutex_lock(&tcon->crfid.fid_mutex);
111115 tcon->crfid.is_valid = false;
116
+ /* cached handle is not valid, so SMB2_CLOSE won't be sent below */
117
+ close_shroot_lease_locked(&tcon->crfid);
112118 memset(tcon->crfid.fid, 0, sizeof(struct cifs_fid));
113119 mutex_unlock(&tcon->crfid.fid_mutex);
114120
....@@ -126,6 +132,7 @@
126132 struct cifs_ses *ses;
127133 struct TCP_Server_Info *server;
128134 struct nls_table *nls_codepage;
135
+ int retries;
129136
130137 /*
131138 * SMBs NegProt, SessSetup, uLogoff do not have tcon yet so check for
....@@ -152,23 +159,29 @@
152159 }
153160 }
154161
162
+ retries = server->nr_targets;
163
+
155164 /*
156
- * Give demultiplex thread up to 10 seconds to reconnect, should be
157
- * greater than cifs socket timeout which is 7 seconds
165
+ * Give demultiplex thread up to 10 seconds to each target available for
166
+ * reconnect -- should be greater than cifs socket timeout which is 7
167
+ * seconds.
158168 */
159169 while (server->tcpStatus == CifsNeedReconnect) {
160170 rc = wait_event_interruptible_timeout(server->response_q,
161171 (server->tcpStatus != CifsNeedReconnect),
162172 10 * HZ);
163173 if (rc < 0) {
164
- cifs_dbg(FYI, "%s: aborting reconnect due to a received"
165
- " signal by the process\n", __func__);
174
+ cifs_dbg(FYI, "%s: aborting reconnect due to a received signal by the process\n",
175
+ __func__);
166176 return -ERESTARTSYS;
167177 }
168178
169179 /* are we still trying to reconnect? */
170180 if (server->tcpStatus != CifsNeedReconnect)
171181 break;
182
+
183
+ if (retries && --retries)
184
+ continue;
172185
173186 /*
174187 * on "soft" mounts we wait once. Hard mounts keep
....@@ -179,6 +192,7 @@
179192 cifs_dbg(FYI, "gave up waiting on reconnect in smb_init\n");
180193 return -EHOSTDOWN;
181194 }
195
+ retries = server->nr_targets;
182196 }
183197
184198 if (!ses->need_reconnect && !tcon->need_reconnect)
....@@ -214,19 +228,19 @@
214228 }
215229
216230 cifs_mark_open_files_invalid(tcon);
217
- rc = CIFSTCon(0, ses, tcon->treeName, tcon, nls_codepage);
231
+ rc = cifs_tree_connect(0, tcon, nls_codepage);
218232 mutex_unlock(&ses->session_mutex);
219233 cifs_dbg(FYI, "reconnect tcon rc = %d\n", rc);
220234
221235 if (rc) {
222
- printk_once(KERN_WARNING "reconnect tcon failed rc = %d\n", rc);
236
+ pr_warn_once("reconnect tcon failed rc = %d\n", rc);
223237 goto out;
224238 }
225239
226240 atomic_inc(&tconInfoReconnectCount);
227241
228242 /* tell server Unix caps we support */
229
- if (ses->capabilities & CAP_UNIX)
243
+ if (cap_unix(ses))
230244 reset_cifs_unix_caps(0, tcon, NULL, NULL);
231245
232246 /*
....@@ -452,7 +466,7 @@
452466 /* If server requires signing, does client allow it? */
453467 if (srv_sign_required) {
454468 if (!mnt_sign_enabled) {
455
- cifs_dbg(VFS, "Server requires signing, but it's disabled in SecurityFlags!");
469
+ cifs_dbg(VFS, "Server requires signing, but it's disabled in SecurityFlags!\n");
456470 return -ENOTSUPP;
457471 }
458472 server->sign = true;
....@@ -461,14 +475,14 @@
461475 /* If client requires signing, does server allow it? */
462476 if (mnt_sign_required) {
463477 if (!srv_sign_enabled) {
464
- cifs_dbg(VFS, "Server does not support signing!");
478
+ cifs_dbg(VFS, "Server does not support signing!\n");
465479 return -ENOTSUPP;
466480 }
467481 server->sign = true;
468482 }
469483
470484 if (cifs_rdma_enabled(server) && server->sign)
471
- cifs_dbg(VFS, "Signing is enabled, and RDMA read/write will be disabled");
485
+ cifs_dbg(VFS, "Signing is enabled, and RDMA read/write will be disabled\n");
472486
473487 return 0;
474488 }
....@@ -489,6 +503,8 @@
489503 cifs_max_pending);
490504 set_credits(server, server->maxReq);
491505 server->maxBuf = le16_to_cpu(rsp->MaxBufSize);
506
+ /* set up max_read for readpages check */
507
+ server->max_read = server->maxBuf;
492508 /* even though we do not use raw we might as well set this
493509 accurately, in case we ever find a need for it */
494510 if ((le16_to_cpu(rsp->RawMode) & RAW_ENABLE) == RAW_ENABLE) {
....@@ -565,7 +581,7 @@
565581 if (global_secflags &
566582 (CIFSSEC_MAY_KRB5 | CIFSSEC_MAY_NTLMSSP))
567583 return true;
568
- /* Fallthrough */
584
+ fallthrough;
569585 default:
570586 return false;
571587 }
....@@ -596,7 +612,7 @@
596612 pSMB->hdr.Flags2 |= (SMBFLG2_UNICODE | SMBFLG2_ERR_STATUS);
597613
598614 if (should_set_ext_sec_flag(ses->sectype)) {
599
- cifs_dbg(FYI, "Requesting extended security.");
615
+ cifs_dbg(FYI, "Requesting extended security\n");
600616 pSMB->hdr.Flags2 |= SMBFLG2_EXT_SEC;
601617 }
602618
....@@ -650,6 +666,8 @@
650666 set_credits(server, server->maxReq);
651667 /* probably no need to store and check maxvcs */
652668 server->maxBuf = le32_to_cpu(pSMBr->MaxBufferSize);
669
+ /* set up max_read for readpages check */
670
+ server->max_read = server->maxBuf;
653671 server->max_rw = le32_to_cpu(pSMBr->MaxRawSize);
654672 cifs_dbg(NOISY, "Max buf = %d\n", ses->server->maxBuf);
655673 server->capabilities = le32_to_cpu(pSMBr->Capabilities);
....@@ -731,9 +749,10 @@
731749 cifs_echo_callback(struct mid_q_entry *mid)
732750 {
733751 struct TCP_Server_Info *server = mid->callback_data;
752
+ struct cifs_credits credits = { .value = 1, .instance = 0 };
734753
735754 DeleteMidQEntry(mid);
736
- add_credits(server, 1, CIFS_ECHO_OP);
755
+ add_credits(server, &credits, CIFS_ECHO_OP);
737756 }
738757
739758 int
....@@ -768,7 +787,7 @@
768787 iov[1].iov_base = (char *)smb + 4;
769788
770789 rc = cifs_call_async(server, &rqst, NULL, cifs_echo_callback, NULL,
771
- server, CIFS_ASYNC_OP | CIFS_ECHO_OP);
790
+ server, CIFS_NON_BLOCKING | CIFS_ECHO_OP, NULL);
772791 if (rc)
773792 cifs_dbg(FYI, "Echo request failed: %d\n", rc);
774793
....@@ -850,10 +869,8 @@
850869 PATH_MAX, nls_codepage, remap);
851870 name_len++; /* trailing null */
852871 name_len *= 2;
853
- } else { /* BB add path length overrun check */
854
- name_len = strnlen(fileName, PATH_MAX);
855
- name_len++; /* trailing null */
856
- strncpy(pSMB->FileName, fileName, name_len);
872
+ } else {
873
+ name_len = copy_path_name(pSMB->FileName, fileName);
857874 }
858875
859876 params = 6 + name_len;
....@@ -923,10 +940,8 @@
923940 remap);
924941 name_len++; /* trailing null */
925942 name_len *= 2;
926
- } else { /* BB improve check for buffer overruns BB */
927
- name_len = strnlen(name, PATH_MAX);
928
- name_len++; /* trailing null */
929
- strncpy(pSMB->fileName, name, name_len);
943
+ } else {
944
+ name_len = copy_path_name(pSMB->fileName, name);
930945 }
931946 pSMB->SearchAttributes =
932947 cpu_to_le16(ATTR_READONLY | ATTR_HIDDEN | ATTR_SYSTEM);
....@@ -970,10 +985,8 @@
970985 remap);
971986 name_len++; /* trailing null */
972987 name_len *= 2;
973
- } else { /* BB improve check for buffer overruns BB */
974
- name_len = strnlen(name, PATH_MAX);
975
- name_len++; /* trailing null */
976
- strncpy(pSMB->DirName, name, name_len);
988
+ } else {
989
+ name_len = copy_path_name(pSMB->DirName, name);
977990 }
978991
979992 pSMB->BufferFormat = 0x04;
....@@ -992,7 +1005,8 @@
9921005 }
9931006
9941007 int
995
-CIFSSMBMkDir(const unsigned int xid, struct cifs_tcon *tcon, const char *name,
1008
+CIFSSMBMkDir(const unsigned int xid, struct inode *inode, umode_t mode,
1009
+ struct cifs_tcon *tcon, const char *name,
9961010 struct cifs_sb_info *cifs_sb)
9971011 {
9981012 int rc = 0;
....@@ -1015,10 +1029,8 @@
10151029 remap);
10161030 name_len++; /* trailing null */
10171031 name_len *= 2;
1018
- } else { /* BB improve check for buffer overruns BB */
1019
- name_len = strnlen(name, PATH_MAX);
1020
- name_len++; /* trailing null */
1021
- strncpy(pSMB->DirName, name, name_len);
1032
+ } else {
1033
+ name_len = copy_path_name(pSMB->DirName, name);
10221034 }
10231035
10241036 pSMB->BufferFormat = 0x04;
....@@ -1065,10 +1077,8 @@
10651077 PATH_MAX, nls_codepage, remap);
10661078 name_len++; /* trailing null */
10671079 name_len *= 2;
1068
- } else { /* BB improve the check for buffer overruns BB */
1069
- name_len = strnlen(name, PATH_MAX);
1070
- name_len++; /* trailing null */
1071
- strncpy(pSMB->FileName, name, name_len);
1080
+ } else {
1081
+ name_len = copy_path_name(pSMB->FileName, name);
10721082 }
10731083
10741084 params = 6 + name_len;
....@@ -1232,11 +1242,9 @@
12321242 fileName, PATH_MAX, nls_codepage, remap);
12331243 name_len++; /* trailing null */
12341244 name_len *= 2;
1235
- } else { /* BB improve check for buffer overruns BB */
1245
+ } else {
12361246 count = 0; /* no pad */
1237
- name_len = strnlen(fileName, PATH_MAX);
1238
- name_len++; /* trailing null */
1239
- strncpy(pSMB->fileName, fileName, name_len);
1247
+ name_len = copy_path_name(pSMB->fileName, fileName);
12401248 }
12411249 if (*pOplock & REQ_OPLOCK)
12421250 pSMB->OpenFlags = cpu_to_le16(REQ_OPLOCK);
....@@ -1313,7 +1321,7 @@
13131321 CIFS_open(const unsigned int xid, struct cifs_open_parms *oparms, int *oplock,
13141322 FILE_ALL_INFO *buf)
13151323 {
1316
- int rc = -EACCES;
1324
+ int rc;
13171325 OPEN_REQ *req = NULL;
13181326 OPEN_RSP *rsp = NULL;
13191327 int bytes_returned;
....@@ -1350,11 +1358,8 @@
13501358 /* BB improve check for buffer overruns BB */
13511359 /* no pad */
13521360 count = 0;
1353
- name_len = strnlen(path, PATH_MAX);
1354
- /* trailing null */
1355
- name_len++;
1361
+ name_len = copy_path_name(req->fileName, path);
13561362 req->NameLength = cpu_to_le16(name_len);
1357
- strncpy(req->fileName, path, name_len);
13581363 }
13591364
13601365 if (*oplock & REQ_OPLOCK)
....@@ -1411,6 +1416,7 @@
14111416 *oplock = rsp->OplockLevel;
14121417 /* cifs fid stays in le */
14131418 oparms->fid->netfid = rsp->Fid;
1419
+ oparms->fid->access = desired_access;
14141420
14151421 /* Let caller know file was created so we can set the mode. */
14161422 /* Do we care about the CreateAction in any other cases? */
....@@ -1445,9 +1451,9 @@
14451451 while (remaining > 0) {
14461452 int length;
14471453
1448
- length = cifs_read_from_socket(server, server->bigbuf,
1449
- min_t(unsigned int, remaining,
1450
- CIFSMaxBufSize + MAX_HEADER_SIZE(server)));
1454
+ length = cifs_discard_from_socket(server,
1455
+ min_t(size_t, remaining,
1456
+ CIFSMaxBufSize + MAX_HEADER_SIZE(server)));
14511457 if (length < 0)
14521458 return length;
14531459 server->total_read += length;
....@@ -1509,12 +1515,11 @@
15091515 if (server->ops->is_session_expired &&
15101516 server->ops->is_session_expired(buf)) {
15111517 cifs_reconnect(server);
1512
- wake_up(&server->response_q);
15131518 return -1;
15141519 }
15151520
15161521 if (server->ops->is_status_pending &&
1517
- server->ops->is_status_pending(buf, server, 0)) {
1522
+ server->ops->is_status_pending(buf, server)) {
15181523 cifs_discard_remaining_data(server);
15191524 return -1;
15201525 }
....@@ -1619,9 +1624,11 @@
16191624 struct smb_rqst rqst = { .rq_iov = rdata->iov,
16201625 .rq_nvec = 2,
16211626 .rq_pages = rdata->pages,
1627
+ .rq_offset = rdata->page_offset,
16221628 .rq_npages = rdata->nr_pages,
16231629 .rq_pagesz = rdata->pagesz,
16241630 .rq_tailsz = rdata->tailsz };
1631
+ struct cifs_credits credits = { .value = 1, .instance = 0 };
16251632
16261633 cifs_dbg(FYI, "%s: mid=%llu state=%d result=%d bytes=%u\n",
16271634 __func__, mid->mid, mid->mid_state, rdata->result,
....@@ -1659,7 +1666,7 @@
16591666
16601667 queue_work(cifsiod_wq, &rdata->work);
16611668 DeleteMidQEntry(mid);
1662
- add_credits(server, 1, 0);
1669
+ add_credits(server, &credits, 0);
16631670 }
16641671
16651672 /* cifs_async_readv - send an async write, and set up mid to handle result */
....@@ -1718,7 +1725,7 @@
17181725
17191726 kref_get(&rdata->refcount);
17201727 rc = cifs_call_async(tcon->ses->server, &rqst, cifs_readv_receive,
1721
- cifs_readv_callback, NULL, rdata, 0);
1728
+ cifs_readv_callback, NULL, rdata, 0, NULL);
17221729
17231730 if (rc == 0)
17241731 cifs_stats_inc(&tcon->stats.cifs_stats.num_reads);
....@@ -2032,10 +2039,13 @@
20322039 wdata2->tailsz = tailsz;
20332040 wdata2->bytes = cur_len;
20342041
2035
- wdata2->cfile = find_writable_file(CIFS_I(inode), false);
2042
+ rc = cifs_get_writable_file(CIFS_I(inode), FIND_WR_ANY,
2043
+ &wdata2->cfile);
20362044 if (!wdata2->cfile) {
2037
- cifs_dbg(VFS, "No writable handle to retry writepages\n");
2038
- rc = -EBADF;
2045
+ cifs_dbg(VFS, "No writable handle to retry writepages rc=%d\n",
2046
+ rc);
2047
+ if (!is_retryable_error(rc))
2048
+ rc = -EBADF;
20392049 } else {
20402050 wdata2->pid = wdata2->cfile->pid;
20412051 rc = server->ops->async_writev(wdata2,
....@@ -2144,6 +2154,7 @@
21442154 struct cifs_tcon *tcon = tlink_tcon(wdata->cfile->tlink);
21452155 unsigned int written;
21462156 WRITE_RSP *smb = (WRITE_RSP *)mid->resp_buf;
2157
+ struct cifs_credits credits = { .value = 1, .instance = 0 };
21472158
21482159 switch (mid->mid_state) {
21492160 case MID_RESPONSE_RECEIVED:
....@@ -2179,7 +2190,7 @@
21792190
21802191 queue_work(cifsiod_wq, &wdata->work);
21812192 DeleteMidQEntry(mid);
2182
- add_credits(tcon->ses->server, 1, 0);
2193
+ add_credits(tcon->ses->server, &credits, 0);
21832194 }
21842195
21852196 /* cifs_async_writev - send an async write, and set up mid to handle result */
....@@ -2232,6 +2243,7 @@
22322243 rqst.rq_iov = iov;
22332244 rqst.rq_nvec = 2;
22342245 rqst.rq_pages = wdata->pages;
2246
+ rqst.rq_offset = wdata->page_offset;
22352247 rqst.rq_npages = wdata->nr_pages;
22362248 rqst.rq_pagesz = wdata->pagesz;
22372249 rqst.rq_tailsz = wdata->tailsz;
....@@ -2256,7 +2268,7 @@
22562268
22572269 kref_get(&wdata->refcount);
22582270 rc = cifs_call_async(tcon->ses->server, &rqst, NULL,
2259
- cifs_writev_callback, NULL, wdata, 0);
2271
+ cifs_writev_callback, NULL, wdata, 0, NULL);
22602272
22612273 if (rc == 0)
22622274 cifs_stats_inc(&tcon->stats.cifs_stats.num_writes);
....@@ -2272,7 +2284,7 @@
22722284 CIFSSMBWrite2(const unsigned int xid, struct cifs_io_parms *io_parms,
22732285 unsigned int *nbytes, struct kvec *iov, int n_vec)
22742286 {
2275
- int rc = -EACCES;
2287
+ int rc;
22762288 WRITE_REQ *pSMB = NULL;
22772289 int wct;
22782290 int smb_hdr_len;
....@@ -2409,8 +2421,8 @@
24092421 iov[1].iov_len = (num_unlock + num_lock) * sizeof(LOCKING_ANDX_RANGE);
24102422
24112423 cifs_stats_inc(&tcon->stats.cifs_stats.num_locks);
2412
- rc = SendReceive2(xid, tcon->ses, iov, 2, &resp_buf_type, CIFS_NO_RESP,
2413
- &rsp_iov);
2424
+ rc = SendReceive2(xid, tcon->ses, iov, 2, &resp_buf_type,
2425
+ CIFS_NO_RSP_BUF, &rsp_iov);
24142426 cifs_small_buf_release(pSMB);
24152427 if (rc)
24162428 cifs_dbg(FYI, "Send error in cifs_lockv = %d\n", rc);
....@@ -2441,7 +2453,7 @@
24412453
24422454 if (lockType == LOCKING_ANDX_OPLOCK_RELEASE) {
24432455 /* no response expected */
2444
- flags = CIFS_ASYNC_OP | CIFS_OBREAK_OP;
2456
+ flags = CIFS_NO_SRV_RSP | CIFS_NON_BLOCKING | CIFS_OBREAK_OP;
24452457 pSMB->Timeout = 0;
24462458 } else if (waitFlag) {
24472459 flags = CIFS_BLOCKING_OP; /* blocking operation, no timeout */
....@@ -2713,15 +2725,10 @@
27132725 remap);
27142726 name_len2 += 1 /* trailing null */ + 1 /* Signature word */ ;
27152727 name_len2 *= 2; /* convert to bytes */
2716
- } else { /* BB improve the check for buffer overruns BB */
2717
- name_len = strnlen(from_name, PATH_MAX);
2718
- name_len++; /* trailing null */
2719
- strncpy(pSMB->OldFileName, from_name, name_len);
2720
- name_len2 = strnlen(to_name, PATH_MAX);
2721
- name_len2++; /* trailing null */
2728
+ } else {
2729
+ name_len = copy_path_name(pSMB->OldFileName, from_name);
2730
+ name_len2 = copy_path_name(pSMB->OldFileName+name_len+1, to_name);
27222731 pSMB->OldFileName[name_len] = 0x04; /* 2nd buffer format */
2723
- strncpy(&pSMB->OldFileName[name_len + 1], to_name, name_len2);
2724
- name_len2++; /* trailing null */
27252732 name_len2++; /* signature byte */
27262733 }
27272734
....@@ -2863,15 +2870,10 @@
28632870 toName, PATH_MAX, nls_codepage, remap);
28642871 name_len2 += 1 /* trailing null */ + 1 /* Signature word */ ;
28652872 name_len2 *= 2; /* convert to bytes */
2866
- } else { /* BB improve the check for buffer overruns BB */
2867
- name_len = strnlen(fromName, PATH_MAX);
2868
- name_len++; /* trailing null */
2869
- strncpy(pSMB->OldFileName, fromName, name_len);
2870
- name_len2 = strnlen(toName, PATH_MAX);
2871
- name_len2++; /* trailing null */
2873
+ } else {
2874
+ name_len = copy_path_name(pSMB->OldFileName, fromName);
28722875 pSMB->OldFileName[name_len] = 0x04; /* 2nd buffer format */
2873
- strncpy(&pSMB->OldFileName[name_len + 1], toName, name_len2);
2874
- name_len2++; /* trailing null */
2876
+ name_len2 = copy_path_name(pSMB->OldFileName+name_len+1, toName);
28752877 name_len2++; /* signature byte */
28762878 }
28772879
....@@ -2922,10 +2924,8 @@
29222924 name_len++; /* trailing null */
29232925 name_len *= 2;
29242926
2925
- } else { /* BB improve the check for buffer overruns BB */
2926
- name_len = strnlen(fromName, PATH_MAX);
2927
- name_len++; /* trailing null */
2928
- strncpy(pSMB->FileName, fromName, name_len);
2927
+ } else {
2928
+ name_len = copy_path_name(pSMB->FileName, fromName);
29292929 }
29302930 params = 6 + name_len;
29312931 pSMB->MaxSetupCount = 0;
....@@ -2945,10 +2945,8 @@
29452945 PATH_MAX, nls_codepage, remap);
29462946 name_len_target++; /* trailing null */
29472947 name_len_target *= 2;
2948
- } else { /* BB improve the check for buffer overruns BB */
2949
- name_len_target = strnlen(toName, PATH_MAX);
2950
- name_len_target++; /* trailing null */
2951
- strncpy(data_offset, toName, name_len_target);
2948
+ } else {
2949
+ name_len_target = copy_path_name(data_offset, toName);
29522950 }
29532951
29542952 pSMB->MaxParameterCount = cpu_to_le16(2);
....@@ -3010,10 +3008,8 @@
30103008 name_len++; /* trailing null */
30113009 name_len *= 2;
30123010
3013
- } else { /* BB improve the check for buffer overruns BB */
3014
- name_len = strnlen(toName, PATH_MAX);
3015
- name_len++; /* trailing null */
3016
- strncpy(pSMB->FileName, toName, name_len);
3011
+ } else {
3012
+ name_len = copy_path_name(pSMB->FileName, toName);
30173013 }
30183014 params = 6 + name_len;
30193015 pSMB->MaxSetupCount = 0;
....@@ -3032,10 +3028,8 @@
30323028 PATH_MAX, nls_codepage, remap);
30333029 name_len_target++; /* trailing null */
30343030 name_len_target *= 2;
3035
- } else { /* BB improve the check for buffer overruns BB */
3036
- name_len_target = strnlen(fromName, PATH_MAX);
3037
- name_len_target++; /* trailing null */
3038
- strncpy(data_offset, fromName, name_len_target);
3031
+ } else {
3032
+ name_len_target = copy_path_name(data_offset, fromName);
30393033 }
30403034
30413035 pSMB->MaxParameterCount = cpu_to_le16(2);
....@@ -3114,15 +3108,10 @@
31143108 remap);
31153109 name_len2 += 1 /* trailing null */ + 1 /* Signature word */ ;
31163110 name_len2 *= 2; /* convert to bytes */
3117
- } else { /* BB improve the check for buffer overruns BB */
3118
- name_len = strnlen(from_name, PATH_MAX);
3119
- name_len++; /* trailing null */
3120
- strncpy(pSMB->OldFileName, from_name, name_len);
3121
- name_len2 = strnlen(to_name, PATH_MAX);
3122
- name_len2++; /* trailing null */
3111
+ } else {
3112
+ name_len = copy_path_name(pSMB->OldFileName, from_name);
31233113 pSMB->OldFileName[name_len] = 0x04; /* 2nd buffer format */
3124
- strncpy(&pSMB->OldFileName[name_len + 1], to_name, name_len2);
3125
- name_len2++; /* trailing null */
3114
+ name_len2 = copy_path_name(pSMB->OldFileName+name_len+1, to_name);
31263115 name_len2++; /* signature byte */
31273116 }
31283117
....@@ -3172,10 +3161,8 @@
31723161 remap);
31733162 name_len++; /* trailing null */
31743163 name_len *= 2;
3175
- } else { /* BB improve the check for buffer overruns BB */
3176
- name_len = strnlen(searchName, PATH_MAX);
3177
- name_len++; /* trailing null */
3178
- strncpy(pSMB->FileName, searchName, name_len);
3164
+ } else {
3165
+ name_len = copy_path_name(pSMB->FileName, searchName);
31793166 }
31803167
31813168 params = 2 /* level */ + 4 /* rsrvd */ + name_len /* incl null */ ;
....@@ -3501,11 +3488,9 @@
35013488 return size;
35023489 }
35033490
3504
-static __u16 convert_ace_to_cifs_ace(struct cifs_posix_ace *cifs_ace,
3491
+static void convert_ace_to_cifs_ace(struct cifs_posix_ace *cifs_ace,
35053492 const struct posix_acl_xattr_entry *local_ace)
35063493 {
3507
- __u16 rc = 0; /* 0 = ACL converted ok */
3508
-
35093494 cifs_ace->cifs_e_perm = le16_to_cpu(local_ace->e_perm);
35103495 cifs_ace->cifs_e_tag = le16_to_cpu(local_ace->e_tag);
35113496 /* BB is there a better way to handle the large uid? */
....@@ -3518,7 +3503,6 @@
35183503 cifs_dbg(FYI, "perm %d tag %d id %d\n",
35193504 ace->e_perm, ace->e_tag, ace->e_id);
35203505 */
3521
- return rc;
35223506 }
35233507
35243508 /* Convert ACL from local Linux POSIX xattr to CIFS POSIX ACL wire format */
....@@ -3554,13 +3538,8 @@
35543538 cifs_dbg(FYI, "unknown ACL type %d\n", acl_type);
35553539 return 0;
35563540 }
3557
- for (i = 0; i < count; i++) {
3558
- rc = convert_ace_to_cifs_ace(&cifs_acl->ace_array[i], &ace[i]);
3559
- if (rc != 0) {
3560
- /* ACE not converted */
3561
- break;
3562
- }
3563
- }
3541
+ for (i = 0; i < count; i++)
3542
+ convert_ace_to_cifs_ace(&cifs_acl->ace_array[i], &ace[i]);
35643543 if (rc == 0) {
35653544 rc = (__u16)(count * sizeof(struct cifs_posix_ace));
35663545 rc += sizeof(struct cifs_posix_acl);
....@@ -3600,10 +3579,8 @@
36003579 name_len *= 2;
36013580 pSMB->FileName[name_len] = 0;
36023581 pSMB->FileName[name_len+1] = 0;
3603
- } else { /* BB improve the check for buffer overruns BB */
3604
- name_len = strnlen(searchName, PATH_MAX);
3605
- name_len++; /* trailing null */
3606
- strncpy(pSMB->FileName, searchName, name_len);
3582
+ } else {
3583
+ name_len = copy_path_name(pSMB->FileName, searchName);
36073584 }
36083585
36093586 params = 2 /* level */ + 4 /* rsrvd */ + name_len /* incl null */ ;
....@@ -3685,10 +3662,8 @@
36853662 PATH_MAX, nls_codepage, remap);
36863663 name_len++; /* trailing null */
36873664 name_len *= 2;
3688
- } else { /* BB improve the check for buffer overruns BB */
3689
- name_len = strnlen(fileName, PATH_MAX);
3690
- name_len++; /* trailing null */
3691
- strncpy(pSMB->FileName, fileName, name_len);
3665
+ } else {
3666
+ name_len = copy_path_name(pSMB->FileName, fileName);
36923667 }
36933668 params = 6 + name_len;
36943669 pSMB->MaxParameterCount = cpu_to_le16(2);
....@@ -3802,7 +3777,7 @@
38023777 struct file_chattr_info *pfinfo;
38033778 /* BB Do we need a cast or hash here ? */
38043779 if (count != 16) {
3805
- cifs_dbg(FYI, "Illegal size ret in GetExtAttr\n");
3780
+ cifs_dbg(FYI, "Invalid size ret in GetExtAttr\n");
38063781 rc = -EIO;
38073782 goto GetExtAttrOut;
38083783 }
....@@ -3821,7 +3796,6 @@
38213796
38223797 #endif /* CONFIG_POSIX */
38233798
3824
-#ifdef CONFIG_CIFS_ACL
38253799 /*
38263800 * Initialize NT TRANSACT SMB into small smb request buffer. This assumes that
38273801 * all NT TRANSACTS that we init here have total parm and data under about 400
....@@ -4065,7 +4039,6 @@
40654039 return (rc);
40664040 }
40674041
4068
-#endif /* CONFIG_CIFS_ACL */
40694042
40704043 /* Legacy Query Path Information call for lookup to old servers such
40714044 as Win9x/WinME */
....@@ -4095,9 +4068,7 @@
40954068 name_len++; /* trailing null */
40964069 name_len *= 2;
40974070 } else {
4098
- name_len = strnlen(search_name, PATH_MAX);
4099
- name_len++; /* trailing null */
4100
- strncpy(pSMB->FileName, search_name, name_len);
4071
+ name_len = copy_path_name(pSMB->FileName, search_name);
41014072 }
41024073 pSMB->BufferFormat = 0x04;
41034074 name_len++; /* account for buffer type byte */
....@@ -4182,7 +4153,7 @@
41824153 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
41834154 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
41844155 if (rc) {
4185
- cifs_dbg(FYI, "Send error in QFileInfo = %d", rc);
4156
+ cifs_dbg(FYI, "Send error in QFileInfo = %d\n", rc);
41864157 } else { /* decode response */
41874158 rc = validate_t2((struct smb_t2_rsp *)pSMBr);
41884159
....@@ -4232,10 +4203,8 @@
42324203 PATH_MAX, nls_codepage, remap);
42334204 name_len++; /* trailing null */
42344205 name_len *= 2;
4235
- } else { /* BB improve the check for buffer overruns BB */
4236
- name_len = strnlen(search_name, PATH_MAX);
4237
- name_len++; /* trailing null */
4238
- strncpy(pSMB->FileName, search_name, name_len);
4206
+ } else {
4207
+ name_len = copy_path_name(pSMB->FileName, search_name);
42394208 }
42404209
42414210 params = 2 /* level */ + 4 /* reserved */ + name_len /* includes NUL */;
....@@ -4351,7 +4320,7 @@
43514320 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
43524321 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
43534322 if (rc) {
4354
- cifs_dbg(FYI, "Send error in UnixQFileInfo = %d", rc);
4323
+ cifs_dbg(FYI, "Send error in UnixQFileInfo = %d\n", rc);
43554324 } else { /* decode response */
43564325 rc = validate_t2((struct smb_t2_rsp *)pSMBr);
43574326
....@@ -4401,10 +4370,8 @@
44014370 PATH_MAX, nls_codepage, remap);
44024371 name_len++; /* trailing null */
44034372 name_len *= 2;
4404
- } else { /* BB improve the check for buffer overruns BB */
4405
- name_len = strnlen(searchName, PATH_MAX);
4406
- name_len++; /* trailing null */
4407
- strncpy(pSMB->FileName, searchName, name_len);
4373
+ } else {
4374
+ name_len = copy_path_name(pSMB->FileName, searchName);
44084375 }
44094376
44104377 params = 2 /* level */ + 4 /* reserved */ + name_len /* includes NUL */;
....@@ -4435,7 +4402,7 @@
44354402 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
44364403 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
44374404 if (rc) {
4438
- cifs_dbg(FYI, "Send error in UnixQPathInfo = %d", rc);
4405
+ cifs_dbg(FYI, "Send error in UnixQPathInfo = %d\n", rc);
44394406 } else { /* decode response */
44404407 rc = validate_t2((struct smb_t2_rsp *)pSMBr);
44414408
....@@ -4504,17 +4471,16 @@
45044471 pSMB->FileName[name_len+1] = 0;
45054472 name_len += 2;
45064473 }
4507
- } else { /* BB add check for overrun of SMB buf BB */
4508
- name_len = strnlen(searchName, PATH_MAX);
4509
-/* BB fix here and in unicode clause above ie
4510
- if (name_len > buffersize-header)
4511
- free buffer exit; BB */
4512
- strncpy(pSMB->FileName, searchName, name_len);
4474
+ } else {
4475
+ name_len = copy_path_name(pSMB->FileName, searchName);
45134476 if (msearch) {
4514
- pSMB->FileName[name_len] = CIFS_DIR_SEP(cifs_sb);
4515
- pSMB->FileName[name_len+1] = '*';
4516
- pSMB->FileName[name_len+2] = 0;
4517
- name_len += 3;
4477
+ if (WARN_ON_ONCE(name_len > PATH_MAX-2))
4478
+ name_len = PATH_MAX-2;
4479
+ /* overwrite nul byte */
4480
+ pSMB->FileName[name_len-1] = CIFS_DIR_SEP(cifs_sb);
4481
+ pSMB->FileName[name_len] = '*';
4482
+ pSMB->FileName[name_len+1] = 0;
4483
+ name_len += 2;
45184484 }
45194485 }
45204486
....@@ -4577,7 +4543,7 @@
45774543 psrch_inf->unicode = false;
45784544
45794545 psrch_inf->ntwrk_buf_start = (char *)pSMBr;
4580
- psrch_inf->smallBuf = 0;
4546
+ psrch_inf->smallBuf = false;
45814547 psrch_inf->srch_entries_start =
45824548 (char *) &pSMBr->hdr.Protocol +
45834549 le16_to_cpu(pSMBr->t2.DataOffset);
....@@ -4711,7 +4677,7 @@
47114677 cifs_buf_release(psrch_inf->ntwrk_buf_start);
47124678 psrch_inf->srch_entries_start = response_data;
47134679 psrch_inf->ntwrk_buf_start = (char *)pSMB;
4714
- psrch_inf->smallBuf = 0;
4680
+ psrch_inf->smallBuf = false;
47154681 if (parms->EndofSearch)
47164682 psrch_inf->endOfSearch = true;
47174683 else
....@@ -4809,10 +4775,8 @@
48094775 remap);
48104776 name_len++; /* trailing null */
48114777 name_len *= 2;
4812
- } else { /* BB improve the check for buffer overruns BB */
4813
- name_len = strnlen(search_name, PATH_MAX);
4814
- name_len++; /* trailing null */
4815
- strncpy(pSMB->FileName, search_name, name_len);
4778
+ } else {
4779
+ name_len = copy_path_name(pSMB->FileName, search_name);
48164780 }
48174781
48184782 params = 2 /* level */ + 4 /* rsrvd */ + name_len /* incl null */ ;
....@@ -4858,7 +4822,7 @@
48584822 struct file_internal_info *pfinfo;
48594823 /* BB Do we need a cast or hash here ? */
48604824 if (count < 8) {
4861
- cifs_dbg(FYI, "Illegal size ret in QryIntrnlInf\n");
4825
+ cifs_dbg(FYI, "Invalid size ret in QryIntrnlInf\n");
48624826 rc = -EIO;
48634827 goto GetInodeNumOut;
48644828 }
....@@ -4895,8 +4859,13 @@
48954859 return -ENODEV;
48964860
48974861 getDFSRetry:
4898
- rc = smb_init(SMB_COM_TRANSACTION2, 15, ses->tcon_ipc, (void **) &pSMB,
4899
- (void **) &pSMBr);
4862
+ /*
4863
+ * Use smb_init_no_reconnect() instead of smb_init() as
4864
+ * CIFSGetDFSRefer() may be called from cifs_reconnect_tcon() and thus
4865
+ * causing an infinite recursion.
4866
+ */
4867
+ rc = smb_init_no_reconnect(SMB_COM_TRANSACTION2, 15, ses->tcon_ipc,
4868
+ (void **)&pSMB, (void **)&pSMBr);
49004869 if (rc)
49014870 return rc;
49024871
....@@ -4919,9 +4888,7 @@
49194888 name_len++; /* trailing null */
49204889 name_len *= 2;
49214890 } else { /* BB improve the check for buffer overruns BB */
4922
- name_len = strnlen(search_name, PATH_MAX);
4923
- name_len++; /* trailing null */
4924
- strncpy(pSMB->RequestFileName, search_name, name_len);
4891
+ name_len = copy_path_name(pSMB->RequestFileName, search_name);
49254892 }
49264893
49274894 if (ses->server->sign)
....@@ -5049,6 +5016,13 @@
50495016 le16_to_cpu(response_data->BytesPerSector) *
50505017 le32_to_cpu(response_data->
50515018 SectorsPerAllocationUnit);
5019
+ /*
5020
+ * much prefer larger but if server doesn't report
5021
+ * a valid size than 4K is a reasonable minimum
5022
+ */
5023
+ if (FSData->f_bsize < 512)
5024
+ FSData->f_bsize = 4096;
5025
+
50525026 FSData->f_blocks =
50535027 le32_to_cpu(response_data->TotalAllocationUnits);
50545028 FSData->f_bfree = FSData->f_bavail =
....@@ -5129,6 +5103,13 @@
51295103 le32_to_cpu(response_data->BytesPerSector) *
51305104 le32_to_cpu(response_data->
51315105 SectorsPerAllocationUnit);
5106
+ /*
5107
+ * much prefer larger but if server doesn't report
5108
+ * a valid size than 4K is a reasonable minimum
5109
+ */
5110
+ if (FSData->f_bsize < 512)
5111
+ FSData->f_bsize = 4096;
5112
+
51325113 FSData->f_blocks =
51335114 le64_to_cpu(response_data->TotalAllocationUnits);
51345115 FSData->f_bfree = FSData->f_bavail =
....@@ -5492,6 +5473,13 @@
54925473 data_offset);
54935474 FSData->f_bsize =
54945475 le32_to_cpu(response_data->BlockSize);
5476
+ /*
5477
+ * much prefer larger but if server doesn't report
5478
+ * a valid size than 4K is a reasonable minimum
5479
+ */
5480
+ if (FSData->f_bsize < 512)
5481
+ FSData->f_bsize = 4096;
5482
+
54955483 FSData->f_blocks =
54965484 le64_to_cpu(response_data->TotalBlocks);
54975485 FSData->f_bfree =
....@@ -5553,10 +5541,8 @@
55535541 PATH_MAX, cifs_sb->local_nls, remap);
55545542 name_len++; /* trailing null */
55555543 name_len *= 2;
5556
- } else { /* BB improve the check for buffer overruns BB */
5557
- name_len = strnlen(file_name, PATH_MAX);
5558
- name_len++; /* trailing null */
5559
- strncpy(pSMB->FileName, file_name, name_len);
5544
+ } else {
5545
+ name_len = copy_path_name(pSMB->FileName, file_name);
55605546 }
55615547 params = 6 + name_len;
55625548 data_count = sizeof(struct file_end_of_file_info);
....@@ -5822,10 +5808,42 @@
58225808 return rc;
58235809 }
58245810
5811
+static int
5812
+CIFSSMBSetPathInfoFB(const unsigned int xid, struct cifs_tcon *tcon,
5813
+ const char *fileName, const FILE_BASIC_INFO *data,
5814
+ const struct nls_table *nls_codepage,
5815
+ struct cifs_sb_info *cifs_sb)
5816
+{
5817
+ int oplock = 0;
5818
+ struct cifs_open_parms oparms;
5819
+ struct cifs_fid fid;
5820
+ int rc;
5821
+
5822
+ oparms.tcon = tcon;
5823
+ oparms.cifs_sb = cifs_sb;
5824
+ oparms.desired_access = GENERIC_WRITE;
5825
+ oparms.create_options = cifs_create_options(cifs_sb, 0);
5826
+ oparms.disposition = FILE_OPEN;
5827
+ oparms.path = fileName;
5828
+ oparms.fid = &fid;
5829
+ oparms.reconnect = false;
5830
+
5831
+ rc = CIFS_open(xid, &oparms, &oplock, NULL);
5832
+ if (rc)
5833
+ goto out;
5834
+
5835
+ rc = CIFSSMBSetFileInfo(xid, tcon, data, fid.netfid, current->tgid);
5836
+ CIFSSMBClose(xid, tcon, fid.netfid);
5837
+out:
5838
+
5839
+ return rc;
5840
+}
5841
+
58255842 int
58265843 CIFSSMBSetPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
58275844 const char *fileName, const FILE_BASIC_INFO *data,
5828
- const struct nls_table *nls_codepage, int remap)
5845
+ const struct nls_table *nls_codepage,
5846
+ struct cifs_sb_info *cifs_sb)
58295847 {
58305848 TRANSACTION2_SPI_REQ *pSMB = NULL;
58315849 TRANSACTION2_SPI_RSP *pSMBr = NULL;
....@@ -5834,6 +5852,7 @@
58345852 int bytes_returned = 0;
58355853 char *data_offset;
58365854 __u16 params, param_offset, offset, byte_count, count;
5855
+ int remap = cifs_remap(cifs_sb);
58375856
58385857 cifs_dbg(FYI, "In SetTimes\n");
58395858
....@@ -5849,10 +5868,8 @@
58495868 PATH_MAX, nls_codepage, remap);
58505869 name_len++; /* trailing null */
58515870 name_len *= 2;
5852
- } else { /* BB improve the check for buffer overruns BB */
5853
- name_len = strnlen(fileName, PATH_MAX);
5854
- name_len++; /* trailing null */
5855
- strncpy(pSMB->FileName, fileName, name_len);
5871
+ } else {
5872
+ name_len = copy_path_name(pSMB->FileName, fileName);
58565873 }
58575874
58585875 params = 6 + name_len;
....@@ -5898,6 +5915,10 @@
58985915 if (rc == -EAGAIN)
58995916 goto SetTimesRetry;
59005917
5918
+ if (rc == -EOPNOTSUPP)
5919
+ return CIFSSMBSetPathInfoFB(xid, tcon, fileName, data,
5920
+ nls_codepage, cifs_sb);
5921
+
59015922 return rc;
59025923 }
59035924
....@@ -5930,10 +5951,8 @@
59305951 PATH_MAX, nls_codepage);
59315952 name_len++; /* trailing null */
59325953 name_len *= 2;
5933
- } else { /* BB improve the check for buffer overruns BB */
5934
- name_len = strnlen(fileName, PATH_MAX);
5935
- name_len++; /* trailing null */
5936
- strncpy(pSMB->fileName, fileName, name_len);
5954
+ } else {
5955
+ name_len = copy_path_name(pSMB->fileName, fileName);
59375956 }
59385957 pSMB->attr = cpu_to_le16(dos_attrs);
59395958 pSMB->BufferFormat = 0x04;
....@@ -6093,10 +6112,8 @@
60936112 PATH_MAX, nls_codepage, remap);
60946113 name_len++; /* trailing null */
60956114 name_len *= 2;
6096
- } else { /* BB improve the check for buffer overruns BB */
6097
- name_len = strnlen(file_name, PATH_MAX);
6098
- name_len++; /* trailing null */
6099
- strncpy(pSMB->FileName, file_name, name_len);
6115
+ } else {
6116
+ name_len = copy_path_name(pSMB->FileName, file_name);
61006117 }
61016118
61026119 params = 6 + name_len;
....@@ -6188,10 +6205,8 @@
61886205 PATH_MAX, nls_codepage, remap);
61896206 list_len++; /* trailing null */
61906207 list_len *= 2;
6191
- } else { /* BB improve the check for buffer overruns BB */
6192
- list_len = strnlen(searchName, PATH_MAX);
6193
- list_len++; /* trailing null */
6194
- strncpy(pSMB->FileName, searchName, list_len);
6208
+ } else {
6209
+ list_len = copy_path_name(pSMB->FileName, searchName);
61956210 }
61966211
61976212 params = 2 /* level */ + 4 /* reserved */ + list_len /* includes NUL */;
....@@ -6370,10 +6385,8 @@
63706385 PATH_MAX, nls_codepage, remap);
63716386 name_len++; /* trailing null */
63726387 name_len *= 2;
6373
- } else { /* BB improve the check for buffer overruns BB */
6374
- name_len = strnlen(fileName, PATH_MAX);
6375
- name_len++; /* trailing null */
6376
- strncpy(pSMB->FileName, fileName, name_len);
6388
+ } else {
6389
+ name_len = copy_path_name(pSMB->FileName, fileName);
63776390 }
63786391
63796392 params = 6 + name_len;
....@@ -6447,93 +6460,3 @@
64476460 return rc;
64486461 }
64496462 #endif
6450
-
6451
-#ifdef CONFIG_CIFS_DNOTIFY_EXPERIMENTAL /* BB unused temporarily */
6452
-/*
6453
- * Years ago the kernel added a "dnotify" function for Samba server,
6454
- * to allow network clients (such as Windows) to display updated
6455
- * lists of files in directory listings automatically when
6456
- * files are added by one user when another user has the
6457
- * same directory open on their desktop. The Linux cifs kernel
6458
- * client hooked into the kernel side of this interface for
6459
- * the same reason, but ironically when the VFS moved from
6460
- * "dnotify" to "inotify" it became harder to plug in Linux
6461
- * network file system clients (the most obvious use case
6462
- * for notify interfaces is when multiple users can update
6463
- * the contents of the same directory - exactly what network
6464
- * file systems can do) although the server (Samba) could
6465
- * still use it. For the short term we leave the worker
6466
- * function ifdeffed out (below) until inotify is fixed
6467
- * in the VFS to make it easier to plug in network file
6468
- * system clients. If inotify turns out to be permanently
6469
- * incompatible for network fs clients, we could instead simply
6470
- * expose this config flag by adding a future cifs (and smb2) notify ioctl.
6471
- */
6472
-int CIFSSMBNotify(const unsigned int xid, struct cifs_tcon *tcon,
6473
- const int notify_subdirs, const __u16 netfid,
6474
- __u32 filter, struct file *pfile, int multishot,
6475
- const struct nls_table *nls_codepage)
6476
-{
6477
- int rc = 0;
6478
- struct smb_com_transaction_change_notify_req *pSMB = NULL;
6479
- struct smb_com_ntransaction_change_notify_rsp *pSMBr = NULL;
6480
- struct dir_notify_req *dnotify_req;
6481
- int bytes_returned;
6482
-
6483
- cifs_dbg(FYI, "In CIFSSMBNotify for file handle %d\n", (int)netfid);
6484
- rc = smb_init(SMB_COM_NT_TRANSACT, 23, tcon, (void **) &pSMB,
6485
- (void **) &pSMBr);
6486
- if (rc)
6487
- return rc;
6488
-
6489
- pSMB->TotalParameterCount = 0 ;
6490
- pSMB->TotalDataCount = 0;
6491
- pSMB->MaxParameterCount = cpu_to_le32(2);
6492
- pSMB->MaxDataCount = cpu_to_le32(CIFSMaxBufSize & 0xFFFFFF00);
6493
- pSMB->MaxSetupCount = 4;
6494
- pSMB->Reserved = 0;
6495
- pSMB->ParameterOffset = 0;
6496
- pSMB->DataCount = 0;
6497
- pSMB->DataOffset = 0;
6498
- pSMB->SetupCount = 4; /* single byte does not need le conversion */
6499
- pSMB->SubCommand = cpu_to_le16(NT_TRANSACT_NOTIFY_CHANGE);
6500
- pSMB->ParameterCount = pSMB->TotalParameterCount;
6501
- if (notify_subdirs)
6502
- pSMB->WatchTree = 1; /* one byte - no le conversion needed */
6503
- pSMB->Reserved2 = 0;
6504
- pSMB->CompletionFilter = cpu_to_le32(filter);
6505
- pSMB->Fid = netfid; /* file handle always le */
6506
- pSMB->ByteCount = 0;
6507
-
6508
- rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
6509
- (struct smb_hdr *)pSMBr, &bytes_returned,
6510
- CIFS_ASYNC_OP);
6511
- if (rc) {
6512
- cifs_dbg(FYI, "Error in Notify = %d\n", rc);
6513
- } else {
6514
- /* Add file to outstanding requests */
6515
- /* BB change to kmem cache alloc */
6516
- dnotify_req = kmalloc(
6517
- sizeof(struct dir_notify_req),
6518
- GFP_KERNEL);
6519
- if (dnotify_req) {
6520
- dnotify_req->Pid = pSMB->hdr.Pid;
6521
- dnotify_req->PidHigh = pSMB->hdr.PidHigh;
6522
- dnotify_req->Mid = pSMB->hdr.Mid;
6523
- dnotify_req->Tid = pSMB->hdr.Tid;
6524
- dnotify_req->Uid = pSMB->hdr.Uid;
6525
- dnotify_req->netfid = netfid;
6526
- dnotify_req->pfile = pfile;
6527
- dnotify_req->filter = filter;
6528
- dnotify_req->multishot = multishot;
6529
- spin_lock(&GlobalMid_Lock);
6530
- list_add_tail(&dnotify_req->lhead,
6531
- &GlobalDnotifyReqList);
6532
- spin_unlock(&GlobalMid_Lock);
6533
- } else
6534
- rc = -ENOMEM;
6535
- }
6536
- cifs_buf_release(pSMB);
6537
- return rc;
6538
-}
6539
-#endif /* was needed for dnotify, and will be needed for inotify when VFS fix */