aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/cifssmb.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/cifs/cifssmb.c')
-rw-r--r--fs/cifs/cifssmb.c540
1 files changed, 270 insertions, 270 deletions
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index b4916eb6fd43..5b19ce2e4351 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -61,7 +61,7 @@ static struct {
61 {LANMAN_PROT, "\2LM1.2X002"}, 61 {LANMAN_PROT, "\2LM1.2X002"},
62 {LANMAN2_PROT, "\2LANMAN2.1"}, 62 {LANMAN2_PROT, "\2LANMAN2.1"},
63#endif /* weak password hashing for legacy clients */ 63#endif /* weak password hashing for legacy clients */
64 {CIFS_PROT, "\2NT LM 0.12"}, 64 {CIFS_PROT, "\2NT LM 0.12"},
65 {BAD_PROT, "\2"} 65 {BAD_PROT, "\2"}
66}; 66};
67#endif 67#endif
@@ -84,17 +84,17 @@ static struct {
84 84
85/* Mark as invalid, all open files on tree connections since they 85/* Mark as invalid, all open files on tree connections since they
86 were closed when session to server was lost */ 86 were closed when session to server was lost */
87static void mark_open_files_invalid(struct cifsTconInfo * pTcon) 87static void mark_open_files_invalid(struct cifsTconInfo *pTcon)
88{ 88{
89 struct cifsFileInfo *open_file = NULL; 89 struct cifsFileInfo *open_file = NULL;
90 struct list_head * tmp; 90 struct list_head *tmp;
91 struct list_head * tmp1; 91 struct list_head *tmp1;
92 92
93/* list all files open on tree connection and mark them invalid */ 93/* list all files open on tree connection and mark them invalid */
94 write_lock(&GlobalSMBSeslock); 94 write_lock(&GlobalSMBSeslock);
95 list_for_each_safe(tmp, tmp1, &pTcon->openFileList) { 95 list_for_each_safe(tmp, tmp1, &pTcon->openFileList) {
96 open_file = list_entry(tmp,struct cifsFileInfo, tlist); 96 open_file = list_entry(tmp, struct cifsFileInfo, tlist);
97 if(open_file) { 97 if (open_file) {
98 open_file->invalidHandle = TRUE; 98 open_file->invalidHandle = TRUE;
99 } 99 }
100 } 100 }
@@ -113,20 +113,20 @@ small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
113 /* SMBs NegProt, SessSetup, uLogoff do not have tcon yet so 113 /* SMBs NegProt, SessSetup, uLogoff do not have tcon yet so
114 check for tcp and smb session status done differently 114 check for tcp and smb session status done differently
115 for those three - in the calling routine */ 115 for those three - in the calling routine */
116 if(tcon) { 116 if (tcon) {
117 if(tcon->tidStatus == CifsExiting) { 117 if (tcon->tidStatus == CifsExiting) {
118 /* only tree disconnect, open, and write, 118 /* only tree disconnect, open, and write,
119 (and ulogoff which does not have tcon) 119 (and ulogoff which does not have tcon)
120 are allowed as we start force umount */ 120 are allowed as we start force umount */
121 if((smb_command != SMB_COM_WRITE_ANDX) && 121 if ((smb_command != SMB_COM_WRITE_ANDX) &&
122 (smb_command != SMB_COM_OPEN_ANDX) && 122 (smb_command != SMB_COM_OPEN_ANDX) &&
123 (smb_command != SMB_COM_TREE_DISCONNECT)) { 123 (smb_command != SMB_COM_TREE_DISCONNECT)) {
124 cFYI(1,("can not send cmd %d while umounting", 124 cFYI(1, ("can not send cmd %d while umounting",
125 smb_command)); 125 smb_command));
126 return -ENODEV; 126 return -ENODEV;
127 } 127 }
128 } 128 }
129 if((tcon->ses) && (tcon->ses->status != CifsExiting) && 129 if ((tcon->ses) && (tcon->ses->status != CifsExiting) &&
130 (tcon->ses->server)){ 130 (tcon->ses->server)){
131 struct nls_table *nls_codepage; 131 struct nls_table *nls_codepage;
132 /* Give Demultiplex thread up to 10 seconds to 132 /* Give Demultiplex thread up to 10 seconds to
@@ -135,9 +135,9 @@ small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
135 while(tcon->ses->server->tcpStatus == CifsNeedReconnect) { 135 while(tcon->ses->server->tcpStatus == CifsNeedReconnect) {
136 wait_event_interruptible_timeout(tcon->ses->server->response_q, 136 wait_event_interruptible_timeout(tcon->ses->server->response_q,
137 (tcon->ses->server->tcpStatus == CifsGood), 10 * HZ); 137 (tcon->ses->server->tcpStatus == CifsGood), 10 * HZ);
138 if(tcon->ses->server->tcpStatus == CifsNeedReconnect) { 138 if (tcon->ses->server->tcpStatus == CifsNeedReconnect) {
139 /* on "soft" mounts we wait once */ 139 /* on "soft" mounts we wait once */
140 if((tcon->retry == FALSE) || 140 if ((tcon->retry == FALSE) ||
141 (tcon->ses->status == CifsExiting)) { 141 (tcon->ses->status == CifsExiting)) {
142 cFYI(1,("gave up waiting on reconnect in smb_init")); 142 cFYI(1,("gave up waiting on reconnect in smb_init"));
143 return -EHOSTDOWN; 143 return -EHOSTDOWN;
@@ -153,10 +153,10 @@ small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
153 /* need to prevent multiple threads trying to 153 /* need to prevent multiple threads trying to
154 simultaneously reconnect the same SMB session */ 154 simultaneously reconnect the same SMB session */
155 down(&tcon->ses->sesSem); 155 down(&tcon->ses->sesSem);
156 if(tcon->ses->status == CifsNeedReconnect) 156 if (tcon->ses->status == CifsNeedReconnect)
157 rc = cifs_setup_session(0, tcon->ses, 157 rc = cifs_setup_session(0, tcon->ses,
158 nls_codepage); 158 nls_codepage);
159 if(!rc && (tcon->tidStatus == CifsNeedReconnect)) { 159 if (!rc && (tcon->tidStatus == CifsNeedReconnect)) {
160 mark_open_files_invalid(tcon); 160 mark_open_files_invalid(tcon);
161 rc = CIFSTCon(0, tcon->ses, tcon->treeName, 161 rc = CIFSTCon(0, tcon->ses, tcon->treeName,
162 tcon, nls_codepage); 162 tcon, nls_codepage);
@@ -170,7 +170,7 @@ small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
170 /* BB FIXME add code to check if wsize needs 170 /* BB FIXME add code to check if wsize needs
171 update due to negotiated smb buffer size 171 update due to negotiated smb buffer size
172 shrinking */ 172 shrinking */
173 if(rc == 0) 173 if (rc == 0)
174 atomic_inc(&tconInfoReconnectCount); 174 atomic_inc(&tconInfoReconnectCount);
175 175
176 cFYI(1, ("reconnect tcon rc = %d", rc)); 176 cFYI(1, ("reconnect tcon rc = %d", rc));
@@ -200,7 +200,7 @@ small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
200 return -EIO; 200 return -EIO;
201 } 201 }
202 } 202 }
203 if(rc) 203 if (rc)
204 return rc; 204 return rc;
205 205
206 *request_buf = cifs_small_buf_get(); 206 *request_buf = cifs_small_buf_get();
@@ -211,8 +211,8 @@ small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
211 211
212 header_assemble((struct smb_hdr *) *request_buf, smb_command, tcon,wct); 212 header_assemble((struct smb_hdr *) *request_buf, smb_command, tcon,wct);
213 213
214 if(tcon != NULL) 214 if (tcon != NULL)
215 cifs_stats_inc(&tcon->num_smbs_sent); 215 cifs_stats_inc(&tcon->num_smbs_sent);
216 216
217 return rc; 217 return rc;
218} 218}
@@ -225,7 +225,7 @@ small_smb_init_no_tc(const int smb_command, const int wct,
225 struct smb_hdr * buffer; 225 struct smb_hdr * buffer;
226 226
227 rc = small_smb_init(smb_command, wct, NULL, request_buf); 227 rc = small_smb_init(smb_command, wct, NULL, request_buf);
228 if(rc) 228 if (rc)
229 return rc; 229 return rc;
230 230
231 buffer = (struct smb_hdr *)*request_buf; 231 buffer = (struct smb_hdr *)*request_buf;
@@ -254,21 +254,21 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
254 /* SMBs NegProt, SessSetup, uLogoff do not have tcon yet so 254 /* SMBs NegProt, SessSetup, uLogoff do not have tcon yet so
255 check for tcp and smb session status done differently 255 check for tcp and smb session status done differently
256 for those three - in the calling routine */ 256 for those three - in the calling routine */
257 if(tcon) { 257 if (tcon) {
258 if(tcon->tidStatus == CifsExiting) { 258 if (tcon->tidStatus == CifsExiting) {
259 /* only tree disconnect, open, and write, 259 /* only tree disconnect, open, and write,
260 (and ulogoff which does not have tcon) 260 (and ulogoff which does not have tcon)
261 are allowed as we start force umount */ 261 are allowed as we start force umount */
262 if((smb_command != SMB_COM_WRITE_ANDX) && 262 if ((smb_command != SMB_COM_WRITE_ANDX) &&
263 (smb_command != SMB_COM_OPEN_ANDX) && 263 (smb_command != SMB_COM_OPEN_ANDX) &&
264 (smb_command != SMB_COM_TREE_DISCONNECT)) { 264 (smb_command != SMB_COM_TREE_DISCONNECT)) {
265 cFYI(1,("can not send cmd %d while umounting", 265 cFYI(1, ("can not send cmd %d while umounting",
266 smb_command)); 266 smb_command));
267 return -ENODEV; 267 return -ENODEV;
268 } 268 }
269 } 269 }
270 270
271 if((tcon->ses) && (tcon->ses->status != CifsExiting) && 271 if ((tcon->ses) && (tcon->ses->status != CifsExiting) &&
272 (tcon->ses->server)){ 272 (tcon->ses->server)){
273 struct nls_table *nls_codepage; 273 struct nls_table *nls_codepage;
274 /* Give Demultiplex thread up to 10 seconds to 274 /* Give Demultiplex thread up to 10 seconds to
@@ -277,10 +277,10 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
277 while(tcon->ses->server->tcpStatus == CifsNeedReconnect) { 277 while(tcon->ses->server->tcpStatus == CifsNeedReconnect) {
278 wait_event_interruptible_timeout(tcon->ses->server->response_q, 278 wait_event_interruptible_timeout(tcon->ses->server->response_q,
279 (tcon->ses->server->tcpStatus == CifsGood), 10 * HZ); 279 (tcon->ses->server->tcpStatus == CifsGood), 10 * HZ);
280 if(tcon->ses->server->tcpStatus == 280 if (tcon->ses->server->tcpStatus ==
281 CifsNeedReconnect) { 281 CifsNeedReconnect) {
282 /* on "soft" mounts we wait once */ 282 /* on "soft" mounts we wait once */
283 if((tcon->retry == FALSE) || 283 if ((tcon->retry == FALSE) ||
284 (tcon->ses->status == CifsExiting)) { 284 (tcon->ses->status == CifsExiting)) {
285 cFYI(1,("gave up waiting on reconnect in smb_init")); 285 cFYI(1,("gave up waiting on reconnect in smb_init"));
286 return -EHOSTDOWN; 286 return -EHOSTDOWN;
@@ -296,10 +296,10 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
296 /* need to prevent multiple threads trying to 296 /* need to prevent multiple threads trying to
297 simultaneously reconnect the same SMB session */ 297 simultaneously reconnect the same SMB session */
298 down(&tcon->ses->sesSem); 298 down(&tcon->ses->sesSem);
299 if(tcon->ses->status == CifsNeedReconnect) 299 if (tcon->ses->status == CifsNeedReconnect)
300 rc = cifs_setup_session(0, tcon->ses, 300 rc = cifs_setup_session(0, tcon->ses,
301 nls_codepage); 301 nls_codepage);
302 if(!rc && (tcon->tidStatus == CifsNeedReconnect)) { 302 if (!rc && (tcon->tidStatus == CifsNeedReconnect)) {
303 mark_open_files_invalid(tcon); 303 mark_open_files_invalid(tcon);
304 rc = CIFSTCon(0, tcon->ses, tcon->treeName, 304 rc = CIFSTCon(0, tcon->ses, tcon->treeName,
305 tcon, nls_codepage); 305 tcon, nls_codepage);
@@ -313,7 +313,7 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
313 /* BB FIXME add code to check if wsize needs 313 /* BB FIXME add code to check if wsize needs
314 update due to negotiated smb buffer size 314 update due to negotiated smb buffer size
315 shrinking */ 315 shrinking */
316 if(rc == 0) 316 if (rc == 0)
317 atomic_inc(&tconInfoReconnectCount); 317 atomic_inc(&tconInfoReconnectCount);
318 318
319 cFYI(1, ("reconnect tcon rc = %d", rc)); 319 cFYI(1, ("reconnect tcon rc = %d", rc));
@@ -343,7 +343,7 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
343 return -EIO; 343 return -EIO;
344 } 344 }
345 } 345 }
346 if(rc) 346 if (rc)
347 return rc; 347 return rc;
348 348
349 *request_buf = cifs_buf_get(); 349 *request_buf = cifs_buf_get();
@@ -355,14 +355,14 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
355 /* potential retries of smb operations it turns out we can determine */ 355 /* potential retries of smb operations it turns out we can determine */
356 /* from the mid flags when the request buffer can be resent without */ 356 /* from the mid flags when the request buffer can be resent without */
357 /* having to use a second distinct buffer for the response */ 357 /* having to use a second distinct buffer for the response */
358 if(response_buf) 358 if (response_buf)
359 *response_buf = *request_buf; 359 *response_buf = *request_buf;
360 360
361 header_assemble((struct smb_hdr *) *request_buf, smb_command, tcon, 361 header_assemble((struct smb_hdr *) *request_buf, smb_command, tcon,
362 wct /*wct */ ); 362 wct /*wct */ );
363 363
364 if(tcon != NULL) 364 if (tcon != NULL)
365 cifs_stats_inc(&tcon->num_smbs_sent); 365 cifs_stats_inc(&tcon->num_smbs_sent);
366 366
367 return rc; 367 return rc;
368} 368}
@@ -375,19 +375,19 @@ static int validate_t2(struct smb_t2_rsp * pSMB)
375 375
376 /* check for plausible wct, bcc and t2 data and parm sizes */ 376 /* check for plausible wct, bcc and t2 data and parm sizes */
377 /* check for parm and data offset going beyond end of smb */ 377 /* check for parm and data offset going beyond end of smb */
378 if(pSMB->hdr.WordCount >= 10) { 378 if (pSMB->hdr.WordCount >= 10) {
379 if((le16_to_cpu(pSMB->t2_rsp.ParameterOffset) <= 1024) && 379 if ((le16_to_cpu(pSMB->t2_rsp.ParameterOffset) <= 1024) &&
380 (le16_to_cpu(pSMB->t2_rsp.DataOffset) <= 1024)) { 380 (le16_to_cpu(pSMB->t2_rsp.DataOffset) <= 1024)) {
381 /* check that bcc is at least as big as parms + data */ 381 /* check that bcc is at least as big as parms + data */
382 /* check that bcc is less than negotiated smb buffer */ 382 /* check that bcc is less than negotiated smb buffer */
383 total_size = le16_to_cpu(pSMB->t2_rsp.ParameterCount); 383 total_size = le16_to_cpu(pSMB->t2_rsp.ParameterCount);
384 if(total_size < 512) { 384 if (total_size < 512) {
385 total_size+=le16_to_cpu(pSMB->t2_rsp.DataCount); 385 total_size+=le16_to_cpu(pSMB->t2_rsp.DataCount);
386 /* BCC le converted in SendReceive */ 386 /* BCC le converted in SendReceive */
387 pBCC = (pSMB->hdr.WordCount * 2) + 387 pBCC = (pSMB->hdr.WordCount * 2) +
388 sizeof(struct smb_hdr) + 388 sizeof(struct smb_hdr) +
389 (char *)pSMB; 389 (char *)pSMB;
390 if((total_size <= (*(u16 *)pBCC)) && 390 if ((total_size <= (*(u16 *)pBCC)) &&
391 (total_size < 391 (total_size <
392 CIFSMaxBufSize+MAX_CIFS_HDR_SIZE)) { 392 CIFSMaxBufSize+MAX_CIFS_HDR_SIZE)) {
393 return 0; 393 return 0;
@@ -413,7 +413,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
413 unsigned int secFlags; 413 unsigned int secFlags;
414 u16 dialect; 414 u16 dialect;
415 415
416 if(ses->server) 416 if (ses->server)
417 server = ses->server; 417 server = ses->server;
418 else { 418 else {
419 rc = -EIO; 419 rc = -EIO;
@@ -425,7 +425,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
425 return rc; 425 return rc;
426 426
427 /* if any of auth flags (ie not sign or seal) are overriden use them */ 427 /* if any of auth flags (ie not sign or seal) are overriden use them */
428 if(ses->overrideSecFlg & (~(CIFSSEC_MUST_SIGN | CIFSSEC_MUST_SEAL))) 428 if (ses->overrideSecFlg & (~(CIFSSEC_MUST_SIGN | CIFSSEC_MUST_SEAL)))
429 secFlags = ses->overrideSecFlg; /* BB FIXME fix sign flags? */ 429 secFlags = ses->overrideSecFlg; /* BB FIXME fix sign flags? */
430 else /* if override flags set only sign/seal OR them with global auth */ 430 else /* if override flags set only sign/seal OR them with global auth */
431 secFlags = extended_security | ses->overrideSecFlg; 431 secFlags = extended_security | ses->overrideSecFlg;
@@ -452,22 +452,22 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
452 goto neg_err_exit; 452 goto neg_err_exit;
453 453
454 dialect = le16_to_cpu(pSMBr->DialectIndex); 454 dialect = le16_to_cpu(pSMBr->DialectIndex);
455 cFYI(1,("Dialect: %d", dialect)); 455 cFYI(1, ("Dialect: %d", dialect));
456 /* Check wct = 1 error case */ 456 /* Check wct = 1 error case */
457 if((pSMBr->hdr.WordCount < 13) || (dialect == BAD_PROT)) { 457 if ((pSMBr->hdr.WordCount < 13) || (dialect == BAD_PROT)) {
458 /* core returns wct = 1, but we do not ask for core - otherwise 458 /* core returns wct = 1, but we do not ask for core - otherwise
459 small wct just comes when dialect index is -1 indicating we 459 small wct just comes when dialect index is -1 indicating we
460 could not negotiate a common dialect */ 460 could not negotiate a common dialect */
461 rc = -EOPNOTSUPP; 461 rc = -EOPNOTSUPP;
462 goto neg_err_exit; 462 goto neg_err_exit;
463#ifdef CONFIG_CIFS_WEAK_PW_HASH 463#ifdef CONFIG_CIFS_WEAK_PW_HASH
464 } else if((pSMBr->hdr.WordCount == 13) 464 } else if ((pSMBr->hdr.WordCount == 13)
465 && ((dialect == LANMAN_PROT) 465 && ((dialect == LANMAN_PROT)
466 || (dialect == LANMAN2_PROT))) { 466 || (dialect == LANMAN2_PROT))) {
467 __s16 tmp; 467 __s16 tmp;
468 struct lanman_neg_rsp * rsp = (struct lanman_neg_rsp *)pSMBr; 468 struct lanman_neg_rsp * rsp = (struct lanman_neg_rsp *)pSMBr;
469 469
470 if((secFlags & CIFSSEC_MAY_LANMAN) || 470 if ((secFlags & CIFSSEC_MAY_LANMAN) ||
471 (secFlags & CIFSSEC_MAY_PLNTXT)) 471 (secFlags & CIFSSEC_MAY_PLNTXT))
472 server->secType = LANMAN; 472 server->secType = LANMAN;
473 else { 473 else {
@@ -483,7 +483,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
483 GETU32(server->sessid) = le32_to_cpu(rsp->SessionKey); 483 GETU32(server->sessid) = le32_to_cpu(rsp->SessionKey);
484 /* even though we do not use raw we might as well set this 484 /* even though we do not use raw we might as well set this
485 accurately, in case we ever find a need for it */ 485 accurately, in case we ever find a need for it */
486 if((le16_to_cpu(rsp->RawMode) & RAW_ENABLE) == RAW_ENABLE) { 486 if ((le16_to_cpu(rsp->RawMode) & RAW_ENABLE) == RAW_ENABLE) {
487 server->maxRw = 0xFF00; 487 server->maxRw = 0xFF00;
488 server->capabilities = CAP_MPX_MODE | CAP_RAW_MODE; 488 server->capabilities = CAP_MPX_MODE | CAP_RAW_MODE;
489 } else { 489 } else {
@@ -511,16 +511,16 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
511 seconds = val < 0 ? -val : val; 511 seconds = val < 0 ? -val : val;
512 result = (seconds / MIN_TZ_ADJ) * MIN_TZ_ADJ; 512 result = (seconds / MIN_TZ_ADJ) * MIN_TZ_ADJ;
513 remain = seconds % MIN_TZ_ADJ; 513 remain = seconds % MIN_TZ_ADJ;
514 if(remain >= (MIN_TZ_ADJ / 2)) 514 if (remain >= (MIN_TZ_ADJ / 2))
515 result += MIN_TZ_ADJ; 515 result += MIN_TZ_ADJ;
516 if(val < 0) 516 if (val < 0)
517 result = - result; 517 result = - result;
518 server->timeAdj = result; 518 server->timeAdj = result;
519 } else { 519 } else {
520 server->timeAdj = (int)tmp; 520 server->timeAdj = (int)tmp;
521 server->timeAdj *= 60; /* also in seconds */ 521 server->timeAdj *= 60; /* also in seconds */
522 } 522 }
523 cFYI(1,("server->timeAdj: %d seconds", server->timeAdj)); 523 cFYI(1, ("server->timeAdj: %d seconds", server->timeAdj));
524 524
525 525
526 /* BB get server time for time conversions and add 526 /* BB get server time for time conversions and add
@@ -535,39 +535,39 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
535 goto neg_err_exit; 535 goto neg_err_exit;
536 } 536 }
537 537
538 cFYI(1,("LANMAN negotiated")); 538 cFYI(1, ("LANMAN negotiated"));
539 /* we will not end up setting signing flags - as no signing 539 /* we will not end up setting signing flags - as no signing
540 was in LANMAN and server did not return the flags on */ 540 was in LANMAN and server did not return the flags on */
541 goto signing_check; 541 goto signing_check;
542#else /* weak security disabled */ 542#else /* weak security disabled */
543 } else if(pSMBr->hdr.WordCount == 13) { 543 } else if (pSMBr->hdr.WordCount == 13) {
544 cERROR(1,("mount failed, cifs module not built " 544 cERROR(1,("mount failed, cifs module not built "
545 "with CIFS_WEAK_PW_HASH support")); 545 "with CIFS_WEAK_PW_HASH support"));
546 rc = -EOPNOTSUPP; 546 rc = -EOPNOTSUPP;
547#endif /* WEAK_PW_HASH */ 547#endif /* WEAK_PW_HASH */
548 goto neg_err_exit; 548 goto neg_err_exit;
549 } else if(pSMBr->hdr.WordCount != 17) { 549 } else if (pSMBr->hdr.WordCount != 17) {
550 /* unknown wct */ 550 /* unknown wct */
551 rc = -EOPNOTSUPP; 551 rc = -EOPNOTSUPP;
552 goto neg_err_exit; 552 goto neg_err_exit;
553 } 553 }
554 /* else wct == 17 NTLM */ 554 /* else wct == 17 NTLM */
555 server->secMode = pSMBr->SecurityMode; 555 server->secMode = pSMBr->SecurityMode;
556 if((server->secMode & SECMODE_USER) == 0) 556 if ((server->secMode & SECMODE_USER) == 0)
557 cFYI(1,("share mode security")); 557 cFYI(1, ("share mode security"));
558 558
559 if((server->secMode & SECMODE_PW_ENCRYPT) == 0) 559 if ((server->secMode & SECMODE_PW_ENCRYPT) == 0)
560#ifdef CONFIG_CIFS_WEAK_PW_HASH 560#ifdef CONFIG_CIFS_WEAK_PW_HASH
561 if ((secFlags & CIFSSEC_MAY_PLNTXT) == 0) 561 if ((secFlags & CIFSSEC_MAY_PLNTXT) == 0)
562#endif /* CIFS_WEAK_PW_HASH */ 562#endif /* CIFS_WEAK_PW_HASH */
563 cERROR(1,("Server requests plain text password" 563 cERROR(1,("Server requests plain text password"
564 " but client support disabled")); 564 " but client support disabled"));
565 565
566 if((secFlags & CIFSSEC_MUST_NTLMV2) == CIFSSEC_MUST_NTLMV2) 566 if ((secFlags & CIFSSEC_MUST_NTLMV2) == CIFSSEC_MUST_NTLMV2)
567 server->secType = NTLMv2; 567 server->secType = NTLMv2;
568 else if(secFlags & CIFSSEC_MAY_NTLM) 568 else if (secFlags & CIFSSEC_MAY_NTLM)
569 server->secType = NTLM; 569 server->secType = NTLM;
570 else if(secFlags & CIFSSEC_MAY_NTLMV2) 570 else if (secFlags & CIFSSEC_MAY_NTLMV2)
571 server->secType = NTLMv2; 571 server->secType = NTLMv2;
572 /* else krb5 ... any others ... */ 572 /* else krb5 ... any others ... */
573 573
@@ -620,7 +620,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
620 SecurityBlob, 620 SecurityBlob,
621 count - 16, 621 count - 16,
622 &server->secType); 622 &server->secType);
623 if(rc == 1) { 623 if (rc == 1) {
624 /* BB Need to fill struct for sessetup here */ 624 /* BB Need to fill struct for sessetup here */
625 rc = -EOPNOTSUPP; 625 rc = -EOPNOTSUPP;
626 } else { 626 } else {
@@ -637,7 +637,7 @@ signing_check:
637 /* MUST_SIGN already includes the MAY_SIGN FLAG 637 /* MUST_SIGN already includes the MAY_SIGN FLAG
638 so if this is zero it means that signing is disabled */ 638 so if this is zero it means that signing is disabled */
639 cFYI(1, ("Signing disabled")); 639 cFYI(1, ("Signing disabled"));
640 if(server->secMode & SECMODE_SIGN_REQUIRED) 640 if (server->secMode & SECMODE_SIGN_REQUIRED)
641 cERROR(1, ("Server requires " 641 cERROR(1, ("Server requires "
642 "/proc/fs/cifs/PacketSigningEnabled " 642 "/proc/fs/cifs/PacketSigningEnabled "
643 "to be on")); 643 "to be on"));
@@ -655,7 +655,7 @@ signing_check:
655 server->secMode |= SECMODE_SIGN_REQUIRED; 655 server->secMode |= SECMODE_SIGN_REQUIRED;
656 } else { 656 } else {
657 /* signing optional ie CIFSSEC_MAY_SIGN */ 657 /* signing optional ie CIFSSEC_MAY_SIGN */
658 if((server->secMode & SECMODE_SIGN_REQUIRED) == 0) 658 if ((server->secMode & SECMODE_SIGN_REQUIRED) == 0)
659 server->secMode &= 659 server->secMode &=
660 ~(SECMODE_SIGN_ENABLED | SECMODE_SIGN_REQUIRED); 660 ~(SECMODE_SIGN_ENABLED | SECMODE_SIGN_REQUIRED);
661 } 661 }
@@ -663,7 +663,7 @@ signing_check:
663neg_err_exit: 663neg_err_exit:
664 cifs_buf_release(pSMB); 664 cifs_buf_release(pSMB);
665 665
666 cFYI(1,("negprot rc %d",rc)); 666 cFYI(1, ("negprot rc %d", rc));
667 return rc; 667 return rc;
668} 668}
669 669
@@ -696,12 +696,12 @@ CIFSSMBTDis(const int xid, struct cifsTconInfo *tcon)
696 696
697 /* No need to return error on this operation if tid invalidated and 697 /* No need to return error on this operation if tid invalidated and
698 closed on server already e.g. due to tcp session crashing */ 698 closed on server already e.g. due to tcp session crashing */
699 if(tcon->tidStatus == CifsNeedReconnect) { 699 if (tcon->tidStatus == CifsNeedReconnect) {
700 up(&tcon->tconSem); 700 up(&tcon->tconSem);
701 return 0; 701 return 0;
702 } 702 }
703 703
704 if((tcon->ses == NULL) || (tcon->ses->server == NULL)) { 704 if ((tcon->ses == NULL) || (tcon->ses->server == NULL)) {
705 up(&tcon->tconSem); 705 up(&tcon->tconSem);
706 return -EIO; 706 return -EIO;
707 } 707 }
@@ -757,10 +757,10 @@ CIFSSMBLogoff(const int xid, struct cifsSesInfo *ses)
757 757
758 smb_buffer_response = (struct smb_hdr *)pSMB; /* BB removeme BB */ 758 smb_buffer_response = (struct smb_hdr *)pSMB; /* BB removeme BB */
759 759
760 if(ses->server) { 760 if (ses->server) {
761 pSMB->hdr.Mid = GetNextMid(ses->server); 761 pSMB->hdr.Mid = GetNextMid(ses->server);
762 762
763 if(ses->server->secMode & 763 if (ses->server->secMode &
764 (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) 764 (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED))
765 pSMB->hdr.Flags2 |= SMBFLG2_SECURITY_SIGNATURE; 765 pSMB->hdr.Flags2 |= SMBFLG2_SECURITY_SIGNATURE;
766 } 766 }
@@ -999,7 +999,7 @@ PsxCreat:
999 goto psx_create_err; 999 goto psx_create_err;
1000 } 1000 }
1001 1001
1002 cFYI(1,("copying inode info")); 1002 cFYI(1, ("copying inode info"));
1003 rc = validate_t2((struct smb_t2_rsp *)pSMBr); 1003 rc = validate_t2((struct smb_t2_rsp *)pSMBr);
1004 1004
1005 if (rc || (pSMBr->ByteCount < sizeof(OPEN_PSX_RSP))) { 1005 if (rc || (pSMBr->ByteCount < sizeof(OPEN_PSX_RSP))) {
@@ -1012,20 +1012,20 @@ PsxCreat:
1012 + le16_to_cpu(pSMBr->t2.DataOffset)); 1012 + le16_to_cpu(pSMBr->t2.DataOffset));
1013 1013
1014 *pOplock = le16_to_cpu(psx_rsp->OplockFlags); 1014 *pOplock = le16_to_cpu(psx_rsp->OplockFlags);
1015 if(netfid) 1015 if (netfid)
1016 *netfid = psx_rsp->Fid; /* cifs fid stays in le */ 1016 *netfid = psx_rsp->Fid; /* cifs fid stays in le */
1017 /* Let caller know file was created so we can set the mode. */ 1017 /* Let caller know file was created so we can set the mode. */
1018 /* Do we care about the CreateAction in any other cases? */ 1018 /* Do we care about the CreateAction in any other cases? */
1019 if(cpu_to_le32(FILE_CREATE) == psx_rsp->CreateAction) 1019 if (cpu_to_le32(FILE_CREATE) == psx_rsp->CreateAction)
1020 *pOplock |= CIFS_CREATE_ACTION; 1020 *pOplock |= CIFS_CREATE_ACTION;
1021 /* check to make sure response data is there */ 1021 /* check to make sure response data is there */
1022 if(psx_rsp->ReturnedLevel != SMB_QUERY_FILE_UNIX_BASIC) { 1022 if (psx_rsp->ReturnedLevel != SMB_QUERY_FILE_UNIX_BASIC) {
1023 pRetData->Type = -1; /* unknown */ 1023 pRetData->Type = -1; /* unknown */
1024#ifdef CONFIG_CIFS_DEBUG2 1024#ifdef CONFIG_CIFS_DEBUG2
1025 cFYI(1,("unknown type")); 1025 cFYI(1, ("unknown type"));
1026#endif 1026#endif
1027 } else { 1027 } else {
1028 if(pSMBr->ByteCount < sizeof(OPEN_PSX_RSP) 1028 if (pSMBr->ByteCount < sizeof(OPEN_PSX_RSP)
1029 + sizeof(FILE_UNIX_BASIC_INFO)) { 1029 + sizeof(FILE_UNIX_BASIC_INFO)) {
1030 cERROR(1,("Open response data too small")); 1030 cERROR(1,("Open response data too small"));
1031 pRetData->Type = -1; 1031 pRetData->Type = -1;
@@ -1072,7 +1072,7 @@ static __u16 convert_disposition(int disposition)
1072 ofun = SMBOPEN_OCREATE | SMBOPEN_OTRUNC; 1072 ofun = SMBOPEN_OCREATE | SMBOPEN_OTRUNC;
1073 break; 1073 break;
1074 default: 1074 default:
1075 cFYI(1,("unknown disposition %d",disposition)); 1075 cFYI(1, ("unknown disposition %d", disposition));
1076 ofun = SMBOPEN_OAPPEND; /* regular open */ 1076 ofun = SMBOPEN_OAPPEND; /* regular open */
1077 } 1077 }
1078 return ofun; 1078 return ofun;
@@ -1131,9 +1131,9 @@ OldOpenRetry:
1131 as fifo and server expecting SFU style and 1131 as fifo and server expecting SFU style and
1132 no Unix extensions */ 1132 no Unix extensions */
1133 1133
1134 if(create_options & CREATE_OPTION_SPECIAL) 1134 if (create_options & CREATE_OPTION_SPECIAL)
1135 pSMB->FileAttributes = cpu_to_le16(ATTR_SYSTEM); 1135 pSMB->FileAttributes = cpu_to_le16(ATTR_SYSTEM);
1136 else 1136 else
1137 pSMB->FileAttributes = cpu_to_le16(0/*ATTR_NORMAL*/); /* BB FIXME */ 1137 pSMB->FileAttributes = cpu_to_le16(0/*ATTR_NORMAL*/); /* BB FIXME */
1138 1138
1139 /* if ((omode & S_IWUGO) == 0) 1139 /* if ((omode & S_IWUGO) == 0)
@@ -1167,11 +1167,11 @@ OldOpenRetry:
1167 /* Let caller know file was created so we can set the mode. */ 1167 /* Let caller know file was created so we can set the mode. */
1168 /* Do we care about the CreateAction in any other cases? */ 1168 /* Do we care about the CreateAction in any other cases? */
1169 /* BB FIXME BB */ 1169 /* BB FIXME BB */
1170/* if(cpu_to_le32(FILE_CREATE) == pSMBr->CreateAction) 1170/* if (cpu_to_le32(FILE_CREATE) == pSMBr->CreateAction)
1171 *pOplock |= CIFS_CREATE_ACTION; */ 1171 *pOplock |= CIFS_CREATE_ACTION; */
1172 /* BB FIXME END */ 1172 /* BB FIXME END */
1173 1173
1174 if(pfile_info) { 1174 if (pfile_info) {
1175 pfile_info->CreationTime = 0; /* BB convert CreateTime*/ 1175 pfile_info->CreationTime = 0; /* BB convert CreateTime*/
1176 pfile_info->LastAccessTime = 0; /* BB fixme */ 1176 pfile_info->LastAccessTime = 0; /* BB fixme */
1177 pfile_info->LastWriteTime = 0; /* BB fixme */ 1177 pfile_info->LastWriteTime = 0; /* BB fixme */
@@ -1239,7 +1239,7 @@ openRetry:
1239 /* set file as system file if special file such 1239 /* set file as system file if special file such
1240 as fifo and server expecting SFU style and 1240 as fifo and server expecting SFU style and
1241 no Unix extensions */ 1241 no Unix extensions */
1242 if(create_options & CREATE_OPTION_SPECIAL) 1242 if (create_options & CREATE_OPTION_SPECIAL)
1243 pSMB->FileAttributes = cpu_to_le32(ATTR_SYSTEM); 1243 pSMB->FileAttributes = cpu_to_le32(ATTR_SYSTEM);
1244 else 1244 else
1245 pSMB->FileAttributes = cpu_to_le32(ATTR_NORMAL); 1245 pSMB->FileAttributes = cpu_to_le32(ATTR_NORMAL);
@@ -1277,9 +1277,9 @@ openRetry:
1277 *netfid = pSMBr->Fid; /* cifs fid stays in le */ 1277 *netfid = pSMBr->Fid; /* cifs fid stays in le */
1278 /* Let caller know file was created so we can set the mode. */ 1278 /* Let caller know file was created so we can set the mode. */
1279 /* Do we care about the CreateAction in any other cases? */ 1279 /* Do we care about the CreateAction in any other cases? */
1280 if(cpu_to_le32(FILE_CREATE) == pSMBr->CreateAction) 1280 if (cpu_to_le32(FILE_CREATE) == pSMBr->CreateAction)
1281 *pOplock |= CIFS_CREATE_ACTION; 1281 *pOplock |= CIFS_CREATE_ACTION;
1282 if(pfile_info) { 1282 if (pfile_info) {
1283 memcpy((char *)pfile_info,(char *)&pSMBr->CreationTime, 1283 memcpy((char *)pfile_info,(char *)&pSMBr->CreationTime,
1284 36 /* CreationTime to Attributes */); 1284 36 /* CreationTime to Attributes */);
1285 /* the file_info buf is endian converted by caller */ 1285 /* the file_info buf is endian converted by caller */
@@ -1309,8 +1309,8 @@ CIFSSMBRead(const int xid, struct cifsTconInfo *tcon,
1309 int resp_buf_type = 0; 1309 int resp_buf_type = 0;
1310 struct kvec iov[1]; 1310 struct kvec iov[1];
1311 1311
1312 cFYI(1,("Reading %d bytes on fid %d",count,netfid)); 1312 cFYI(1, ("Reading %d bytes on fid %d", count, netfid));
1313 if(tcon->ses->capabilities & CAP_LARGE_FILES) 1313 if (tcon->ses->capabilities & CAP_LARGE_FILES)
1314 wct = 12; 1314 wct = 12;
1315 else 1315 else
1316 wct = 10; /* old style read */ 1316 wct = 10; /* old style read */
@@ -1327,15 +1327,15 @@ CIFSSMBRead(const int xid, struct cifsTconInfo *tcon,
1327 pSMB->AndXCommand = 0xFF; /* none */ 1327 pSMB->AndXCommand = 0xFF; /* none */
1328 pSMB->Fid = netfid; 1328 pSMB->Fid = netfid;
1329 pSMB->OffsetLow = cpu_to_le32(lseek & 0xFFFFFFFF); 1329 pSMB->OffsetLow = cpu_to_le32(lseek & 0xFFFFFFFF);
1330 if(wct == 12) 1330 if (wct == 12)
1331 pSMB->OffsetHigh = cpu_to_le32(lseek >> 32); 1331 pSMB->OffsetHigh = cpu_to_le32(lseek >> 32);
1332 else if((lseek >> 32) > 0) /* can not handle this big offset for old */ 1332 else if ((lseek >> 32) > 0) /* can not handle this big offset for old */
1333 return -EIO; 1333 return -EIO;
1334 1334
1335 pSMB->Remaining = 0; 1335 pSMB->Remaining = 0;
1336 pSMB->MaxCount = cpu_to_le16(count & 0xFFFF); 1336 pSMB->MaxCount = cpu_to_le16(count & 0xFFFF);
1337 pSMB->MaxCountHigh = cpu_to_le32(count >> 16); 1337 pSMB->MaxCountHigh = cpu_to_le32(count >> 16);
1338 if(wct == 12) 1338 if (wct == 12)
1339 pSMB->ByteCount = 0; /* no need to do le conversion since 0 */ 1339 pSMB->ByteCount = 0; /* no need to do le conversion since 0 */
1340 else { 1340 else {
1341 /* old style read */ 1341 /* old style read */
@@ -1368,27 +1368,27 @@ CIFSSMBRead(const int xid, struct cifsTconInfo *tcon,
1368 } else { 1368 } else {
1369 pReadData = (char *) (&pSMBr->hdr.Protocol) + 1369 pReadData = (char *) (&pSMBr->hdr.Protocol) +
1370 le16_to_cpu(pSMBr->DataOffset); 1370 le16_to_cpu(pSMBr->DataOffset);
1371/* if(rc = copy_to_user(buf, pReadData, data_length)) { 1371/* if (rc = copy_to_user(buf, pReadData, data_length)) {
1372 cERROR(1,("Faulting on read rc = %d",rc)); 1372 cERROR(1,("Faulting on read rc = %d",rc));
1373 rc = -EFAULT; 1373 rc = -EFAULT;
1374 }*/ /* can not use copy_to_user when using page cache*/ 1374 }*/ /* can not use copy_to_user when using page cache*/
1375 if(*buf) 1375 if (*buf)
1376 memcpy(*buf,pReadData,data_length); 1376 memcpy(*buf,pReadData,data_length);
1377 } 1377 }
1378 } 1378 }
1379 1379
1380/* cifs_small_buf_release(pSMB); */ /* Freed earlier now in SendReceive2 */ 1380/* cifs_small_buf_release(pSMB); */ /* Freed earlier now in SendReceive2 */
1381 if(*buf) { 1381 if (*buf) {
1382 if(resp_buf_type == CIFS_SMALL_BUFFER) 1382 if (resp_buf_type == CIFS_SMALL_BUFFER)
1383 cifs_small_buf_release(iov[0].iov_base); 1383 cifs_small_buf_release(iov[0].iov_base);
1384 else if(resp_buf_type == CIFS_LARGE_BUFFER) 1384 else if (resp_buf_type == CIFS_LARGE_BUFFER)
1385 cifs_buf_release(iov[0].iov_base); 1385 cifs_buf_release(iov[0].iov_base);
1386 } else if(resp_buf_type != CIFS_NO_BUFFER) { 1386 } else if (resp_buf_type != CIFS_NO_BUFFER) {
1387 /* return buffer to caller to free */ 1387 /* return buffer to caller to free */
1388 *buf = iov[0].iov_base; 1388 *buf = iov[0].iov_base;
1389 if(resp_buf_type == CIFS_SMALL_BUFFER) 1389 if (resp_buf_type == CIFS_SMALL_BUFFER)
1390 *pbuf_type = CIFS_SMALL_BUFFER; 1390 *pbuf_type = CIFS_SMALL_BUFFER;
1391 else if(resp_buf_type == CIFS_LARGE_BUFFER) 1391 else if (resp_buf_type == CIFS_LARGE_BUFFER)
1392 *pbuf_type = CIFS_LARGE_BUFFER; 1392 *pbuf_type = CIFS_LARGE_BUFFER;
1393 } /* else no valid buffer on return - leave as null */ 1393 } /* else no valid buffer on return - leave as null */
1394 1394
@@ -1412,10 +1412,10 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
1412 __u16 byte_count; 1412 __u16 byte_count;
1413 1413
1414 /* cFYI(1,("write at %lld %d bytes",offset,count));*/ 1414 /* cFYI(1,("write at %lld %d bytes",offset,count));*/
1415 if(tcon->ses == NULL) 1415 if (tcon->ses == NULL)
1416 return -ECONNABORTED; 1416 return -ECONNABORTED;
1417 1417
1418 if(tcon->ses->capabilities & CAP_LARGE_FILES) 1418 if (tcon->ses->capabilities & CAP_LARGE_FILES)
1419 wct = 14; 1419 wct = 14;
1420 else 1420 else
1421 wct = 12; 1421 wct = 12;
@@ -1431,9 +1431,9 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
1431 pSMB->AndXCommand = 0xFF; /* none */ 1431 pSMB->AndXCommand = 0xFF; /* none */
1432 pSMB->Fid = netfid; 1432 pSMB->Fid = netfid;
1433 pSMB->OffsetLow = cpu_to_le32(offset & 0xFFFFFFFF); 1433 pSMB->OffsetLow = cpu_to_le32(offset & 0xFFFFFFFF);
1434 if(wct == 14) 1434 if (wct == 14)
1435 pSMB->OffsetHigh = cpu_to_le32(offset >> 32); 1435 pSMB->OffsetHigh = cpu_to_le32(offset >> 32);
1436 else if((offset >> 32) > 0) /* can not handle this big offset for old */ 1436 else if ((offset >> 32) > 0) /* can not handle big offset for old srv */
1437 return -EIO; 1437 return -EIO;
1438 1438
1439 pSMB->Reserved = 0xFFFFFFFF; 1439 pSMB->Reserved = 0xFFFFFFFF;
@@ -1444,7 +1444,7 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
1444 can send more if LARGE_WRITE_X capability returned by the server and if 1444 can send more if LARGE_WRITE_X capability returned by the server and if
1445 our buffer is big enough or if we convert to iovecs on socket writes 1445 our buffer is big enough or if we convert to iovecs on socket writes
1446 and eliminate the copy to the CIFS buffer */ 1446 and eliminate the copy to the CIFS buffer */
1447 if(tcon->ses->capabilities & CAP_LARGE_WRITE_X) { 1447 if (tcon->ses->capabilities & CAP_LARGE_WRITE_X) {
1448 bytes_sent = min_t(const unsigned int, CIFSMaxBufSize, count); 1448 bytes_sent = min_t(const unsigned int, CIFSMaxBufSize, count);
1449 } else { 1449 } else {
1450 bytes_sent = (tcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE) 1450 bytes_sent = (tcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE)
@@ -1455,10 +1455,10 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
1455 bytes_sent = count; 1455 bytes_sent = count;
1456 pSMB->DataOffset = 1456 pSMB->DataOffset =
1457 cpu_to_le16(offsetof(struct smb_com_write_req,Data) - 4); 1457 cpu_to_le16(offsetof(struct smb_com_write_req,Data) - 4);
1458 if(buf) 1458 if (buf)
1459 memcpy(pSMB->Data,buf,bytes_sent); 1459 memcpy(pSMB->Data,buf,bytes_sent);
1460 else if(ubuf) { 1460 else if (ubuf) {
1461 if(copy_from_user(pSMB->Data,ubuf,bytes_sent)) { 1461 if (copy_from_user(pSMB->Data, ubuf, bytes_sent)) {
1462 cifs_buf_release(pSMB); 1462 cifs_buf_release(pSMB);
1463 return -EFAULT; 1463 return -EFAULT;
1464 } 1464 }
@@ -1467,7 +1467,7 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
1467 cifs_buf_release(pSMB); 1467 cifs_buf_release(pSMB);
1468 return -EINVAL; 1468 return -EINVAL;
1469 } /* else setting file size with write of zero bytes */ 1469 } /* else setting file size with write of zero bytes */
1470 if(wct == 14) 1470 if (wct == 14)
1471 byte_count = bytes_sent + 1; /* pad */ 1471 byte_count = bytes_sent + 1; /* pad */
1472 else /* wct == 12 */ { 1472 else /* wct == 12 */ {
1473 byte_count = bytes_sent + 5; /* bigger pad, smaller smb hdr */ 1473 byte_count = bytes_sent + 5; /* bigger pad, smaller smb hdr */
@@ -1476,7 +1476,7 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
1476 pSMB->DataLengthHigh = cpu_to_le16(bytes_sent >> 16); 1476 pSMB->DataLengthHigh = cpu_to_le16(bytes_sent >> 16);
1477 pSMB->hdr.smb_buf_length += byte_count; 1477 pSMB->hdr.smb_buf_length += byte_count;
1478 1478
1479 if(wct == 14) 1479 if (wct == 14)
1480 pSMB->ByteCount = cpu_to_le16(byte_count); 1480 pSMB->ByteCount = cpu_to_le16(byte_count);
1481 else { /* old style write has byte count 4 bytes earlier so 4 bytes pad */ 1481 else { /* old style write has byte count 4 bytes earlier so 4 bytes pad */
1482 struct smb_com_writex_req * pSMBW = 1482 struct smb_com_writex_req * pSMBW =
@@ -1516,9 +1516,9 @@ CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,
1516 int smb_hdr_len; 1516 int smb_hdr_len;
1517 int resp_buf_type = 0; 1517 int resp_buf_type = 0;
1518 1518
1519 cFYI(1,("write2 at %lld %d bytes", (long long)offset, count)); 1519 cFYI(1, ("write2 at %lld %d bytes", (long long)offset, count));
1520 1520
1521 if(tcon->ses->capabilities & CAP_LARGE_FILES) 1521 if (tcon->ses->capabilities & CAP_LARGE_FILES)
1522 wct = 14; 1522 wct = 14;
1523 else 1523 else
1524 wct = 12; 1524 wct = 12;
@@ -1532,9 +1532,9 @@ CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,
1532 pSMB->AndXCommand = 0xFF; /* none */ 1532 pSMB->AndXCommand = 0xFF; /* none */
1533 pSMB->Fid = netfid; 1533 pSMB->Fid = netfid;
1534 pSMB->OffsetLow = cpu_to_le32(offset & 0xFFFFFFFF); 1534 pSMB->OffsetLow = cpu_to_le32(offset & 0xFFFFFFFF);
1535 if(wct == 14) 1535 if (wct == 14)
1536 pSMB->OffsetHigh = cpu_to_le32(offset >> 32); 1536 pSMB->OffsetHigh = cpu_to_le32(offset >> 32);
1537 else if((offset >> 32) > 0) /* can not handle this big offset for old */ 1537 else if ((offset >> 32) > 0) /* can not handle big offset for old srv */
1538 return -EIO; 1538 return -EIO;
1539 pSMB->Reserved = 0xFFFFFFFF; 1539 pSMB->Reserved = 0xFFFFFFFF;
1540 pSMB->WriteMode = 0; 1540 pSMB->WriteMode = 0;
@@ -1546,11 +1546,11 @@ CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,
1546 pSMB->DataLengthLow = cpu_to_le16(count & 0xFFFF); 1546 pSMB->DataLengthLow = cpu_to_le16(count & 0xFFFF);
1547 pSMB->DataLengthHigh = cpu_to_le16(count >> 16); 1547 pSMB->DataLengthHigh = cpu_to_le16(count >> 16);
1548 smb_hdr_len = pSMB->hdr.smb_buf_length + 1; /* hdr + 1 byte pad */ 1548 smb_hdr_len = pSMB->hdr.smb_buf_length + 1; /* hdr + 1 byte pad */
1549 if(wct == 14) 1549 if (wct == 14)
1550 pSMB->hdr.smb_buf_length += count+1; 1550 pSMB->hdr.smb_buf_length += count+1;
1551 else /* wct == 12 */ 1551 else /* wct == 12 */
1552 pSMB->hdr.smb_buf_length += count+5; /* smb data starts later */ 1552 pSMB->hdr.smb_buf_length += count+5; /* smb data starts later */
1553 if(wct == 14) 1553 if (wct == 14)
1554 pSMB->ByteCount = cpu_to_le16(count + 1); 1554 pSMB->ByteCount = cpu_to_le16(count + 1);
1555 else /* wct == 12 */ /* bigger pad, smaller smb hdr, keep offset ok */ { 1555 else /* wct == 12 */ /* bigger pad, smaller smb hdr, keep offset ok */ {
1556 struct smb_com_writex_req * pSMBW = 1556 struct smb_com_writex_req * pSMBW =
@@ -1558,7 +1558,7 @@ CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,
1558 pSMBW->ByteCount = cpu_to_le16(count + 5); 1558 pSMBW->ByteCount = cpu_to_le16(count + 5);
1559 } 1559 }
1560 iov[0].iov_base = pSMB; 1560 iov[0].iov_base = pSMB;
1561 if(wct == 14) 1561 if (wct == 14)
1562 iov[0].iov_len = smb_hdr_len + 4; 1562 iov[0].iov_len = smb_hdr_len + 4;
1563 else /* wct == 12 pad bigger by four bytes */ 1563 else /* wct == 12 pad bigger by four bytes */
1564 iov[0].iov_len = smb_hdr_len + 8; 1564 iov[0].iov_len = smb_hdr_len + 8;
@@ -1570,7 +1570,7 @@ CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,
1570 if (rc) { 1570 if (rc) {
1571 cFYI(1, ("Send error Write2 = %d", rc)); 1571 cFYI(1, ("Send error Write2 = %d", rc));
1572 *nbytes = 0; 1572 *nbytes = 0;
1573 } else if(resp_buf_type == 0) { 1573 } else if (resp_buf_type == 0) {
1574 /* presumably this can not happen, but best to be safe */ 1574 /* presumably this can not happen, but best to be safe */
1575 rc = -EIO; 1575 rc = -EIO;
1576 *nbytes = 0; 1576 *nbytes = 0;
@@ -1582,9 +1582,9 @@ CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,
1582 } 1582 }
1583 1583
1584/* cifs_small_buf_release(pSMB); */ /* Freed earlier now in SendReceive2 */ 1584/* cifs_small_buf_release(pSMB); */ /* Freed earlier now in SendReceive2 */
1585 if(resp_buf_type == CIFS_SMALL_BUFFER) 1585 if (resp_buf_type == CIFS_SMALL_BUFFER)
1586 cifs_small_buf_release(iov[0].iov_base); 1586 cifs_small_buf_release(iov[0].iov_base);
1587 else if(resp_buf_type == CIFS_LARGE_BUFFER) 1587 else if (resp_buf_type == CIFS_LARGE_BUFFER)
1588 cifs_buf_release(iov[0].iov_base); 1588 cifs_buf_release(iov[0].iov_base);
1589 1589
1590 /* Note: On -EAGAIN error only caller can retry on handle based calls 1590 /* Note: On -EAGAIN error only caller can retry on handle based calls
@@ -1615,7 +1615,7 @@ CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
1615 1615
1616 pSMBr = (LOCK_RSP *)pSMB; /* BB removeme BB */ 1616 pSMBr = (LOCK_RSP *)pSMB; /* BB removeme BB */
1617 1617
1618 if(lockType == LOCKING_ANDX_OPLOCK_RELEASE) { 1618 if (lockType == LOCKING_ANDX_OPLOCK_RELEASE) {
1619 timeout = -1; /* no response expected */ 1619 timeout = -1; /* no response expected */
1620 pSMB->Timeout = 0; 1620 pSMB->Timeout = 0;
1621 } else if (waitFlag == TRUE) { 1621 } else if (waitFlag == TRUE) {
@@ -1631,7 +1631,7 @@ CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
1631 pSMB->AndXCommand = 0xFF; /* none */ 1631 pSMB->AndXCommand = 0xFF; /* none */
1632 pSMB->Fid = smb_file_id; /* netfid stays le */ 1632 pSMB->Fid = smb_file_id; /* netfid stays le */
1633 1633
1634 if((numLock != 0) || (numUnlock != 0)) { 1634 if ((numLock != 0) || (numUnlock != 0)) {
1635 pSMB->Locks[0].Pid = cpu_to_le16(current->tgid); 1635 pSMB->Locks[0].Pid = cpu_to_le16(current->tgid);
1636 /* BB where to store pid high? */ 1636 /* BB where to store pid high? */
1637 pSMB->Locks[0].LengthLow = cpu_to_le32((u32)len); 1637 pSMB->Locks[0].LengthLow = cpu_to_le32((u32)len);
@@ -1681,7 +1681,7 @@ CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon,
1681 1681
1682 cFYI(1, ("Posix Lock")); 1682 cFYI(1, ("Posix Lock"));
1683 1683
1684 if(pLockData == NULL) 1684 if (pLockData == NULL)
1685 return EINVAL; 1685 return EINVAL;
1686 1686
1687 rc = small_smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB); 1687 rc = small_smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB);
@@ -1706,7 +1706,7 @@ CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon,
1706 pSMB->MaxDataCount = cpu_to_le16(1000); /* BB find max SMB PDU from sess */ 1706 pSMB->MaxDataCount = cpu_to_le16(1000); /* BB find max SMB PDU from sess */
1707 pSMB->SetupCount = 1; 1707 pSMB->SetupCount = 1;
1708 pSMB->Reserved3 = 0; 1708 pSMB->Reserved3 = 0;
1709 if(get_flag) 1709 if (get_flag)
1710 pSMB->SubCommand = cpu_to_le16(TRANS2_QUERY_FILE_INFORMATION); 1710 pSMB->SubCommand = cpu_to_le16(TRANS2_QUERY_FILE_INFORMATION);
1711 else 1711 else
1712 pSMB->SubCommand = cpu_to_le16(TRANS2_SET_FILE_INFORMATION); 1712 pSMB->SubCommand = cpu_to_le16(TRANS2_SET_FILE_INFORMATION);
@@ -1720,7 +1720,7 @@ CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon,
1720 (((char *) &pSMB->hdr.Protocol) + offset); 1720 (((char *) &pSMB->hdr.Protocol) + offset);
1721 1721
1722 parm_data->lock_type = cpu_to_le16(lock_type); 1722 parm_data->lock_type = cpu_to_le16(lock_type);
1723 if(waitFlag) { 1723 if (waitFlag) {
1724 timeout = 3; /* blocking operation, no timeout */ 1724 timeout = 3; /* blocking operation, no timeout */
1725 parm_data->lock_flags = cpu_to_le16(1); 1725 parm_data->lock_flags = cpu_to_le16(1);
1726 pSMB->Timeout = cpu_to_le32(-1); 1726 pSMB->Timeout = cpu_to_le32(-1);
@@ -1757,19 +1757,19 @@ CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon,
1757 rc = -EIO; /* bad smb */ 1757 rc = -EIO; /* bad smb */
1758 goto plk_err_exit; 1758 goto plk_err_exit;
1759 } 1759 }
1760 if(pLockData == NULL) { 1760 if (pLockData == NULL) {
1761 rc = -EINVAL; 1761 rc = -EINVAL;
1762 goto plk_err_exit; 1762 goto plk_err_exit;
1763 } 1763 }
1764 data_offset = le16_to_cpu(pSMBr->t2.DataOffset); 1764 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
1765 data_count = le16_to_cpu(pSMBr->t2.DataCount); 1765 data_count = le16_to_cpu(pSMBr->t2.DataCount);
1766 if(data_count < sizeof(struct cifs_posix_lock)) { 1766 if (data_count < sizeof(struct cifs_posix_lock)) {
1767 rc = -EIO; 1767 rc = -EIO;
1768 goto plk_err_exit; 1768 goto plk_err_exit;
1769 } 1769 }
1770 parm_data = (struct cifs_posix_lock *) 1770 parm_data = (struct cifs_posix_lock *)
1771 ((char *)&pSMBr->hdr.Protocol + data_offset); 1771 ((char *)&pSMBr->hdr.Protocol + data_offset);
1772 if(parm_data->lock_type == cpu_to_le16(CIFS_UNLCK)) 1772 if (parm_data->lock_type == cpu_to_le16(CIFS_UNLCK))
1773 pLockData->fl_type = F_UNLCK; 1773 pLockData->fl_type = F_UNLCK;
1774 } 1774 }
1775 1775
@@ -1795,7 +1795,7 @@ CIFSSMBClose(const int xid, struct cifsTconInfo *tcon, int smb_file_id)
1795 1795
1796/* do not retry on dead session on close */ 1796/* do not retry on dead session on close */
1797 rc = small_smb_init(SMB_COM_CLOSE, 3, tcon, (void **) &pSMB); 1797 rc = small_smb_init(SMB_COM_CLOSE, 3, tcon, (void **) &pSMB);
1798 if(rc == -EAGAIN) 1798 if (rc == -EAGAIN)
1799 return 0; 1799 return 0;
1800 if (rc) 1800 if (rc)
1801 return rc; 1801 return rc;
@@ -1809,7 +1809,7 @@ CIFSSMBClose(const int xid, struct cifsTconInfo *tcon, int smb_file_id)
1809 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 1809 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
1810 cifs_stats_inc(&tcon->num_closes); 1810 cifs_stats_inc(&tcon->num_closes);
1811 if (rc) { 1811 if (rc) {
1812 if(rc!=-EINTR) { 1812 if (rc != -EINTR) {
1813 /* EINTR is expected when user ctl-c to kill app */ 1813 /* EINTR is expected when user ctl-c to kill app */
1814 cERROR(1, ("Send error in Close = %d", rc)); 1814 cERROR(1, ("Send error in Close = %d", rc));
1815 } 1815 }
@@ -1818,7 +1818,7 @@ CIFSSMBClose(const int xid, struct cifsTconInfo *tcon, int smb_file_id)
1818 cifs_small_buf_release(pSMB); 1818 cifs_small_buf_release(pSMB);
1819 1819
1820 /* Since session is dead, file will be closed on server already */ 1820 /* Since session is dead, file will be closed on server already */
1821 if(rc == -EAGAIN) 1821 if (rc == -EAGAIN)
1822 rc = 0; 1822 rc = 0;
1823 1823
1824 return rc; 1824 return rc;
@@ -1938,7 +1938,7 @@ int CIFSSMBRenameOpenFile(const int xid,struct cifsTconInfo *pTcon,
1938 rename_info->overwrite = cpu_to_le32(1); 1938 rename_info->overwrite = cpu_to_le32(1);
1939 rename_info->root_fid = 0; 1939 rename_info->root_fid = 0;
1940 /* unicode only call */ 1940 /* unicode only call */
1941 if(target_name == NULL) { 1941 if (target_name == NULL) {
1942 sprintf(dummy_string,"cifs%x",pSMB->hdr.Mid); 1942 sprintf(dummy_string,"cifs%x",pSMB->hdr.Mid);
1943 len_of_str = cifsConvertToUCS((__le16 *)rename_info->target_name, 1943 len_of_str = cifsConvertToUCS((__le16 *)rename_info->target_name,
1944 dummy_string, 24, nls_codepage, remap); 1944 dummy_string, 24, nls_codepage, remap);
@@ -1961,7 +1961,7 @@ int CIFSSMBRenameOpenFile(const int xid,struct cifsTconInfo *pTcon,
1961 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 1961 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
1962 cifs_stats_inc(&pTcon->num_t2renames); 1962 cifs_stats_inc(&pTcon->num_t2renames);
1963 if (rc) { 1963 if (rc) {
1964 cFYI(1,("Send error in Rename (by file handle) = %d", rc)); 1964 cFYI(1, ("Send error in Rename (by file handle) = %d", rc));
1965 } 1965 }
1966 1966
1967 cifs_buf_release(pSMB); 1967 cifs_buf_release(pSMB);
@@ -2434,7 +2434,7 @@ validate_ntransact(char * buf, char ** ppparm, char ** ppdata,
2434 __u32 data_count, data_offset, parm_count, parm_offset; 2434 __u32 data_count, data_offset, parm_count, parm_offset;
2435 struct smb_com_ntransact_rsp * pSMBr; 2435 struct smb_com_ntransact_rsp * pSMBr;
2436 2436
2437 if(buf == NULL) 2437 if (buf == NULL)
2438 return -EINVAL; 2438 return -EINVAL;
2439 2439
2440 pSMBr = (struct smb_com_ntransact_rsp *)buf; 2440 pSMBr = (struct smb_com_ntransact_rsp *)buf;
@@ -2453,21 +2453,21 @@ validate_ntransact(char * buf, char ** ppparm, char ** ppdata,
2453 *ppdata = (char *)&pSMBr->hdr.Protocol + data_offset; 2453 *ppdata = (char *)&pSMBr->hdr.Protocol + data_offset;
2454 2454
2455 /* should we also check that parm and data areas do not overlap? */ 2455 /* should we also check that parm and data areas do not overlap? */
2456 if(*ppparm > end_of_smb) { 2456 if (*ppparm > end_of_smb) {
2457 cFYI(1,("parms start after end of smb")); 2457 cFYI(1, ("parms start after end of smb"));
2458 return -EINVAL; 2458 return -EINVAL;
2459 } else if(parm_count + *ppparm > end_of_smb) { 2459 } else if (parm_count + *ppparm > end_of_smb) {
2460 cFYI(1,("parm end after end of smb")); 2460 cFYI(1, ("parm end after end of smb"));
2461 return -EINVAL; 2461 return -EINVAL;
2462 } else if(*ppdata > end_of_smb) { 2462 } else if (*ppdata > end_of_smb) {
2463 cFYI(1,("data starts after end of smb")); 2463 cFYI(1, ("data starts after end of smb"));
2464 return -EINVAL; 2464 return -EINVAL;
2465 } else if(data_count + *ppdata > end_of_smb) { 2465 } else if (data_count + *ppdata > end_of_smb) {
2466 cFYI(1,("data %p + count %d (%p) ends after end of smb %p start %p", 2466 cFYI(1,("data %p + count %d (%p) ends after end of smb %p start %p",
2467 *ppdata, data_count, (data_count + *ppdata), end_of_smb, pSMBr)); /* BB FIXME */ 2467 *ppdata, data_count, (data_count + *ppdata), end_of_smb, pSMBr)); /* BB FIXME */
2468 return -EINVAL; 2468 return -EINVAL;
2469 } else if(parm_count + data_count > pSMBr->ByteCount) { 2469 } else if (parm_count + data_count > pSMBr->ByteCount) {
2470 cFYI(1,("parm count and data count larger than SMB")); 2470 cFYI(1, ("parm count and data count larger than SMB"));
2471 return -EINVAL; 2471 return -EINVAL;
2472 } 2472 }
2473 return 0; 2473 return 0;
@@ -2522,18 +2522,18 @@ CIFSSMBQueryReparseLinkInfo(const int xid, struct cifsTconInfo *tcon,
2522 /* BB also check enough total bytes returned */ 2522 /* BB also check enough total bytes returned */
2523 rc = -EIO; /* bad smb */ 2523 rc = -EIO; /* bad smb */
2524 else { 2524 else {
2525 if(data_count && (data_count < 2048)) { 2525 if (data_count && (data_count < 2048)) {
2526 char * end_of_smb = 2 /* sizeof byte count */ + 2526 char * end_of_smb = 2 /* sizeof byte count */ +
2527 pSMBr->ByteCount + 2527 pSMBr->ByteCount +
2528 (char *)&pSMBr->ByteCount; 2528 (char *)&pSMBr->ByteCount;
2529 2529
2530 struct reparse_data * reparse_buf = (struct reparse_data *) 2530 struct reparse_data * reparse_buf = (struct reparse_data *)
2531 ((char *)&pSMBr->hdr.Protocol + data_offset); 2531 ((char *)&pSMBr->hdr.Protocol + data_offset);
2532 if((char*)reparse_buf >= end_of_smb) { 2532 if ((char *)reparse_buf >= end_of_smb) {
2533 rc = -EIO; 2533 rc = -EIO;
2534 goto qreparse_out; 2534 goto qreparse_out;
2535 } 2535 }
2536 if((reparse_buf->LinkNamesBuf + 2536 if ((reparse_buf->LinkNamesBuf +
2537 reparse_buf->TargetNameOffset + 2537 reparse_buf->TargetNameOffset +
2538 reparse_buf->TargetNameLen) > 2538 reparse_buf->TargetNameLen) >
2539 end_of_smb) { 2539 end_of_smb) {
@@ -2602,17 +2602,17 @@ static int cifs_copy_posix_acl(char * trgt,char * src, const int buflen,
2602 if (le16_to_cpu(cifs_acl->version) != CIFS_ACL_VERSION) 2602 if (le16_to_cpu(cifs_acl->version) != CIFS_ACL_VERSION)
2603 return -EOPNOTSUPP; 2603 return -EOPNOTSUPP;
2604 2604
2605 if(acl_type & ACL_TYPE_ACCESS) { 2605 if (acl_type & ACL_TYPE_ACCESS) {
2606 count = le16_to_cpu(cifs_acl->access_entry_count); 2606 count = le16_to_cpu(cifs_acl->access_entry_count);
2607 pACE = &cifs_acl->ace_array[0]; 2607 pACE = &cifs_acl->ace_array[0];
2608 size = sizeof(struct cifs_posix_acl); 2608 size = sizeof(struct cifs_posix_acl);
2609 size += sizeof(struct cifs_posix_ace) * count; 2609 size += sizeof(struct cifs_posix_ace) * count;
2610 /* check if we would go beyond end of SMB */ 2610 /* check if we would go beyond end of SMB */
2611 if(size_of_data_area < size) { 2611 if (size_of_data_area < size) {
2612 cFYI(1,("bad CIFS POSIX ACL size %d vs. %d",size_of_data_area,size)); 2612 cFYI(1,("bad CIFS POSIX ACL size %d vs. %d",size_of_data_area,size));
2613 return -EINVAL; 2613 return -EINVAL;
2614 } 2614 }
2615 } else if(acl_type & ACL_TYPE_DEFAULT) { 2615 } else if (acl_type & ACL_TYPE_DEFAULT) {
2616 count = le16_to_cpu(cifs_acl->access_entry_count); 2616 count = le16_to_cpu(cifs_acl->access_entry_count);
2617 size = sizeof(struct cifs_posix_acl); 2617 size = sizeof(struct cifs_posix_acl);
2618 size += sizeof(struct cifs_posix_ace) * count; 2618 size += sizeof(struct cifs_posix_ace) * count;
@@ -2621,7 +2621,7 @@ static int cifs_copy_posix_acl(char * trgt,char * src, const int buflen,
2621 count = le16_to_cpu(cifs_acl->default_entry_count); 2621 count = le16_to_cpu(cifs_acl->default_entry_count);
2622 size += sizeof(struct cifs_posix_ace) * count; 2622 size += sizeof(struct cifs_posix_ace) * count;
2623 /* check if we would go beyond end of SMB */ 2623 /* check if we would go beyond end of SMB */
2624 if(size_of_data_area < size) 2624 if (size_of_data_area < size)
2625 return -EINVAL; 2625 return -EINVAL;
2626 } else { 2626 } else {
2627 /* illegal type */ 2627 /* illegal type */
@@ -2629,9 +2629,9 @@ static int cifs_copy_posix_acl(char * trgt,char * src, const int buflen,
2629 } 2629 }
2630 2630
2631 size = posix_acl_xattr_size(count); 2631 size = posix_acl_xattr_size(count);
2632 if((buflen == 0) || (local_acl == NULL)) { 2632 if ((buflen == 0) || (local_acl == NULL)) {
2633 /* used to query ACL EA size */ 2633 /* used to query ACL EA size */
2634 } else if(size > buflen) { 2634 } else if (size > buflen) {
2635 return -ERANGE; 2635 return -ERANGE;
2636 } else /* buffer big enough */ { 2636 } else /* buffer big enough */ {
2637 local_acl->a_version = cpu_to_le32(POSIX_ACL_XATTR_VERSION); 2637 local_acl->a_version = cpu_to_le32(POSIX_ACL_XATTR_VERSION);
@@ -2651,7 +2651,7 @@ static __u16 convert_ace_to_cifs_ace(struct cifs_posix_ace * cifs_ace,
2651 cifs_ace->cifs_e_perm = le16_to_cpu(local_ace->e_perm); 2651 cifs_ace->cifs_e_perm = le16_to_cpu(local_ace->e_perm);
2652 cifs_ace->cifs_e_tag = le16_to_cpu(local_ace->e_tag); 2652 cifs_ace->cifs_e_tag = le16_to_cpu(local_ace->e_tag);
2653 /* BB is there a better way to handle the large uid? */ 2653 /* BB is there a better way to handle the large uid? */
2654 if(local_ace->e_id == cpu_to_le32(-1)) { 2654 if (local_ace->e_id == cpu_to_le32(-1)) {
2655 /* Probably no need to le convert -1 on any arch but can not hurt */ 2655 /* Probably no need to le convert -1 on any arch but can not hurt */
2656 cifs_ace->cifs_uid = cpu_to_le64(-1); 2656 cifs_ace->cifs_uid = cpu_to_le64(-1);
2657 } else 2657 } else
@@ -2670,21 +2670,21 @@ static __u16 ACL_to_cifs_posix(char * parm_data,const char * pACL,const int bufl
2670 int count; 2670 int count;
2671 int i; 2671 int i;
2672 2672
2673 if((buflen == 0) || (pACL == NULL) || (cifs_acl == NULL)) 2673 if ((buflen == 0) || (pACL == NULL) || (cifs_acl == NULL))
2674 return 0; 2674 return 0;
2675 2675
2676 count = posix_acl_xattr_count((size_t)buflen); 2676 count = posix_acl_xattr_count((size_t)buflen);
2677 cFYI(1,("setting acl with %d entries from buf of length %d and version of %d", 2677 cFYI(1,("setting acl with %d entries from buf of length %d and version of %d",
2678 count, buflen, le32_to_cpu(local_acl->a_version))); 2678 count, buflen, le32_to_cpu(local_acl->a_version)));
2679 if(le32_to_cpu(local_acl->a_version) != 2) { 2679 if (le32_to_cpu(local_acl->a_version) != 2) {
2680 cFYI(1,("unknown POSIX ACL version %d", 2680 cFYI(1,("unknown POSIX ACL version %d",
2681 le32_to_cpu(local_acl->a_version))); 2681 le32_to_cpu(local_acl->a_version)));
2682 return 0; 2682 return 0;
2683 } 2683 }
2684 cifs_acl->version = cpu_to_le16(1); 2684 cifs_acl->version = cpu_to_le16(1);
2685 if(acl_type == ACL_TYPE_ACCESS) 2685 if (acl_type == ACL_TYPE_ACCESS)
2686 cifs_acl->access_entry_count = cpu_to_le16(count); 2686 cifs_acl->access_entry_count = cpu_to_le16(count);
2687 else if(acl_type == ACL_TYPE_DEFAULT) 2687 else if (acl_type == ACL_TYPE_DEFAULT)
2688 cifs_acl->default_entry_count = cpu_to_le16(count); 2688 cifs_acl->default_entry_count = cpu_to_le16(count);
2689 else { 2689 else {
2690 cFYI(1,("unknown ACL type %d",acl_type)); 2690 cFYI(1,("unknown ACL type %d",acl_type));
@@ -2693,12 +2693,12 @@ static __u16 ACL_to_cifs_posix(char * parm_data,const char * pACL,const int bufl
2693 for(i=0;i<count;i++) { 2693 for(i=0;i<count;i++) {
2694 rc = convert_ace_to_cifs_ace(&cifs_acl->ace_array[i], 2694 rc = convert_ace_to_cifs_ace(&cifs_acl->ace_array[i],
2695 &local_acl->a_entries[i]); 2695 &local_acl->a_entries[i]);
2696 if(rc != 0) { 2696 if (rc != 0) {
2697 /* ACE not converted */ 2697 /* ACE not converted */
2698 break; 2698 break;
2699 } 2699 }
2700 } 2700 }
2701 if(rc == 0) { 2701 if (rc == 0) {
2702 rc = (__u16)(count * sizeof(struct cifs_posix_ace)); 2702 rc = (__u16)(count * sizeof(struct cifs_posix_ace));
2703 rc += sizeof(struct cifs_posix_acl); 2703 rc += sizeof(struct cifs_posix_acl);
2704 /* BB add check to make sure ACL does not overflow SMB */ 2704 /* BB add check to make sure ACL does not overflow SMB */
@@ -2842,7 +2842,7 @@ setAclRetry:
2842 /* convert to on the wire format for POSIX ACL */ 2842 /* convert to on the wire format for POSIX ACL */
2843 data_count = ACL_to_cifs_posix(parm_data,local_acl,buflen,acl_type); 2843 data_count = ACL_to_cifs_posix(parm_data,local_acl,buflen,acl_type);
2844 2844
2845 if(data_count == 0) { 2845 if (data_count == 0) {
2846 rc = -EOPNOTSUPP; 2846 rc = -EOPNOTSUPP;
2847 goto setACLerrorExit; 2847 goto setACLerrorExit;
2848 } 2848 }
@@ -2883,78 +2883,77 @@ CIFSGetExtAttr(const int xid, struct cifsTconInfo *tcon,
2883 int bytes_returned; 2883 int bytes_returned;
2884 __u16 params, byte_count; 2884 __u16 params, byte_count;
2885 2885
2886 cFYI(1,("In GetExtAttr")); 2886 cFYI(1, ("In GetExtAttr"));
2887 if(tcon == NULL) 2887 if (tcon == NULL)
2888 return -ENODEV; 2888 return -ENODEV;
2889 2889
2890GetExtAttrRetry: 2890GetExtAttrRetry:
2891 rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB, 2891 rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB,
2892 (void **) &pSMBr); 2892 (void **) &pSMBr);
2893 if (rc) 2893 if (rc)
2894 return rc; 2894 return rc;
2895 2895
2896 params = 2 /* level */ +2 /* fid */; 2896 params = 2 /* level */ +2 /* fid */;
2897 pSMB->t2.TotalDataCount = 0; 2897 pSMB->t2.TotalDataCount = 0;
2898 pSMB->t2.MaxParameterCount = cpu_to_le16(4); 2898 pSMB->t2.MaxParameterCount = cpu_to_le16(4);
2899 /* BB find exact max data count below from sess structure BB */ 2899 /* BB find exact max data count below from sess structure BB */
2900 pSMB->t2.MaxDataCount = cpu_to_le16(4000); 2900 pSMB->t2.MaxDataCount = cpu_to_le16(4000);
2901 pSMB->t2.MaxSetupCount = 0; 2901 pSMB->t2.MaxSetupCount = 0;
2902 pSMB->t2.Reserved = 0; 2902 pSMB->t2.Reserved = 0;
2903 pSMB->t2.Flags = 0; 2903 pSMB->t2.Flags = 0;
2904 pSMB->t2.Timeout = 0; 2904 pSMB->t2.Timeout = 0;
2905 pSMB->t2.Reserved2 = 0; 2905 pSMB->t2.Reserved2 = 0;
2906 pSMB->t2.ParameterOffset = cpu_to_le16(offsetof(struct smb_t2_qfi_req, 2906 pSMB->t2.ParameterOffset = cpu_to_le16(offsetof(struct smb_t2_qfi_req,
2907 Fid) - 4); 2907 Fid) - 4);
2908 pSMB->t2.DataCount = 0; 2908 pSMB->t2.DataCount = 0;
2909 pSMB->t2.DataOffset = 0; 2909 pSMB->t2.DataOffset = 0;
2910 pSMB->t2.SetupCount = 1; 2910 pSMB->t2.SetupCount = 1;
2911 pSMB->t2.Reserved3 = 0; 2911 pSMB->t2.Reserved3 = 0;
2912 pSMB->t2.SubCommand = cpu_to_le16(TRANS2_QUERY_FILE_INFORMATION); 2912 pSMB->t2.SubCommand = cpu_to_le16(TRANS2_QUERY_FILE_INFORMATION);
2913 byte_count = params + 1 /* pad */ ; 2913 byte_count = params + 1 /* pad */ ;
2914 pSMB->t2.TotalParameterCount = cpu_to_le16(params); 2914 pSMB->t2.TotalParameterCount = cpu_to_le16(params);
2915 pSMB->t2.ParameterCount = pSMB->t2.TotalParameterCount; 2915 pSMB->t2.ParameterCount = pSMB->t2.TotalParameterCount;
2916 pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_ATTR_FLAGS); 2916 pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_ATTR_FLAGS);
2917 pSMB->Pad = 0; 2917 pSMB->Pad = 0;
2918 pSMB->Fid = netfid; 2918 pSMB->Fid = netfid;
2919 pSMB->hdr.smb_buf_length += byte_count; 2919 pSMB->hdr.smb_buf_length += byte_count;
2920 pSMB->t2.ByteCount = cpu_to_le16(byte_count); 2920 pSMB->t2.ByteCount = cpu_to_le16(byte_count);
2921 2921
2922 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, 2922 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
2923 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 2923 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
2924 if (rc) { 2924 if (rc) {
2925 cFYI(1, ("error %d in GetExtAttr", rc)); 2925 cFYI(1, ("error %d in GetExtAttr", rc));
2926 } else { 2926 } else {
2927 /* decode response */ 2927 /* decode response */
2928 rc = validate_t2((struct smb_t2_rsp *)pSMBr); 2928 rc = validate_t2((struct smb_t2_rsp *)pSMBr);
2929 if (rc || (pSMBr->ByteCount < 2)) 2929 if (rc || (pSMBr->ByteCount < 2))
2930 /* BB also check enough total bytes returned */ 2930 /* BB also check enough total bytes returned */
2931 /* If rc should we check for EOPNOSUPP and 2931 /* If rc should we check for EOPNOSUPP and
2932 disable the srvino flag? or in caller? */ 2932 disable the srvino flag? or in caller? */
2933 rc = -EIO; /* bad smb */ 2933 rc = -EIO; /* bad smb */
2934 else { 2934 else {
2935 __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset); 2935 __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
2936 __u16 count = le16_to_cpu(pSMBr->t2.DataCount); 2936 __u16 count = le16_to_cpu(pSMBr->t2.DataCount);
2937 struct file_chattr_info * pfinfo; 2937 struct file_chattr_info *pfinfo;
2938 /* BB Do we need a cast or hash here ? */ 2938 /* BB Do we need a cast or hash here ? */
2939 if(count != 16) { 2939 if (count != 16) {
2940 cFYI(1, ("Illegal size ret in GetExtAttr")); 2940 cFYI(1, ("Illegal size ret in GetExtAttr"));
2941 rc = -EIO; 2941 rc = -EIO;
2942 goto GetExtAttrOut; 2942 goto GetExtAttrOut;
2943 } 2943 }
2944 pfinfo = (struct file_chattr_info *) 2944 pfinfo = (struct file_chattr_info *)
2945 (data_offset + (char *) &pSMBr->hdr.Protocol); 2945 (data_offset + (char *) &pSMBr->hdr.Protocol);
2946 *pExtAttrBits = le64_to_cpu(pfinfo->mode); 2946 *pExtAttrBits = le64_to_cpu(pfinfo->mode);
2947 *pMask = le64_to_cpu(pfinfo->mask); 2947 *pMask = le64_to_cpu(pfinfo->mask);
2948 } 2948 }
2949 } 2949 }
2950GetExtAttrOut: 2950GetExtAttrOut:
2951 cifs_buf_release(pSMB); 2951 cifs_buf_release(pSMB);
2952 if (rc == -EAGAIN) 2952 if (rc == -EAGAIN)
2953 goto GetExtAttrRetry; 2953 goto GetExtAttrRetry;
2954 return rc; 2954 return rc;
2955} 2955}
2956 2956
2957
2958#endif /* CONFIG_POSIX */ 2957#endif /* CONFIG_POSIX */
2959 2958
2960 2959
@@ -3017,7 +3016,7 @@ CIFSSMBGetCIFSACL(const int xid, struct cifsTconInfo *tcon, __u16 fid,
3017 (char **)&psec_desc, 3016 (char **)&psec_desc,
3018 &parm_len, &data_len); 3017 &parm_len, &data_len);
3019 3018
3020 if(rc) 3019 if (rc)
3021 goto qsec_out; 3020 goto qsec_out;
3022 pSMBr = (struct smb_com_ntransact_rsp *)iov[0].iov_base; 3021 pSMBr = (struct smb_com_ntransact_rsp *)iov[0].iov_base;
3023 3022
@@ -3031,14 +3030,14 @@ CIFSSMBGetCIFSACL(const int xid, struct cifsTconInfo *tcon, __u16 fid,
3031/* BB check that data area is minimum length and as big as acl_len */ 3030/* BB check that data area is minimum length and as big as acl_len */
3032 3031
3033 acl_len = le32_to_cpu(*(__le32 *)parm); 3032 acl_len = le32_to_cpu(*(__le32 *)parm);
3034 /* BB check if(acl_len > bufsize) */ 3033 /* BB check if (acl_len > bufsize) */
3035 3034
3036 parse_sec_desc(psec_desc, acl_len); 3035 parse_sec_desc(psec_desc, acl_len);
3037 } 3036 }
3038qsec_out: 3037qsec_out:
3039 if(buf_type == CIFS_SMALL_BUFFER) 3038 if (buf_type == CIFS_SMALL_BUFFER)
3040 cifs_small_buf_release(iov[0].iov_base); 3039 cifs_small_buf_release(iov[0].iov_base);
3041 else if(buf_type == CIFS_LARGE_BUFFER) 3040 else if (buf_type == CIFS_LARGE_BUFFER)
3042 cifs_buf_release(iov[0].iov_base); 3041 cifs_buf_release(iov[0].iov_base);
3043/* cifs_small_buf_release(pSMB); */ /* Freed earlier now in SendReceive2 */ 3042/* cifs_small_buf_release(pSMB); */ /* Freed earlier now in SendReceive2 */
3044 return rc; 3043 return rc;
@@ -3167,7 +3166,7 @@ QPathInfoRetry:
3167 byte_count = params + 1 /* pad */ ; 3166 byte_count = params + 1 /* pad */ ;
3168 pSMB->TotalParameterCount = cpu_to_le16(params); 3167 pSMB->TotalParameterCount = cpu_to_le16(params);
3169 pSMB->ParameterCount = pSMB->TotalParameterCount; 3168 pSMB->ParameterCount = pSMB->TotalParameterCount;
3170 if(legacy) 3169 if (legacy)
3171 pSMB->InformationLevel = cpu_to_le16(SMB_INFO_STANDARD); 3170 pSMB->InformationLevel = cpu_to_le16(SMB_INFO_STANDARD);
3172 else 3171 else
3173 pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_FILE_ALL_INFO); 3172 pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_FILE_ALL_INFO);
@@ -3186,14 +3185,15 @@ QPathInfoRetry:
3186 rc = -EIO; 3185 rc = -EIO;
3187 else if (!legacy && (pSMBr->ByteCount < 40)) 3186 else if (!legacy && (pSMBr->ByteCount < 40))
3188 rc = -EIO; /* bad smb */ 3187 rc = -EIO; /* bad smb */
3189 else if(legacy && (pSMBr->ByteCount < 24)) 3188 else if (legacy && (pSMBr->ByteCount < 24))
3190 rc = -EIO; /* 24 or 26 expected but we do not read last field */ 3189 rc = -EIO; /* 24 or 26 expected but we do not read last field */
3191 else if (pFindData){ 3190 else if (pFindData){
3192 int size; 3191 int size;
3193 __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset); 3192 __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
3194 if(legacy) /* we do not read the last field, EAsize, fortunately 3193 if (legacy) /* we do not read the last field, EAsize,
3195 since it varies by subdialect and on Set vs. Get, is 3194 fortunately since it varies by subdialect
3196 two bytes or 4 bytes depending but we don't care here */ 3195 and on Set vs. Get, is two bytes or 4
3196 bytes depending but we don't care here */
3197 size = sizeof(FILE_INFO_STANDARD); 3197 size = sizeof(FILE_INFO_STANDARD);
3198 else 3198 else
3199 size = sizeof(FILE_ALL_INFO); 3199 size = sizeof(FILE_ALL_INFO);
@@ -3416,7 +3416,7 @@ findFirstRetry:
3416 } else { /* BB add check for overrun of SMB buf BB */ 3416 } else { /* BB add check for overrun of SMB buf BB */
3417 name_len = strnlen(searchName, PATH_MAX); 3417 name_len = strnlen(searchName, PATH_MAX);
3418/* BB fix here and in unicode clause above ie 3418/* BB fix here and in unicode clause above ie
3419 if(name_len > buffersize-header) 3419 if (name_len > buffersize-header)
3420 free buffer exit; BB */ 3420 free buffer exit; BB */
3421 strncpy(pSMB->FileName, searchName, name_len); 3421 strncpy(pSMB->FileName, searchName, name_len);
3422 pSMB->FileName[name_len] = dirsep; 3422 pSMB->FileName[name_len] = dirsep;
@@ -3477,7 +3477,7 @@ findFirstRetry:
3477 } else { /* decode response */ 3477 } else { /* decode response */
3478 /* BB remember to free buffer if error BB */ 3478 /* BB remember to free buffer if error BB */
3479 rc = validate_t2((struct smb_t2_rsp *)pSMBr); 3479 rc = validate_t2((struct smb_t2_rsp *)pSMBr);
3480 if(rc == 0) { 3480 if (rc == 0) {
3481 if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE) 3481 if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE)
3482 psrch_inf->unicode = TRUE; 3482 psrch_inf->unicode = TRUE;
3483 else 3483 else
@@ -3491,7 +3491,7 @@ findFirstRetry:
3491 parms = (T2_FFIRST_RSP_PARMS *)((char *) &pSMBr->hdr.Protocol + 3491 parms = (T2_FFIRST_RSP_PARMS *)((char *) &pSMBr->hdr.Protocol +
3492 le16_to_cpu(pSMBr->t2.ParameterOffset)); 3492 le16_to_cpu(pSMBr->t2.ParameterOffset));
3493 3493
3494 if(parms->EndofSearch) 3494 if (parms->EndofSearch)
3495 psrch_inf->endOfSearch = TRUE; 3495 psrch_inf->endOfSearch = TRUE;
3496 else 3496 else
3497 psrch_inf->endOfSearch = FALSE; 3497 psrch_inf->endOfSearch = FALSE;
@@ -3521,7 +3521,7 @@ int CIFSFindNext(const int xid, struct cifsTconInfo *tcon,
3521 3521
3522 cFYI(1, ("In FindNext")); 3522 cFYI(1, ("In FindNext"));
3523 3523
3524 if(psrch_inf->endOfSearch == TRUE) 3524 if (psrch_inf->endOfSearch == TRUE)
3525 return -ENOENT; 3525 return -ENOENT;
3526 3526
3527 rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB, 3527 rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB,
@@ -3566,7 +3566,7 @@ int CIFSFindNext(const int xid, struct cifsTconInfo *tcon,
3566 3566
3567 name_len = psrch_inf->resume_name_len; 3567 name_len = psrch_inf->resume_name_len;
3568 params += name_len; 3568 params += name_len;
3569 if(name_len < PATH_MAX) { 3569 if (name_len < PATH_MAX) {
3570 memcpy(pSMB->ResumeFileName, psrch_inf->presume_name, name_len); 3570 memcpy(pSMB->ResumeFileName, psrch_inf->presume_name, name_len);
3571 byte_count += name_len; 3571 byte_count += name_len;
3572 /* 14 byte parm len above enough for 2 byte null terminator */ 3572 /* 14 byte parm len above enough for 2 byte null terminator */
@@ -3594,7 +3594,7 @@ int CIFSFindNext(const int xid, struct cifsTconInfo *tcon,
3594 } else { /* decode response */ 3594 } else { /* decode response */
3595 rc = validate_t2((struct smb_t2_rsp *)pSMBr); 3595 rc = validate_t2((struct smb_t2_rsp *)pSMBr);
3596 3596
3597 if(rc == 0) { 3597 if (rc == 0) {
3598 /* BB fixme add lock for file (srch_info) struct here */ 3598 /* BB fixme add lock for file (srch_info) struct here */
3599 if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE) 3599 if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE)
3600 psrch_inf->unicode = TRUE; 3600 psrch_inf->unicode = TRUE;
@@ -3605,7 +3605,7 @@ int CIFSFindNext(const int xid, struct cifsTconInfo *tcon,
3605 parms = (T2_FNEXT_RSP_PARMS *)response_data; 3605 parms = (T2_FNEXT_RSP_PARMS *)response_data;
3606 response_data = (char *)&pSMBr->hdr.Protocol + 3606 response_data = (char *)&pSMBr->hdr.Protocol +
3607 le16_to_cpu(pSMBr->t2.DataOffset); 3607 le16_to_cpu(pSMBr->t2.DataOffset);
3608 if(psrch_inf->smallBuf) 3608 if (psrch_inf->smallBuf)
3609 cifs_small_buf_release( 3609 cifs_small_buf_release(
3610 psrch_inf->ntwrk_buf_start); 3610 psrch_inf->ntwrk_buf_start);
3611 else 3611 else
@@ -3613,7 +3613,7 @@ int CIFSFindNext(const int xid, struct cifsTconInfo *tcon,
3613 psrch_inf->srch_entries_start = response_data; 3613 psrch_inf->srch_entries_start = response_data;
3614 psrch_inf->ntwrk_buf_start = (char *)pSMB; 3614 psrch_inf->ntwrk_buf_start = (char *)pSMB;
3615 psrch_inf->smallBuf = 0; 3615 psrch_inf->smallBuf = 0;
3616 if(parms->EndofSearch) 3616 if (parms->EndofSearch)
3617 psrch_inf->endOfSearch = TRUE; 3617 psrch_inf->endOfSearch = TRUE;
3618 else 3618 else
3619 psrch_inf->endOfSearch = FALSE; 3619 psrch_inf->endOfSearch = FALSE;
@@ -3653,7 +3653,7 @@ CIFSFindClose(const int xid, struct cifsTconInfo *tcon, const __u16 searchHandle
3653 3653
3654 /* no sense returning error if session restarted 3654 /* no sense returning error if session restarted
3655 as file handle has been closed */ 3655 as file handle has been closed */
3656 if(rc == -EAGAIN) 3656 if (rc == -EAGAIN)
3657 return 0; 3657 return 0;
3658 if (rc) 3658 if (rc)
3659 return rc; 3659 return rc;
@@ -3689,7 +3689,7 @@ CIFSGetSrvInodeNumber(const int xid, struct cifsTconInfo *tcon,
3689 __u16 params, byte_count; 3689 __u16 params, byte_count;
3690 3690
3691 cFYI(1,("In GetSrvInodeNum for %s",searchName)); 3691 cFYI(1,("In GetSrvInodeNum for %s",searchName));
3692 if(tcon == NULL) 3692 if (tcon == NULL)
3693 return -ENODEV; 3693 return -ENODEV;
3694 3694
3695GetInodeNumberRetry: 3695GetInodeNumberRetry:
@@ -3753,7 +3753,7 @@ GetInodeNumberRetry:
3753 __u16 count = le16_to_cpu(pSMBr->t2.DataCount); 3753 __u16 count = le16_to_cpu(pSMBr->t2.DataCount);
3754 struct file_internal_info * pfinfo; 3754 struct file_internal_info * pfinfo;
3755 /* BB Do we need a cast or hash here ? */ 3755 /* BB Do we need a cast or hash here ? */
3756 if(count < 8) { 3756 if (count < 8) {
3757 cFYI(1, ("Illegal size ret in QryIntrnlInf")); 3757 cFYI(1, ("Illegal size ret in QryIntrnlInf"));
3758 rc = -EIO; 3758 rc = -EIO;
3759 goto GetInodeNumOut; 3759 goto GetInodeNumOut;
@@ -3824,8 +3824,8 @@ getDFSRetry:
3824 strncpy(pSMB->RequestFileName, searchName, name_len); 3824 strncpy(pSMB->RequestFileName, searchName, name_len);
3825 } 3825 }
3826 3826
3827 if(ses->server) { 3827 if (ses->server) {
3828 if(ses->server->secMode & 3828 if (ses->server->secMode &
3829 (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) 3829 (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED))
3830 pSMB->hdr.Flags2 |= SMBFLG2_SECURITY_SIGNATURE; 3830 pSMB->hdr.Flags2 |= SMBFLG2_SECURITY_SIGNATURE;
3831 } 3831 }
@@ -3885,7 +3885,7 @@ getDFSRetry:
3885 *number_of_UNC_in_array = le16_to_cpu(pSMBr->NumberOfReferrals); 3885 *number_of_UNC_in_array = le16_to_cpu(pSMBr->NumberOfReferrals);
3886 3886
3887 /* BB Fix below so can return more than one referral */ 3887 /* BB Fix below so can return more than one referral */
3888 if(*number_of_UNC_in_array > 1) 3888 if (*number_of_UNC_in_array > 1)
3889 *number_of_UNC_in_array = 1; 3889 *number_of_UNC_in_array = 1;
3890 3890
3891 /* get the length of the strings describing refs */ 3891 /* get the length of the strings describing refs */
@@ -3913,7 +3913,7 @@ getDFSRetry:
3913 /* BB add check for name_len bigger than bcc */ 3913 /* BB add check for name_len bigger than bcc */
3914 *targetUNCs = 3914 *targetUNCs =
3915 kmalloc(name_len+1+ (*number_of_UNC_in_array),GFP_KERNEL); 3915 kmalloc(name_len+1+ (*number_of_UNC_in_array),GFP_KERNEL);
3916 if(*targetUNCs == NULL) { 3916 if (*targetUNCs == NULL) {
3917 rc = -ENOMEM; 3917 rc = -ENOMEM;
3918 goto GetDFSRefExit; 3918 goto GetDFSRefExit;
3919 } 3919 }
@@ -4458,16 +4458,16 @@ QFSPosixRetry:
4458 le64_to_cpu(response_data->TotalBlocks); 4458 le64_to_cpu(response_data->TotalBlocks);
4459 FSData->f_bfree = 4459 FSData->f_bfree =
4460 le64_to_cpu(response_data->BlocksAvail); 4460 le64_to_cpu(response_data->BlocksAvail);
4461 if(response_data->UserBlocksAvail == cpu_to_le64(-1)) { 4461 if (response_data->UserBlocksAvail == cpu_to_le64(-1)) {
4462 FSData->f_bavail = FSData->f_bfree; 4462 FSData->f_bavail = FSData->f_bfree;
4463 } else { 4463 } else {
4464 FSData->f_bavail = 4464 FSData->f_bavail =
4465 le64_to_cpu(response_data->UserBlocksAvail); 4465 le64_to_cpu(response_data->UserBlocksAvail);
4466 } 4466 }
4467 if(response_data->TotalFileNodes != cpu_to_le64(-1)) 4467 if (response_data->TotalFileNodes != cpu_to_le64(-1))
4468 FSData->f_files = 4468 FSData->f_files =
4469 le64_to_cpu(response_data->TotalFileNodes); 4469 le64_to_cpu(response_data->TotalFileNodes);
4470 if(response_data->FreeFileNodes != cpu_to_le64(-1)) 4470 if (response_data->FreeFileNodes != cpu_to_le64(-1))
4471 FSData->f_ffree = 4471 FSData->f_ffree =
4472 le64_to_cpu(response_data->FreeFileNodes); 4472 le64_to_cpu(response_data->FreeFileNodes);
4473 } 4473 }
@@ -4530,7 +4530,7 @@ SetEOFRetry:
4530 param_offset = offsetof(struct smb_com_transaction2_spi_req, 4530 param_offset = offsetof(struct smb_com_transaction2_spi_req,
4531 InformationLevel) - 4; 4531 InformationLevel) - 4;
4532 offset = param_offset + params; 4532 offset = param_offset + params;
4533 if(SetAllocation) { 4533 if (SetAllocation) {
4534 if (tcon->ses->capabilities & CAP_INFOLEVEL_PASSTHRU) 4534 if (tcon->ses->capabilities & CAP_INFOLEVEL_PASSTHRU)
4535 pSMB->InformationLevel = 4535 pSMB->InformationLevel =
4536 cpu_to_le16(SMB_SET_FILE_ALLOCATION_INFO2); 4536 cpu_to_le16(SMB_SET_FILE_ALLOCATION_INFO2);
@@ -4630,7 +4630,7 @@ CIFSSMBSetFileSize(const int xid, struct cifsTconInfo *tcon, __u64 size,
4630 pSMB->DataOffset = cpu_to_le16(offset); 4630 pSMB->DataOffset = cpu_to_le16(offset);
4631 parm_data->FileSize = cpu_to_le64(size); 4631 parm_data->FileSize = cpu_to_le64(size);
4632 pSMB->Fid = fid; 4632 pSMB->Fid = fid;
4633 if(SetAllocation) { 4633 if (SetAllocation) {
4634 if (tcon->ses->capabilities & CAP_INFOLEVEL_PASSTHRU) 4634 if (tcon->ses->capabilities & CAP_INFOLEVEL_PASSTHRU)
4635 pSMB->InformationLevel = 4635 pSMB->InformationLevel =
4636 cpu_to_le16(SMB_SET_FILE_ALLOCATION_INFO2); 4636 cpu_to_le16(SMB_SET_FILE_ALLOCATION_INFO2);
@@ -4955,19 +4955,19 @@ setPermsRetry:
4955 data_offset->DevMinor = cpu_to_le64(MINOR(device)); 4955 data_offset->DevMinor = cpu_to_le64(MINOR(device));
4956 data_offset->Permissions = cpu_to_le64(mode); 4956 data_offset->Permissions = cpu_to_le64(mode);
4957 4957
4958 if(S_ISREG(mode)) 4958 if (S_ISREG(mode))
4959 data_offset->Type = cpu_to_le32(UNIX_FILE); 4959 data_offset->Type = cpu_to_le32(UNIX_FILE);
4960 else if(S_ISDIR(mode)) 4960 else if (S_ISDIR(mode))
4961 data_offset->Type = cpu_to_le32(UNIX_DIR); 4961 data_offset->Type = cpu_to_le32(UNIX_DIR);
4962 else if(S_ISLNK(mode)) 4962 else if (S_ISLNK(mode))
4963 data_offset->Type = cpu_to_le32(UNIX_SYMLINK); 4963 data_offset->Type = cpu_to_le32(UNIX_SYMLINK);
4964 else if(S_ISCHR(mode)) 4964 else if (S_ISCHR(mode))
4965 data_offset->Type = cpu_to_le32(UNIX_CHARDEV); 4965 data_offset->Type = cpu_to_le32(UNIX_CHARDEV);
4966 else if(S_ISBLK(mode)) 4966 else if (S_ISBLK(mode))
4967 data_offset->Type = cpu_to_le32(UNIX_BLOCKDEV); 4967 data_offset->Type = cpu_to_le32(UNIX_BLOCKDEV);
4968 else if(S_ISFIFO(mode)) 4968 else if (S_ISFIFO(mode))
4969 data_offset->Type = cpu_to_le32(UNIX_FIFO); 4969 data_offset->Type = cpu_to_le32(UNIX_FIFO);
4970 else if(S_ISSOCK(mode)) 4970 else if (S_ISSOCK(mode))
4971 data_offset->Type = cpu_to_le32(UNIX_SOCKET); 4971 data_offset->Type = cpu_to_le32(UNIX_SOCKET);
4972 4972
4973 4973
@@ -5019,7 +5019,7 @@ int CIFSSMBNotify(const int xid, struct cifsTconInfo *tcon,
5019 pSMB->SetupCount = 4; /* single byte does not need le conversion */ 5019 pSMB->SetupCount = 4; /* single byte does not need le conversion */
5020 pSMB->SubCommand = cpu_to_le16(NT_TRANSACT_NOTIFY_CHANGE); 5020 pSMB->SubCommand = cpu_to_le16(NT_TRANSACT_NOTIFY_CHANGE);
5021 pSMB->ParameterCount = pSMB->TotalParameterCount; 5021 pSMB->ParameterCount = pSMB->TotalParameterCount;
5022 if(notify_subdirs) 5022 if (notify_subdirs)
5023 pSMB->WatchTree = 1; /* one byte - no le conversion needed */ 5023 pSMB->WatchTree = 1; /* one byte - no le conversion needed */
5024 pSMB->Reserved2 = 0; 5024 pSMB->Reserved2 = 0;
5025 pSMB->CompletionFilter = cpu_to_le32(filter); 5025 pSMB->CompletionFilter = cpu_to_le32(filter);
@@ -5036,7 +5036,7 @@ int CIFSSMBNotify(const int xid, struct cifsTconInfo *tcon,
5036 dnotify_req = kmalloc( 5036 dnotify_req = kmalloc(
5037 sizeof(struct dir_notify_req), 5037 sizeof(struct dir_notify_req),
5038 GFP_KERNEL); 5038 GFP_KERNEL);
5039 if(dnotify_req) { 5039 if (dnotify_req) {
5040 dnotify_req->Pid = pSMB->hdr.Pid; 5040 dnotify_req->Pid = pSMB->hdr.Pid;
5041 dnotify_req->PidHigh = pSMB->hdr.PidHigh; 5041 dnotify_req->PidHigh = pSMB->hdr.PidHigh;
5042 dnotify_req->Mid = pSMB->hdr.Mid; 5042 dnotify_req->Mid = pSMB->hdr.Mid;
@@ -5142,13 +5142,13 @@ QAllEAsRetry:
5142 struct fealist * ea_response_data; 5142 struct fealist * ea_response_data;
5143 rc = 0; 5143 rc = 0;
5144 /* validate_trans2_offsets() */ 5144 /* validate_trans2_offsets() */
5145 /* BB to check if(start of smb + data_offset > &bcc+ bcc)*/ 5145 /* BB check if start of smb + data_offset > &bcc+ bcc */
5146 ea_response_data = (struct fealist *) 5146 ea_response_data = (struct fealist *)
5147 (((char *) &pSMBr->hdr.Protocol) + 5147 (((char *) &pSMBr->hdr.Protocol) +
5148 data_offset); 5148 data_offset);
5149 name_len = le32_to_cpu(ea_response_data->list_len); 5149 name_len = le32_to_cpu(ea_response_data->list_len);
5150 cFYI(1,("ea length %d", name_len)); 5150 cFYI(1,("ea length %d", name_len));
5151 if(name_len <= 8) { 5151 if (name_len <= 8) {
5152 /* returned EA size zeroed at top of function */ 5152 /* returned EA size zeroed at top of function */
5153 cFYI(1,("empty EA list returned from server")); 5153 cFYI(1,("empty EA list returned from server"));
5154 } else { 5154 } else {
@@ -5162,8 +5162,8 @@ QAllEAsRetry:
5162 temp_ptr += 4; 5162 temp_ptr += 4;
5163 rc += temp_fea->name_len; 5163 rc += temp_fea->name_len;
5164 /* account for prefix user. and trailing null */ 5164 /* account for prefix user. and trailing null */
5165 rc = rc + 5 + 1; 5165 rc = rc + 5 + 1;
5166 if(rc<(int)buf_size) { 5166 if (rc < (int)buf_size) {
5167 memcpy(EAData,"user.",5); 5167 memcpy(EAData,"user.",5);
5168 EAData+=5; 5168 EAData+=5;
5169 memcpy(EAData,temp_ptr,temp_fea->name_len); 5169 memcpy(EAData,temp_ptr,temp_fea->name_len);
@@ -5171,7 +5171,7 @@ QAllEAsRetry:
5171 /* null terminate name */ 5171 /* null terminate name */
5172 *EAData = 0; 5172 *EAData = 0;
5173 EAData = EAData + 1; 5173 EAData = EAData + 1;
5174 } else if(buf_size == 0) { 5174 } else if (buf_size == 0) {
5175 /* skip copy - calc size only */ 5175 /* skip copy - calc size only */
5176 } else { 5176 } else {
5177 /* stop before overrun buffer */ 5177 /* stop before overrun buffer */
@@ -5285,13 +5285,13 @@ QEARetry:
5285 struct fealist * ea_response_data; 5285 struct fealist * ea_response_data;
5286 rc = -ENODATA; 5286 rc = -ENODATA;
5287 /* validate_trans2_offsets() */ 5287 /* validate_trans2_offsets() */
5288 /* BB to check if(start of smb + data_offset > &bcc+ bcc)*/ 5288 /* BB check if start of smb + data_offset > &bcc+ bcc*/
5289 ea_response_data = (struct fealist *) 5289 ea_response_data = (struct fealist *)
5290 (((char *) &pSMBr->hdr.Protocol) + 5290 (((char *) &pSMBr->hdr.Protocol) +
5291 data_offset); 5291 data_offset);
5292 name_len = le32_to_cpu(ea_response_data->list_len); 5292 name_len = le32_to_cpu(ea_response_data->list_len);
5293 cFYI(1,("ea length %d", name_len)); 5293 cFYI(1,("ea length %d", name_len));
5294 if(name_len <= 8) { 5294 if (name_len <= 8) {
5295 /* returned EA size zeroed at top of function */ 5295 /* returned EA size zeroed at top of function */
5296 cFYI(1,("empty EA list returned from server")); 5296 cFYI(1,("empty EA list returned from server"));
5297 } else { 5297 } else {
@@ -5308,18 +5308,18 @@ QEARetry:
5308 value_len = le16_to_cpu(temp_fea->value_len); 5308 value_len = le16_to_cpu(temp_fea->value_len);
5309 /* BB validate that value_len falls within SMB, 5309 /* BB validate that value_len falls within SMB,
5310 even though maximum for name_len is 255 */ 5310 even though maximum for name_len is 255 */
5311 if(memcmp(temp_fea->name,ea_name, 5311 if (memcmp(temp_fea->name, ea_name,
5312 temp_fea->name_len) == 0) { 5312 temp_fea->name_len) == 0) {
5313 /* found a match */ 5313 /* found a match */
5314 rc = value_len; 5314 rc = value_len;
5315 /* account for prefix user. and trailing null */ 5315 /* account for prefix user. and trailing null */
5316 if(rc<=(int)buf_size) { 5316 if (rc <= (int)buf_size) {
5317 memcpy(ea_value, 5317 memcpy(ea_value,
5318 temp_fea->name+temp_fea->name_len+1, 5318 temp_fea->name+temp_fea->name_len+1,
5319 rc); 5319 rc);
5320 /* ea values, unlike ea names, 5320 /* ea values, unlike ea names,
5321 are not null terminated */ 5321 are not null terminated */
5322 } else if(buf_size == 0) { 5322 } else if (buf_size == 0) {
5323 /* skip copy - calc size only */ 5323 /* skip copy - calc size only */
5324 } else { 5324 } else {
5325 /* stop before overrun buffer */ 5325 /* stop before overrun buffer */
@@ -5387,7 +5387,7 @@ SetEARetry:
5387 /* done calculating parms using name_len of file name, 5387 /* done calculating parms using name_len of file name,
5388 now use name_len to calculate length of ea name 5388 now use name_len to calculate length of ea name
5389 we are going to create in the inode xattrs */ 5389 we are going to create in the inode xattrs */
5390 if(ea_name == NULL) 5390 if (ea_name == NULL)
5391 name_len = 0; 5391 name_len = 0;
5392 else 5392 else
5393 name_len = strnlen(ea_name,255); 5393 name_len = strnlen(ea_name,255);
@@ -5421,7 +5421,7 @@ SetEARetry:
5421 /* we checked above that name len is less than 255 */ 5421 /* we checked above that name len is less than 255 */
5422 parm_data->list[0].name_len = (__u8)name_len; 5422 parm_data->list[0].name_len = (__u8)name_len;
5423 /* EA names are always ASCII */ 5423 /* EA names are always ASCII */
5424 if(ea_name) 5424 if (ea_name)
5425 strncpy(parm_data->list[0].name,ea_name,name_len); 5425 strncpy(parm_data->list[0].name,ea_name,name_len);
5426 parm_data->list[0].name[name_len] = 0; 5426 parm_data->list[0].name[name_len] = 0;
5427 parm_data->list[0].value_len = cpu_to_le16(ea_value_len); 5427 parm_data->list[0].value_len = cpu_to_le16(ea_value_len);
@@ -5429,8 +5429,8 @@ SetEARetry:
5429 we need to ensure that it fits within the smb */ 5429 we need to ensure that it fits within the smb */
5430 5430
5431 /*BB add length check that it would fit in negotiated SMB buffer size BB */ 5431 /*BB add length check that it would fit in negotiated SMB buffer size BB */
5432 /* if(ea_value_len > buffer_size - 512 (enough for header)) */ 5432 /* if (ea_value_len > buffer_size - 512 (enough for header)) */
5433 if(ea_value_len) 5433 if (ea_value_len)
5434 memcpy(parm_data->list[0].name+name_len+1,ea_value,ea_value_len); 5434 memcpy(parm_data->list[0].name+name_len+1,ea_value,ea_value_len);
5435 5435
5436 pSMB->TotalDataCount = pSMB->DataCount; 5436 pSMB->TotalDataCount = pSMB->DataCount;