1 // SPDX-License-Identifier: GPL-2.0-only 2 /* 3 * SMB1 (CIFS) version specific operations 4 * 5 * Copyright (c) 2012, Jeff Layton <jlayton@redhat.com> 6 */ 7 8 #include <linux/pagemap.h> 9 #include <linux/vfs.h> 10 #include <uapi/linux/magic.h> 11 #include "cifsglob.h" 12 #include "cifsproto.h" 13 #include "cifs_debug.h" 14 #include "cifspdu.h" 15 #include "cifs_unicode.h" 16 #include "fs_context.h" 17 #include "nterr.h" 18 #include "smberr.h" 19 20 /* 21 * An NT cancel request header looks just like the original request except: 22 * 23 * The Command is SMB_COM_NT_CANCEL 24 * The WordCount is zeroed out 25 * The ByteCount is zeroed out 26 * 27 * This function mangles an existing request buffer into a 28 * SMB_COM_NT_CANCEL request and then sends it. 29 */ 30 static int 31 send_nt_cancel(struct TCP_Server_Info *server, struct smb_rqst *rqst, 32 struct mid_q_entry *mid) 33 { 34 int rc = 0; 35 struct smb_hdr *in_buf = (struct smb_hdr *)rqst->rq_iov[0].iov_base; 36 37 /* -4 for RFC1001 length and +2 for BCC field */ 38 in_buf->smb_buf_length = cpu_to_be32(sizeof(struct smb_hdr) - 4 + 2); 39 in_buf->Command = SMB_COM_NT_CANCEL; 40 in_buf->WordCount = 0; 41 put_bcc(0, in_buf); 42 43 cifs_server_lock(server); 44 rc = cifs_sign_smb(in_buf, server, &mid->sequence_number); 45 if (rc) { 46 cifs_server_unlock(server); 47 return rc; 48 } 49 50 /* 51 * The response to this call was already factored into the sequence 52 * number when the call went out, so we must adjust it back downward 53 * after signing here. 54 */ 55 --server->sequence_number; 56 rc = smb_send(server, in_buf, be32_to_cpu(in_buf->smb_buf_length)); 57 if (rc < 0) 58 server->sequence_number--; 59 60 cifs_server_unlock(server); 61 62 cifs_dbg(FYI, "issued NT_CANCEL for mid %u, rc = %d\n", 63 get_mid(in_buf), rc); 64 65 return rc; 66 } 67 68 static bool 69 cifs_compare_fids(struct cifsFileInfo *ob1, struct cifsFileInfo *ob2) 70 { 71 return ob1->fid.netfid == ob2->fid.netfid; 72 } 73 74 static unsigned int 75 cifs_read_data_offset(char *buf) 76 { 77 READ_RSP *rsp = (READ_RSP *)buf; 78 return le16_to_cpu(rsp->DataOffset); 79 } 80 81 static unsigned int 82 cifs_read_data_length(char *buf, bool in_remaining) 83 { 84 READ_RSP *rsp = (READ_RSP *)buf; 85 /* It's a bug reading remaining data for SMB1 packets */ 86 WARN_ON(in_remaining); 87 return (le16_to_cpu(rsp->DataLengthHigh) << 16) + 88 le16_to_cpu(rsp->DataLength); 89 } 90 91 static struct mid_q_entry * 92 cifs_find_mid(struct TCP_Server_Info *server, char *buffer) 93 { 94 struct smb_hdr *buf = (struct smb_hdr *)buffer; 95 struct mid_q_entry *mid; 96 97 spin_lock(&server->mid_lock); 98 list_for_each_entry(mid, &server->pending_mid_q, qhead) { 99 if (compare_mid(mid->mid, buf) && 100 mid->mid_state == MID_REQUEST_SUBMITTED && 101 le16_to_cpu(mid->command) == buf->Command) { 102 kref_get(&mid->refcount); 103 spin_unlock(&server->mid_lock); 104 return mid; 105 } 106 } 107 spin_unlock(&server->mid_lock); 108 return NULL; 109 } 110 111 static void 112 cifs_add_credits(struct TCP_Server_Info *server, 113 struct cifs_credits *credits, const int optype) 114 { 115 spin_lock(&server->req_lock); 116 server->credits += credits->value; 117 server->in_flight--; 118 spin_unlock(&server->req_lock); 119 wake_up(&server->request_q); 120 } 121 122 static void 123 cifs_set_credits(struct TCP_Server_Info *server, const int val) 124 { 125 spin_lock(&server->req_lock); 126 server->credits = val; 127 server->oplocks = val > 1 ? enable_oplocks : false; 128 spin_unlock(&server->req_lock); 129 } 130 131 static int * 132 cifs_get_credits_field(struct TCP_Server_Info *server, const int optype) 133 { 134 return &server->credits; 135 } 136 137 static unsigned int 138 cifs_get_credits(struct mid_q_entry *mid) 139 { 140 return 1; 141 } 142 143 /* 144 * Find a free multiplex id (SMB mid). Otherwise there could be 145 * mid collisions which might cause problems, demultiplexing the 146 * wrong response to this request. Multiplex ids could collide if 147 * one of a series requests takes much longer than the others, or 148 * if a very large number of long lived requests (byte range 149 * locks or FindNotify requests) are pending. No more than 150 * 64K-1 requests can be outstanding at one time. If no 151 * mids are available, return zero. A future optimization 152 * could make the combination of mids and uid the key we use 153 * to demultiplex on (rather than mid alone). 154 * In addition to the above check, the cifs demultiplex 155 * code already used the command code as a secondary 156 * check of the frame and if signing is negotiated the 157 * response would be discarded if the mid were the same 158 * but the signature was wrong. Since the mid is not put in the 159 * pending queue until later (when it is about to be dispatched) 160 * we do have to limit the number of outstanding requests 161 * to somewhat less than 64K-1 although it is hard to imagine 162 * so many threads being in the vfs at one time. 163 */ 164 static __u64 165 cifs_get_next_mid(struct TCP_Server_Info *server) 166 { 167 __u64 mid = 0; 168 __u16 last_mid, cur_mid; 169 bool collision, reconnect = false; 170 171 spin_lock(&server->mid_lock); 172 173 /* mid is 16 bit only for CIFS/SMB */ 174 cur_mid = (__u16)((server->CurrentMid) & 0xffff); 175 /* we do not want to loop forever */ 176 last_mid = cur_mid; 177 cur_mid++; 178 /* avoid 0xFFFF MID */ 179 if (cur_mid == 0xffff) 180 cur_mid++; 181 182 /* 183 * This nested loop looks more expensive than it is. 184 * In practice the list of pending requests is short, 185 * fewer than 50, and the mids are likely to be unique 186 * on the first pass through the loop unless some request 187 * takes longer than the 64 thousand requests before it 188 * (and it would also have to have been a request that 189 * did not time out). 190 */ 191 while (cur_mid != last_mid) { 192 struct mid_q_entry *mid_entry; 193 unsigned int num_mids; 194 195 collision = false; 196 if (cur_mid == 0) 197 cur_mid++; 198 199 num_mids = 0; 200 list_for_each_entry(mid_entry, &server->pending_mid_q, qhead) { 201 ++num_mids; 202 if (mid_entry->mid == cur_mid && 203 mid_entry->mid_state == MID_REQUEST_SUBMITTED) { 204 /* This mid is in use, try a different one */ 205 collision = true; 206 break; 207 } 208 } 209 210 /* 211 * if we have more than 32k mids in the list, then something 212 * is very wrong. Possibly a local user is trying to DoS the 213 * box by issuing long-running calls and SIGKILL'ing them. If 214 * we get to 2^16 mids then we're in big trouble as this 215 * function could loop forever. 216 * 217 * Go ahead and assign out the mid in this situation, but force 218 * an eventual reconnect to clean out the pending_mid_q. 219 */ 220 if (num_mids > 32768) 221 reconnect = true; 222 223 if (!collision) { 224 mid = (__u64)cur_mid; 225 server->CurrentMid = mid; 226 break; 227 } 228 cur_mid++; 229 } 230 spin_unlock(&server->mid_lock); 231 232 if (reconnect) { 233 cifs_signal_cifsd_for_reconnect(server, false); 234 } 235 236 return mid; 237 } 238 239 /* 240 return codes: 241 0 not a transact2, or all data present 242 >0 transact2 with that much data missing 243 -EINVAL invalid transact2 244 */ 245 static int 246 check2ndT2(char *buf) 247 { 248 struct smb_hdr *pSMB = (struct smb_hdr *)buf; 249 struct smb_t2_rsp *pSMBt; 250 int remaining; 251 __u16 total_data_size, data_in_this_rsp; 252 253 if (pSMB->Command != SMB_COM_TRANSACTION2) 254 return 0; 255 256 /* check for plausible wct, bcc and t2 data and parm sizes */ 257 /* check for parm and data offset going beyond end of smb */ 258 if (pSMB->WordCount != 10) { /* coalesce_t2 depends on this */ 259 cifs_dbg(FYI, "Invalid transact2 word count\n"); 260 return -EINVAL; 261 } 262 263 pSMBt = (struct smb_t2_rsp *)pSMB; 264 265 total_data_size = get_unaligned_le16(&pSMBt->t2_rsp.TotalDataCount); 266 data_in_this_rsp = get_unaligned_le16(&pSMBt->t2_rsp.DataCount); 267 268 if (total_data_size == data_in_this_rsp) 269 return 0; 270 else if (total_data_size < data_in_this_rsp) { 271 cifs_dbg(FYI, "total data %d smaller than data in frame %d\n", 272 total_data_size, data_in_this_rsp); 273 return -EINVAL; 274 } 275 276 remaining = total_data_size - data_in_this_rsp; 277 278 cifs_dbg(FYI, "missing %d bytes from transact2, check next response\n", 279 remaining); 280 if (total_data_size > CIFSMaxBufSize) { 281 cifs_dbg(VFS, "TotalDataSize %d is over maximum buffer %d\n", 282 total_data_size, CIFSMaxBufSize); 283 return -EINVAL; 284 } 285 return remaining; 286 } 287 288 static int 289 coalesce_t2(char *second_buf, struct smb_hdr *target_hdr) 290 { 291 struct smb_t2_rsp *pSMBs = (struct smb_t2_rsp *)second_buf; 292 struct smb_t2_rsp *pSMBt = (struct smb_t2_rsp *)target_hdr; 293 char *data_area_of_tgt; 294 char *data_area_of_src; 295 int remaining; 296 unsigned int byte_count, total_in_tgt; 297 __u16 tgt_total_cnt, src_total_cnt, total_in_src; 298 299 src_total_cnt = get_unaligned_le16(&pSMBs->t2_rsp.TotalDataCount); 300 tgt_total_cnt = get_unaligned_le16(&pSMBt->t2_rsp.TotalDataCount); 301 302 if (tgt_total_cnt != src_total_cnt) 303 cifs_dbg(FYI, "total data count of primary and secondary t2 differ source=%hu target=%hu\n", 304 src_total_cnt, tgt_total_cnt); 305 306 total_in_tgt = get_unaligned_le16(&pSMBt->t2_rsp.DataCount); 307 308 remaining = tgt_total_cnt - total_in_tgt; 309 310 if (remaining < 0) { 311 cifs_dbg(FYI, "Server sent too much data. tgt_total_cnt=%hu total_in_tgt=%u\n", 312 tgt_total_cnt, total_in_tgt); 313 return -EPROTO; 314 } 315 316 if (remaining == 0) { 317 /* nothing to do, ignore */ 318 cifs_dbg(FYI, "no more data remains\n"); 319 return 0; 320 } 321 322 total_in_src = get_unaligned_le16(&pSMBs->t2_rsp.DataCount); 323 if (remaining < total_in_src) 324 cifs_dbg(FYI, "transact2 2nd response contains too much data\n"); 325 326 /* find end of first SMB data area */ 327 data_area_of_tgt = (char *)&pSMBt->hdr.Protocol + 328 get_unaligned_le16(&pSMBt->t2_rsp.DataOffset); 329 330 /* validate target area */ 331 data_area_of_src = (char *)&pSMBs->hdr.Protocol + 332 get_unaligned_le16(&pSMBs->t2_rsp.DataOffset); 333 334 data_area_of_tgt += total_in_tgt; 335 336 total_in_tgt += total_in_src; 337 /* is the result too big for the field? */ 338 if (total_in_tgt > USHRT_MAX) { 339 cifs_dbg(FYI, "coalesced DataCount too large (%u)\n", 340 total_in_tgt); 341 return -EPROTO; 342 } 343 put_unaligned_le16(total_in_tgt, &pSMBt->t2_rsp.DataCount); 344 345 /* fix up the BCC */ 346 byte_count = get_bcc(target_hdr); 347 byte_count += total_in_src; 348 /* is the result too big for the field? */ 349 if (byte_count > USHRT_MAX) { 350 cifs_dbg(FYI, "coalesced BCC too large (%u)\n", byte_count); 351 return -EPROTO; 352 } 353 put_bcc(byte_count, target_hdr); 354 355 byte_count = be32_to_cpu(target_hdr->smb_buf_length); 356 byte_count += total_in_src; 357 /* don't allow buffer to overflow */ 358 if (byte_count > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) { 359 cifs_dbg(FYI, "coalesced BCC exceeds buffer size (%u)\n", 360 byte_count); 361 return -ENOBUFS; 362 } 363 target_hdr->smb_buf_length = cpu_to_be32(byte_count); 364 365 /* copy second buffer into end of first buffer */ 366 memcpy(data_area_of_tgt, data_area_of_src, total_in_src); 367 368 if (remaining != total_in_src) { 369 /* more responses to go */ 370 cifs_dbg(FYI, "waiting for more secondary responses\n"); 371 return 1; 372 } 373 374 /* we are done */ 375 cifs_dbg(FYI, "found the last secondary response\n"); 376 return 0; 377 } 378 379 static void 380 cifs_downgrade_oplock(struct TCP_Server_Info *server, 381 struct cifsInodeInfo *cinode, __u32 oplock, 382 __u16 epoch, bool *purge_cache) 383 { 384 cifs_set_oplock_level(cinode, oplock); 385 } 386 387 static bool 388 cifs_check_trans2(struct mid_q_entry *mid, struct TCP_Server_Info *server, 389 char *buf, int malformed) 390 { 391 if (malformed) 392 return false; 393 if (check2ndT2(buf) <= 0) 394 return false; 395 mid->multiRsp = true; 396 if (mid->resp_buf) { 397 /* merge response - fix up 1st*/ 398 malformed = coalesce_t2(buf, mid->resp_buf); 399 if (malformed > 0) 400 return true; 401 /* All parts received or packet is malformed. */ 402 mid->multiEnd = true; 403 dequeue_mid(mid, malformed); 404 return true; 405 } 406 if (!server->large_buf) { 407 /*FIXME: switch to already allocated largebuf?*/ 408 cifs_dbg(VFS, "1st trans2 resp needs bigbuf\n"); 409 } else { 410 /* Have first buffer */ 411 mid->resp_buf = buf; 412 mid->large_buf = true; 413 server->bigbuf = NULL; 414 } 415 return true; 416 } 417 418 static bool 419 cifs_need_neg(struct TCP_Server_Info *server) 420 { 421 return server->maxBuf == 0; 422 } 423 424 static int 425 cifs_negotiate(const unsigned int xid, 426 struct cifs_ses *ses, 427 struct TCP_Server_Info *server) 428 { 429 int rc; 430 rc = CIFSSMBNegotiate(xid, ses, server); 431 return rc; 432 } 433 434 static unsigned int 435 cifs_negotiate_wsize(struct cifs_tcon *tcon, struct smb3_fs_context *ctx) 436 { 437 __u64 unix_cap = le64_to_cpu(tcon->fsUnixInfo.Capability); 438 struct TCP_Server_Info *server = tcon->ses->server; 439 unsigned int wsize; 440 441 /* start with specified wsize, or default */ 442 if (ctx->got_wsize) 443 wsize = ctx->vol_wsize; 444 else if (tcon->unix_ext && (unix_cap & CIFS_UNIX_LARGE_WRITE_CAP)) 445 wsize = CIFS_DEFAULT_IOSIZE; 446 else 447 wsize = CIFS_DEFAULT_NON_POSIX_WSIZE; 448 449 /* can server support 24-bit write sizes? (via UNIX extensions) */ 450 if (!tcon->unix_ext || !(unix_cap & CIFS_UNIX_LARGE_WRITE_CAP)) 451 wsize = min_t(unsigned int, wsize, CIFS_MAX_RFC1002_WSIZE); 452 453 /* 454 * no CAP_LARGE_WRITE_X or is signing enabled without CAP_UNIX set? 455 * Limit it to max buffer offered by the server, minus the size of the 456 * WRITEX header, not including the 4 byte RFC1001 length. 457 */ 458 if (!(server->capabilities & CAP_LARGE_WRITE_X) || 459 (!(server->capabilities & CAP_UNIX) && server->sign)) 460 wsize = min_t(unsigned int, wsize, 461 server->maxBuf - sizeof(WRITE_REQ) + 4); 462 463 /* hard limit of CIFS_MAX_WSIZE */ 464 wsize = min_t(unsigned int, wsize, CIFS_MAX_WSIZE); 465 466 return wsize; 467 } 468 469 static unsigned int 470 cifs_negotiate_rsize(struct cifs_tcon *tcon, struct smb3_fs_context *ctx) 471 { 472 __u64 unix_cap = le64_to_cpu(tcon->fsUnixInfo.Capability); 473 struct TCP_Server_Info *server = tcon->ses->server; 474 unsigned int rsize, defsize; 475 476 /* 477 * Set default value... 478 * 479 * HACK alert! Ancient servers have very small buffers. Even though 480 * MS-CIFS indicates that servers are only limited by the client's 481 * bufsize for reads, testing against win98se shows that it throws 482 * INVALID_PARAMETER errors if you try to request too large a read. 483 * OS/2 just sends back short reads. 484 * 485 * If the server doesn't advertise CAP_LARGE_READ_X, then assume that 486 * it can't handle a read request larger than its MaxBufferSize either. 487 */ 488 if (tcon->unix_ext && (unix_cap & CIFS_UNIX_LARGE_READ_CAP)) 489 defsize = CIFS_DEFAULT_IOSIZE; 490 else if (server->capabilities & CAP_LARGE_READ_X) 491 defsize = CIFS_DEFAULT_NON_POSIX_RSIZE; 492 else 493 defsize = server->maxBuf - sizeof(READ_RSP); 494 495 rsize = ctx->got_rsize ? ctx->vol_rsize : defsize; 496 497 /* 498 * no CAP_LARGE_READ_X? Then MS-CIFS states that we must limit this to 499 * the client's MaxBufferSize. 500 */ 501 if (!(server->capabilities & CAP_LARGE_READ_X)) 502 rsize = min_t(unsigned int, CIFSMaxBufSize, rsize); 503 504 /* hard limit of CIFS_MAX_RSIZE */ 505 rsize = min_t(unsigned int, rsize, CIFS_MAX_RSIZE); 506 507 return rsize; 508 } 509 510 static void 511 cifs_qfs_tcon(const unsigned int xid, struct cifs_tcon *tcon, 512 struct cifs_sb_info *cifs_sb) 513 { 514 CIFSSMBQFSDeviceInfo(xid, tcon); 515 CIFSSMBQFSAttributeInfo(xid, tcon); 516 } 517 518 static int 519 cifs_is_path_accessible(const unsigned int xid, struct cifs_tcon *tcon, 520 struct cifs_sb_info *cifs_sb, const char *full_path) 521 { 522 int rc; 523 FILE_ALL_INFO *file_info; 524 525 file_info = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL); 526 if (file_info == NULL) 527 return -ENOMEM; 528 529 rc = CIFSSMBQPathInfo(xid, tcon, full_path, file_info, 530 0 /* not legacy */, cifs_sb->local_nls, 531 cifs_remap(cifs_sb)); 532 533 if (rc == -EOPNOTSUPP || rc == -EINVAL) 534 rc = SMBQueryInformation(xid, tcon, full_path, file_info, 535 cifs_sb->local_nls, cifs_remap(cifs_sb)); 536 kfree(file_info); 537 return rc; 538 } 539 540 static int cifs_query_path_info(const unsigned int xid, 541 struct cifs_tcon *tcon, 542 struct cifs_sb_info *cifs_sb, 543 const char *full_path, 544 struct cifs_open_info_data *data) 545 { 546 int rc; 547 FILE_ALL_INFO fi = {}; 548 549 data->reparse_point = false; 550 data->adjust_tz = false; 551 552 /* could do find first instead but this returns more info */ 553 rc = CIFSSMBQPathInfo(xid, tcon, full_path, &fi, 0 /* not legacy */, cifs_sb->local_nls, 554 cifs_remap(cifs_sb)); 555 /* 556 * BB optimize code so we do not make the above call when server claims 557 * no NT SMB support and the above call failed at least once - set flag 558 * in tcon or mount. 559 */ 560 if ((rc == -EOPNOTSUPP) || (rc == -EINVAL)) { 561 rc = SMBQueryInformation(xid, tcon, full_path, &fi, cifs_sb->local_nls, 562 cifs_remap(cifs_sb)); 563 data->adjust_tz = true; 564 } 565 566 if (!rc) { 567 move_cifs_info_to_smb2(&data->fi, &fi); 568 data->reparse_point = le32_to_cpu(fi.Attributes) & ATTR_REPARSE; 569 } 570 571 #ifdef CONFIG_CIFS_XATTR 572 /* 573 * For WSL CHR and BLK reparse points it is required to fetch 574 * EA $LXDEV which contains major and minor device numbers. 575 */ 576 if (!rc && data->reparse_point) { 577 struct smb2_file_full_ea_info *ea; 578 579 ea = (struct smb2_file_full_ea_info *)data->wsl.eas; 580 rc = CIFSSMBQAllEAs(xid, tcon, full_path, SMB2_WSL_XATTR_DEV, 581 &ea->ea_data[SMB2_WSL_XATTR_NAME_LEN + 1], 582 SMB2_WSL_XATTR_DEV_SIZE, cifs_sb); 583 if (rc == SMB2_WSL_XATTR_DEV_SIZE) { 584 ea->next_entry_offset = cpu_to_le32(0); 585 ea->flags = 0; 586 ea->ea_name_length = SMB2_WSL_XATTR_NAME_LEN; 587 ea->ea_value_length = cpu_to_le16(SMB2_WSL_XATTR_DEV_SIZE); 588 memcpy(&ea->ea_data[0], SMB2_WSL_XATTR_DEV, SMB2_WSL_XATTR_NAME_LEN + 1); 589 data->wsl.eas_len = sizeof(*ea) + SMB2_WSL_XATTR_NAME_LEN + 1 + 590 SMB2_WSL_XATTR_DEV_SIZE; 591 rc = 0; 592 } else if (rc >= 0) { 593 /* It is an error if EA $LXDEV has wrong size. */ 594 rc = -EINVAL; 595 } else { 596 /* 597 * In all other cases ignore error if fetching 598 * of EA $LXDEV failed. It is needed only for 599 * WSL CHR and BLK reparse points and wsl_to_fattr() 600 * handle the case when EA is missing. 601 */ 602 rc = 0; 603 } 604 } 605 #endif 606 607 return rc; 608 } 609 610 static int cifs_get_srv_inum(const unsigned int xid, struct cifs_tcon *tcon, 611 struct cifs_sb_info *cifs_sb, const char *full_path, 612 u64 *uniqueid, struct cifs_open_info_data *unused) 613 { 614 /* 615 * We can not use the IndexNumber field by default from Windows or 616 * Samba (in ALL_INFO buf) but we can request it explicitly. The SNIA 617 * CIFS spec claims that this value is unique within the scope of a 618 * share, and the windows docs hint that it's actually unique 619 * per-machine. 620 * 621 * There may be higher info levels that work but are there Windows 622 * server or network appliances for which IndexNumber field is not 623 * guaranteed unique? 624 * 625 * CIFSGetSrvInodeNumber() uses SMB_QUERY_FILE_INTERNAL_INFO 626 * which is SMB PASSTHROUGH level therefore check for capability. 627 * Note that this function can be called with tcon == NULL. 628 */ 629 if (tcon && !(tcon->ses->capabilities & CAP_INFOLEVEL_PASSTHRU)) 630 return -EOPNOTSUPP; 631 return CIFSGetSrvInodeNumber(xid, tcon, full_path, uniqueid, 632 cifs_sb->local_nls, 633 cifs_remap(cifs_sb)); 634 } 635 636 static int cifs_query_file_info(const unsigned int xid, struct cifs_tcon *tcon, 637 struct cifsFileInfo *cfile, struct cifs_open_info_data *data) 638 { 639 int rc; 640 FILE_ALL_INFO fi = {}; 641 642 if (cfile->symlink_target) { 643 data->symlink_target = kstrdup(cfile->symlink_target, GFP_KERNEL); 644 if (!data->symlink_target) 645 return -ENOMEM; 646 } 647 648 rc = CIFSSMBQFileInfo(xid, tcon, cfile->fid.netfid, &fi); 649 if (!rc) 650 move_cifs_info_to_smb2(&data->fi, &fi); 651 return rc; 652 } 653 654 static void 655 cifs_clear_stats(struct cifs_tcon *tcon) 656 { 657 atomic_set(&tcon->stats.cifs_stats.num_writes, 0); 658 atomic_set(&tcon->stats.cifs_stats.num_reads, 0); 659 atomic_set(&tcon->stats.cifs_stats.num_flushes, 0); 660 atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0); 661 atomic_set(&tcon->stats.cifs_stats.num_opens, 0); 662 atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0); 663 atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0); 664 atomic_set(&tcon->stats.cifs_stats.num_closes, 0); 665 atomic_set(&tcon->stats.cifs_stats.num_deletes, 0); 666 atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0); 667 atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0); 668 atomic_set(&tcon->stats.cifs_stats.num_renames, 0); 669 atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0); 670 atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0); 671 atomic_set(&tcon->stats.cifs_stats.num_fnext, 0); 672 atomic_set(&tcon->stats.cifs_stats.num_fclose, 0); 673 atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0); 674 atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0); 675 atomic_set(&tcon->stats.cifs_stats.num_locks, 0); 676 atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0); 677 atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0); 678 } 679 680 static void 681 cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon) 682 { 683 seq_printf(m, " Oplocks breaks: %d", 684 atomic_read(&tcon->stats.cifs_stats.num_oplock_brks)); 685 seq_printf(m, "\nReads: %d Bytes: %llu", 686 atomic_read(&tcon->stats.cifs_stats.num_reads), 687 (long long)(tcon->bytes_read)); 688 seq_printf(m, "\nWrites: %d Bytes: %llu", 689 atomic_read(&tcon->stats.cifs_stats.num_writes), 690 (long long)(tcon->bytes_written)); 691 seq_printf(m, "\nFlushes: %d", 692 atomic_read(&tcon->stats.cifs_stats.num_flushes)); 693 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d", 694 atomic_read(&tcon->stats.cifs_stats.num_locks), 695 atomic_read(&tcon->stats.cifs_stats.num_hardlinks), 696 atomic_read(&tcon->stats.cifs_stats.num_symlinks)); 697 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d", 698 atomic_read(&tcon->stats.cifs_stats.num_opens), 699 atomic_read(&tcon->stats.cifs_stats.num_closes), 700 atomic_read(&tcon->stats.cifs_stats.num_deletes)); 701 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d", 702 atomic_read(&tcon->stats.cifs_stats.num_posixopens), 703 atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs)); 704 seq_printf(m, "\nMkdirs: %d Rmdirs: %d", 705 atomic_read(&tcon->stats.cifs_stats.num_mkdirs), 706 atomic_read(&tcon->stats.cifs_stats.num_rmdirs)); 707 seq_printf(m, "\nRenames: %d T2 Renames %d", 708 atomic_read(&tcon->stats.cifs_stats.num_renames), 709 atomic_read(&tcon->stats.cifs_stats.num_t2renames)); 710 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d", 711 atomic_read(&tcon->stats.cifs_stats.num_ffirst), 712 atomic_read(&tcon->stats.cifs_stats.num_fnext), 713 atomic_read(&tcon->stats.cifs_stats.num_fclose)); 714 } 715 716 static void 717 cifs_mkdir_setinfo(struct inode *inode, const char *full_path, 718 struct cifs_sb_info *cifs_sb, struct cifs_tcon *tcon, 719 const unsigned int xid) 720 { 721 FILE_BASIC_INFO info; 722 struct cifsInodeInfo *cifsInode; 723 u32 dosattrs; 724 int rc; 725 726 memset(&info, 0, sizeof(info)); 727 cifsInode = CIFS_I(inode); 728 dosattrs = cifsInode->cifsAttrs|ATTR_READONLY; 729 info.Attributes = cpu_to_le32(dosattrs); 730 rc = CIFSSMBSetPathInfo(xid, tcon, full_path, &info, cifs_sb->local_nls, 731 cifs_sb); 732 if (rc == 0) 733 cifsInode->cifsAttrs = dosattrs; 734 } 735 736 static int cifs_open_file(const unsigned int xid, struct cifs_open_parms *oparms, __u32 *oplock, 737 void *buf) 738 { 739 struct cifs_open_info_data *data = buf; 740 FILE_ALL_INFO fi = {}; 741 int rc; 742 743 if (!(oparms->tcon->ses->capabilities & CAP_NT_SMBS)) 744 rc = SMBLegacyOpen(xid, oparms->tcon, oparms->path, 745 oparms->disposition, 746 oparms->desired_access, 747 oparms->create_options, 748 &oparms->fid->netfid, oplock, &fi, 749 oparms->cifs_sb->local_nls, 750 cifs_remap(oparms->cifs_sb)); 751 else 752 rc = CIFS_open(xid, oparms, oplock, &fi); 753 754 if (!rc && data) 755 move_cifs_info_to_smb2(&data->fi, &fi); 756 757 return rc; 758 } 759 760 static void 761 cifs_set_fid(struct cifsFileInfo *cfile, struct cifs_fid *fid, __u32 oplock) 762 { 763 struct cifsInodeInfo *cinode = CIFS_I(d_inode(cfile->dentry)); 764 cfile->fid.netfid = fid->netfid; 765 cifs_set_oplock_level(cinode, oplock); 766 cinode->can_cache_brlcks = CIFS_CACHE_WRITE(cinode); 767 } 768 769 static int 770 cifs_close_file(const unsigned int xid, struct cifs_tcon *tcon, 771 struct cifs_fid *fid) 772 { 773 return CIFSSMBClose(xid, tcon, fid->netfid); 774 } 775 776 static int 777 cifs_flush_file(const unsigned int xid, struct cifs_tcon *tcon, 778 struct cifs_fid *fid) 779 { 780 return CIFSSMBFlush(xid, tcon, fid->netfid); 781 } 782 783 static int 784 cifs_sync_read(const unsigned int xid, struct cifs_fid *pfid, 785 struct cifs_io_parms *parms, unsigned int *bytes_read, 786 char **buf, int *buf_type) 787 { 788 parms->netfid = pfid->netfid; 789 return CIFSSMBRead(xid, parms, bytes_read, buf, buf_type); 790 } 791 792 static int 793 cifs_sync_write(const unsigned int xid, struct cifs_fid *pfid, 794 struct cifs_io_parms *parms, unsigned int *written, 795 struct kvec *iov, unsigned long nr_segs) 796 { 797 798 parms->netfid = pfid->netfid; 799 return CIFSSMBWrite2(xid, parms, written, iov, nr_segs); 800 } 801 802 static int 803 smb_set_file_info(struct inode *inode, const char *full_path, 804 FILE_BASIC_INFO *buf, const unsigned int xid) 805 { 806 int oplock = 0; 807 int rc; 808 __u32 netpid; 809 struct cifs_fid fid; 810 struct cifs_open_parms oparms; 811 struct cifsFileInfo *open_file; 812 struct cifsInodeInfo *cinode = CIFS_I(inode); 813 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 814 struct tcon_link *tlink = NULL; 815 struct cifs_tcon *tcon; 816 817 /* if the file is already open for write, just use that fileid */ 818 open_file = find_writable_file(cinode, FIND_WR_FSUID_ONLY); 819 if (open_file) { 820 fid.netfid = open_file->fid.netfid; 821 netpid = open_file->pid; 822 tcon = tlink_tcon(open_file->tlink); 823 goto set_via_filehandle; 824 } 825 826 tlink = cifs_sb_tlink(cifs_sb); 827 if (IS_ERR(tlink)) { 828 rc = PTR_ERR(tlink); 829 tlink = NULL; 830 goto out; 831 } 832 tcon = tlink_tcon(tlink); 833 834 rc = CIFSSMBSetPathInfo(xid, tcon, full_path, buf, cifs_sb->local_nls, 835 cifs_sb); 836 if (rc == 0) { 837 cinode->cifsAttrs = le32_to_cpu(buf->Attributes); 838 goto out; 839 } else if (rc != -EOPNOTSUPP && rc != -EINVAL) { 840 goto out; 841 } 842 843 oparms = (struct cifs_open_parms) { 844 .tcon = tcon, 845 .cifs_sb = cifs_sb, 846 .desired_access = SYNCHRONIZE | FILE_WRITE_ATTRIBUTES, 847 .create_options = cifs_create_options(cifs_sb, CREATE_NOT_DIR), 848 .disposition = FILE_OPEN, 849 .path = full_path, 850 .fid = &fid, 851 }; 852 853 cifs_dbg(FYI, "calling SetFileInfo since SetPathInfo for times not supported by this server\n"); 854 rc = CIFS_open(xid, &oparms, &oplock, NULL); 855 if (rc != 0) { 856 if (rc == -EIO) 857 rc = -EINVAL; 858 goto out; 859 } 860 861 netpid = current->tgid; 862 863 set_via_filehandle: 864 rc = CIFSSMBSetFileInfo(xid, tcon, buf, fid.netfid, netpid); 865 if (!rc) 866 cinode->cifsAttrs = le32_to_cpu(buf->Attributes); 867 868 if (open_file == NULL) 869 CIFSSMBClose(xid, tcon, fid.netfid); 870 else 871 cifsFileInfo_put(open_file); 872 out: 873 if (tlink != NULL) 874 cifs_put_tlink(tlink); 875 return rc; 876 } 877 878 static int 879 cifs_set_compression(const unsigned int xid, struct cifs_tcon *tcon, 880 struct cifsFileInfo *cfile) 881 { 882 return CIFSSMB_set_compression(xid, tcon, cfile->fid.netfid); 883 } 884 885 static int 886 cifs_query_dir_first(const unsigned int xid, struct cifs_tcon *tcon, 887 const char *path, struct cifs_sb_info *cifs_sb, 888 struct cifs_fid *fid, __u16 search_flags, 889 struct cifs_search_info *srch_inf) 890 { 891 int rc; 892 893 rc = CIFSFindFirst(xid, tcon, path, cifs_sb, 894 &fid->netfid, search_flags, srch_inf, true); 895 if (rc) 896 cifs_dbg(FYI, "find first failed=%d\n", rc); 897 return rc; 898 } 899 900 static int 901 cifs_query_dir_next(const unsigned int xid, struct cifs_tcon *tcon, 902 struct cifs_fid *fid, __u16 search_flags, 903 struct cifs_search_info *srch_inf) 904 { 905 return CIFSFindNext(xid, tcon, fid->netfid, search_flags, srch_inf); 906 } 907 908 static int 909 cifs_close_dir(const unsigned int xid, struct cifs_tcon *tcon, 910 struct cifs_fid *fid) 911 { 912 return CIFSFindClose(xid, tcon, fid->netfid); 913 } 914 915 static int 916 cifs_oplock_response(struct cifs_tcon *tcon, __u64 persistent_fid, 917 __u64 volatile_fid, __u16 net_fid, struct cifsInodeInfo *cinode) 918 { 919 return CIFSSMBLock(0, tcon, net_fid, current->tgid, 0, 0, 0, 0, 920 LOCKING_ANDX_OPLOCK_RELEASE, false, CIFS_CACHE_READ(cinode) ? 1 : 0); 921 } 922 923 static int 924 cifs_queryfs(const unsigned int xid, struct cifs_tcon *tcon, 925 const char *path, struct cifs_sb_info *cifs_sb, struct kstatfs *buf) 926 { 927 int rc = -EOPNOTSUPP; 928 929 buf->f_type = CIFS_SUPER_MAGIC; 930 931 /* 932 * We could add a second check for a QFS Unix capability bit 933 */ 934 if ((tcon->ses->capabilities & CAP_UNIX) && 935 (CIFS_POSIX_EXTENSIONS & le64_to_cpu(tcon->fsUnixInfo.Capability))) 936 rc = CIFSSMBQFSPosixInfo(xid, tcon, buf); 937 938 /* 939 * Only need to call the old QFSInfo if failed on newer one, 940 * e.g. by OS/2. 941 **/ 942 if (rc && (tcon->ses->capabilities & CAP_NT_SMBS)) 943 rc = CIFSSMBQFSInfo(xid, tcon, buf); 944 945 /* 946 * Some old Windows servers also do not support level 103, retry with 947 * older level one if old server failed the previous call or we 948 * bypassed it because we detected that this was an older LANMAN sess 949 */ 950 if (rc) 951 rc = SMBOldQFSInfo(xid, tcon, buf); 952 return rc; 953 } 954 955 static int 956 cifs_mand_lock(const unsigned int xid, struct cifsFileInfo *cfile, __u64 offset, 957 __u64 length, __u32 type, int lock, int unlock, bool wait) 958 { 959 return CIFSSMBLock(xid, tlink_tcon(cfile->tlink), cfile->fid.netfid, 960 current->tgid, length, offset, unlock, lock, 961 (__u8)type, wait, 0); 962 } 963 964 static int 965 cifs_unix_dfs_readlink(const unsigned int xid, struct cifs_tcon *tcon, 966 const unsigned char *searchName, char **symlinkinfo, 967 const struct nls_table *nls_codepage) 968 { 969 #ifdef CONFIG_CIFS_DFS_UPCALL 970 int rc; 971 struct dfs_info3_param referral = {0}; 972 973 rc = get_dfs_path(xid, tcon->ses, searchName, nls_codepage, &referral, 974 0); 975 976 if (!rc) { 977 *symlinkinfo = kstrdup(referral.node_name, GFP_KERNEL); 978 free_dfs_info_param(&referral); 979 if (!*symlinkinfo) 980 rc = -ENOMEM; 981 } 982 return rc; 983 #else /* No DFS support */ 984 return -EREMOTE; 985 #endif 986 } 987 988 static int cifs_query_symlink(const unsigned int xid, 989 struct cifs_tcon *tcon, 990 struct cifs_sb_info *cifs_sb, 991 const char *full_path, 992 char **target_path) 993 { 994 int rc; 995 996 cifs_tcon_dbg(FYI, "%s: path=%s\n", __func__, full_path); 997 998 if (!cap_unix(tcon->ses)) 999 return -EOPNOTSUPP; 1000 1001 rc = CIFSSMBUnixQuerySymLink(xid, tcon, full_path, target_path, 1002 cifs_sb->local_nls, cifs_remap(cifs_sb)); 1003 if (rc == -EREMOTE) 1004 rc = cifs_unix_dfs_readlink(xid, tcon, full_path, 1005 target_path, cifs_sb->local_nls); 1006 return rc; 1007 } 1008 1009 static struct reparse_data_buffer *cifs_get_reparse_point_buffer(const struct kvec *rsp_iov, 1010 u32 *plen) 1011 { 1012 TRANSACT_IOCTL_RSP *io = rsp_iov->iov_base; 1013 *plen = le16_to_cpu(io->ByteCount); 1014 return (struct reparse_data_buffer *)((__u8 *)&io->hdr.Protocol + 1015 le32_to_cpu(io->DataOffset)); 1016 } 1017 1018 static bool 1019 cifs_is_read_op(__u32 oplock) 1020 { 1021 return oplock == OPLOCK_READ; 1022 } 1023 1024 static unsigned int 1025 cifs_wp_retry_size(struct inode *inode) 1026 { 1027 return CIFS_SB(inode->i_sb)->ctx->wsize; 1028 } 1029 1030 static bool 1031 cifs_dir_needs_close(struct cifsFileInfo *cfile) 1032 { 1033 return !cfile->srch_inf.endOfSearch && !cfile->invalidHandle; 1034 } 1035 1036 static bool 1037 cifs_can_echo(struct TCP_Server_Info *server) 1038 { 1039 if (server->tcpStatus == CifsGood) 1040 return true; 1041 1042 return false; 1043 } 1044 1045 static int 1046 cifs_make_node(unsigned int xid, struct inode *inode, 1047 struct dentry *dentry, struct cifs_tcon *tcon, 1048 const char *full_path, umode_t mode, dev_t dev) 1049 { 1050 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 1051 struct inode *newinode = NULL; 1052 int rc; 1053 1054 if (tcon->unix_ext) { 1055 /* 1056 * SMB1 Unix Extensions: requires server support but 1057 * works with all special files 1058 */ 1059 struct cifs_unix_set_info_args args = { 1060 .mode = mode & ~current_umask(), 1061 .ctime = NO_CHANGE_64, 1062 .atime = NO_CHANGE_64, 1063 .mtime = NO_CHANGE_64, 1064 .device = dev, 1065 }; 1066 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) { 1067 args.uid = current_fsuid(); 1068 args.gid = current_fsgid(); 1069 } else { 1070 args.uid = INVALID_UID; /* no change */ 1071 args.gid = INVALID_GID; /* no change */ 1072 } 1073 rc = CIFSSMBUnixSetPathInfo(xid, tcon, full_path, &args, 1074 cifs_sb->local_nls, 1075 cifs_remap(cifs_sb)); 1076 if (rc) 1077 return rc; 1078 1079 rc = cifs_get_inode_info_unix(&newinode, full_path, 1080 inode->i_sb, xid); 1081 1082 if (rc == 0) 1083 d_instantiate(dentry, newinode); 1084 return rc; 1085 } 1086 /* 1087 * Check if mounted with mount parm 'sfu' mount parm. 1088 * SFU emulation should work with all servers, but only 1089 * supports block and char device, socket & fifo, 1090 * and was used by default in earlier versions of Windows 1091 */ 1092 if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL)) 1093 return -EPERM; 1094 return cifs_sfu_make_node(xid, inode, dentry, tcon, 1095 full_path, mode, dev); 1096 } 1097 1098 static bool 1099 cifs_is_network_name_deleted(char *buf, struct TCP_Server_Info *server) 1100 { 1101 struct smb_hdr *shdr = (struct smb_hdr *)buf; 1102 struct TCP_Server_Info *pserver; 1103 struct cifs_ses *ses; 1104 struct cifs_tcon *tcon; 1105 1106 if (shdr->Flags2 & SMBFLG2_ERR_STATUS) { 1107 if (shdr->Status.CifsError != cpu_to_le32(NT_STATUS_NETWORK_NAME_DELETED)) 1108 return false; 1109 } else { 1110 if (shdr->Status.DosError.ErrorClass != ERRSRV || 1111 shdr->Status.DosError.Error != cpu_to_le16(ERRinvtid)) 1112 return false; 1113 } 1114 1115 /* If server is a channel, select the primary channel */ 1116 pserver = SERVER_IS_CHAN(server) ? server->primary_server : server; 1117 1118 spin_lock(&cifs_tcp_ses_lock); 1119 list_for_each_entry(ses, &pserver->smb_ses_list, smb_ses_list) { 1120 if (cifs_ses_exiting(ses)) 1121 continue; 1122 list_for_each_entry(tcon, &ses->tcon_list, tcon_list) { 1123 if (tcon->tid == shdr->Tid) { 1124 spin_lock(&tcon->tc_lock); 1125 tcon->need_reconnect = true; 1126 spin_unlock(&tcon->tc_lock); 1127 spin_unlock(&cifs_tcp_ses_lock); 1128 pr_warn_once("Server share %s deleted.\n", 1129 tcon->tree_name); 1130 return true; 1131 } 1132 } 1133 } 1134 spin_unlock(&cifs_tcp_ses_lock); 1135 1136 return false; 1137 } 1138 1139 struct smb_version_operations smb1_operations = { 1140 .send_cancel = send_nt_cancel, 1141 .compare_fids = cifs_compare_fids, 1142 .setup_request = cifs_setup_request, 1143 .setup_async_request = cifs_setup_async_request, 1144 .check_receive = cifs_check_receive, 1145 .add_credits = cifs_add_credits, 1146 .set_credits = cifs_set_credits, 1147 .get_credits_field = cifs_get_credits_field, 1148 .get_credits = cifs_get_credits, 1149 .wait_mtu_credits = cifs_wait_mtu_credits, 1150 .get_next_mid = cifs_get_next_mid, 1151 .read_data_offset = cifs_read_data_offset, 1152 .read_data_length = cifs_read_data_length, 1153 .map_error = map_smb_to_linux_error, 1154 .find_mid = cifs_find_mid, 1155 .check_message = checkSMB, 1156 .dump_detail = cifs_dump_detail, 1157 .clear_stats = cifs_clear_stats, 1158 .print_stats = cifs_print_stats, 1159 .is_oplock_break = is_valid_oplock_break, 1160 .downgrade_oplock = cifs_downgrade_oplock, 1161 .check_trans2 = cifs_check_trans2, 1162 .need_neg = cifs_need_neg, 1163 .negotiate = cifs_negotiate, 1164 .negotiate_wsize = cifs_negotiate_wsize, 1165 .negotiate_rsize = cifs_negotiate_rsize, 1166 .sess_setup = CIFS_SessSetup, 1167 .logoff = CIFSSMBLogoff, 1168 .tree_connect = CIFSTCon, 1169 .tree_disconnect = CIFSSMBTDis, 1170 .get_dfs_refer = CIFSGetDFSRefer, 1171 .qfs_tcon = cifs_qfs_tcon, 1172 .is_path_accessible = cifs_is_path_accessible, 1173 .can_echo = cifs_can_echo, 1174 .query_path_info = cifs_query_path_info, 1175 .query_reparse_point = cifs_query_reparse_point, 1176 .query_file_info = cifs_query_file_info, 1177 .get_srv_inum = cifs_get_srv_inum, 1178 .set_path_size = CIFSSMBSetEOF, 1179 .set_file_size = CIFSSMBSetFileSize, 1180 .set_file_info = smb_set_file_info, 1181 .set_compression = cifs_set_compression, 1182 .echo = CIFSSMBEcho, 1183 .mkdir = CIFSSMBMkDir, 1184 .mkdir_setinfo = cifs_mkdir_setinfo, 1185 .rmdir = CIFSSMBRmDir, 1186 .unlink = CIFSSMBDelFile, 1187 .rename_pending_delete = cifs_rename_pending_delete, 1188 .rename = CIFSSMBRename, 1189 .create_hardlink = CIFSCreateHardLink, 1190 .query_symlink = cifs_query_symlink, 1191 .get_reparse_point_buffer = cifs_get_reparse_point_buffer, 1192 .open = cifs_open_file, 1193 .set_fid = cifs_set_fid, 1194 .close = cifs_close_file, 1195 .flush = cifs_flush_file, 1196 .async_readv = cifs_async_readv, 1197 .async_writev = cifs_async_writev, 1198 .sync_read = cifs_sync_read, 1199 .sync_write = cifs_sync_write, 1200 .query_dir_first = cifs_query_dir_first, 1201 .query_dir_next = cifs_query_dir_next, 1202 .close_dir = cifs_close_dir, 1203 .calc_smb_size = smbCalcSize, 1204 .oplock_response = cifs_oplock_response, 1205 .queryfs = cifs_queryfs, 1206 .mand_lock = cifs_mand_lock, 1207 .mand_unlock_range = cifs_unlock_range, 1208 .push_mand_locks = cifs_push_mandatory_locks, 1209 .query_mf_symlink = cifs_query_mf_symlink, 1210 .create_mf_symlink = cifs_create_mf_symlink, 1211 .is_read_op = cifs_is_read_op, 1212 .wp_retry_size = cifs_wp_retry_size, 1213 .dir_needs_close = cifs_dir_needs_close, 1214 .select_sectype = cifs_select_sectype, 1215 #ifdef CONFIG_CIFS_XATTR 1216 .query_all_EAs = CIFSSMBQAllEAs, 1217 .set_EA = CIFSSMBSetEA, 1218 #endif /* CIFS_XATTR */ 1219 .get_acl = get_cifs_acl, 1220 .get_acl_by_fid = get_cifs_acl_by_fid, 1221 .set_acl = set_cifs_acl, 1222 .make_node = cifs_make_node, 1223 .is_network_name_deleted = cifs_is_network_name_deleted, 1224 }; 1225 1226 struct smb_version_values smb1_values = { 1227 .version_string = SMB1_VERSION_STRING, 1228 .protocol_id = SMB10_PROT_ID, 1229 .large_lock_type = LOCKING_ANDX_LARGE_FILES, 1230 .exclusive_lock_type = 0, 1231 .shared_lock_type = LOCKING_ANDX_SHARED_LOCK, 1232 .unlock_lock_type = 0, 1233 .header_preamble_size = 4, 1234 .header_size = sizeof(struct smb_hdr), 1235 .max_header_size = MAX_CIFS_HDR_SIZE, 1236 .read_rsp_size = sizeof(READ_RSP), 1237 .lock_cmd = cpu_to_le16(SMB_COM_LOCKING_ANDX), 1238 .cap_unix = CAP_UNIX, 1239 .cap_nt_find = CAP_NT_SMBS | CAP_NT_FIND, 1240 .cap_large_files = CAP_LARGE_FILES, 1241 .cap_unicode = CAP_UNICODE, 1242 .signing_enabled = SECMODE_SIGN_ENABLED, 1243 .signing_required = SECMODE_SIGN_REQUIRED, 1244 }; 1245