Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cifs: Create a new shared file holding smb2 pdu definitions

This file will contain all the definitions we need for SMB2 packets
and will follow the naming convention of MS-SMB2.PDF as closely
as possible to make it easier to cross-reference beween the definitions
and the standard.

The content of this file will mostly consist of migration of existing
definitions in the cifs/smb2.pdu.h and ksmbd/smb2pdu.h files
with some additional tweaks as the two files have diverged.

This patch introduces the new smbfs_common/smb2pdu.h file
and migrates the SMB2 header as well as TREE_CONNECT and TREE_DISCONNECT
to the shared file.

Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
Reviewed-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>

authored by

Ronnie Sahlberg and committed by
Steve French
0d35e382 7ae5e588

+493 -476
-1
fs/cifs/cifsfs.c
··· 38 38 #include <linux/key-type.h> 39 39 #include "cifs_spnego.h" 40 40 #include "fscache.h" 41 - #include "smb2pdu.h" 42 41 #ifdef CONFIG_CIFS_DFS_UPCALL 43 42 #include "dfs_cache.h" 44 43 #endif
+2 -1
fs/cifs/cifsglob.h
··· 20 20 #include <crypto/internal/hash.h> 21 21 #include <linux/scatterlist.h> 22 22 #include <uapi/linux/cifs/cifs_mount.h> 23 + #include "../smbfs_common/smb2pdu.h" 23 24 #include "smb2pdu.h" 24 25 25 26 #define CIFS_MAGIC_NUMBER 0xFF534D42 /* the first four bytes of SMB PDUs */ ··· 777 776 778 777 static inline void 779 778 revert_current_mid_from_hdr(struct TCP_Server_Info *server, 780 - const struct smb2_sync_hdr *shdr) 779 + const struct smb2_hdr *shdr) 781 780 { 782 781 unsigned int num = le16_to_cpu(shdr->CreditCharge); 783 782
+2 -2
fs/cifs/connect.c
··· 677 677 static unsigned int 678 678 smb2_get_credits_from_hdr(char *buffer, struct TCP_Server_Info *server) 679 679 { 680 - struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)buffer; 680 + struct smb2_hdr *shdr = (struct smb2_hdr *)buffer; 681 681 682 682 /* 683 683 * SMB1 does not use credits. ··· 877 877 static void 878 878 smb2_add_credits_from_hdr(char *buffer, struct TCP_Server_Info *server) 879 879 { 880 - struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)buffer; 880 + struct smb2_hdr *shdr = (struct smb2_hdr *)buffer; 881 881 int scredits, in_flight; 882 882 883 883 /*
+1 -1
fs/cifs/misc.c
··· 152 152 * SMB2 header is bigger than CIFS one - no problems to clean some 153 153 * more bytes for CIFS. 154 154 */ 155 - size_t buf_size = sizeof(struct smb2_sync_hdr); 155 + size_t buf_size = sizeof(struct smb2_hdr); 156 156 157 157 /* 158 158 * We could use negotiated size instead of max_msgsize -
+10 -6
fs/cifs/smb2maperror.c
··· 2439 2439 int 2440 2440 map_smb2_to_linux_error(char *buf, bool log_err) 2441 2441 { 2442 - struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)buf; 2442 + struct smb2_hdr *shdr = (struct smb2_hdr *)buf; 2443 2443 unsigned int i; 2444 2444 int rc = -EIO; 2445 2445 __le32 smb2err = shdr->Status; 2446 2446 2447 2447 if (smb2err == 0) { 2448 - trace_smb3_cmd_done(shdr->TreeId, shdr->SessionId, 2449 - le16_to_cpu(shdr->Command), le64_to_cpu(shdr->MessageId)); 2448 + trace_smb3_cmd_done(le32_to_cpu(shdr->Id.SyncId.TreeId), 2449 + le64_to_cpu(shdr->SessionId), 2450 + le16_to_cpu(shdr->Command), 2451 + le64_to_cpu(shdr->MessageId)); 2450 2452 return 0; 2451 2453 } 2452 2454 ··· 2472 2470 cifs_dbg(FYI, "Mapping SMB2 status code 0x%08x to POSIX err %d\n", 2473 2471 __le32_to_cpu(smb2err), rc); 2474 2472 2475 - trace_smb3_cmd_err(shdr->TreeId, shdr->SessionId, 2476 - le16_to_cpu(shdr->Command), 2477 - le64_to_cpu(shdr->MessageId), le32_to_cpu(smb2err), rc); 2473 + trace_smb3_cmd_err(le32_to_cpu(shdr->Id.SyncId.TreeId), 2474 + le64_to_cpu(shdr->SessionId), 2475 + le16_to_cpu(shdr->Command), 2476 + le64_to_cpu(shdr->MessageId), 2477 + le32_to_cpu(smb2err), rc); 2478 2478 return rc; 2479 2479 }
+21 -22
fs/cifs/smb2misc.c
··· 8 8 * 9 9 */ 10 10 #include <linux/ctype.h> 11 - #include "smb2pdu.h" 12 11 #include "cifsglob.h" 13 12 #include "cifsproto.h" 14 13 #include "smb2proto.h" ··· 18 19 #include "nterr.h" 19 20 20 21 static int 21 - check_smb2_hdr(struct smb2_sync_hdr *shdr, __u64 mid) 22 + check_smb2_hdr(struct smb2_hdr *shdr, __u64 mid) 22 23 { 23 24 __u64 wire_mid = le64_to_cpu(shdr->MessageId); 24 25 ··· 80 81 /* SMB2_OPLOCK_BREAK */ cpu_to_le16(24) 81 82 }; 82 83 83 - #define SMB311_NEGPROT_BASE_SIZE (sizeof(struct smb2_sync_hdr) + sizeof(struct smb2_negotiate_rsp)) 84 + #define SMB311_NEGPROT_BASE_SIZE (sizeof(struct smb2_hdr) + sizeof(struct smb2_negotiate_rsp)) 84 85 85 - static __u32 get_neg_ctxt_len(struct smb2_sync_hdr *hdr, __u32 len, 86 + static __u32 get_neg_ctxt_len(struct smb2_hdr *hdr, __u32 len, 86 87 __u32 non_ctxlen) 87 88 { 88 89 __u16 neg_count; ··· 134 135 int 135 136 smb2_check_message(char *buf, unsigned int len, struct TCP_Server_Info *srvr) 136 137 { 137 - struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)buf; 138 - struct smb2_sync_pdu *pdu = (struct smb2_sync_pdu *)shdr; 138 + struct smb2_hdr *shdr = (struct smb2_hdr *)buf; 139 + struct smb2_pdu *pdu = (struct smb2_pdu *)shdr; 139 140 __u64 mid; 140 141 __u32 clc_len; /* calculated length */ 141 142 int command; 142 - int pdu_size = sizeof(struct smb2_sync_pdu); 143 - int hdr_size = sizeof(struct smb2_sync_hdr); 143 + int pdu_size = sizeof(struct smb2_pdu); 144 + int hdr_size = sizeof(struct smb2_hdr); 144 145 145 146 /* 146 147 * Add function to do table lookup of StructureSize by command ··· 154 155 /* decrypt frame now that it is completely read in */ 155 156 spin_lock(&cifs_tcp_ses_lock); 156 157 list_for_each_entry(ses, &srvr->smb_ses_list, smb_ses_list) { 157 - if (ses->Suid == thdr->SessionId) 158 + if (ses->Suid == le64_to_cpu(thdr->SessionId)) 158 159 break; 159 160 } 160 161 spin_unlock(&cifs_tcp_ses_lock); ··· 295 296 * area and the offset to it (from the beginning of the smb are also returned. 296 297 */ 297 298 char * 298 - smb2_get_data_area_len(int *off, int *len, struct smb2_sync_hdr *shdr) 299 + smb2_get_data_area_len(int *off, int *len, struct smb2_hdr *shdr) 299 300 { 300 301 *off = 0; 301 302 *len = 0; ··· 400 401 unsigned int 401 402 smb2_calc_size(void *buf, struct TCP_Server_Info *srvr) 402 403 { 403 - struct smb2_sync_pdu *pdu = (struct smb2_sync_pdu *)buf; 404 - struct smb2_sync_hdr *shdr = &pdu->sync_hdr; 404 + struct smb2_pdu *pdu = (struct smb2_pdu *)buf; 405 + struct smb2_hdr *shdr = &pdu->hdr; 405 406 int offset; /* the offset from the beginning of SMB to data area */ 406 407 int data_length; /* the length of the variable length data area */ 407 408 /* Structure Size has already been checked to make sure it is 64 */ ··· 668 669 669 670 cifs_dbg(FYI, "Checking for oplock break\n"); 670 671 671 - if (rsp->sync_hdr.Command != SMB2_OPLOCK_BREAK) 672 + if (rsp->hdr.Command != SMB2_OPLOCK_BREAK) 672 673 return false; 673 674 674 675 if (rsp->StructureSize != ··· 815 816 int 816 817 smb2_handle_cancelled_mid(struct mid_q_entry *mid, struct TCP_Server_Info *server) 817 818 { 818 - struct smb2_sync_hdr *sync_hdr = mid->resp_buf; 819 + struct smb2_hdr *hdr = mid->resp_buf; 819 820 struct smb2_create_rsp *rsp = mid->resp_buf; 820 821 struct cifs_tcon *tcon; 821 822 int rc; 822 823 823 - if ((mid->optype & CIFS_CP_CREATE_CLOSE_OP) || sync_hdr->Command != SMB2_CREATE || 824 - sync_hdr->Status != STATUS_SUCCESS) 824 + if ((mid->optype & CIFS_CP_CREATE_CLOSE_OP) || hdr->Command != SMB2_CREATE || 825 + hdr->Status != STATUS_SUCCESS) 825 826 return 0; 826 827 827 - tcon = smb2_find_smb_tcon(server, sync_hdr->SessionId, 828 - sync_hdr->TreeId); 828 + tcon = smb2_find_smb_tcon(server, le64_to_cpu(hdr->SessionId), 829 + le32_to_cpu(hdr->Id.SyncId.TreeId)); 829 830 if (!tcon) 830 831 return -ENOENT; 831 832 832 833 rc = __smb2_handle_cancelled_cmd(tcon, 833 - le16_to_cpu(sync_hdr->Command), 834 - le64_to_cpu(sync_hdr->MessageId), 834 + le16_to_cpu(hdr->Command), 835 + le64_to_cpu(hdr->MessageId), 835 836 rsp->PersistentFileId, 836 837 rsp->VolatileFileId); 837 838 if (rc) ··· 855 856 { 856 857 int i, rc; 857 858 struct sdesc *d; 858 - struct smb2_sync_hdr *hdr; 859 + struct smb2_hdr *hdr; 859 860 struct TCP_Server_Info *server = cifs_ses_server(ses); 860 861 861 - hdr = (struct smb2_sync_hdr *)iov[0].iov_base; 862 + hdr = (struct smb2_hdr *)iov[0].iov_base; 862 863 /* neg prot are always taken */ 863 864 if (hdr->Command == SMB2_NEGOTIATE) 864 865 goto ok;
+33 -32
fs/cifs/smb2ops.c
··· 325 325 __smb2_find_mid(struct TCP_Server_Info *server, char *buf, bool dequeue) 326 326 { 327 327 struct mid_q_entry *mid; 328 - struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)buf; 328 + struct smb2_hdr *shdr = (struct smb2_hdr *)buf; 329 329 __u64 wire_mid = le64_to_cpu(shdr->MessageId); 330 330 331 331 if (shdr->ProtocolId == SMB2_TRANSFORM_PROTO_NUM) { ··· 367 367 smb2_dump_detail(void *buf, struct TCP_Server_Info *server) 368 368 { 369 369 #ifdef CONFIG_CIFS_DEBUG2 370 - struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)buf; 370 + struct smb2_hdr *shdr = (struct smb2_hdr *)buf; 371 371 372 372 cifs_server_dbg(VFS, "Cmd: %d Err: 0x%x Flags: 0x%x Mid: %llu Pid: %d\n", 373 373 shdr->Command, shdr->Status, shdr->Flags, shdr->MessageId, 374 - shdr->ProcessId); 374 + shdr->Id.SyncId.ProcessId); 375 375 cifs_server_dbg(VFS, "smb buf %p len %u\n", buf, 376 376 server->ops->calc_smb_size(buf, server)); 377 377 #endif ··· 888 888 oparms.fid->persistent_fid = o_rsp->PersistentFileId; 889 889 oparms.fid->volatile_fid = o_rsp->VolatileFileId; 890 890 #ifdef CONFIG_CIFS_DEBUG2 891 - oparms.fid->mid = le64_to_cpu(o_rsp->sync_hdr.MessageId); 891 + oparms.fid->mid = le64_to_cpu(o_rsp->hdr.MessageId); 892 892 #endif /* CIFS_DEBUG2 */ 893 893 894 894 tcon->crfid.tcon = tcon; ··· 2391 2391 2392 2392 /* If the open failed there is nothing to do */ 2393 2393 op_rsp = (struct smb2_create_rsp *)rsp_iov[0].iov_base; 2394 - if (op_rsp == NULL || op_rsp->sync_hdr.Status != STATUS_SUCCESS) { 2394 + if (op_rsp == NULL || op_rsp->hdr.Status != STATUS_SUCCESS) { 2395 2395 cifs_dbg(FYI, "query_dir_first: open failed rc=%d\n", rc); 2396 2396 goto qdf_free; 2397 2397 } ··· 2410 2410 atomic_inc(&tcon->num_remote_opens); 2411 2411 2412 2412 qd_rsp = (struct smb2_query_directory_rsp *)rsp_iov[1].iov_base; 2413 - if (qd_rsp->sync_hdr.Status == STATUS_NO_MORE_FILES) { 2413 + if (qd_rsp->hdr.Status == STATUS_NO_MORE_FILES) { 2414 2414 trace_smb3_query_dir_done(xid, fid->persistent_fid, 2415 2415 tcon->tid, tcon->ses->Suid, 0, 0); 2416 2416 srch_inf->endOfSearch = true; ··· 2462 2462 static bool 2463 2463 smb2_is_status_pending(char *buf, struct TCP_Server_Info *server) 2464 2464 { 2465 - struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)buf; 2465 + struct smb2_hdr *shdr = (struct smb2_hdr *)buf; 2466 2466 int scredits, in_flight; 2467 2467 2468 2468 if (shdr->Status != STATUS_PENDING) ··· 2489 2489 static bool 2490 2490 smb2_is_session_expired(char *buf) 2491 2491 { 2492 - struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)buf; 2492 + struct smb2_hdr *shdr = (struct smb2_hdr *)buf; 2493 2493 2494 2494 if (shdr->Status != STATUS_NETWORK_SESSION_EXPIRED && 2495 2495 shdr->Status != STATUS_USER_SESSION_DELETED) 2496 2496 return false; 2497 2497 2498 - trace_smb3_ses_expired(shdr->TreeId, shdr->SessionId, 2498 + trace_smb3_ses_expired(le32_to_cpu(shdr->Id.SyncId.TreeId), 2499 + le64_to_cpu(shdr->SessionId), 2499 2500 le16_to_cpu(shdr->Command), 2500 2501 le64_to_cpu(shdr->MessageId)); 2501 2502 cifs_dbg(FYI, "Session expired or deleted\n"); ··· 2507 2506 static bool 2508 2507 smb2_is_status_io_timeout(char *buf) 2509 2508 { 2510 - struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)buf; 2509 + struct smb2_hdr *shdr = (struct smb2_hdr *)buf; 2511 2510 2512 2511 if (shdr->Status == STATUS_IO_TIMEOUT) 2513 2512 return true; ··· 2518 2517 static void 2519 2518 smb2_is_network_name_deleted(char *buf, struct TCP_Server_Info *server) 2520 2519 { 2521 - struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)buf; 2520 + struct smb2_hdr *shdr = (struct smb2_hdr *)buf; 2522 2521 struct list_head *tmp, *tmp1; 2523 2522 struct cifs_ses *ses; 2524 2523 struct cifs_tcon *tcon; ··· 2531 2530 ses = list_entry(tmp, struct cifs_ses, smb_ses_list); 2532 2531 list_for_each(tmp1, &ses->tcon_list) { 2533 2532 tcon = list_entry(tmp1, struct cifs_tcon, tcon_list); 2534 - if (tcon->tid == shdr->TreeId) { 2533 + if (tcon->tid == le32_to_cpu(shdr->Id.SyncId.TreeId)) { 2535 2534 tcon->need_reconnect = true; 2536 2535 spin_unlock(&cifs_tcp_ses_lock); 2537 2536 pr_warn_once("Server share %s deleted.\n", ··· 2559 2558 void 2560 2559 smb2_set_related(struct smb_rqst *rqst) 2561 2560 { 2562 - struct smb2_sync_hdr *shdr; 2561 + struct smb2_hdr *shdr; 2563 2562 2564 - shdr = (struct smb2_sync_hdr *)(rqst->rq_iov[0].iov_base); 2563 + shdr = (struct smb2_hdr *)(rqst->rq_iov[0].iov_base); 2565 2564 if (shdr == NULL) { 2566 2565 cifs_dbg(FYI, "shdr NULL in smb2_set_related\n"); 2567 2566 return; ··· 2574 2573 void 2575 2574 smb2_set_next_command(struct cifs_tcon *tcon, struct smb_rqst *rqst) 2576 2575 { 2577 - struct smb2_sync_hdr *shdr; 2576 + struct smb2_hdr *shdr; 2578 2577 struct cifs_ses *ses = tcon->ses; 2579 2578 struct TCP_Server_Info *server = ses->server; 2580 2579 unsigned long len = smb_rqst_len(server, rqst); 2581 2580 int i, num_padding; 2582 2581 2583 - shdr = (struct smb2_sync_hdr *)(rqst->rq_iov[0].iov_base); 2582 + shdr = (struct smb2_hdr *)(rqst->rq_iov[0].iov_base); 2584 2583 if (shdr == NULL) { 2585 2584 cifs_dbg(FYI, "shdr NULL in smb2_set_next_command\n"); 2586 2585 return; ··· 3125 3124 resp_buftype, rsp_iov); 3126 3125 3127 3126 create_rsp = rsp_iov[0].iov_base; 3128 - if (create_rsp && create_rsp->sync_hdr.Status) 3127 + if (create_rsp && create_rsp->hdr.Status) 3129 3128 err_iov = rsp_iov[0]; 3130 3129 ioctl_rsp = rsp_iov[1].iov_base; 3131 3130 ··· 4370 4369 fill_transform_hdr(struct smb2_transform_hdr *tr_hdr, unsigned int orig_len, 4371 4370 struct smb_rqst *old_rq, __le16 cipher_type) 4372 4371 { 4373 - struct smb2_sync_hdr *shdr = 4374 - (struct smb2_sync_hdr *)old_rq->rq_iov[0].iov_base; 4372 + struct smb2_hdr *shdr = 4373 + (struct smb2_hdr *)old_rq->rq_iov[0].iov_base; 4375 4374 4376 4375 memset(tr_hdr, 0, sizeof(struct smb2_transform_hdr)); 4377 4376 tr_hdr->ProtocolId = SMB2_TRANSFORM_PROTO_NUM; ··· 4497 4496 struct crypto_aead *tfm; 4498 4497 unsigned int crypt_len = le32_to_cpu(tr_hdr->OriginalMessageSize); 4499 4498 4500 - rc = smb2_get_enc_key(server, tr_hdr->SessionId, enc, key); 4499 + rc = smb2_get_enc_key(server, le64_to_cpu(tr_hdr->SessionId), enc, key); 4501 4500 if (rc) { 4502 4501 cifs_server_dbg(VFS, "%s: Could not get %scryption key\n", __func__, 4503 4502 enc ? "en" : "de"); ··· 4789 4788 unsigned int cur_page_idx; 4790 4789 unsigned int pad_len; 4791 4790 struct cifs_readdata *rdata = mid->callback_data; 4792 - struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)buf; 4791 + struct smb2_hdr *shdr = (struct smb2_hdr *)buf; 4793 4792 struct bio_vec *bvec = NULL; 4794 4793 struct iov_iter iter; 4795 4794 struct kvec iov; ··· 5118 5117 { 5119 5118 int ret, length; 5120 5119 char *buf = server->smallbuf; 5121 - struct smb2_sync_hdr *shdr; 5120 + struct smb2_hdr *shdr; 5122 5121 unsigned int pdu_length = server->pdu_size; 5123 5122 unsigned int buf_size; 5124 5123 struct mid_q_entry *mid_entry; ··· 5148 5147 5149 5148 next_is_large = server->large_buf; 5150 5149 one_more: 5151 - shdr = (struct smb2_sync_hdr *)buf; 5150 + shdr = (struct smb2_hdr *)buf; 5152 5151 if (shdr->NextCommand) { 5153 5152 if (next_is_large) 5154 5153 next_buffer = (char *)cifs_buf_get(); ··· 5214 5213 unsigned int orig_len = le32_to_cpu(tr_hdr->OriginalMessageSize); 5215 5214 5216 5215 if (pdu_length < sizeof(struct smb2_transform_hdr) + 5217 - sizeof(struct smb2_sync_hdr)) { 5216 + sizeof(struct smb2_hdr)) { 5218 5217 cifs_server_dbg(VFS, "Transform message is too small (%u)\n", 5219 5218 pdu_length); 5220 5219 cifs_reconnect(server); ··· 5247 5246 static int 5248 5247 smb2_next_header(char *buf) 5249 5248 { 5250 - struct smb2_sync_hdr *hdr = (struct smb2_sync_hdr *)buf; 5249 + struct smb2_hdr *hdr = (struct smb2_hdr *)buf; 5251 5250 struct smb2_transform_hdr *t_hdr = (struct smb2_transform_hdr *)buf; 5252 5251 5253 5252 if (hdr->ProtocolId == SMB2_TRANSFORM_PROTO_NUM) ··· 5789 5788 .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK, 5790 5789 .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK, 5791 5790 .unlock_lock_type = SMB2_LOCKFLAG_UNLOCK, 5792 - .header_size = sizeof(struct smb2_sync_hdr), 5791 + .header_size = sizeof(struct smb2_hdr), 5793 5792 .header_preamble_size = 0, 5794 5793 .max_header_size = MAX_SMB2_HDR_SIZE, 5795 5794 .read_rsp_size = sizeof(struct smb2_read_rsp) - 1, ··· 5810 5809 .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK, 5811 5810 .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK, 5812 5811 .unlock_lock_type = SMB2_LOCKFLAG_UNLOCK, 5813 - .header_size = sizeof(struct smb2_sync_hdr), 5812 + .header_size = sizeof(struct smb2_hdr), 5814 5813 .header_preamble_size = 0, 5815 5814 .max_header_size = MAX_SMB2_HDR_SIZE, 5816 5815 .read_rsp_size = sizeof(struct smb2_read_rsp) - 1, ··· 5831 5830 .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK, 5832 5831 .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK, 5833 5832 .unlock_lock_type = SMB2_LOCKFLAG_UNLOCK, 5834 - .header_size = sizeof(struct smb2_sync_hdr), 5833 + .header_size = sizeof(struct smb2_hdr), 5835 5834 .header_preamble_size = 0, 5836 5835 .max_header_size = MAX_SMB2_HDR_SIZE, 5837 5836 .read_rsp_size = sizeof(struct smb2_read_rsp) - 1, ··· 5852 5851 .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK, 5853 5852 .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK, 5854 5853 .unlock_lock_type = SMB2_LOCKFLAG_UNLOCK, 5855 - .header_size = sizeof(struct smb2_sync_hdr), 5854 + .header_size = sizeof(struct smb2_hdr), 5856 5855 .header_preamble_size = 0, 5857 5856 .max_header_size = MAX_SMB2_HDR_SIZE, 5858 5857 .read_rsp_size = sizeof(struct smb2_read_rsp) - 1, ··· 5873 5872 .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK, 5874 5873 .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK, 5875 5874 .unlock_lock_type = SMB2_LOCKFLAG_UNLOCK, 5876 - .header_size = sizeof(struct smb2_sync_hdr), 5875 + .header_size = sizeof(struct smb2_hdr), 5877 5876 .header_preamble_size = 0, 5878 5877 .max_header_size = MAX_SMB2_HDR_SIZE, 5879 5878 .read_rsp_size = sizeof(struct smb2_read_rsp) - 1, ··· 5894 5893 .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK, 5895 5894 .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK, 5896 5895 .unlock_lock_type = SMB2_LOCKFLAG_UNLOCK, 5897 - .header_size = sizeof(struct smb2_sync_hdr), 5896 + .header_size = sizeof(struct smb2_hdr), 5898 5897 .header_preamble_size = 0, 5899 5898 .max_header_size = MAX_SMB2_HDR_SIZE, 5900 5899 .read_rsp_size = sizeof(struct smb2_read_rsp) - 1, ··· 5915 5914 .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK, 5916 5915 .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK, 5917 5916 .unlock_lock_type = SMB2_LOCKFLAG_UNLOCK, 5918 - .header_size = sizeof(struct smb2_sync_hdr), 5917 + .header_size = sizeof(struct smb2_hdr), 5919 5918 .header_preamble_size = 0, 5920 5919 .max_header_size = MAX_SMB2_HDR_SIZE, 5921 5920 .read_rsp_size = sizeof(struct smb2_read_rsp) - 1,
+52 -54
fs/cifs/smb2pdu.c
··· 23 23 #include <linux/uuid.h> 24 24 #include <linux/pagemap.h> 25 25 #include <linux/xattr.h> 26 - #include "smb2pdu.h" 27 26 #include "cifsglob.h" 28 27 #include "cifsacl.h" 29 28 #include "cifsproto.h" ··· 83 84 } 84 85 85 86 static void 86 - smb2_hdr_assemble(struct smb2_sync_hdr *shdr, __le16 smb2_cmd, 87 + smb2_hdr_assemble(struct smb2_hdr *shdr, __le16 smb2_cmd, 87 88 const struct cifs_tcon *tcon, 88 89 struct TCP_Server_Info *server) 89 90 { ··· 103 104 } else { 104 105 shdr->CreditRequest = cpu_to_le16(2); 105 106 } 106 - shdr->ProcessId = cpu_to_le32((__u16)current->tgid); 107 + shdr->Id.SyncId.ProcessId = cpu_to_le32((__u16)current->tgid); 107 108 108 109 if (!tcon) 109 110 goto out; ··· 114 115 shdr->CreditCharge = cpu_to_le16(1); 115 116 /* else CreditCharge MBZ */ 116 117 117 - shdr->TreeId = tcon->tid; 118 + shdr->Id.SyncId.TreeId = cpu_to_le32(tcon->tid); 118 119 /* Uid is not converted */ 119 120 if (tcon->ses) 120 - shdr->SessionId = tcon->ses->Suid; 121 + shdr->SessionId = cpu_to_le64(tcon->ses->Suid); 121 122 122 123 /* 123 124 * If we would set SMB2_FLAGS_DFS_OPERATIONS on open we also would have ··· 330 331 void *buf, 331 332 unsigned int *total_len) 332 333 { 333 - struct smb2_sync_pdu *spdu = (struct smb2_sync_pdu *)buf; 334 + struct smb2_pdu *spdu = (struct smb2_pdu *)buf; 334 335 /* lookup word count ie StructureSize from table */ 335 336 __u16 parmsize = smb2_req_struct_sizes[le16_to_cpu(smb2_command)]; 336 337 ··· 340 341 */ 341 342 memset(buf, 0, 256); 342 343 343 - smb2_hdr_assemble(&spdu->sync_hdr, smb2_command, tcon, server); 344 + smb2_hdr_assemble(&spdu->hdr, smb2_command, tcon, server); 344 345 spdu->StructureSize2 = cpu_to_le16(parmsize); 345 346 346 - *total_len = parmsize + sizeof(struct smb2_sync_hdr); 347 + *total_len = parmsize + sizeof(struct smb2_hdr); 347 348 } 348 349 349 350 /* ··· 366 367 } 367 368 368 369 fill_small_buf(smb2_command, tcon, server, 369 - (struct smb2_sync_hdr *)(*request_buf), 370 + (struct smb2_hdr *)(*request_buf), 370 371 total_len); 371 372 372 373 if (tcon != NULL) { ··· 856 857 if (rc) 857 858 return rc; 858 859 859 - req->sync_hdr.SessionId = 0; 860 + req->hdr.SessionId = 0; 860 861 861 862 memset(server->preauth_sha_hash, 0, SMB2_PREAUTH_HASH_SIZE); 862 863 memset(ses->preauth_sha_hash, 0, SMB2_PREAUTH_HASH_SIZE); ··· 1017 1018 server->cipher_type = SMB2_ENCRYPTION_AES128_CCM; 1018 1019 1019 1020 security_blob = smb2_get_data_area_len(&blob_offset, &blob_length, 1020 - (struct smb2_sync_hdr *)rsp); 1021 + (struct smb2_hdr *)rsp); 1021 1022 /* 1022 1023 * See MS-SMB2 section 2.2.4: if no blob, client picks default which 1023 1024 * for us will be ··· 1249 1250 return rc; 1250 1251 1251 1252 if (sess_data->ses->binding) { 1252 - req->sync_hdr.SessionId = sess_data->ses->Suid; 1253 - req->sync_hdr.Flags |= SMB2_FLAGS_SIGNED; 1253 + req->hdr.SessionId = cpu_to_le64(sess_data->ses->Suid); 1254 + req->hdr.Flags |= SMB2_FLAGS_SIGNED; 1254 1255 req->PreviousSessionId = 0; 1255 1256 req->Flags = SMB2_SESSION_REQ_FLAG_BINDING; 1256 1257 } else { 1257 1258 /* First session, not a reauthenticate */ 1258 - req->sync_hdr.SessionId = 0; 1259 + req->hdr.SessionId = 0; 1259 1260 /* 1260 1261 * if reconnect, we need to send previous sess id 1261 1262 * otherwise it is 0 ··· 1265 1266 } 1266 1267 1267 1268 /* enough to enable echos and oplocks and one max size write */ 1268 - req->sync_hdr.CreditRequest = cpu_to_le16(130); 1269 + req->hdr.CreditRequest = cpu_to_le16(130); 1269 1270 1270 1271 /* only one of SMB2 signing flags may be set in SMB2 request */ 1271 1272 if (server->sign) ··· 1424 1425 rsp = (struct smb2_sess_setup_rsp *)sess_data->iov[0].iov_base; 1425 1426 /* keep session id and flags if binding */ 1426 1427 if (!ses->binding) { 1427 - ses->Suid = rsp->sync_hdr.SessionId; 1428 + ses->Suid = le64_to_cpu(rsp->hdr.SessionId); 1428 1429 ses->session_flags = le16_to_cpu(rsp->SessionFlags); 1429 1430 } 1430 1431 ··· 1500 1501 1501 1502 /* If true, rc here is expected and not an error */ 1502 1503 if (sess_data->buf0_type != CIFS_NO_BUFFER && 1503 - rsp->sync_hdr.Status == STATUS_MORE_PROCESSING_REQUIRED) 1504 + rsp->hdr.Status == STATUS_MORE_PROCESSING_REQUIRED) 1504 1505 rc = 0; 1505 1506 1506 1507 if (rc) ··· 1522 1523 1523 1524 /* keep existing ses id and flags if binding */ 1524 1525 if (!ses->binding) { 1525 - ses->Suid = rsp->sync_hdr.SessionId; 1526 + ses->Suid = le64_to_cpu(rsp->hdr.SessionId); 1526 1527 ses->session_flags = le16_to_cpu(rsp->SessionFlags); 1527 1528 } 1528 1529 ··· 1557 1558 goto out; 1558 1559 1559 1560 req = (struct smb2_sess_setup_req *) sess_data->iov[0].iov_base; 1560 - req->sync_hdr.SessionId = ses->Suid; 1561 + req->hdr.SessionId = cpu_to_le64(ses->Suid); 1561 1562 1562 1563 rc = build_ntlmssp_auth_blob(&ntlmssp_blob, &blob_length, ses, 1563 1564 sess_data->nls_cp); ··· 1583 1584 1584 1585 /* keep existing ses id and flags if binding */ 1585 1586 if (!ses->binding) { 1586 - ses->Suid = rsp->sync_hdr.SessionId; 1587 + ses->Suid = le64_to_cpu(rsp->hdr.SessionId); 1587 1588 ses->session_flags = le16_to_cpu(rsp->SessionFlags); 1588 1589 } 1589 1590 ··· 1714 1715 return rc; 1715 1716 1716 1717 /* since no tcon, smb2_init can not do this, so do here */ 1717 - req->sync_hdr.SessionId = ses->Suid; 1718 + req->hdr.SessionId = cpu_to_le64(ses->Suid); 1718 1719 1719 1720 if (ses->session_flags & SMB2_SESSION_FLAG_ENCRYPT_DATA) 1720 1721 flags |= CIFS_TRANSFORM_REQ; 1721 1722 else if (server->sign) 1722 - req->sync_hdr.Flags |= SMB2_FLAGS_SIGNED; 1723 + req->hdr.Flags |= SMB2_FLAGS_SIGNED; 1723 1724 1724 1725 flags |= CIFS_NO_RSP_BUF; 1725 1726 ··· 1827 1828 !(ses->session_flags & 1828 1829 (SMB2_SESSION_FLAG_IS_GUEST|SMB2_SESSION_FLAG_IS_NULL)) && 1829 1830 ((ses->user_name != NULL) || (ses->sectype == Kerberos))) 1830 - req->sync_hdr.Flags |= SMB2_FLAGS_SIGNED; 1831 + req->hdr.Flags |= SMB2_FLAGS_SIGNED; 1831 1832 1832 1833 memset(&rqst, 0, sizeof(struct smb_rqst)); 1833 1834 rqst.rq_iov = iov; 1834 1835 rqst.rq_nvec = 2; 1835 1836 1836 1837 /* Need 64 for max size write so ask for more in case not there yet */ 1837 - req->sync_hdr.CreditRequest = cpu_to_le16(64); 1838 + req->hdr.CreditRequest = cpu_to_le16(64); 1838 1839 1839 1840 rc = cifs_send_recv(xid, ses, server, 1840 1841 &rqst, &resp_buftype, flags, &rsp_iov); ··· 1870 1871 tcon->maximal_access = le32_to_cpu(rsp->MaximalAccess); 1871 1872 tcon->tidStatus = CifsGood; 1872 1873 tcon->need_reconnect = false; 1873 - tcon->tid = rsp->sync_hdr.TreeId; 1874 + tcon->tid = le32_to_cpu(rsp->hdr.Id.SyncId.TreeId); 1874 1875 strlcpy(tcon->treeName, tree, sizeof(tcon->treeName)); 1875 1876 1876 1877 if ((rsp->Capabilities & SMB2_SHARE_CAP_DFS) && ··· 1891 1892 return rc; 1892 1893 1893 1894 tcon_error_exit: 1894 - if (rsp && rsp->sync_hdr.Status == STATUS_BAD_NETWORK_NAME) { 1895 + if (rsp && rsp->hdr.Status == STATUS_BAD_NETWORK_NAME) 1895 1896 cifs_tcon_dbg(VFS, "BAD_NETWORK_NAME: %s\n", tree); 1896 - } 1897 1897 goto tcon_exit; 1898 1898 } 1899 1899 ··· 2606 2608 if (tcon->share_flags & SHI1005_FLAGS_DFS) { 2607 2609 int name_len; 2608 2610 2609 - req->sync_hdr.Flags |= SMB2_FLAGS_DFS_OPERATIONS; 2611 + req->hdr.Flags |= SMB2_FLAGS_DFS_OPERATIONS; 2610 2612 rc = alloc_path_with_tree_prefix(&copy_path, &copy_size, 2611 2613 &name_len, 2612 2614 tcon->treeName, utf16_path); ··· 2738 2740 if (tcon->share_flags & SHI1005_FLAGS_DFS) { 2739 2741 int name_len; 2740 2742 2741 - req->sync_hdr.Flags |= SMB2_FLAGS_DFS_OPERATIONS; 2743 + req->hdr.Flags |= SMB2_FLAGS_DFS_OPERATIONS; 2742 2744 rc = alloc_path_with_tree_prefix(&copy_path, &copy_size, 2743 2745 &name_len, 2744 2746 tcon->treeName, path); ··· 2950 2952 oparms->fid->volatile_fid = rsp->VolatileFileId; 2951 2953 oparms->fid->access = oparms->desired_access; 2952 2954 #ifdef CONFIG_CIFS_DEBUG2 2953 - oparms->fid->mid = le64_to_cpu(rsp->sync_hdr.MessageId); 2955 + oparms->fid->mid = le64_to_cpu(rsp->hdr.MessageId); 2954 2956 #endif /* CIFS_DEBUG2 */ 2955 2957 2956 2958 if (buf) { ··· 3050 3052 * response size smaller. 3051 3053 */ 3052 3054 req->MaxOutputResponse = cpu_to_le32(max_response_size); 3053 - req->sync_hdr.CreditCharge = 3055 + req->hdr.CreditCharge = 3054 3056 cpu_to_le16(DIV_ROUND_UP(max(indatalen, max_response_size), 3055 3057 SMB2_MAX_BUFFER_SIZE)); 3056 3058 if (is_fsctl) ··· 3060 3062 3061 3063 /* validate negotiate request must be signed - see MS-SMB2 3.2.5.5 */ 3062 3064 if (opcode == FSCTL_VALIDATE_NEGOTIATE_INFO) 3063 - req->sync_hdr.Flags |= SMB2_FLAGS_SIGNED; 3065 + req->hdr.Flags |= SMB2_FLAGS_SIGNED; 3064 3066 3065 3067 return 0; 3066 3068 } ··· 3685 3687 3686 3688 if (mid->mid_state == MID_RESPONSE_RECEIVED 3687 3689 || mid->mid_state == MID_RESPONSE_MALFORMED) { 3688 - credits.value = le16_to_cpu(rsp->sync_hdr.CreditRequest); 3690 + credits.value = le16_to_cpu(rsp->hdr.CreditRequest); 3689 3691 credits.instance = server->reconnect_instance; 3690 3692 } 3691 3693 ··· 3785 3787 if (rc) 3786 3788 return rc; 3787 3789 3788 - req->sync_hdr.CreditRequest = cpu_to_le16(1); 3790 + req->hdr.CreditRequest = cpu_to_le16(1); 3789 3791 3790 3792 iov[0].iov_len = total_len; 3791 3793 iov[0].iov_base = (char *)req; ··· 3889 3891 { 3890 3892 int rc = -EACCES; 3891 3893 struct smb2_read_plain_req *req = NULL; 3892 - struct smb2_sync_hdr *shdr; 3894 + struct smb2_hdr *shdr; 3893 3895 struct TCP_Server_Info *server = io_parms->server; 3894 3896 3895 3897 rc = smb2_plain_req_init(SMB2_READ, io_parms->tcon, server, ··· 3900 3902 if (server == NULL) 3901 3903 return -ECONNABORTED; 3902 3904 3903 - shdr = &req->sync_hdr; 3904 - shdr->ProcessId = cpu_to_le32(io_parms->pid); 3905 + shdr = &req->hdr; 3906 + shdr->Id.SyncId.ProcessId = cpu_to_le32(io_parms->pid); 3905 3907 3906 3908 req->PersistentFileId = io_parms->persistent_fid; 3907 3909 req->VolatileFileId = io_parms->volatile_fid; ··· 3962 3964 * Related requests use info from previous read request 3963 3965 * in chain. 3964 3966 */ 3965 - shdr->SessionId = 0xFFFFFFFFFFFFFFFF; 3966 - shdr->TreeId = 0xFFFFFFFF; 3967 + shdr->SessionId = cpu_to_le64(0xFFFFFFFFFFFFFFFF); 3968 + shdr->Id.SyncId.TreeId = cpu_to_le32(0xFFFFFFFF); 3967 3969 req->PersistentFileId = 0xFFFFFFFFFFFFFFFF; 3968 3970 req->VolatileFileId = 0xFFFFFFFFFFFFFFFF; 3969 3971 } ··· 3983 3985 struct cifs_readdata *rdata = mid->callback_data; 3984 3986 struct cifs_tcon *tcon = tlink_tcon(rdata->cfile->tlink); 3985 3987 struct TCP_Server_Info *server = rdata->server; 3986 - struct smb2_sync_hdr *shdr = 3987 - (struct smb2_sync_hdr *)rdata->iov[0].iov_base; 3988 + struct smb2_hdr *shdr = 3989 + (struct smb2_hdr *)rdata->iov[0].iov_base; 3988 3990 struct cifs_credits credits = { .value = 0, .instance = 0 }; 3989 3991 struct smb_rqst rqst = { .rq_iov = &rdata->iov[1], 3990 3992 .rq_nvec = 1, ··· 4070 4072 { 4071 4073 int rc, flags = 0; 4072 4074 char *buf; 4073 - struct smb2_sync_hdr *shdr; 4075 + struct smb2_hdr *shdr; 4074 4076 struct cifs_io_parms io_parms; 4075 4077 struct smb_rqst rqst = { .rq_iov = rdata->iov, 4076 4078 .rq_nvec = 1 }; ··· 4103 4105 rdata->iov[0].iov_base = buf; 4104 4106 rdata->iov[0].iov_len = total_len; 4105 4107 4106 - shdr = (struct smb2_sync_hdr *)buf; 4108 + shdr = (struct smb2_hdr *)buf; 4107 4109 4108 4110 if (rdata->credits.value > 0) { 4109 4111 shdr->CreditCharge = cpu_to_le16(DIV_ROUND_UP(rdata->bytes, ··· 4236 4238 4237 4239 switch (mid->mid_state) { 4238 4240 case MID_RESPONSE_RECEIVED: 4239 - credits.value = le16_to_cpu(rsp->sync_hdr.CreditRequest); 4241 + credits.value = le16_to_cpu(rsp->hdr.CreditRequest); 4240 4242 credits.instance = server->reconnect_instance; 4241 4243 wdata->result = smb2_check_receive(mid, server, 0); 4242 4244 if (wdata->result != 0) ··· 4262 4264 wdata->result = -EAGAIN; 4263 4265 break; 4264 4266 case MID_RESPONSE_MALFORMED: 4265 - credits.value = le16_to_cpu(rsp->sync_hdr.CreditRequest); 4267 + credits.value = le16_to_cpu(rsp->hdr.CreditRequest); 4266 4268 credits.instance = server->reconnect_instance; 4267 4269 fallthrough; 4268 4270 default: ··· 4309 4311 { 4310 4312 int rc = -EACCES, flags = 0; 4311 4313 struct smb2_write_req *req = NULL; 4312 - struct smb2_sync_hdr *shdr; 4314 + struct smb2_hdr *shdr; 4313 4315 struct cifs_tcon *tcon = tlink_tcon(wdata->cfile->tlink); 4314 4316 struct TCP_Server_Info *server = wdata->server; 4315 4317 struct kvec iov[1]; ··· 4327 4329 if (smb3_encryption_required(tcon)) 4328 4330 flags |= CIFS_TRANSFORM_REQ; 4329 4331 4330 - shdr = (struct smb2_sync_hdr *)req; 4331 - shdr->ProcessId = cpu_to_le32(wdata->cfile->pid); 4332 + shdr = (struct smb2_hdr *)req; 4333 + shdr->Id.SyncId.ProcessId = cpu_to_le32(wdata->cfile->pid); 4332 4334 4333 4335 req->PersistentFileId = wdata->cfile->fid.persistent_fid; 4334 4336 req->VolatileFileId = wdata->cfile->fid.volatile_fid; ··· 4479 4481 if (smb3_encryption_required(io_parms->tcon)) 4480 4482 flags |= CIFS_TRANSFORM_REQ; 4481 4483 4482 - req->sync_hdr.ProcessId = cpu_to_le32(io_parms->pid); 4484 + req->hdr.Id.SyncId.ProcessId = cpu_to_le32(io_parms->pid); 4483 4485 4484 4486 req->PersistentFileId = io_parms->persistent_fid; 4485 4487 req->VolatileFileId = io_parms->volatile_fid; ··· 4864 4866 4865 4867 if (rc) { 4866 4868 if (rc == -ENODATA && 4867 - rsp->sync_hdr.Status == STATUS_NO_MORE_FILES) { 4869 + rsp->hdr.Status == STATUS_NO_MORE_FILES) { 4868 4870 trace_smb3_query_dir_done(xid, persistent_fid, 4869 4871 tcon->tid, tcon->ses->Suid, index, 0); 4870 4872 srch_inf->endOfSearch = true; ··· 4912 4914 if (rc) 4913 4915 return rc; 4914 4916 4915 - req->sync_hdr.ProcessId = cpu_to_le32(pid); 4917 + req->hdr.Id.SyncId.ProcessId = cpu_to_le32(pid); 4916 4918 req->InfoType = info_type; 4917 4919 req->FileInfoClass = info_class; 4918 4920 req->PersistentFileId = persistent_fid; ··· 5072 5074 req->VolatileFid = volatile_fid; 5073 5075 req->PersistentFid = persistent_fid; 5074 5076 req->OplockLevel = oplock_level; 5075 - req->sync_hdr.CreditRequest = cpu_to_le16(1); 5077 + req->hdr.CreditRequest = cpu_to_le16(1); 5076 5078 5077 5079 flags |= CIFS_NO_RSP_BUF; 5078 5080 ··· 5374 5376 if (smb3_encryption_required(tcon)) 5375 5377 flags |= CIFS_TRANSFORM_REQ; 5376 5378 5377 - req->sync_hdr.ProcessId = cpu_to_le32(pid); 5379 + req->hdr.Id.SyncId.ProcessId = cpu_to_le32(pid); 5378 5380 req->LockCount = cpu_to_le16(num_lock); 5379 5381 5380 5382 req->PersistentFileId = persist_fid; ··· 5450 5452 if (smb3_encryption_required(tcon)) 5451 5453 flags |= CIFS_TRANSFORM_REQ; 5452 5454 5453 - req->sync_hdr.CreditRequest = cpu_to_le16(1); 5455 + req->hdr.CreditRequest = cpu_to_le16(1); 5454 5456 req->StructureSize = cpu_to_le16(36); 5455 5457 total_len += 12; 5456 5458
+35 -338
fs/cifs/smb2pdu.h
··· 14 14 #include <net/sock.h> 15 15 #include "cifsacl.h" 16 16 17 - /* 18 - * Note that, due to trying to use names similar to the protocol specifications, 19 - * there are many mixed case field names in the structures below. Although 20 - * this does not match typical Linux kernel style, it is necessary to be 21 - * able to match against the protocol specfication. 22 - * 23 - * SMB2 commands 24 - * Some commands have minimal (wct=0,bcc=0), or uninteresting, responses 25 - * (ie no useful data other than the SMB error code itself) and are marked such. 26 - * Knowing this helps avoid response buffer allocations and copy in some cases. 27 - */ 28 - 29 - /* List of commands in host endian */ 30 - #define SMB2_NEGOTIATE_HE 0x0000 31 - #define SMB2_SESSION_SETUP_HE 0x0001 32 - #define SMB2_LOGOFF_HE 0x0002 /* trivial request/resp */ 33 - #define SMB2_TREE_CONNECT_HE 0x0003 34 - #define SMB2_TREE_DISCONNECT_HE 0x0004 /* trivial req/resp */ 35 - #define SMB2_CREATE_HE 0x0005 36 - #define SMB2_CLOSE_HE 0x0006 37 - #define SMB2_FLUSH_HE 0x0007 /* trivial resp */ 38 - #define SMB2_READ_HE 0x0008 39 - #define SMB2_WRITE_HE 0x0009 40 - #define SMB2_LOCK_HE 0x000A 41 - #define SMB2_IOCTL_HE 0x000B 42 - #define SMB2_CANCEL_HE 0x000C 43 - #define SMB2_ECHO_HE 0x000D 44 - #define SMB2_QUERY_DIRECTORY_HE 0x000E 45 - #define SMB2_CHANGE_NOTIFY_HE 0x000F 46 - #define SMB2_QUERY_INFO_HE 0x0010 47 - #define SMB2_SET_INFO_HE 0x0011 48 - #define SMB2_OPLOCK_BREAK_HE 0x0012 49 - 50 - /* The same list in little endian */ 51 - #define SMB2_NEGOTIATE cpu_to_le16(SMB2_NEGOTIATE_HE) 52 - #define SMB2_SESSION_SETUP cpu_to_le16(SMB2_SESSION_SETUP_HE) 53 - #define SMB2_LOGOFF cpu_to_le16(SMB2_LOGOFF_HE) 54 - #define SMB2_TREE_CONNECT cpu_to_le16(SMB2_TREE_CONNECT_HE) 55 - #define SMB2_TREE_DISCONNECT cpu_to_le16(SMB2_TREE_DISCONNECT_HE) 56 - #define SMB2_CREATE cpu_to_le16(SMB2_CREATE_HE) 57 - #define SMB2_CLOSE cpu_to_le16(SMB2_CLOSE_HE) 58 - #define SMB2_FLUSH cpu_to_le16(SMB2_FLUSH_HE) 59 - #define SMB2_READ cpu_to_le16(SMB2_READ_HE) 60 - #define SMB2_WRITE cpu_to_le16(SMB2_WRITE_HE) 61 - #define SMB2_LOCK cpu_to_le16(SMB2_LOCK_HE) 62 - #define SMB2_IOCTL cpu_to_le16(SMB2_IOCTL_HE) 63 - #define SMB2_CANCEL cpu_to_le16(SMB2_CANCEL_HE) 64 - #define SMB2_ECHO cpu_to_le16(SMB2_ECHO_HE) 65 - #define SMB2_QUERY_DIRECTORY cpu_to_le16(SMB2_QUERY_DIRECTORY_HE) 66 - #define SMB2_CHANGE_NOTIFY cpu_to_le16(SMB2_CHANGE_NOTIFY_HE) 67 - #define SMB2_QUERY_INFO cpu_to_le16(SMB2_QUERY_INFO_HE) 68 - #define SMB2_SET_INFO cpu_to_le16(SMB2_SET_INFO_HE) 69 - #define SMB2_OPLOCK_BREAK cpu_to_le16(SMB2_OPLOCK_BREAK_HE) 70 - 71 - #define SMB2_INTERNAL_CMD cpu_to_le16(0xFFFF) 72 - 73 - #define NUMBER_OF_SMB2_COMMANDS 0x0013 74 - 75 17 /* 52 transform hdr + 64 hdr + 88 create rsp */ 76 18 #define SMB2_TRANSFORM_HEADER_SIZE 52 77 19 #define MAX_SMB2_HDR_SIZE 204 78 20 79 - #define SMB2_PROTO_NUMBER cpu_to_le32(0x424d53fe) 80 - #define SMB2_TRANSFORM_PROTO_NUM cpu_to_le32(0x424d53fd) 81 - #define SMB2_COMPRESSION_TRANSFORM_ID cpu_to_le32(0x424d53fc) 82 - 83 - /* 84 - * SMB2 Header Definition 85 - * 86 - * "MBZ" : Must be Zero 87 - * "BB" : BugBug, Something to check/review/analyze later 88 - * "PDU" : "Protocol Data Unit" (ie a network "frame") 89 - * 90 - */ 91 - 92 - #define SMB2_HEADER_STRUCTURE_SIZE cpu_to_le16(64) 93 - 94 - struct smb2_sync_hdr { 95 - __le32 ProtocolId; /* 0xFE 'S' 'M' 'B' */ 96 - __le16 StructureSize; /* 64 */ 97 - __le16 CreditCharge; /* MBZ */ 98 - __le32 Status; /* Error from server */ 99 - __le16 Command; 100 - __le16 CreditRequest; /* CreditResponse */ 101 - __le32 Flags; 102 - __le32 NextCommand; 103 - __le64 MessageId; 104 - __le32 ProcessId; 105 - __u32 TreeId; /* opaque - so do not make little endian */ 106 - __u64 SessionId; /* opaque - so do not make little endian */ 107 - __u8 Signature[16]; 108 - } __packed; 109 - 110 21 /* The total header size for SMB2 read and write */ 111 - #define SMB2_READWRITE_PDU_HEADER_SIZE (48 + sizeof(struct smb2_sync_hdr)) 112 - 113 - struct smb2_sync_pdu { 114 - struct smb2_sync_hdr sync_hdr; 115 - __le16 StructureSize2; /* size of wct area (varies, request specific) */ 116 - } __packed; 117 - 118 - #define SMB3_AES_CCM_NONCE 11 119 - #define SMB3_AES_GCM_NONCE 12 120 - 121 - /* Transform flags (for 3.0 dialect this flag indicates CCM */ 122 - #define TRANSFORM_FLAG_ENCRYPTED 0x0001 123 - struct smb2_transform_hdr { 124 - __le32 ProtocolId; /* 0xFD 'S' 'M' 'B' */ 125 - __u8 Signature[16]; 126 - __u8 Nonce[16]; 127 - __le32 OriginalMessageSize; 128 - __u16 Reserved1; 129 - __le16 Flags; /* EncryptionAlgorithm for 3.0, enc enabled for 3.1.1 */ 130 - __u64 SessionId; 131 - } __packed; 132 - 133 - /* See MS-SMB2 2.2.42 */ 134 - struct smb2_compression_transform_hdr_unchained { 135 - __le32 ProtocolId; /* 0xFC 'S' 'M' 'B' */ 136 - __le32 OriginalCompressedSegmentSize; 137 - __le16 CompressionAlgorithm; 138 - __le16 Flags; 139 - __le16 Length; /* if chained it is length, else offset */ 140 - } __packed; 141 - 142 - /* See MS-SMB2 2.2.42.1 */ 143 - #define SMB2_COMPRESSION_FLAG_NONE 0x0000 144 - #define SMB2_COMPRESSION_FLAG_CHAINED 0x0001 145 - 146 - struct compression_payload_header { 147 - __le16 CompressionAlgorithm; 148 - __le16 Flags; 149 - __le32 Length; /* length of compressed playload including field below if present */ 150 - /* __le32 OriginalPayloadSize; */ /* optional, present when LZNT1, LZ77, LZ77+Huffman */ 151 - } __packed; 152 - 153 - /* See MS-SMB2 2.2.42.2 */ 154 - struct smb2_compression_transform_hdr_chained { 155 - __le32 ProtocolId; /* 0xFC 'S' 'M' 'B' */ 156 - __le32 OriginalCompressedSegmentSize; 157 - /* struct compression_payload_header[] */ 158 - } __packed; 159 - 160 - /* See MS-SMB2 2.2.42.2.2 */ 161 - struct compression_pattern_payload_v1 { 162 - __le16 Pattern; 163 - __le16 Reserved1; 164 - __le16 Reserved2; 165 - __le32 Repetitions; 166 - } __packed; 22 + #define SMB2_READWRITE_PDU_HEADER_SIZE (48 + sizeof(struct smb2_hdr)) 167 23 168 24 /* See MS-SMB2 2.2.43 */ 169 25 struct smb2_rdma_transform { ··· 46 190 } __packed; 47 191 48 192 /* 49 - * SMB2 flag definitions 50 - */ 51 - #define SMB2_FLAGS_SERVER_TO_REDIR cpu_to_le32(0x00000001) 52 - #define SMB2_FLAGS_ASYNC_COMMAND cpu_to_le32(0x00000002) 53 - #define SMB2_FLAGS_RELATED_OPERATIONS cpu_to_le32(0x00000004) 54 - #define SMB2_FLAGS_SIGNED cpu_to_le32(0x00000008) 55 - #define SMB2_FLAGS_PRIORITY_MASK cpu_to_le32(0x00000070) /* SMB3.1.1 */ 56 - #define SMB2_FLAGS_DFS_OPERATIONS cpu_to_le32(0x10000000) 57 - #define SMB2_FLAGS_REPLAY_OPERATION cpu_to_le32(0x20000000) /* SMB3 & up */ 58 - 59 - /* 60 193 * Definitions for SMB2 Protocol Data Units (network frames) 61 194 * 62 195 * See MS-SMB2.PDF specification for protocol details. ··· 59 214 #define SMB2_ERROR_STRUCTURE_SIZE2 cpu_to_le16(9) 60 215 61 216 struct smb2_err_rsp { 62 - struct smb2_sync_hdr sync_hdr; 217 + struct smb2_hdr hdr; 63 218 __le16 StructureSize; 64 219 __le16 Reserved; /* MBZ */ 65 220 __le32 ByteCount; /* even if zero, at least one byte follows */ ··· 118 273 #define SMB2_CLIENT_GUID_SIZE 16 119 274 120 275 struct smb2_negotiate_req { 121 - struct smb2_sync_hdr sync_hdr; 276 + struct smb2_hdr hdr; 122 277 __le16 StructureSize; /* Must be 36 */ 123 278 __le16 DialectCount; 124 279 __le16 SecurityMode; ··· 317 472 } __packed; 318 473 319 474 struct smb2_negotiate_rsp { 320 - struct smb2_sync_hdr sync_hdr; 475 + struct smb2_hdr hdr; 321 476 __le16 StructureSize; /* Must be 65 */ 322 477 __le16 SecurityMode; 323 478 __le16 DialectRevision; ··· 340 495 #define SMB2_SESSION_REQ_FLAG_ENCRYPT_DATA 0x04 341 496 342 497 struct smb2_sess_setup_req { 343 - struct smb2_sync_hdr sync_hdr; 498 + struct smb2_hdr hdr; 344 499 __le16 StructureSize; /* Must be 25 */ 345 500 __u8 Flags; 346 501 __u8 SecurityMode; ··· 357 512 #define SMB2_SESSION_FLAG_IS_NULL 0x0002 358 513 #define SMB2_SESSION_FLAG_ENCRYPT_DATA 0x0004 359 514 struct smb2_sess_setup_rsp { 360 - struct smb2_sync_hdr sync_hdr; 515 + struct smb2_hdr hdr; 361 516 __le16 StructureSize; /* Must be 9 */ 362 517 __le16 SessionFlags; 363 518 __le16 SecurityBufferOffset; ··· 366 521 } __packed; 367 522 368 523 struct smb2_logoff_req { 369 - struct smb2_sync_hdr sync_hdr; 524 + struct smb2_hdr hdr; 370 525 __le16 StructureSize; /* Must be 4 */ 371 526 __le16 Reserved; 372 527 } __packed; 373 528 374 529 struct smb2_logoff_rsp { 375 - struct smb2_sync_hdr sync_hdr; 376 - __le16 StructureSize; /* Must be 4 */ 377 - __le16 Reserved; 378 - } __packed; 379 - 380 - /* Flags/Reserved for SMB3.1.1 */ 381 - #define SMB2_TREE_CONNECT_FLAG_CLUSTER_RECONNECT cpu_to_le16(0x0001) 382 - #define SMB2_TREE_CONNECT_FLAG_REDIRECT_TO_OWNER cpu_to_le16(0x0002) 383 - #define SMB2_TREE_CONNECT_FLAG_EXTENSION_PRESENT cpu_to_le16(0x0004) 384 - 385 - struct smb2_tree_connect_req { 386 - struct smb2_sync_hdr sync_hdr; 387 - __le16 StructureSize; /* Must be 9 */ 388 - __le16 Flags; /* Reserved MBZ for dialects prior to SMB3.1.1 */ 389 - __le16 PathOffset; 390 - __le16 PathLength; 391 - __u8 Buffer[1]; /* variable length */ 392 - } __packed; 393 - 394 - /* See MS-SMB2 section 2.2.9.2 */ 395 - /* Context Types */ 396 - #define SMB2_RESERVED_TREE_CONNECT_CONTEXT_ID 0x0000 397 - #define SMB2_REMOTED_IDENTITY_TREE_CONNECT_CONTEXT_ID cpu_to_le16(0x0001) 398 - 399 - struct tree_connect_contexts { 400 - __le16 ContextType; 401 - __le16 DataLength; 402 - __le32 Reserved; 403 - __u8 Data[]; 404 - } __packed; 405 - 406 - /* Remoted identity tree connect context structures - see MS-SMB2 2.2.9.2.1 */ 407 - struct smb3_blob_data { 408 - __le16 BlobSize; 409 - __u8 BlobData[]; 410 - } __packed; 411 - 412 - /* Valid values for Attr */ 413 - #define SE_GROUP_MANDATORY 0x00000001 414 - #define SE_GROUP_ENABLED_BY_DEFAULT 0x00000002 415 - #define SE_GROUP_ENABLED 0x00000004 416 - #define SE_GROUP_OWNER 0x00000008 417 - #define SE_GROUP_USE_FOR_DENY_ONLY 0x00000010 418 - #define SE_GROUP_INTEGRITY 0x00000020 419 - #define SE_GROUP_INTEGRITY_ENABLED 0x00000040 420 - #define SE_GROUP_RESOURCE 0x20000000 421 - #define SE_GROUP_LOGON_ID 0xC0000000 422 - 423 - /* struct sid_attr_data is SidData array in BlobData format then le32 Attr */ 424 - 425 - struct sid_array_data { 426 - __le16 SidAttrCount; 427 - /* SidAttrList - array of sid_attr_data structs */ 428 - } __packed; 429 - 430 - struct luid_attr_data { 431 - 432 - } __packed; 433 - 434 - /* 435 - * struct privilege_data is the same as BLOB_DATA - see MS-SMB2 2.2.9.2.1.5 436 - * but with size of LUID_ATTR_DATA struct and BlobData set to LUID_ATTR DATA 437 - */ 438 - 439 - struct privilege_array_data { 440 - __le16 PrivilegeCount; 441 - /* array of privilege_data structs */ 442 - } __packed; 443 - 444 - struct remoted_identity_tcon_context { 445 - __le16 TicketType; /* must be 0x0001 */ 446 - __le16 TicketSize; /* total size of this struct */ 447 - __le16 User; /* offset to SID_ATTR_DATA struct with user info */ 448 - __le16 UserName; /* offset to null terminated Unicode username string */ 449 - __le16 Domain; /* offset to null terminated Unicode domain name */ 450 - __le16 Groups; /* offset to SID_ARRAY_DATA struct with group info */ 451 - __le16 RestrictedGroups; /* similar to above */ 452 - __le16 Privileges; /* offset to PRIVILEGE_ARRAY_DATA struct */ 453 - __le16 PrimaryGroup; /* offset to SID_ARRAY_DATA struct */ 454 - __le16 Owner; /* offset to BLOB_DATA struct */ 455 - __le16 DefaultDacl; /* offset to BLOB_DATA struct */ 456 - __le16 DeviceGroups; /* offset to SID_ARRAY_DATA struct */ 457 - __le16 UserClaims; /* offset to BLOB_DATA struct */ 458 - __le16 DeviceClaims; /* offset to BLOB_DATA struct */ 459 - __u8 TicketInfo[]; /* variable length buf - remoted identity data */ 460 - } __packed; 461 - 462 - struct smb2_tree_connect_req_extension { 463 - __le32 TreeConnectContextOffset; 464 - __le16 TreeConnectContextCount; 465 - __u8 Reserved[10]; 466 - __u8 PathName[]; /* variable sized array */ 467 - /* followed by array of TreeConnectContexts */ 468 - } __packed; 469 - 470 - struct smb2_tree_connect_rsp { 471 - struct smb2_sync_hdr sync_hdr; 472 - __le16 StructureSize; /* Must be 16 */ 473 - __u8 ShareType; /* see below */ 474 - __u8 Reserved; 475 - __le32 ShareFlags; /* see below */ 476 - __le32 Capabilities; /* see below */ 477 - __le32 MaximalAccess; 478 - } __packed; 479 - 480 - /* Possible ShareType values */ 481 - #define SMB2_SHARE_TYPE_DISK 0x01 482 - #define SMB2_SHARE_TYPE_PIPE 0x02 483 - #define SMB2_SHARE_TYPE_PRINT 0x03 484 - 485 - /* 486 - * Possible ShareFlags - exactly one and only one of the first 4 caching flags 487 - * must be set (any of the remaining, SHI1005, flags may be set individually 488 - * or in combination. 489 - */ 490 - #define SMB2_SHAREFLAG_MANUAL_CACHING 0x00000000 491 - #define SMB2_SHAREFLAG_AUTO_CACHING 0x00000010 492 - #define SMB2_SHAREFLAG_VDO_CACHING 0x00000020 493 - #define SMB2_SHAREFLAG_NO_CACHING 0x00000030 494 - #define SHI1005_FLAGS_DFS 0x00000001 495 - #define SHI1005_FLAGS_DFS_ROOT 0x00000002 496 - #define SHI1005_FLAGS_RESTRICT_EXCLUSIVE_OPENS 0x00000100 497 - #define SHI1005_FLAGS_FORCE_SHARED_DELETE 0x00000200 498 - #define SHI1005_FLAGS_ALLOW_NAMESPACE_CACHING 0x00000400 499 - #define SHI1005_FLAGS_ACCESS_BASED_DIRECTORY_ENUM 0x00000800 500 - #define SHI1005_FLAGS_FORCE_LEVELII_OPLOCK 0x00001000 501 - #define SHI1005_FLAGS_ENABLE_HASH_V1 0x00002000 502 - #define SHI1005_FLAGS_ENABLE_HASH_V2 0x00004000 503 - #define SHI1005_FLAGS_ENCRYPT_DATA 0x00008000 504 - #define SMB2_SHAREFLAG_IDENTITY_REMOTING 0x00040000 /* 3.1.1 */ 505 - #define SMB2_SHAREFLAG_COMPRESS_DATA 0x00100000 /* 3.1.1 */ 506 - #define SHI1005_FLAGS_ALL 0x0014FF33 507 - 508 - /* Possible share capabilities */ 509 - #define SMB2_SHARE_CAP_DFS cpu_to_le32(0x00000008) /* all dialects */ 510 - #define SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY cpu_to_le32(0x00000010) /* 3.0 */ 511 - #define SMB2_SHARE_CAP_SCALEOUT cpu_to_le32(0x00000020) /* 3.0 */ 512 - #define SMB2_SHARE_CAP_CLUSTER cpu_to_le32(0x00000040) /* 3.0 */ 513 - #define SMB2_SHARE_CAP_ASYMMETRIC cpu_to_le32(0x00000080) /* 3.02 */ 514 - #define SMB2_SHARE_CAP_REDIRECT_TO_OWNER cpu_to_le32(0x00000100) /* 3.1.1 */ 515 - 516 - struct smb2_tree_disconnect_req { 517 - struct smb2_sync_hdr sync_hdr; 518 - __le16 StructureSize; /* Must be 4 */ 519 - __le16 Reserved; 520 - } __packed; 521 - 522 - struct smb2_tree_disconnect_rsp { 523 - struct smb2_sync_hdr sync_hdr; 530 + struct smb2_hdr hdr; 524 531 __le16 StructureSize; /* Must be 4 */ 525 532 __le16 Reserved; 526 533 } __packed; ··· 505 808 #define SMB2_CREATE_IOV_SIZE 8 506 809 507 810 struct smb2_create_req { 508 - struct smb2_sync_hdr sync_hdr; 811 + struct smb2_hdr hdr; 509 812 __le16 StructureSize; /* Must be 57 */ 510 813 __u8 SecurityFlags; 511 814 __u8 RequestedOplockLevel; ··· 532 835 #define MAX_SMB2_CREATE_RESPONSE_SIZE 880 533 836 534 837 struct smb2_create_rsp { 535 - struct smb2_sync_hdr sync_hdr; 838 + struct smb2_hdr hdr; 536 839 __le16 StructureSize; /* Must be 89 */ 537 840 __u8 OplockLevel; 538 841 __u8 Flag; /* 0x01 if reparse point */ ··· 907 1210 #define SMB2_IOCTL_IOV_SIZE 2 908 1211 909 1212 struct smb2_ioctl_req { 910 - struct smb2_sync_hdr sync_hdr; 1213 + struct smb2_hdr hdr; 911 1214 __le16 StructureSize; /* Must be 57 */ 912 1215 __u16 Reserved; 913 1216 __le32 CtlCode; ··· 925 1228 } __packed; 926 1229 927 1230 struct smb2_ioctl_rsp { 928 - struct smb2_sync_hdr sync_hdr; 1231 + struct smb2_hdr hdr; 929 1232 __le16 StructureSize; /* Must be 57 */ 930 1233 __u16 Reserved; 931 1234 __le32 CtlCode; ··· 943 1246 /* Currently defined values for close flags */ 944 1247 #define SMB2_CLOSE_FLAG_POSTQUERY_ATTRIB cpu_to_le16(0x0001) 945 1248 struct smb2_close_req { 946 - struct smb2_sync_hdr sync_hdr; 1249 + struct smb2_hdr hdr; 947 1250 __le16 StructureSize; /* Must be 24 */ 948 1251 __le16 Flags; 949 1252 __le32 Reserved; ··· 957 1260 #define MAX_SMB2_CLOSE_RESPONSE_SIZE 124 958 1261 959 1262 struct smb2_close_rsp { 960 - struct smb2_sync_hdr sync_hdr; 1263 + struct smb2_hdr hdr; 961 1264 __le16 StructureSize; /* 60 */ 962 1265 __le16 Flags; 963 1266 __le32 Reserved; ··· 971 1274 } __packed; 972 1275 973 1276 struct smb2_flush_req { 974 - struct smb2_sync_hdr sync_hdr; 1277 + struct smb2_hdr hdr; 975 1278 __le16 StructureSize; /* Must be 24 */ 976 1279 __le16 Reserved1; 977 1280 __le32 Reserved2; ··· 980 1283 } __packed; 981 1284 982 1285 struct smb2_flush_rsp { 983 - struct smb2_sync_hdr sync_hdr; 1286 + struct smb2_hdr hdr; 984 1287 __le16 StructureSize; 985 1288 __le16 Reserved; 986 1289 } __packed; ··· 997 1300 998 1301 /* SMB2 read request without RFC1001 length at the beginning */ 999 1302 struct smb2_read_plain_req { 1000 - struct smb2_sync_hdr sync_hdr; 1303 + struct smb2_hdr hdr; 1001 1304 __le16 StructureSize; /* Must be 49 */ 1002 1305 __u8 Padding; /* offset from start of SMB2 header to place read */ 1003 1306 __u8 Flags; /* MBZ unless SMB3.02 or later */ ··· 1018 1321 #define SMB2_READFLAG_RESPONSE_RDMA_TRANSFORM 0x00000001 1019 1322 1020 1323 struct smb2_read_rsp { 1021 - struct smb2_sync_hdr sync_hdr; 1324 + struct smb2_hdr hdr; 1022 1325 __le16 StructureSize; /* Must be 17 */ 1023 1326 __u8 DataOffset; 1024 1327 __u8 Reserved; ··· 1033 1336 #define SMB2_WRITEFLAG_WRITE_UNBUFFERED 0x00000002 /* SMB3.02 or later */ 1034 1337 1035 1338 struct smb2_write_req { 1036 - struct smb2_sync_hdr sync_hdr; 1339 + struct smb2_hdr hdr; 1037 1340 __le16 StructureSize; /* Must be 49 */ 1038 1341 __le16 DataOffset; /* offset from start of SMB2 header to write data */ 1039 1342 __le32 Length; ··· 1049 1352 } __packed; 1050 1353 1051 1354 struct smb2_write_rsp { 1052 - struct smb2_sync_hdr sync_hdr; 1355 + struct smb2_hdr hdr; 1053 1356 __le16 StructureSize; /* Must be 17 */ 1054 1357 __u8 DataOffset; 1055 1358 __u8 Reserved; ··· 1077 1380 #define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800 1078 1381 1079 1382 struct smb2_change_notify_req { 1080 - struct smb2_sync_hdr sync_hdr; 1383 + struct smb2_hdr hdr; 1081 1384 __le16 StructureSize; 1082 1385 __le16 Flags; 1083 1386 __le32 OutputBufferLength; ··· 1088 1391 } __packed; 1089 1392 1090 1393 struct smb2_change_notify_rsp { 1091 - struct smb2_sync_hdr sync_hdr; 1394 + struct smb2_hdr hdr; 1092 1395 __le16 StructureSize; /* Must be 9 */ 1093 1396 __le16 OutputBufferOffset; 1094 1397 __le32 OutputBufferLength; ··· 1108 1411 } __packed; 1109 1412 1110 1413 struct smb2_lock_req { 1111 - struct smb2_sync_hdr sync_hdr; 1414 + struct smb2_hdr hdr; 1112 1415 __le16 StructureSize; /* Must be 48 */ 1113 1416 __le16 LockCount; 1114 1417 /* ··· 1123 1426 } __packed; 1124 1427 1125 1428 struct smb2_lock_rsp { 1126 - struct smb2_sync_hdr sync_hdr; 1429 + struct smb2_hdr hdr; 1127 1430 __le16 StructureSize; /* Must be 4 */ 1128 1431 __le16 Reserved; 1129 1432 } __packed; 1130 1433 1131 1434 struct smb2_echo_req { 1132 - struct smb2_sync_hdr sync_hdr; 1435 + struct smb2_hdr hdr; 1133 1436 __le16 StructureSize; /* Must be 4 */ 1134 1437 __u16 Reserved; 1135 1438 } __packed; 1136 1439 1137 1440 struct smb2_echo_rsp { 1138 - struct smb2_sync_hdr sync_hdr; 1441 + struct smb2_hdr hdr; 1139 1442 __le16 StructureSize; /* Must be 4 */ 1140 1443 __u16 Reserved; 1141 1444 } __packed; ··· 1165 1468 */ 1166 1469 1167 1470 struct smb2_query_directory_req { 1168 - struct smb2_sync_hdr sync_hdr; 1471 + struct smb2_hdr hdr; 1169 1472 __le16 StructureSize; /* Must be 33 */ 1170 1473 __u8 FileInformationClass; 1171 1474 __u8 Flags; ··· 1179 1482 } __packed; 1180 1483 1181 1484 struct smb2_query_directory_rsp { 1182 - struct smb2_sync_hdr sync_hdr; 1485 + struct smb2_hdr hdr; 1183 1486 __le16 StructureSize; /* Must be 9 */ 1184 1487 __le16 OutputBufferOffset; 1185 1488 __le32 OutputBufferLength; ··· 1212 1515 #define SL_INDEX_SPECIFIED 0x00000004 1213 1516 1214 1517 struct smb2_query_info_req { 1215 - struct smb2_sync_hdr sync_hdr; 1518 + struct smb2_hdr hdr; 1216 1519 __le16 StructureSize; /* Must be 41 */ 1217 1520 __u8 InfoType; 1218 1521 __u8 FileInfoClass; ··· 1228 1531 } __packed; 1229 1532 1230 1533 struct smb2_query_info_rsp { 1231 - struct smb2_sync_hdr sync_hdr; 1534 + struct smb2_hdr hdr; 1232 1535 __le16 StructureSize; /* Must be 9 */ 1233 1536 __le16 OutputBufferOffset; 1234 1537 __le32 OutputBufferLength; ··· 1245 1548 #define SMB2_SET_INFO_IOV_SIZE 3 1246 1549 1247 1550 struct smb2_set_info_req { 1248 - struct smb2_sync_hdr sync_hdr; 1551 + struct smb2_hdr hdr; 1249 1552 __le16 StructureSize; /* Must be 33 */ 1250 1553 __u8 InfoType; 1251 1554 __u8 FileInfoClass; ··· 1259 1562 } __packed; 1260 1563 1261 1564 struct smb2_set_info_rsp { 1262 - struct smb2_sync_hdr sync_hdr; 1565 + struct smb2_hdr hdr; 1263 1566 __le16 StructureSize; /* Must be 2 */ 1264 1567 } __packed; 1265 1568 1266 1569 struct smb2_oplock_break { 1267 - struct smb2_sync_hdr sync_hdr; 1570 + struct smb2_hdr hdr; 1268 1571 __le16 StructureSize; /* Must be 24 */ 1269 1572 __u8 OplockLevel; 1270 1573 __u8 Reserved; ··· 1276 1579 #define SMB2_NOTIFY_BREAK_LEASE_FLAG_ACK_REQUIRED cpu_to_le32(0x01) 1277 1580 1278 1581 struct smb2_lease_break { 1279 - struct smb2_sync_hdr sync_hdr; 1582 + struct smb2_hdr hdr; 1280 1583 __le16 StructureSize; /* Must be 44 */ 1281 1584 __le16 Epoch; 1282 1585 __le32 Flags; ··· 1289 1592 } __packed; 1290 1593 1291 1594 struct smb2_lease_ack { 1292 - struct smb2_sync_hdr sync_hdr; 1595 + struct smb2_hdr hdr; 1293 1596 __le16 StructureSize; /* Must be 36 */ 1294 1597 __le16 Reserved; 1295 1598 __le32 Flags;
+1 -1
fs/cifs/smb2proto.h
··· 25 25 struct TCP_Server_Info *server); 26 26 extern unsigned int smb2_calc_size(void *buf, struct TCP_Server_Info *server); 27 27 extern char *smb2_get_data_area_len(int *off, int *len, 28 - struct smb2_sync_hdr *shdr); 28 + struct smb2_hdr *shdr); 29 29 extern __le16 *cifs_convert_path_to_utf16(const char *from, 30 30 struct cifs_sb_info *cifs_sb); 31 31
+18 -18
fs/cifs/smb2transport.c
··· 19 19 #include <linux/mempool.h> 20 20 #include <linux/highmem.h> 21 21 #include <crypto/aead.h> 22 - #include "smb2pdu.h" 23 22 #include "cifsglob.h" 24 23 #include "cifsproto.h" 25 24 #include "smb2proto.h" ··· 212 213 unsigned char smb2_signature[SMB2_HMACSHA256_SIZE]; 213 214 unsigned char *sigptr = smb2_signature; 214 215 struct kvec *iov = rqst->rq_iov; 215 - struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)iov[0].iov_base; 216 + struct smb2_hdr *shdr = (struct smb2_hdr *)iov[0].iov_base; 216 217 struct cifs_ses *ses; 217 218 struct shash_desc *shash; 218 219 struct crypto_shash *hash; 219 220 struct sdesc *sdesc = NULL; 220 221 struct smb_rqst drqst; 221 222 222 - ses = smb2_find_smb_ses(server, shdr->SessionId); 223 + ses = smb2_find_smb_ses(server, le64_to_cpu(shdr->SessionId)); 223 224 if (!ses) { 224 225 cifs_server_dbg(VFS, "%s: Could not find session\n", __func__); 225 226 return 0; ··· 533 534 unsigned char smb3_signature[SMB2_CMACAES_SIZE]; 534 535 unsigned char *sigptr = smb3_signature; 535 536 struct kvec *iov = rqst->rq_iov; 536 - struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)iov[0].iov_base; 537 + struct smb2_hdr *shdr = (struct smb2_hdr *)iov[0].iov_base; 537 538 struct shash_desc *shash; 538 539 struct crypto_shash *hash; 539 540 struct sdesc *sdesc = NULL; 540 541 struct smb_rqst drqst; 541 542 u8 key[SMB3_SIGN_KEY_SIZE]; 542 543 543 - rc = smb2_get_sign_key(shdr->SessionId, server, key); 544 + rc = smb2_get_sign_key(le64_to_cpu(shdr->SessionId), server, key); 544 545 if (rc) 545 546 return 0; 546 547 ··· 610 611 smb2_sign_rqst(struct smb_rqst *rqst, struct TCP_Server_Info *server) 611 612 { 612 613 int rc = 0; 613 - struct smb2_sync_hdr *shdr; 614 + struct smb2_hdr *shdr; 614 615 struct smb2_sess_setup_req *ssr; 615 616 bool is_binding; 616 617 bool is_signed; 617 618 618 - shdr = (struct smb2_sync_hdr *)rqst->rq_iov[0].iov_base; 619 + shdr = (struct smb2_hdr *)rqst->rq_iov[0].iov_base; 619 620 ssr = (struct smb2_sess_setup_req *)shdr; 620 621 621 622 is_binding = shdr->Command == SMB2_SESSION_SETUP && ··· 641 642 { 642 643 unsigned int rc; 643 644 char server_response_sig[SMB2_SIGNATURE_SIZE]; 644 - struct smb2_sync_hdr *shdr = 645 - (struct smb2_sync_hdr *)rqst->rq_iov[0].iov_base; 645 + struct smb2_hdr *shdr = 646 + (struct smb2_hdr *)rqst->rq_iov[0].iov_base; 646 647 647 648 if ((shdr->Command == SMB2_NEGOTIATE) || 648 649 (shdr->Command == SMB2_SESSION_SETUP) || ··· 688 689 */ 689 690 static inline void 690 691 smb2_seq_num_into_buf(struct TCP_Server_Info *server, 691 - struct smb2_sync_hdr *shdr) 692 + struct smb2_hdr *shdr) 692 693 { 693 694 unsigned int i, num = le16_to_cpu(shdr->CreditCharge); 694 695 ··· 699 700 } 700 701 701 702 static struct mid_q_entry * 702 - smb2_mid_entry_alloc(const struct smb2_sync_hdr *shdr, 703 + smb2_mid_entry_alloc(const struct smb2_hdr *shdr, 703 704 struct TCP_Server_Info *server) 704 705 { 705 706 struct mid_q_entry *temp; ··· 731 732 732 733 atomic_inc(&midCount); 733 734 temp->mid_state = MID_REQUEST_ALLOCATED; 734 - trace_smb3_cmd_enter(shdr->TreeId, shdr->SessionId, 735 - le16_to_cpu(shdr->Command), temp->mid); 735 + trace_smb3_cmd_enter(le32_to_cpu(shdr->Id.SyncId.TreeId), 736 + le64_to_cpu(shdr->SessionId), 737 + le16_to_cpu(shdr->Command), temp->mid); 736 738 return temp; 737 739 } 738 740 739 741 static int 740 742 smb2_get_mid_entry(struct cifs_ses *ses, struct TCP_Server_Info *server, 741 - struct smb2_sync_hdr *shdr, struct mid_q_entry **mid) 743 + struct smb2_hdr *shdr, struct mid_q_entry **mid) 742 744 { 743 745 if (server->tcpStatus == CifsExiting) 744 746 return -ENOENT; ··· 807 807 struct smb_rqst *rqst) 808 808 { 809 809 int rc; 810 - struct smb2_sync_hdr *shdr = 811 - (struct smb2_sync_hdr *)rqst->rq_iov[0].iov_base; 810 + struct smb2_hdr *shdr = 811 + (struct smb2_hdr *)rqst->rq_iov[0].iov_base; 812 812 struct mid_q_entry *mid; 813 813 814 814 smb2_seq_num_into_buf(server, shdr); ··· 833 833 smb2_setup_async_request(struct TCP_Server_Info *server, struct smb_rqst *rqst) 834 834 { 835 835 int rc; 836 - struct smb2_sync_hdr *shdr = 837 - (struct smb2_sync_hdr *)rqst->rq_iov[0].iov_base; 836 + struct smb2_hdr *shdr = 837 + (struct smb2_hdr *)rqst->rq_iov[0].iov_base; 838 838 struct mid_q_entry *mid; 839 839 840 840 if (server->tcpStatus == CifsNeedNegotiate &&
+318
fs/smbfs_common/smb2pdu.h
··· 1 + /* SPDX-License-Identifier: LGPL-2.1 */ 2 + #ifndef _COMMON_SMB2PDU_H 3 + #define _COMMON_SMB2PDU_H 4 + 5 + /* 6 + * Note that, due to trying to use names similar to the protocol specifications, 7 + * there are many mixed case field names in the structures below. Although 8 + * this does not match typical Linux kernel style, it is necessary to be 9 + * able to match against the protocol specfication. 10 + * 11 + * SMB2 commands 12 + * Some commands have minimal (wct=0,bcc=0), or uninteresting, responses 13 + * (ie no useful data other than the SMB error code itself) and are marked such. 14 + * Knowing this helps avoid response buffer allocations and copy in some cases. 15 + */ 16 + 17 + /* List of commands in host endian */ 18 + #define SMB2_NEGOTIATE_HE 0x0000 19 + #define SMB2_SESSION_SETUP_HE 0x0001 20 + #define SMB2_LOGOFF_HE 0x0002 /* trivial request/resp */ 21 + #define SMB2_TREE_CONNECT_HE 0x0003 22 + #define SMB2_TREE_DISCONNECT_HE 0x0004 /* trivial req/resp */ 23 + #define SMB2_CREATE_HE 0x0005 24 + #define SMB2_CLOSE_HE 0x0006 25 + #define SMB2_FLUSH_HE 0x0007 /* trivial resp */ 26 + #define SMB2_READ_HE 0x0008 27 + #define SMB2_WRITE_HE 0x0009 28 + #define SMB2_LOCK_HE 0x000A 29 + #define SMB2_IOCTL_HE 0x000B 30 + #define SMB2_CANCEL_HE 0x000C 31 + #define SMB2_ECHO_HE 0x000D 32 + #define SMB2_QUERY_DIRECTORY_HE 0x000E 33 + #define SMB2_CHANGE_NOTIFY_HE 0x000F 34 + #define SMB2_QUERY_INFO_HE 0x0010 35 + #define SMB2_SET_INFO_HE 0x0011 36 + #define SMB2_OPLOCK_BREAK_HE 0x0012 37 + 38 + /* The same list in little endian */ 39 + #define SMB2_NEGOTIATE cpu_to_le16(SMB2_NEGOTIATE_HE) 40 + #define SMB2_SESSION_SETUP cpu_to_le16(SMB2_SESSION_SETUP_HE) 41 + #define SMB2_LOGOFF cpu_to_le16(SMB2_LOGOFF_HE) 42 + #define SMB2_TREE_CONNECT cpu_to_le16(SMB2_TREE_CONNECT_HE) 43 + #define SMB2_TREE_DISCONNECT cpu_to_le16(SMB2_TREE_DISCONNECT_HE) 44 + #define SMB2_CREATE cpu_to_le16(SMB2_CREATE_HE) 45 + #define SMB2_CLOSE cpu_to_le16(SMB2_CLOSE_HE) 46 + #define SMB2_FLUSH cpu_to_le16(SMB2_FLUSH_HE) 47 + #define SMB2_READ cpu_to_le16(SMB2_READ_HE) 48 + #define SMB2_WRITE cpu_to_le16(SMB2_WRITE_HE) 49 + #define SMB2_LOCK cpu_to_le16(SMB2_LOCK_HE) 50 + #define SMB2_IOCTL cpu_to_le16(SMB2_IOCTL_HE) 51 + #define SMB2_CANCEL cpu_to_le16(SMB2_CANCEL_HE) 52 + #define SMB2_ECHO cpu_to_le16(SMB2_ECHO_HE) 53 + #define SMB2_QUERY_DIRECTORY cpu_to_le16(SMB2_QUERY_DIRECTORY_HE) 54 + #define SMB2_CHANGE_NOTIFY cpu_to_le16(SMB2_CHANGE_NOTIFY_HE) 55 + #define SMB2_QUERY_INFO cpu_to_le16(SMB2_QUERY_INFO_HE) 56 + #define SMB2_SET_INFO cpu_to_le16(SMB2_SET_INFO_HE) 57 + #define SMB2_OPLOCK_BREAK cpu_to_le16(SMB2_OPLOCK_BREAK_HE) 58 + 59 + #define SMB2_INTERNAL_CMD cpu_to_le16(0xFFFF) 60 + 61 + #define NUMBER_OF_SMB2_COMMANDS 0x0013 62 + 63 + /* 64 + * SMB2 Header Definition 65 + * 66 + * "MBZ" : Must be Zero 67 + * "BB" : BugBug, Something to check/review/analyze later 68 + * "PDU" : "Protocol Data Unit" (ie a network "frame") 69 + * 70 + */ 71 + 72 + #define __SMB2_HEADER_STRUCTURE_SIZE 64 73 + #define SMB2_HEADER_STRUCTURE_SIZE \ 74 + cpu_to_le16(__SMB2_HEADER_STRUCTURE_SIZE) 75 + 76 + #define SMB2_PROTO_NUMBER cpu_to_le32(0x424d53fe) 77 + #define SMB2_TRANSFORM_PROTO_NUM cpu_to_le32(0x424d53fd) 78 + #define SMB2_COMPRESSION_TRANSFORM_ID cpu_to_le32(0x424d53fc) 79 + 80 + /* 81 + * SMB2 flag definitions 82 + */ 83 + #define SMB2_FLAGS_SERVER_TO_REDIR cpu_to_le32(0x00000001) 84 + #define SMB2_FLAGS_ASYNC_COMMAND cpu_to_le32(0x00000002) 85 + #define SMB2_FLAGS_RELATED_OPERATIONS cpu_to_le32(0x00000004) 86 + #define SMB2_FLAGS_SIGNED cpu_to_le32(0x00000008) 87 + #define SMB2_FLAGS_PRIORITY_MASK cpu_to_le32(0x00000070) /* SMB3.1.1 */ 88 + #define SMB2_FLAGS_DFS_OPERATIONS cpu_to_le32(0x10000000) 89 + #define SMB2_FLAGS_REPLAY_OPERATION cpu_to_le32(0x20000000) /* SMB3 & up */ 90 + 91 + /* See MS-SMB2 section 2.2.1 */ 92 + struct smb2_hdr { 93 + __le32 ProtocolId; /* 0xFE 'S' 'M' 'B' */ 94 + __le16 StructureSize; /* 64 */ 95 + __le16 CreditCharge; /* MBZ */ 96 + __le32 Status; /* Error from server */ 97 + __le16 Command; 98 + __le16 CreditRequest; /* CreditResponse */ 99 + __le32 Flags; 100 + __le32 NextCommand; 101 + __le64 MessageId; 102 + union { 103 + struct { 104 + __le32 ProcessId; 105 + __le32 TreeId; 106 + } __packed SyncId; 107 + __le64 AsyncId; 108 + } __packed Id; 109 + __le64 SessionId; 110 + __u8 Signature[16]; 111 + } __packed; 112 + 113 + struct smb2_pdu { 114 + struct smb2_hdr hdr; 115 + __le16 StructureSize2; /* size of wct area (varies, request specific) */ 116 + } __packed; 117 + 118 + #define SMB3_AES_CCM_NONCE 11 119 + #define SMB3_AES_GCM_NONCE 12 120 + 121 + /* Transform flags (for 3.0 dialect this flag indicates CCM */ 122 + #define TRANSFORM_FLAG_ENCRYPTED 0x0001 123 + struct smb2_transform_hdr { 124 + __le32 ProtocolId; /* 0xFD 'S' 'M' 'B' */ 125 + __u8 Signature[16]; 126 + __u8 Nonce[16]; 127 + __le32 OriginalMessageSize; 128 + __u16 Reserved1; 129 + __le16 Flags; /* EncryptionAlgorithm for 3.0, enc enabled for 3.1.1 */ 130 + __le64 SessionId; 131 + } __packed; 132 + 133 + 134 + /* See MS-SMB2 2.2.42 */ 135 + struct smb2_compression_transform_hdr_unchained { 136 + __le32 ProtocolId; /* 0xFC 'S' 'M' 'B' */ 137 + __le32 OriginalCompressedSegmentSize; 138 + __le16 CompressionAlgorithm; 139 + __le16 Flags; 140 + __le16 Length; /* if chained it is length, else offset */ 141 + } __packed; 142 + 143 + /* See MS-SMB2 2.2.42.1 */ 144 + #define SMB2_COMPRESSION_FLAG_NONE 0x0000 145 + #define SMB2_COMPRESSION_FLAG_CHAINED 0x0001 146 + 147 + struct compression_payload_header { 148 + __le16 CompressionAlgorithm; 149 + __le16 Flags; 150 + __le32 Length; /* length of compressed playload including field below if present */ 151 + /* __le32 OriginalPayloadSize; */ /* optional, present when LZNT1, LZ77, LZ77+Huffman */ 152 + } __packed; 153 + 154 + /* See MS-SMB2 2.2.42.2 */ 155 + struct smb2_compression_transform_hdr_chained { 156 + __le32 ProtocolId; /* 0xFC 'S' 'M' 'B' */ 157 + __le32 OriginalCompressedSegmentSize; 158 + /* struct compression_payload_header[] */ 159 + } __packed; 160 + 161 + /* See MS-SMB2 2.2.42.2.2 */ 162 + struct compression_pattern_payload_v1 { 163 + __le16 Pattern; 164 + __le16 Reserved1; 165 + __le16 Reserved2; 166 + __le32 Repetitions; 167 + } __packed; 168 + 169 + /* See MS-SMB2 section 2.2.9.2 */ 170 + /* Context Types */ 171 + #define SMB2_RESERVED_TREE_CONNECT_CONTEXT_ID 0x0000 172 + #define SMB2_REMOTED_IDENTITY_TREE_CONNECT_CONTEXT_ID cpu_to_le16(0x0001) 173 + 174 + struct tree_connect_contexts { 175 + __le16 ContextType; 176 + __le16 DataLength; 177 + __le32 Reserved; 178 + __u8 Data[]; 179 + } __packed; 180 + 181 + /* Remoted identity tree connect context structures - see MS-SMB2 2.2.9.2.1 */ 182 + struct smb3_blob_data { 183 + __le16 BlobSize; 184 + __u8 BlobData[]; 185 + } __packed; 186 + 187 + /* Valid values for Attr */ 188 + #define SE_GROUP_MANDATORY 0x00000001 189 + #define SE_GROUP_ENABLED_BY_DEFAULT 0x00000002 190 + #define SE_GROUP_ENABLED 0x00000004 191 + #define SE_GROUP_OWNER 0x00000008 192 + #define SE_GROUP_USE_FOR_DENY_ONLY 0x00000010 193 + #define SE_GROUP_INTEGRITY 0x00000020 194 + #define SE_GROUP_INTEGRITY_ENABLED 0x00000040 195 + #define SE_GROUP_RESOURCE 0x20000000 196 + #define SE_GROUP_LOGON_ID 0xC0000000 197 + 198 + /* struct sid_attr_data is SidData array in BlobData format then le32 Attr */ 199 + 200 + struct sid_array_data { 201 + __le16 SidAttrCount; 202 + /* SidAttrList - array of sid_attr_data structs */ 203 + } __packed; 204 + 205 + struct luid_attr_data { 206 + 207 + } __packed; 208 + 209 + /* 210 + * struct privilege_data is the same as BLOB_DATA - see MS-SMB2 2.2.9.2.1.5 211 + * but with size of LUID_ATTR_DATA struct and BlobData set to LUID_ATTR DATA 212 + */ 213 + 214 + struct privilege_array_data { 215 + __le16 PrivilegeCount; 216 + /* array of privilege_data structs */ 217 + } __packed; 218 + 219 + struct remoted_identity_tcon_context { 220 + __le16 TicketType; /* must be 0x0001 */ 221 + __le16 TicketSize; /* total size of this struct */ 222 + __le16 User; /* offset to SID_ATTR_DATA struct with user info */ 223 + __le16 UserName; /* offset to null terminated Unicode username string */ 224 + __le16 Domain; /* offset to null terminated Unicode domain name */ 225 + __le16 Groups; /* offset to SID_ARRAY_DATA struct with group info */ 226 + __le16 RestrictedGroups; /* similar to above */ 227 + __le16 Privileges; /* offset to PRIVILEGE_ARRAY_DATA struct */ 228 + __le16 PrimaryGroup; /* offset to SID_ARRAY_DATA struct */ 229 + __le16 Owner; /* offset to BLOB_DATA struct */ 230 + __le16 DefaultDacl; /* offset to BLOB_DATA struct */ 231 + __le16 DeviceGroups; /* offset to SID_ARRAY_DATA struct */ 232 + __le16 UserClaims; /* offset to BLOB_DATA struct */ 233 + __le16 DeviceClaims; /* offset to BLOB_DATA struct */ 234 + __u8 TicketInfo[]; /* variable length buf - remoted identity data */ 235 + } __packed; 236 + 237 + struct smb2_tree_connect_req_extension { 238 + __le32 TreeConnectContextOffset; 239 + __le16 TreeConnectContextCount; 240 + __u8 Reserved[10]; 241 + __u8 PathName[]; /* variable sized array */ 242 + /* followed by array of TreeConnectContexts */ 243 + } __packed; 244 + 245 + /* Flags/Reserved for SMB3.1.1 */ 246 + #define SMB2_TREE_CONNECT_FLAG_CLUSTER_RECONNECT cpu_to_le16(0x0001) 247 + #define SMB2_TREE_CONNECT_FLAG_REDIRECT_TO_OWNER cpu_to_le16(0x0002) 248 + #define SMB2_TREE_CONNECT_FLAG_EXTENSION_PRESENT cpu_to_le16(0x0004) 249 + 250 + struct smb2_tree_connect_req { 251 + struct smb2_hdr hdr; 252 + __le16 StructureSize; /* Must be 9 */ 253 + __le16 Flags; /* Flags in SMB3.1.1 */ 254 + __le16 PathOffset; 255 + __le16 PathLength; 256 + __u8 Buffer[1]; /* variable length */ 257 + } __packed; 258 + 259 + /* Possible ShareType values */ 260 + #define SMB2_SHARE_TYPE_DISK 0x01 261 + #define SMB2_SHARE_TYPE_PIPE 0x02 262 + #define SMB2_SHARE_TYPE_PRINT 0x03 263 + 264 + /* 265 + * Possible ShareFlags - exactly one and only one of the first 4 caching flags 266 + * must be set (any of the remaining, SHI1005, flags may be set individually 267 + * or in combination. 268 + */ 269 + #define SMB2_SHAREFLAG_MANUAL_CACHING 0x00000000 270 + #define SMB2_SHAREFLAG_AUTO_CACHING 0x00000010 271 + #define SMB2_SHAREFLAG_VDO_CACHING 0x00000020 272 + #define SMB2_SHAREFLAG_NO_CACHING 0x00000030 273 + #define SHI1005_FLAGS_DFS 0x00000001 274 + #define SHI1005_FLAGS_DFS_ROOT 0x00000002 275 + #define SHI1005_FLAGS_RESTRICT_EXCLUSIVE_OPENS 0x00000100 276 + #define SHI1005_FLAGS_FORCE_SHARED_DELETE 0x00000200 277 + #define SHI1005_FLAGS_ALLOW_NAMESPACE_CACHING 0x00000400 278 + #define SHI1005_FLAGS_ACCESS_BASED_DIRECTORY_ENUM 0x00000800 279 + #define SHI1005_FLAGS_FORCE_LEVELII_OPLOCK 0x00001000 280 + #define SHI1005_FLAGS_ENABLE_HASH_V1 0x00002000 281 + #define SHI1005_FLAGS_ENABLE_HASH_V2 0x00004000 282 + #define SHI1005_FLAGS_ENCRYPT_DATA 0x00008000 283 + #define SMB2_SHAREFLAG_IDENTITY_REMOTING 0x00040000 /* 3.1.1 */ 284 + #define SMB2_SHAREFLAG_COMPRESS_DATA 0x00100000 /* 3.1.1 */ 285 + #define SHI1005_FLAGS_ALL 0x0014FF33 286 + 287 + /* Possible share capabilities */ 288 + #define SMB2_SHARE_CAP_DFS cpu_to_le32(0x00000008) /* all dialects */ 289 + #define SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY cpu_to_le32(0x00000010) /* 3.0 */ 290 + #define SMB2_SHARE_CAP_SCALEOUT cpu_to_le32(0x00000020) /* 3.0 */ 291 + #define SMB2_SHARE_CAP_CLUSTER cpu_to_le32(0x00000040) /* 3.0 */ 292 + #define SMB2_SHARE_CAP_ASYMMETRIC cpu_to_le32(0x00000080) /* 3.02 */ 293 + #define SMB2_SHARE_CAP_REDIRECT_TO_OWNER cpu_to_le32(0x00000100) /* 3.1.1 */ 294 + 295 + struct smb2_tree_connect_rsp { 296 + struct smb2_hdr hdr; 297 + __le16 StructureSize; /* Must be 16 */ 298 + __u8 ShareType; /* see below */ 299 + __u8 Reserved; 300 + __le32 ShareFlags; /* see below */ 301 + __le32 Capabilities; /* see below */ 302 + __le32 MaximalAccess; 303 + } __packed; 304 + 305 + struct smb2_tree_disconnect_req { 306 + struct smb2_hdr hdr; 307 + __le16 StructureSize; /* Must be 4 */ 308 + __le16 Reserved; 309 + } __packed; 310 + 311 + struct smb2_tree_disconnect_rsp { 312 + struct smb2_hdr hdr; 313 + __le16 StructureSize; /* Must be 4 */ 314 + __le16 Reserved; 315 + } __packed; 316 + 317 + 318 + #endif /* _COMMON_SMB2PDU_H */