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

Merge tag '5.16-rc-part1-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6

Pull cifs updates from Steve French:

- reconnect fix for stable

- minor mount option fix

- debugging improvement for (TCP) connection issues

- refactoring of common code to help ksmbd

* tag '5.16-rc-part1-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6:
smb3: add dynamic trace points for socket connection
cifs: Move SMB2_Create definitions to the shared area
cifs: Move more definitions into the shared area
cifs: move NEGOTIATE_PROTOCOL definitions out into the common area
cifs: Create a new shared file holding smb2 pdu definitions
cifs: add mount parameter tcpnodelay
cifs: To match file servers, make sure the server hostname matches

+1299 -1091
-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
+15 -11
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. ··· 794 794 */ 795 795 } 796 796 797 - kfree(server->hostname); 798 797 kfree(server); 799 798 800 799 length = atomic_dec_return(&tcpSesAllocCount); ··· 877 878 static void 878 879 smb2_add_credits_from_hdr(char *buffer, struct TCP_Server_Info *server) 879 880 { 880 - struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)buffer; 881 + struct smb2_hdr *shdr = (struct smb2_hdr *)buffer; 881 882 int scredits, in_flight; 882 883 883 884 /* ··· 1234 1235 if (!net_eq(cifs_net_ns(server), current->nsproxy->net_ns)) 1235 1236 return 0; 1236 1237 1238 + if (strcasecmp(server->hostname, ctx->server_hostname)) 1239 + return 0; 1240 + 1237 1241 if (!match_address(server, addr, 1238 1242 (struct sockaddr *)&ctx->srcaddr)) 1239 1243 return 0; ··· 1338 1336 kfree(server->session_key.response); 1339 1337 server->session_key.response = NULL; 1340 1338 server->session_key.len = 0; 1339 + kfree(server->hostname); 1341 1340 1342 1341 task = xchg(&server->tsk, NULL); 1343 1342 if (task) ··· 1364 1361 goto out_err; 1365 1362 } 1366 1363 1364 + tcp_ses->hostname = kstrdup(ctx->server_hostname, GFP_KERNEL); 1365 + if (!tcp_ses->hostname) { 1366 + rc = -ENOMEM; 1367 + goto out_err; 1368 + } 1369 + 1367 1370 tcp_ses->ops = ctx->ops; 1368 1371 tcp_ses->vals = ctx->vals; 1369 1372 cifs_set_net_ns(tcp_ses, get_net(current->nsproxy->net_ns)); 1370 - tcp_ses->hostname = extract_hostname(ctx->UNC); 1371 - if (IS_ERR(tcp_ses->hostname)) { 1372 - rc = PTR_ERR(tcp_ses->hostname); 1373 - goto out_err_crypto_release; 1374 - } 1375 1373 1376 1374 tcp_ses->conn_id = atomic_inc_return(&tcpSesNextId); 1377 1375 tcp_ses->noblockcnt = ctx->rootfs; ··· 1501 1497 1502 1498 out_err: 1503 1499 if (tcp_ses) { 1504 - if (!IS_ERR(tcp_ses->hostname)) 1505 - kfree(tcp_ses->hostname); 1500 + kfree(tcp_ses->hostname); 1506 1501 if (tcp_ses->ssocket) 1507 1502 sock_release(tcp_ses->ssocket); 1508 1503 kfree(tcp_ses); ··· 2649 2646 rc = 0; 2650 2647 if (rc < 0) { 2651 2648 cifs_dbg(FYI, "Error %d connecting to server\n", rc); 2649 + trace_smb3_connect_err(server->hostname, server->conn_id, &server->dstaddr, rc); 2652 2650 sock_release(socket); 2653 2651 server->ssocket = NULL; 2654 2652 return rc; 2655 2653 } 2656 - 2654 + trace_smb3_connect_done(server->hostname, server->conn_id, &server->dstaddr); 2657 2655 if (sport == htons(RFC1001_PORT)) 2658 2656 rc = ip_rfc1001_connect(server); 2659 2657
+16
fs/cifs/fs_context.c
··· 116 116 fsparam_flag("nosharesock", Opt_nosharesock), 117 117 fsparam_flag_no("persistenthandles", Opt_persistent), 118 118 fsparam_flag_no("resilienthandles", Opt_resilient), 119 + fsparam_flag_no("tcpnodelay", Opt_tcp_nodelay), 119 120 fsparam_flag("domainauto", Opt_domainauto), 120 121 fsparam_flag("rdma", Opt_rdma), 121 122 fsparam_flag("modesid", Opt_modesid), ··· 319 318 DUP_CTX_STR(mount_options); 320 319 DUP_CTX_STR(username); 321 320 DUP_CTX_STR(password); 321 + DUP_CTX_STR(server_hostname); 322 322 DUP_CTX_STR(UNC); 323 323 DUP_CTX_STR(source); 324 324 DUP_CTX_STR(domainname); ··· 457 455 pos = strpbrk(devname + 2, delims); 458 456 if (!pos) 459 457 return -EINVAL; 458 + 459 + /* record the server hostname */ 460 + ctx->server_hostname = kstrndup(devname + 2, pos - devname - 2, GFP_KERNEL); 461 + if (!ctx->server_hostname) 462 + return -ENOMEM; 460 463 461 464 /* skip past delimiter */ 462 465 ++pos; ··· 1390 1383 } 1391 1384 } 1392 1385 break; 1386 + case Opt_tcp_nodelay: 1387 + /* tcp nodelay should not usually be needed since we CORK/UNCORK the socket */ 1388 + if (result.negated) 1389 + ctx->sockopt_tcp_nodelay = false; 1390 + else 1391 + ctx->sockopt_tcp_nodelay = true; 1392 + break; 1393 1393 case Opt_domainauto: 1394 1394 ctx->domainauto = true; 1395 1395 break; ··· 1510 1496 ctx->username = NULL; 1511 1497 kfree_sensitive(ctx->password); 1512 1498 ctx->password = NULL; 1499 + kfree(ctx->server_hostname); 1500 + ctx->server_hostname = NULL; 1513 1501 kfree(ctx->UNC); 1514 1502 ctx->UNC = NULL; 1515 1503 kfree(ctx->source);
+2
fs/cifs/fs_context.h
··· 98 98 Opt_nosharesock, 99 99 Opt_persistent, 100 100 Opt_resilient, 101 + Opt_tcp_nodelay, 101 102 Opt_domainauto, 102 103 Opt_rdma, 103 104 Opt_modesid, ··· 167 166 char *password; 168 167 char *domainname; 169 168 char *source; 169 + char *server_hostname; 170 170 char *UNC; 171 171 char *nodename; 172 172 char *iocharset; /* local code page for mapping to and from Unicode */
+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 }
+23 -24
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), 835 - rsp->PersistentFileId, 836 - rsp->VolatileFileId); 834 + le16_to_cpu(hdr->Command), 835 + le64_to_cpu(hdr->MessageId), 836 + le64_to_cpu(rsp->PersistentFileId), 837 + le64_to_cpu(rsp->VolatileFileId)); 837 838 if (rc) 838 839 cifs_put_tcon(tcon); 839 840 ··· 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;
+37 -36
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 ··· 885 885 atomic_inc(&tcon->num_remote_opens); 886 886 887 887 o_rsp = (struct smb2_create_rsp *)rsp_iov[0].iov_base; 888 - oparms.fid->persistent_fid = o_rsp->PersistentFileId; 889 - oparms.fid->volatile_fid = o_rsp->VolatileFileId; 888 + oparms.fid->persistent_fid = le64_to_cpu(o_rsp->PersistentFileId); 889 + oparms.fid->volatile_fid = le64_to_cpu(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 } 2398 - fid->persistent_fid = op_rsp->PersistentFileId; 2399 - fid->volatile_fid = op_rsp->VolatileFileId; 2398 + fid->persistent_fid = le64_to_cpu(op_rsp->PersistentFileId); 2399 + fid->volatile_fid = le64_to_cpu(op_rsp->VolatileFileId); 2400 2400 2401 2401 /* Anything else than ENODATA means a genuine error */ 2402 2402 if (rc && rc != -ENODATA) { ··· 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,
+97 -90
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) { ··· 413 414 pneg_ctxt->ContextType = SMB2_PREAUTH_INTEGRITY_CAPABILITIES; 414 415 pneg_ctxt->DataLength = cpu_to_le16(38); 415 416 pneg_ctxt->HashAlgorithmCount = cpu_to_le16(1); 416 - pneg_ctxt->SaltLength = cpu_to_le16(SMB311_LINUX_CLIENT_SALT_SIZE); 417 - get_random_bytes(pneg_ctxt->Salt, SMB311_LINUX_CLIENT_SALT_SIZE); 417 + pneg_ctxt->SaltLength = cpu_to_le16(SMB311_SALT_SIZE); 418 + get_random_bytes(pneg_ctxt->Salt, SMB311_SALT_SIZE); 418 419 pneg_ctxt->HashAlgorithms = SMB2_PREAUTH_INTEGRITY_SHA512; 419 420 } 420 421 ··· 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 1262 1263 */ 1263 - req->PreviousSessionId = sess_data->previous_session; 1264 + req->PreviousSessionId = cpu_to_le64(sess_data->previous_session); 1264 1265 req->Flags = 0; /* MBZ */ 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); ··· 2670 2672 } 2671 2673 2672 2674 rsp = (struct smb2_create_rsp *)rsp_iov.iov_base; 2673 - trace_smb3_posix_mkdir_done(xid, rsp->PersistentFileId, tcon->tid, 2675 + trace_smb3_posix_mkdir_done(xid, le64_to_cpu(rsp->PersistentFileId), 2676 + tcon->tid, 2674 2677 ses->Suid, CREATE_NOT_FILE, 2675 2678 FILE_WRITE_ATTRIBUTES); 2676 2679 2677 - SMB2_close(xid, tcon, rsp->PersistentFileId, rsp->VolatileFileId); 2680 + SMB2_close(xid, tcon, le64_to_cpu(rsp->PersistentFileId), 2681 + le64_to_cpu(rsp->VolatileFileId)); 2678 2682 2679 2683 /* Eventually save off posix specific response info and timestaps */ 2680 2684 ··· 2740 2740 if (tcon->share_flags & SHI1005_FLAGS_DFS) { 2741 2741 int name_len; 2742 2742 2743 - req->sync_hdr.Flags |= SMB2_FLAGS_DFS_OPERATIONS; 2743 + req->hdr.Flags |= SMB2_FLAGS_DFS_OPERATIONS; 2744 2744 rc = alloc_path_with_tree_prefix(&copy_path, &copy_size, 2745 2745 &name_len, 2746 2746 tcon->treeName, path); ··· 2943 2943 } 2944 2944 goto creat_exit; 2945 2945 } else 2946 - trace_smb3_open_done(xid, rsp->PersistentFileId, tcon->tid, 2946 + trace_smb3_open_done(xid, le64_to_cpu(rsp->PersistentFileId), 2947 + tcon->tid, 2947 2948 ses->Suid, oparms->create_options, 2948 2949 oparms->desired_access); 2949 2950 2950 2951 atomic_inc(&tcon->num_remote_opens); 2951 - oparms->fid->persistent_fid = rsp->PersistentFileId; 2952 - oparms->fid->volatile_fid = rsp->VolatileFileId; 2952 + oparms->fid->persistent_fid = le64_to_cpu(rsp->PersistentFileId); 2953 + oparms->fid->volatile_fid = le64_to_cpu(rsp->VolatileFileId); 2953 2954 oparms->fid->access = oparms->desired_access; 2954 2955 #ifdef CONFIG_CIFS_DEBUG2 2955 - oparms->fid->mid = le64_to_cpu(rsp->sync_hdr.MessageId); 2956 + oparms->fid->mid = le64_to_cpu(rsp->hdr.MessageId); 2956 2957 #endif /* CIFS_DEBUG2 */ 2957 2958 2958 2959 if (buf) { ··· 3053 3052 * response size smaller. 3054 3053 */ 3055 3054 req->MaxOutputResponse = cpu_to_le32(max_response_size); 3056 - req->sync_hdr.CreditCharge = 3055 + req->hdr.CreditCharge = 3057 3056 cpu_to_le16(DIV_ROUND_UP(max(indatalen, max_response_size), 3058 3057 SMB2_MAX_BUFFER_SIZE)); 3059 3058 if (is_fsctl) ··· 3063 3062 3064 3063 /* validate negotiate request must be signed - see MS-SMB2 3.2.5.5 */ 3065 3064 if (opcode == FSCTL_VALIDATE_NEGOTIATE_INFO) 3066 - req->sync_hdr.Flags |= SMB2_FLAGS_SIGNED; 3065 + req->hdr.Flags |= SMB2_FLAGS_SIGNED; 3067 3066 3068 3067 return 0; 3069 3068 } ··· 3237 3236 if (rc) 3238 3237 return rc; 3239 3238 3240 - req->PersistentFileId = persistent_fid; 3241 - req->VolatileFileId = volatile_fid; 3239 + req->PersistentFileId = cpu_to_le64(persistent_fid); 3240 + req->VolatileFileId = cpu_to_le64(volatile_fid); 3242 3241 if (query_attrs) 3243 3242 req->Flags = SMB2_CLOSE_FLAG_POSTQUERY_ATTRIB; 3244 3243 else ··· 3601 3600 if (rc) 3602 3601 return rc; 3603 3602 3604 - req->PersistentFileId = persistent_fid; 3605 - req->VolatileFileId = volatile_fid; 3603 + req->PersistentFileId = cpu_to_le64(persistent_fid); 3604 + req->VolatileFileId = cpu_to_le64(volatile_fid); 3606 3605 /* See note 354 of MS-SMB2, 64K max */ 3607 3606 req->OutputBufferLength = 3608 3607 cpu_to_le32(SMB2_MAX_BUFFER_SIZE - MAX_SMB2_HDR_SIZE); ··· 3688 3687 3689 3688 if (mid->mid_state == MID_RESPONSE_RECEIVED 3690 3689 || mid->mid_state == MID_RESPONSE_MALFORMED) { 3691 - credits.value = le16_to_cpu(rsp->sync_hdr.CreditRequest); 3690 + credits.value = le16_to_cpu(rsp->hdr.CreditRequest); 3692 3691 credits.instance = server->reconnect_instance; 3693 3692 } 3694 3693 ··· 3788 3787 if (rc) 3789 3788 return rc; 3790 3789 3791 - req->sync_hdr.CreditRequest = cpu_to_le16(1); 3790 + req->hdr.CreditRequest = cpu_to_le16(1); 3792 3791 3793 3792 iov[0].iov_len = total_len; 3794 3793 iov[0].iov_base = (char *)req; ··· 3824 3823 if (rc) 3825 3824 return rc; 3826 3825 3827 - req->PersistentFileId = persistent_fid; 3828 - req->VolatileFileId = volatile_fid; 3826 + req->PersistentFileId = cpu_to_le64(persistent_fid); 3827 + req->VolatileFileId = cpu_to_le64(volatile_fid); 3829 3828 3830 3829 iov[0].iov_base = (char *)req; 3831 3830 iov[0].iov_len = total_len; ··· 3891 3890 unsigned int remaining_bytes, int request_type) 3892 3891 { 3893 3892 int rc = -EACCES; 3894 - struct smb2_read_plain_req *req = NULL; 3895 - struct smb2_sync_hdr *shdr; 3893 + struct smb2_read_req *req = NULL; 3894 + struct smb2_hdr *shdr; 3896 3895 struct TCP_Server_Info *server = io_parms->server; 3897 3896 3898 3897 rc = smb2_plain_req_init(SMB2_READ, io_parms->tcon, server, ··· 3903 3902 if (server == NULL) 3904 3903 return -ECONNABORTED; 3905 3904 3906 - shdr = &req->sync_hdr; 3907 - shdr->ProcessId = cpu_to_le32(io_parms->pid); 3905 + shdr = &req->hdr; 3906 + shdr->Id.SyncId.ProcessId = cpu_to_le32(io_parms->pid); 3908 3907 3909 - req->PersistentFileId = io_parms->persistent_fid; 3910 - req->VolatileFileId = io_parms->volatile_fid; 3908 + req->PersistentFileId = cpu_to_le64(io_parms->persistent_fid); 3909 + req->VolatileFileId = cpu_to_le64(io_parms->volatile_fid); 3911 3910 req->ReadChannelInfoOffset = 0; /* reserved */ 3912 3911 req->ReadChannelInfoLength = 0; /* reserved */ 3913 3912 req->Channel = 0; /* reserved */ ··· 3941 3940 if (need_invalidate) 3942 3941 req->Channel = SMB2_CHANNEL_RDMA_V1; 3943 3942 req->ReadChannelInfoOffset = 3944 - cpu_to_le16(offsetof(struct smb2_read_plain_req, Buffer)); 3943 + cpu_to_le16(offsetof(struct smb2_read_req, Buffer)); 3945 3944 req->ReadChannelInfoLength = 3946 3945 cpu_to_le16(sizeof(struct smbd_buffer_descriptor_v1)); 3947 3946 v1 = (struct smbd_buffer_descriptor_v1 *) &req->Buffer[0]; ··· 3965 3964 * Related requests use info from previous read request 3966 3965 * in chain. 3967 3966 */ 3968 - shdr->SessionId = 0xFFFFFFFFFFFFFFFF; 3969 - shdr->TreeId = 0xFFFFFFFF; 3970 - req->PersistentFileId = 0xFFFFFFFFFFFFFFFF; 3971 - req->VolatileFileId = 0xFFFFFFFFFFFFFFFF; 3967 + shdr->SessionId = cpu_to_le64(0xFFFFFFFFFFFFFFFF); 3968 + shdr->Id.SyncId.TreeId = cpu_to_le32(0xFFFFFFFF); 3969 + req->PersistentFileId = cpu_to_le64(0xFFFFFFFFFFFFFFFF); 3970 + req->VolatileFileId = cpu_to_le64(0xFFFFFFFFFFFFFFFF); 3972 3971 } 3973 3972 } 3974 3973 if (remaining_bytes > io_parms->length) ··· 3986 3985 struct cifs_readdata *rdata = mid->callback_data; 3987 3986 struct cifs_tcon *tcon = tlink_tcon(rdata->cfile->tlink); 3988 3987 struct TCP_Server_Info *server = rdata->server; 3989 - struct smb2_sync_hdr *shdr = 3990 - (struct smb2_sync_hdr *)rdata->iov[0].iov_base; 3988 + struct smb2_hdr *shdr = 3989 + (struct smb2_hdr *)rdata->iov[0].iov_base; 3991 3990 struct cifs_credits credits = { .value = 0, .instance = 0 }; 3992 3991 struct smb_rqst rqst = { .rq_iov = &rdata->iov[1], 3993 3992 .rq_nvec = 1, ··· 4073 4072 { 4074 4073 int rc, flags = 0; 4075 4074 char *buf; 4076 - struct smb2_sync_hdr *shdr; 4075 + struct smb2_hdr *shdr; 4077 4076 struct cifs_io_parms io_parms; 4078 4077 struct smb_rqst rqst = { .rq_iov = rdata->iov, 4079 4078 .rq_nvec = 1 }; ··· 4106 4105 rdata->iov[0].iov_base = buf; 4107 4106 rdata->iov[0].iov_len = total_len; 4108 4107 4109 - shdr = (struct smb2_sync_hdr *)buf; 4108 + shdr = (struct smb2_hdr *)buf; 4110 4109 4111 4110 if (rdata->credits.value > 0) { 4112 4111 shdr->CreditCharge = cpu_to_le16(DIV_ROUND_UP(rdata->bytes, ··· 4145 4144 { 4146 4145 struct smb_rqst rqst; 4147 4146 int resp_buftype, rc; 4148 - struct smb2_read_plain_req *req = NULL; 4147 + struct smb2_read_req *req = NULL; 4149 4148 struct smb2_read_rsp *rsp = NULL; 4150 4149 struct kvec iov[1]; 4151 4150 struct kvec rsp_iov; ··· 4179 4178 if (rc != -ENODATA) { 4180 4179 cifs_stats_fail_inc(io_parms->tcon, SMB2_READ_HE); 4181 4180 cifs_dbg(VFS, "Send error in read = %d\n", rc); 4182 - trace_smb3_read_err(xid, req->PersistentFileId, 4181 + trace_smb3_read_err(xid, 4182 + le64_to_cpu(req->PersistentFileId), 4183 4183 io_parms->tcon->tid, ses->Suid, 4184 4184 io_parms->offset, io_parms->length, 4185 4185 rc); 4186 4186 } else 4187 - trace_smb3_read_done(xid, req->PersistentFileId, 4188 - io_parms->tcon->tid, ses->Suid, 4189 - io_parms->offset, 0); 4187 + trace_smb3_read_done(xid, 4188 + le64_to_cpu(req->PersistentFileId), 4189 + io_parms->tcon->tid, ses->Suid, 4190 + io_parms->offset, 0); 4190 4191 free_rsp_buf(resp_buftype, rsp_iov.iov_base); 4191 4192 cifs_small_buf_release(req); 4192 4193 return rc == -ENODATA ? 0 : rc; 4193 4194 } else 4194 - trace_smb3_read_done(xid, req->PersistentFileId, 4195 + trace_smb3_read_done(xid, 4196 + le64_to_cpu(req->PersistentFileId), 4195 4197 io_parms->tcon->tid, ses->Suid, 4196 4198 io_parms->offset, io_parms->length); 4197 4199 ··· 4242 4238 4243 4239 switch (mid->mid_state) { 4244 4240 case MID_RESPONSE_RECEIVED: 4245 - credits.value = le16_to_cpu(rsp->sync_hdr.CreditRequest); 4241 + credits.value = le16_to_cpu(rsp->hdr.CreditRequest); 4246 4242 credits.instance = server->reconnect_instance; 4247 4243 wdata->result = smb2_check_receive(mid, server, 0); 4248 4244 if (wdata->result != 0) ··· 4268 4264 wdata->result = -EAGAIN; 4269 4265 break; 4270 4266 case MID_RESPONSE_MALFORMED: 4271 - credits.value = le16_to_cpu(rsp->sync_hdr.CreditRequest); 4267 + credits.value = le16_to_cpu(rsp->hdr.CreditRequest); 4272 4268 credits.instance = server->reconnect_instance; 4273 4269 fallthrough; 4274 4270 default: ··· 4315 4311 { 4316 4312 int rc = -EACCES, flags = 0; 4317 4313 struct smb2_write_req *req = NULL; 4318 - struct smb2_sync_hdr *shdr; 4314 + struct smb2_hdr *shdr; 4319 4315 struct cifs_tcon *tcon = tlink_tcon(wdata->cfile->tlink); 4320 4316 struct TCP_Server_Info *server = wdata->server; 4321 4317 struct kvec iov[1]; ··· 4333 4329 if (smb3_encryption_required(tcon)) 4334 4330 flags |= CIFS_TRANSFORM_REQ; 4335 4331 4336 - shdr = (struct smb2_sync_hdr *)req; 4337 - 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); 4338 4334 4339 - req->PersistentFileId = wdata->cfile->fid.persistent_fid; 4340 - req->VolatileFileId = wdata->cfile->fid.volatile_fid; 4335 + req->PersistentFileId = cpu_to_le64(wdata->cfile->fid.persistent_fid); 4336 + req->VolatileFileId = cpu_to_le64(wdata->cfile->fid.volatile_fid); 4341 4337 req->WriteChannelInfoOffset = 0; 4342 4338 req->WriteChannelInfoLength = 0; 4343 4339 req->Channel = 0; ··· 4434 4430 wdata, flags, &wdata->credits); 4435 4431 4436 4432 if (rc) { 4437 - trace_smb3_write_err(0 /* no xid */, req->PersistentFileId, 4433 + trace_smb3_write_err(0 /* no xid */, 4434 + le64_to_cpu(req->PersistentFileId), 4438 4435 tcon->tid, tcon->ses->Suid, wdata->offset, 4439 4436 wdata->bytes, rc); 4440 4437 kref_put(&wdata->refcount, release); ··· 4486 4481 if (smb3_encryption_required(io_parms->tcon)) 4487 4482 flags |= CIFS_TRANSFORM_REQ; 4488 4483 4489 - req->sync_hdr.ProcessId = cpu_to_le32(io_parms->pid); 4484 + req->hdr.Id.SyncId.ProcessId = cpu_to_le32(io_parms->pid); 4490 4485 4491 - req->PersistentFileId = io_parms->persistent_fid; 4492 - req->VolatileFileId = io_parms->volatile_fid; 4486 + req->PersistentFileId = cpu_to_le64(io_parms->persistent_fid); 4487 + req->VolatileFileId = cpu_to_le64(io_parms->volatile_fid); 4493 4488 req->WriteChannelInfoOffset = 0; 4494 4489 req->WriteChannelInfoLength = 0; 4495 4490 req->Channel = 0; ··· 4517 4512 rsp = (struct smb2_write_rsp *)rsp_iov.iov_base; 4518 4513 4519 4514 if (rc) { 4520 - trace_smb3_write_err(xid, req->PersistentFileId, 4515 + trace_smb3_write_err(xid, 4516 + le64_to_cpu(req->PersistentFileId), 4521 4517 io_parms->tcon->tid, 4522 4518 io_parms->tcon->ses->Suid, 4523 4519 io_parms->offset, io_parms->length, rc); ··· 4526 4520 cifs_dbg(VFS, "Send error in write = %d\n", rc); 4527 4521 } else { 4528 4522 *nbytes = le32_to_cpu(rsp->DataLength); 4529 - trace_smb3_write_done(xid, req->PersistentFileId, 4530 - io_parms->tcon->tid, 4531 - io_parms->tcon->ses->Suid, 4532 - io_parms->offset, *nbytes); 4523 + trace_smb3_write_done(xid, 4524 + le64_to_cpu(req->PersistentFileId), 4525 + io_parms->tcon->tid, 4526 + io_parms->tcon->ses->Suid, 4527 + io_parms->offset, *nbytes); 4533 4528 } 4534 4529 4535 4530 cifs_small_buf_release(req); ··· 4873 4866 4874 4867 if (rc) { 4875 4868 if (rc == -ENODATA && 4876 - rsp->sync_hdr.Status == STATUS_NO_MORE_FILES) { 4869 + rsp->hdr.Status == STATUS_NO_MORE_FILES) { 4877 4870 trace_smb3_query_dir_done(xid, persistent_fid, 4878 4871 tcon->tid, tcon->ses->Suid, index, 0); 4879 4872 srch_inf->endOfSearch = true; ··· 4921 4914 if (rc) 4922 4915 return rc; 4923 4916 4924 - req->sync_hdr.ProcessId = cpu_to_le32(pid); 4917 + req->hdr.Id.SyncId.ProcessId = cpu_to_le32(pid); 4925 4918 req->InfoType = info_type; 4926 4919 req->FileInfoClass = info_class; 4927 4920 req->PersistentFileId = persistent_fid; ··· 5081 5074 req->VolatileFid = volatile_fid; 5082 5075 req->PersistentFid = persistent_fid; 5083 5076 req->OplockLevel = oplock_level; 5084 - req->sync_hdr.CreditRequest = cpu_to_le16(1); 5077 + req->hdr.CreditRequest = cpu_to_le16(1); 5085 5078 5086 5079 flags |= CIFS_NO_RSP_BUF; 5087 5080 ··· 5383 5376 if (smb3_encryption_required(tcon)) 5384 5377 flags |= CIFS_TRANSFORM_REQ; 5385 5378 5386 - req->sync_hdr.ProcessId = cpu_to_le32(pid); 5379 + req->hdr.Id.SyncId.ProcessId = cpu_to_le32(pid); 5387 5380 req->LockCount = cpu_to_le16(num_lock); 5388 5381 5389 5382 req->PersistentFileId = persist_fid; ··· 5459 5452 if (smb3_encryption_required(tcon)) 5460 5453 flags |= CIFS_TRANSFORM_REQ; 5461 5454 5462 - req->sync_hdr.CreditRequest = cpu_to_le16(1); 5455 + req->hdr.CreditRequest = cpu_to_le16(1); 5463 5456 req->StructureSize = cpu_to_le16(36); 5464 5457 total_len += 12; 5465 5458
+17 -902
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 */ ··· 115 270 /* __u8 ResourceName[] */ /* Name of share as counted Unicode string */ 116 271 } __packed; 117 272 118 - #define SMB2_CLIENT_GUID_SIZE 16 119 - 120 - struct smb2_negotiate_req { 121 - struct smb2_sync_hdr sync_hdr; 122 - __le16 StructureSize; /* Must be 36 */ 123 - __le16 DialectCount; 124 - __le16 SecurityMode; 125 - __le16 Reserved; /* MBZ */ 126 - __le32 Capabilities; 127 - __u8 ClientGUID[SMB2_CLIENT_GUID_SIZE]; 128 - /* In SMB3.02 and earlier next three were MBZ le64 ClientStartTime */ 129 - __le32 NegotiateContextOffset; /* SMB3.1.1 only. MBZ earlier */ 130 - __le16 NegotiateContextCount; /* SMB3.1.1 only. MBZ earlier */ 131 - __le16 Reserved2; 132 - __le16 Dialects[4]; /* BB expand this if autonegotiate > 4 dialects */ 133 - } __packed; 134 - 135 - /* Dialects */ 136 - #define SMB10_PROT_ID 0x0000 /* local only, not sent on wire w/CIFS negprot */ 137 - #define SMB20_PROT_ID 0x0202 138 - #define SMB21_PROT_ID 0x0210 139 - #define SMB30_PROT_ID 0x0300 140 - #define SMB302_PROT_ID 0x0302 141 - #define SMB311_PROT_ID 0x0311 142 - #define BAD_PROT_ID 0xFFFF 143 - 144 - /* SecurityMode flags */ 145 - #define SMB2_NEGOTIATE_SIGNING_ENABLED 0x0001 146 - #define SMB2_NEGOTIATE_SIGNING_REQUIRED 0x0002 147 - #define SMB2_SEC_MODE_FLAGS_ALL 0x0003 148 - 149 - /* Capabilities flags */ 150 - #define SMB2_GLOBAL_CAP_DFS 0x00000001 151 - #define SMB2_GLOBAL_CAP_LEASING 0x00000002 /* Resp only New to SMB2.1 */ 152 - #define SMB2_GLOBAL_CAP_LARGE_MTU 0X00000004 /* Resp only New to SMB2.1 */ 153 - #define SMB2_GLOBAL_CAP_MULTI_CHANNEL 0x00000008 /* New to SMB3 */ 154 - #define SMB2_GLOBAL_CAP_PERSISTENT_HANDLES 0x00000010 /* New to SMB3 */ 155 - #define SMB2_GLOBAL_CAP_DIRECTORY_LEASING 0x00000020 /* New to SMB3 */ 156 - #define SMB2_GLOBAL_CAP_ENCRYPTION 0x00000040 /* New to SMB3 */ 157 - /* Internal types */ 158 - #define SMB2_NT_FIND 0x00100000 159 - #define SMB2_LARGE_FILES 0x00200000 160 - 161 - 162 - /* Negotiate Contexts - ContextTypes. See MS-SMB2 section 2.2.3.1 for details */ 163 - #define SMB2_PREAUTH_INTEGRITY_CAPABILITIES cpu_to_le16(1) 164 - #define SMB2_ENCRYPTION_CAPABILITIES cpu_to_le16(2) 165 - #define SMB2_COMPRESSION_CAPABILITIES cpu_to_le16(3) 166 - #define SMB2_NETNAME_NEGOTIATE_CONTEXT_ID cpu_to_le16(5) 167 - #define SMB2_TRANSPORT_CAPABILITIES cpu_to_le16(6) 168 - #define SMB2_RDMA_TRANSFORM_CAPABILITIES cpu_to_le16(7) 169 - #define SMB2_SIGNING_CAPABILITIES cpu_to_le16(8) 170 - #define SMB2_POSIX_EXTENSIONS_AVAILABLE cpu_to_le16(0x100) 171 - 172 - struct smb2_neg_context { 173 - __le16 ContextType; 174 - __le16 DataLength; 175 - __le32 Reserved; 176 - /* Followed by array of data. NOTE: some servers require padding to 8 byte boundary */ 177 - } __packed; 178 - 179 - #define SMB311_LINUX_CLIENT_SALT_SIZE 32 180 - /* Hash Algorithm Types */ 181 - #define SMB2_PREAUTH_INTEGRITY_SHA512 cpu_to_le16(0x0001) 182 - #define SMB2_PREAUTH_HASH_SIZE 64 183 - 184 - /* 185 - * SaltLength that the server send can be zero, so the only three required 186 - * fields (all __le16) end up six bytes total, so the minimum context data len 187 - * in the response is six bytes which accounts for 188 - * 189 - * HashAlgorithmCount, SaltLength, and 1 HashAlgorithm. 190 - */ 191 - #define MIN_PREAUTH_CTXT_DATA_LEN 6 192 - 193 - struct smb2_preauth_neg_context { 194 - __le16 ContextType; /* 1 */ 195 - __le16 DataLength; 196 - __le32 Reserved; 197 - __le16 HashAlgorithmCount; /* 1 */ 198 - __le16 SaltLength; 199 - __le16 HashAlgorithms; /* HashAlgorithms[0] since only one defined */ 200 - __u8 Salt[SMB311_LINUX_CLIENT_SALT_SIZE]; 201 - } __packed; 202 - 203 - /* Encryption Algorithms Ciphers */ 204 - #define SMB2_ENCRYPTION_AES128_CCM cpu_to_le16(0x0001) 205 - #define SMB2_ENCRYPTION_AES128_GCM cpu_to_le16(0x0002) 206 - /* we currently do not request AES256_CCM since presumably GCM faster */ 207 - #define SMB2_ENCRYPTION_AES256_CCM cpu_to_le16(0x0003) 208 - #define SMB2_ENCRYPTION_AES256_GCM cpu_to_le16(0x0004) 209 - 210 - /* Min encrypt context data is one cipher so 2 bytes + 2 byte count field */ 211 - #define MIN_ENCRYPT_CTXT_DATA_LEN 4 212 - struct smb2_encryption_neg_context { 213 - __le16 ContextType; /* 2 */ 214 - __le16 DataLength; 215 - __le32 Reserved; 216 - /* CipherCount usally 2, but can be 3 when AES256-GCM enabled */ 217 - __le16 CipherCount; /* AES128-GCM and AES128-CCM by default */ 218 - __le16 Ciphers[3]; 219 - } __packed; 220 - 221 - /* See MS-SMB2 2.2.3.1.3 */ 222 - #define SMB3_COMPRESS_NONE cpu_to_le16(0x0000) 223 - #define SMB3_COMPRESS_LZNT1 cpu_to_le16(0x0001) 224 - #define SMB3_COMPRESS_LZ77 cpu_to_le16(0x0002) 225 - #define SMB3_COMPRESS_LZ77_HUFF cpu_to_le16(0x0003) 226 - /* Pattern scanning algorithm See MS-SMB2 3.1.4.4.1 */ 227 - #define SMB3_COMPRESS_PATTERN cpu_to_le16(0x0004) /* Pattern_V1 */ 228 - 229 - /* Compression Flags */ 230 - #define SMB2_COMPRESSION_CAPABILITIES_FLAG_NONE cpu_to_le32(0x00000000) 231 - #define SMB2_COMPRESSION_CAPABILITIES_FLAG_CHAINED cpu_to_le32(0x00000001) 232 - 233 - struct smb2_compression_capabilities_context { 234 - __le16 ContextType; /* 3 */ 235 - __le16 DataLength; 236 - __u32 Reserved; 237 - __le16 CompressionAlgorithmCount; 238 - __u16 Padding; 239 - __u32 Flags; 240 - __le16 CompressionAlgorithms[3]; 241 - __u16 Pad; /* Some servers require pad to DataLen multiple of 8 */ 242 - /* Check if pad needed */ 243 - } __packed; 244 - 245 - /* 246 - * For smb2_netname_negotiate_context_id See MS-SMB2 2.2.3.1.4. 247 - * Its struct simply contains NetName, an array of Unicode characters 248 - */ 249 - struct smb2_netname_neg_context { 250 - __le16 ContextType; /* 5 */ 251 - __le16 DataLength; 252 - __le32 Reserved; 253 - __le16 NetName[]; /* hostname of target converted to UCS-2 */ 254 - } __packed; 255 - 256 - /* 257 - * For smb2_transport_capabilities context see MS-SMB2 2.2.3.1.5 258 - * and 2.2.4.1.5 259 - */ 260 - 261 - /* Flags */ 262 - #define SMB2_ACCEPT_TRANSFORM_LEVEL_SECURITY 0x00000001 263 - 264 - struct smb2_transport_capabilities_context { 265 - __le16 ContextType; /* 6 */ 266 - __le16 DataLength; 267 - __u32 Reserved; 268 - __le32 Flags; 269 - __u32 Pad; 270 - } __packed; 271 - 272 - /* 273 - * For rdma transform capabilities context see MS-SMB2 2.2.3.1.6 274 - * and 2.2.4.1.6 275 - */ 276 - 277 - /* RDMA Transform IDs */ 278 - #define SMB2_RDMA_TRANSFORM_NONE 0x0000 279 - #define SMB2_RDMA_TRANSFORM_ENCRYPTION 0x0001 280 - #define SMB2_RDMA_TRANSFORM_SIGNING 0x0002 281 - 282 - struct smb2_rdma_transform_capabilities_context { 283 - __le16 ContextType; /* 7 */ 284 - __le16 DataLength; 285 - __u32 Reserved; 286 - __le16 TransformCount; 287 - __u16 Reserved1; 288 - __u32 Reserved2; 289 - __le16 RDMATransformIds[]; 290 - } __packed; 291 - 292 - /* 293 - * For signing capabilities context see MS-SMB2 2.2.3.1.7 294 - * and 2.2.4.1.7 295 - */ 296 - 297 - /* Signing algorithms */ 298 - #define SIGNING_ALG_HMAC_SHA256 0 299 - #define SIGNING_ALG_AES_CMAC 1 300 - #define SIGNING_ALG_AES_GMAC 2 301 - 302 - struct smb2_signing_capabilities { 303 - __le16 ContextType; /* 8 */ 304 - __le16 DataLength; 305 - __u32 Reserved; 306 - __le16 SigningAlgorithmCount; 307 - __le16 SigningAlgorithms[]; 308 - /* Followed by padding to 8 byte boundary (required by some servers) */ 309 - } __packed; 310 - 311 - #define POSIX_CTXT_DATA_LEN 16 312 - struct smb2_posix_neg_context { 313 - __le16 ContextType; /* 0x100 */ 314 - __le16 DataLength; 315 - __le32 Reserved; 316 - __u8 Name[16]; /* POSIX ctxt GUID 93AD25509CB411E7B42383DE968BCD7C */ 317 - } __packed; 318 - 319 - struct smb2_negotiate_rsp { 320 - struct smb2_sync_hdr sync_hdr; 321 - __le16 StructureSize; /* Must be 65 */ 322 - __le16 SecurityMode; 323 - __le16 DialectRevision; 324 - __le16 NegotiateContextCount; /* Prior to SMB3.1.1 was Reserved & MBZ */ 325 - __u8 ServerGUID[16]; 326 - __le32 Capabilities; 327 - __le32 MaxTransactSize; 328 - __le32 MaxReadSize; 329 - __le32 MaxWriteSize; 330 - __le64 SystemTime; /* MBZ */ 331 - __le64 ServerStartTime; 332 - __le16 SecurityBufferOffset; 333 - __le16 SecurityBufferLength; 334 - __le32 NegotiateContextOffset; /* Pre:SMB3.1.1 was reserved/ignored */ 335 - __u8 Buffer[1]; /* variable length GSS security buffer */ 336 - } __packed; 337 - 338 - /* Flags */ 339 - #define SMB2_SESSION_REQ_FLAG_BINDING 0x01 340 - #define SMB2_SESSION_REQ_FLAG_ENCRYPT_DATA 0x04 341 - 342 - struct smb2_sess_setup_req { 343 - struct smb2_sync_hdr sync_hdr; 344 - __le16 StructureSize; /* Must be 25 */ 345 - __u8 Flags; 346 - __u8 SecurityMode; 347 - __le32 Capabilities; 348 - __le32 Channel; 349 - __le16 SecurityBufferOffset; 350 - __le16 SecurityBufferLength; 351 - __u64 PreviousSessionId; 352 - __u8 Buffer[1]; /* variable length GSS security buffer */ 353 - } __packed; 354 - 355 - /* Currently defined SessionFlags */ 356 - #define SMB2_SESSION_FLAG_IS_GUEST 0x0001 357 - #define SMB2_SESSION_FLAG_IS_NULL 0x0002 358 - #define SMB2_SESSION_FLAG_ENCRYPT_DATA 0x0004 359 - struct smb2_sess_setup_rsp { 360 - struct smb2_sync_hdr sync_hdr; 361 - __le16 StructureSize; /* Must be 9 */ 362 - __le16 SessionFlags; 363 - __le16 SecurityBufferOffset; 364 - __le16 SecurityBufferLength; 365 - __u8 Buffer[1]; /* variable length GSS security buffer */ 366 - } __packed; 367 - 368 - struct smb2_logoff_req { 369 - struct smb2_sync_hdr sync_hdr; 370 - __le16 StructureSize; /* Must be 4 */ 371 - __le16 Reserved; 372 - } __packed; 373 - 374 - 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; 524 - __le16 StructureSize; /* Must be 4 */ 525 - __le16 Reserved; 526 - } __packed; 527 - 528 - /* File Attrubutes */ 529 - #define FILE_ATTRIBUTE_READONLY 0x00000001 530 - #define FILE_ATTRIBUTE_HIDDEN 0x00000002 531 - #define FILE_ATTRIBUTE_SYSTEM 0x00000004 532 - #define FILE_ATTRIBUTE_DIRECTORY 0x00000010 533 - #define FILE_ATTRIBUTE_ARCHIVE 0x00000020 534 - #define FILE_ATTRIBUTE_NORMAL 0x00000080 535 - #define FILE_ATTRIBUTE_TEMPORARY 0x00000100 536 - #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200 537 - #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400 538 - #define FILE_ATTRIBUTE_COMPRESSED 0x00000800 539 - #define FILE_ATTRIBUTE_OFFLINE 0x00001000 540 - #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000 541 - #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000 542 - #define FILE_ATTRIBUTE_INTEGRITY_STREAM 0x00008000 543 - #define FILE_ATTRIBUTE_NO_SCRUB_DATA 0x00020000 544 - 545 - /* Oplock levels */ 546 - #define SMB2_OPLOCK_LEVEL_NONE 0x00 547 - #define SMB2_OPLOCK_LEVEL_II 0x01 548 - #define SMB2_OPLOCK_LEVEL_EXCLUSIVE 0x08 549 - #define SMB2_OPLOCK_LEVEL_BATCH 0x09 550 - #define SMB2_OPLOCK_LEVEL_LEASE 0xFF 551 - /* Non-spec internal type */ 552 - #define SMB2_OPLOCK_LEVEL_NOCHANGE 0x99 553 - 554 - /* Desired Access Flags */ 555 - #define FILE_READ_DATA_LE cpu_to_le32(0x00000001) 556 - #define FILE_WRITE_DATA_LE cpu_to_le32(0x00000002) 557 - #define FILE_APPEND_DATA_LE cpu_to_le32(0x00000004) 558 - #define FILE_READ_EA_LE cpu_to_le32(0x00000008) 559 - #define FILE_WRITE_EA_LE cpu_to_le32(0x00000010) 560 - #define FILE_EXECUTE_LE cpu_to_le32(0x00000020) 561 - #define FILE_READ_ATTRIBUTES_LE cpu_to_le32(0x00000080) 562 - #define FILE_WRITE_ATTRIBUTES_LE cpu_to_le32(0x00000100) 563 - #define FILE_DELETE_LE cpu_to_le32(0x00010000) 564 - #define FILE_READ_CONTROL_LE cpu_to_le32(0x00020000) 565 - #define FILE_WRITE_DAC_LE cpu_to_le32(0x00040000) 566 - #define FILE_WRITE_OWNER_LE cpu_to_le32(0x00080000) 567 - #define FILE_SYNCHRONIZE_LE cpu_to_le32(0x00100000) 568 - #define FILE_ACCESS_SYSTEM_SECURITY_LE cpu_to_le32(0x01000000) 569 - #define FILE_MAXIMAL_ACCESS_LE cpu_to_le32(0x02000000) 570 - #define FILE_GENERIC_ALL_LE cpu_to_le32(0x10000000) 571 - #define FILE_GENERIC_EXECUTE_LE cpu_to_le32(0x20000000) 572 - #define FILE_GENERIC_WRITE_LE cpu_to_le32(0x40000000) 573 - #define FILE_GENERIC_READ_LE cpu_to_le32(0x80000000) 574 - 575 - /* ShareAccess Flags */ 576 - #define FILE_SHARE_READ_LE cpu_to_le32(0x00000001) 577 - #define FILE_SHARE_WRITE_LE cpu_to_le32(0x00000002) 578 - #define FILE_SHARE_DELETE_LE cpu_to_le32(0x00000004) 579 - #define FILE_SHARE_ALL_LE cpu_to_le32(0x00000007) 580 - 581 - /* CreateDisposition Flags */ 582 - #define FILE_SUPERSEDE_LE cpu_to_le32(0x00000000) 583 - #define FILE_OPEN_LE cpu_to_le32(0x00000001) 584 - #define FILE_CREATE_LE cpu_to_le32(0x00000002) 585 - #define FILE_OPEN_IF_LE cpu_to_le32(0x00000003) 586 - #define FILE_OVERWRITE_LE cpu_to_le32(0x00000004) 587 - #define FILE_OVERWRITE_IF_LE cpu_to_le32(0x00000005) 588 - 589 - /* CreateOptions Flags */ 590 - #define FILE_DIRECTORY_FILE_LE cpu_to_le32(0x00000001) 591 - /* same as #define CREATE_NOT_FILE_LE cpu_to_le32(0x00000001) */ 592 - #define FILE_WRITE_THROUGH_LE cpu_to_le32(0x00000002) 593 - #define FILE_SEQUENTIAL_ONLY_LE cpu_to_le32(0x00000004) 594 - #define FILE_NO_INTERMEDIATE_BUFFERRING_LE cpu_to_le32(0x00000008) 595 - #define FILE_SYNCHRONOUS_IO_ALERT_LE cpu_to_le32(0x00000010) 596 - #define FILE_SYNCHRONOUS_IO_NON_ALERT_LE cpu_to_le32(0x00000020) 597 - #define FILE_NON_DIRECTORY_FILE_LE cpu_to_le32(0x00000040) 598 - #define FILE_COMPLETE_IF_OPLOCKED_LE cpu_to_le32(0x00000100) 599 - #define FILE_NO_EA_KNOWLEDGE_LE cpu_to_le32(0x00000200) 600 - #define FILE_RANDOM_ACCESS_LE cpu_to_le32(0x00000800) 601 - #define FILE_DELETE_ON_CLOSE_LE cpu_to_le32(0x00001000) 602 - #define FILE_OPEN_BY_FILE_ID_LE cpu_to_le32(0x00002000) 603 - #define FILE_OPEN_FOR_BACKUP_INTENT_LE cpu_to_le32(0x00004000) 604 - #define FILE_NO_COMPRESSION_LE cpu_to_le32(0x00008000) 605 - #define FILE_RESERVE_OPFILTER_LE cpu_to_le32(0x00100000) 606 - #define FILE_OPEN_REPARSE_POINT_LE cpu_to_le32(0x00200000) 607 - #define FILE_OPEN_NO_RECALL_LE cpu_to_le32(0x00400000) 608 - #define FILE_OPEN_FOR_FREE_SPACE_QUERY_LE cpu_to_le32(0x00800000) 609 - 610 - #define FILE_READ_RIGHTS_LE (FILE_READ_DATA_LE | FILE_READ_EA_LE \ 611 - | FILE_READ_ATTRIBUTES_LE) 612 - #define FILE_WRITE_RIGHTS_LE (FILE_WRITE_DATA_LE | FILE_APPEND_DATA_LE \ 613 - | FILE_WRITE_EA_LE | FILE_WRITE_ATTRIBUTES_LE) 614 - #define FILE_EXEC_RIGHTS_LE (FILE_EXECUTE_LE) 615 - 616 - /* Impersonation Levels. See MS-WPO section 9.7 and MSDN-IMPERS */ 617 - #define IL_ANONYMOUS cpu_to_le32(0x00000000) 618 - #define IL_IDENTIFICATION cpu_to_le32(0x00000001) 619 - #define IL_IMPERSONATION cpu_to_le32(0x00000002) 620 - #define IL_DELEGATE cpu_to_le32(0x00000003) 621 - 622 - /* Create Context Values */ 623 - #define SMB2_CREATE_EA_BUFFER "ExtA" /* extended attributes */ 624 - #define SMB2_CREATE_SD_BUFFER "SecD" /* security descriptor */ 625 - #define SMB2_CREATE_DURABLE_HANDLE_REQUEST "DHnQ" 626 - #define SMB2_CREATE_DURABLE_HANDLE_RECONNECT "DHnC" 627 - #define SMB2_CREATE_ALLOCATION_SIZE "AISi" 628 - #define SMB2_CREATE_QUERY_MAXIMAL_ACCESS_REQUEST "MxAc" 629 - #define SMB2_CREATE_TIMEWARP_REQUEST "TWrp" 630 - #define SMB2_CREATE_QUERY_ON_DISK_ID "QFid" 631 - #define SMB2_CREATE_REQUEST_LEASE "RqLs" 632 - #define SMB2_CREATE_DURABLE_HANDLE_REQUEST_V2 "DH2Q" 633 - #define SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2 "DH2C" 634 - #define SMB2_CREATE_APP_INSTANCE_ID 0x45BCA66AEFA7F74A9008FA462E144D74 635 - #define SMB2_CREATE_APP_INSTANCE_VERSION 0xB982D0B73B56074FA07B524A8116A010 636 - #define SVHDX_OPEN_DEVICE_CONTEX 0x9CCBCF9E04C1E643980E158DA1F6EC83 637 - #define SMB2_CREATE_TAG_POSIX 0x93AD25509CB411E7B42383DE968BCD7C 638 - 639 - /* Flag (SMB3 open response) values */ 640 - #define SMB2_CREATE_FLAG_REPARSEPOINT 0x01 641 - 642 273 /* 643 274 * Maximum number of iovs we need for an open/create request. 644 275 * [0] : struct smb2_create_req ··· 128 807 */ 129 808 #define SMB2_CREATE_IOV_SIZE 8 130 809 131 - struct smb2_create_req { 132 - struct smb2_sync_hdr sync_hdr; 133 - __le16 StructureSize; /* Must be 57 */ 134 - __u8 SecurityFlags; 135 - __u8 RequestedOplockLevel; 136 - __le32 ImpersonationLevel; 137 - __le64 SmbCreateFlags; 138 - __le64 Reserved; 139 - __le32 DesiredAccess; 140 - __le32 FileAttributes; 141 - __le32 ShareAccess; 142 - __le32 CreateDisposition; 143 - __le32 CreateOptions; 144 - __le16 NameOffset; 145 - __le16 NameLength; 146 - __le32 CreateContextsOffset; 147 - __le32 CreateContextsLength; 148 - __u8 Buffer[]; 149 - } __packed; 150 - 151 810 /* 152 811 * Maximum size of a SMB2_CREATE response is 64 (smb2 header) + 153 812 * 88 (fixed part of create response) + 520 (path) + 208 (contexts) + 154 813 * 2 bytes of padding. 155 814 */ 156 815 #define MAX_SMB2_CREATE_RESPONSE_SIZE 880 157 - 158 - struct smb2_create_rsp { 159 - struct smb2_sync_hdr sync_hdr; 160 - __le16 StructureSize; /* Must be 89 */ 161 - __u8 OplockLevel; 162 - __u8 Flag; /* 0x01 if reparse point */ 163 - __le32 CreateAction; 164 - __le64 CreationTime; 165 - __le64 LastAccessTime; 166 - __le64 LastWriteTime; 167 - __le64 ChangeTime; 168 - __le64 AllocationSize; 169 - __le64 EndofFile; 170 - __le32 FileAttributes; 171 - __le32 Reserved2; 172 - __u64 PersistentFileId; /* opaque endianness */ 173 - __u64 VolatileFileId; /* opaque endianness */ 174 - __le32 CreateContextsOffset; 175 - __le32 CreateContextsLength; 176 - __u8 Buffer[1]; 177 - } __packed; 178 - 179 - struct create_context { 180 - __le32 Next; 181 - __le16 NameOffset; 182 - __le16 NameLength; 183 - __le16 Reserved; 184 - __le16 DataOffset; 185 - __le32 DataLength; 186 - __u8 Buffer[]; 187 - } __packed; 188 816 189 817 #define SMB2_LEASE_READ_CACHING_HE 0x01 190 818 #define SMB2_LEASE_HANDLE_CACHING_HE 0x02 ··· 480 1210 #define SMB2_IOCTL_IOV_SIZE 2 481 1211 482 1212 struct smb2_ioctl_req { 483 - struct smb2_sync_hdr sync_hdr; 1213 + struct smb2_hdr hdr; 484 1214 __le16 StructureSize; /* Must be 57 */ 485 1215 __u16 Reserved; 486 1216 __le32 CtlCode; ··· 498 1228 } __packed; 499 1229 500 1230 struct smb2_ioctl_rsp { 501 - struct smb2_sync_hdr sync_hdr; 1231 + struct smb2_hdr hdr; 502 1232 __le16 StructureSize; /* Must be 57 */ 503 1233 __u16 Reserved; 504 1234 __le32 CtlCode; ··· 511 1241 __le32 Flags; 512 1242 __u32 Reserved2; 513 1243 /* char * buffer[] */ 514 - } __packed; 515 - 516 - /* Currently defined values for close flags */ 517 - #define SMB2_CLOSE_FLAG_POSTQUERY_ATTRIB cpu_to_le16(0x0001) 518 - struct smb2_close_req { 519 - struct smb2_sync_hdr sync_hdr; 520 - __le16 StructureSize; /* Must be 24 */ 521 - __le16 Flags; 522 - __le32 Reserved; 523 - __u64 PersistentFileId; /* opaque endianness */ 524 - __u64 VolatileFileId; /* opaque endianness */ 525 - } __packed; 526 - 527 - /* 528 - * Maximum size of a SMB2_CLOSE response is 64 (smb2 header) + 60 (data) 529 - */ 530 - #define MAX_SMB2_CLOSE_RESPONSE_SIZE 124 531 - 532 - struct smb2_close_rsp { 533 - struct smb2_sync_hdr sync_hdr; 534 - __le16 StructureSize; /* 60 */ 535 - __le16 Flags; 536 - __le32 Reserved; 537 - __le64 CreationTime; 538 - __le64 LastAccessTime; 539 - __le64 LastWriteTime; 540 - __le64 ChangeTime; 541 - __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */ 542 - __le64 EndOfFile; 543 - __le32 Attributes; 544 - } __packed; 545 - 546 - struct smb2_flush_req { 547 - struct smb2_sync_hdr sync_hdr; 548 - __le16 StructureSize; /* Must be 24 */ 549 - __le16 Reserved1; 550 - __le32 Reserved2; 551 - __u64 PersistentFileId; /* opaque endianness */ 552 - __u64 VolatileFileId; /* opaque endianness */ 553 - } __packed; 554 - 555 - struct smb2_flush_rsp { 556 - struct smb2_sync_hdr sync_hdr; 557 - __le16 StructureSize; 558 - __le16 Reserved; 559 - } __packed; 560 - 561 - /* For read request Flags field below, following flag is defined for SMB3.02 */ 562 - #define SMB2_READFLAG_READ_UNBUFFERED 0x01 563 - #define SMB2_READFLAG_REQUEST_COMPRESSED 0x02 /* See MS-SMB2 2.2.19 */ 564 - 565 - /* Channel field for read and write: exactly one of following flags can be set*/ 566 - #define SMB2_CHANNEL_NONE cpu_to_le32(0x00000000) 567 - #define SMB2_CHANNEL_RDMA_V1 cpu_to_le32(0x00000001) /* SMB3 or later */ 568 - #define SMB2_CHANNEL_RDMA_V1_INVALIDATE cpu_to_le32(0x00000002) /* >= SMB3.02 */ 569 - #define SMB2_CHANNEL_RDMA_TRANSFORM cpu_to_le32(0x00000003) /* >= SMB3.02, only used on write */ 570 - 571 - /* SMB2 read request without RFC1001 length at the beginning */ 572 - struct smb2_read_plain_req { 573 - struct smb2_sync_hdr sync_hdr; 574 - __le16 StructureSize; /* Must be 49 */ 575 - __u8 Padding; /* offset from start of SMB2 header to place read */ 576 - __u8 Flags; /* MBZ unless SMB3.02 or later */ 577 - __le32 Length; 578 - __le64 Offset; 579 - __u64 PersistentFileId; /* opaque endianness */ 580 - __u64 VolatileFileId; /* opaque endianness */ 581 - __le32 MinimumCount; 582 - __le32 Channel; /* MBZ except for SMB3 or later */ 583 - __le32 RemainingBytes; 584 - __le16 ReadChannelInfoOffset; 585 - __le16 ReadChannelInfoLength; 586 - __u8 Buffer[1]; 587 - } __packed; 588 - 589 - /* Read flags */ 590 - #define SMB2_READFLAG_RESPONSE_NONE 0x00000000 591 - #define SMB2_READFLAG_RESPONSE_RDMA_TRANSFORM 0x00000001 592 - 593 - struct smb2_read_rsp { 594 - struct smb2_sync_hdr sync_hdr; 595 - __le16 StructureSize; /* Must be 17 */ 596 - __u8 DataOffset; 597 - __u8 Reserved; 598 - __le32 DataLength; 599 - __le32 DataRemaining; 600 - __u32 Flags; 601 - __u8 Buffer[1]; 602 - } __packed; 603 - 604 - /* For write request Flags field below the following flags are defined: */ 605 - #define SMB2_WRITEFLAG_WRITE_THROUGH 0x00000001 /* SMB2.1 or later */ 606 - #define SMB2_WRITEFLAG_WRITE_UNBUFFERED 0x00000002 /* SMB3.02 or later */ 607 - 608 - struct smb2_write_req { 609 - struct smb2_sync_hdr sync_hdr; 610 - __le16 StructureSize; /* Must be 49 */ 611 - __le16 DataOffset; /* offset from start of SMB2 header to write data */ 612 - __le32 Length; 613 - __le64 Offset; 614 - __u64 PersistentFileId; /* opaque endianness */ 615 - __u64 VolatileFileId; /* opaque endianness */ 616 - __le32 Channel; /* MBZ unless SMB3.02 or later */ 617 - __le32 RemainingBytes; 618 - __le16 WriteChannelInfoOffset; 619 - __le16 WriteChannelInfoLength; 620 - __le32 Flags; 621 - __u8 Buffer[1]; 622 - } __packed; 623 - 624 - struct smb2_write_rsp { 625 - struct smb2_sync_hdr sync_hdr; 626 - __le16 StructureSize; /* Must be 17 */ 627 - __u8 DataOffset; 628 - __u8 Reserved; 629 - __le32 DataLength; 630 - __le32 DataRemaining; 631 - __u32 Reserved2; 632 - __u8 Buffer[1]; 633 - } __packed; 634 - 635 - /* notify flags */ 636 - #define SMB2_WATCH_TREE 0x0001 637 - 638 - /* notify completion filter flags. See MS-FSCC 2.6 and MS-SMB2 2.2.35 */ 639 - #define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001 640 - #define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002 641 - #define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004 642 - #define FILE_NOTIFY_CHANGE_SIZE 0x00000008 643 - #define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010 644 - #define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020 645 - #define FILE_NOTIFY_CHANGE_CREATION 0x00000040 646 - #define FILE_NOTIFY_CHANGE_EA 0x00000080 647 - #define FILE_NOTIFY_CHANGE_SECURITY 0x00000100 648 - #define FILE_NOTIFY_CHANGE_STREAM_NAME 0x00000200 649 - #define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400 650 - #define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800 651 - 652 - struct smb2_change_notify_req { 653 - struct smb2_sync_hdr sync_hdr; 654 - __le16 StructureSize; 655 - __le16 Flags; 656 - __le32 OutputBufferLength; 657 - __u64 PersistentFileId; /* opaque endianness */ 658 - __u64 VolatileFileId; /* opaque endianness */ 659 - __le32 CompletionFilter; 660 - __u32 Reserved; 661 - } __packed; 662 - 663 - struct smb2_change_notify_rsp { 664 - struct smb2_sync_hdr sync_hdr; 665 - __le16 StructureSize; /* Must be 9 */ 666 - __le16 OutputBufferOffset; 667 - __le32 OutputBufferLength; 668 - __u8 Buffer[1]; /* array of file notify structs */ 669 1244 } __packed; 670 1245 671 1246 #define SMB2_LOCKFLAG_SHARED_LOCK 0x0001 ··· 526 1411 } __packed; 527 1412 528 1413 struct smb2_lock_req { 529 - struct smb2_sync_hdr sync_hdr; 1414 + struct smb2_hdr hdr; 530 1415 __le16 StructureSize; /* Must be 48 */ 531 1416 __le16 LockCount; 532 1417 /* ··· 541 1426 } __packed; 542 1427 543 1428 struct smb2_lock_rsp { 544 - struct smb2_sync_hdr sync_hdr; 1429 + struct smb2_hdr hdr; 545 1430 __le16 StructureSize; /* Must be 4 */ 546 1431 __le16 Reserved; 547 1432 } __packed; 548 1433 549 1434 struct smb2_echo_req { 550 - struct smb2_sync_hdr sync_hdr; 1435 + struct smb2_hdr hdr; 551 1436 __le16 StructureSize; /* Must be 4 */ 552 1437 __u16 Reserved; 553 1438 } __packed; 554 1439 555 1440 struct smb2_echo_rsp { 556 - struct smb2_sync_hdr sync_hdr; 1441 + struct smb2_hdr hdr; 557 1442 __le16 StructureSize; /* Must be 4 */ 558 1443 __u16 Reserved; 559 1444 } __packed; ··· 583 1468 */ 584 1469 585 1470 struct smb2_query_directory_req { 586 - struct smb2_sync_hdr sync_hdr; 1471 + struct smb2_hdr hdr; 587 1472 __le16 StructureSize; /* Must be 33 */ 588 1473 __u8 FileInformationClass; 589 1474 __u8 Flags; ··· 597 1482 } __packed; 598 1483 599 1484 struct smb2_query_directory_rsp { 600 - struct smb2_sync_hdr sync_hdr; 1485 + struct smb2_hdr hdr; 601 1486 __le16 StructureSize; /* Must be 9 */ 602 1487 __le16 OutputBufferOffset; 603 1488 __le32 OutputBufferLength; ··· 630 1515 #define SL_INDEX_SPECIFIED 0x00000004 631 1516 632 1517 struct smb2_query_info_req { 633 - struct smb2_sync_hdr sync_hdr; 1518 + struct smb2_hdr hdr; 634 1519 __le16 StructureSize; /* Must be 41 */ 635 1520 __u8 InfoType; 636 1521 __u8 FileInfoClass; ··· 646 1531 } __packed; 647 1532 648 1533 struct smb2_query_info_rsp { 649 - struct smb2_sync_hdr sync_hdr; 1534 + struct smb2_hdr hdr; 650 1535 __le16 StructureSize; /* Must be 9 */ 651 1536 __le16 OutputBufferOffset; 652 1537 __le32 OutputBufferLength; ··· 663 1548 #define SMB2_SET_INFO_IOV_SIZE 3 664 1549 665 1550 struct smb2_set_info_req { 666 - struct smb2_sync_hdr sync_hdr; 1551 + struct smb2_hdr hdr; 667 1552 __le16 StructureSize; /* Must be 33 */ 668 1553 __u8 InfoType; 669 1554 __u8 FileInfoClass; ··· 677 1562 } __packed; 678 1563 679 1564 struct smb2_set_info_rsp { 680 - struct smb2_sync_hdr sync_hdr; 1565 + struct smb2_hdr hdr; 681 1566 __le16 StructureSize; /* Must be 2 */ 682 1567 } __packed; 683 1568 684 1569 struct smb2_oplock_break { 685 - struct smb2_sync_hdr sync_hdr; 1570 + struct smb2_hdr hdr; 686 1571 __le16 StructureSize; /* Must be 24 */ 687 1572 __u8 OplockLevel; 688 1573 __u8 Reserved; ··· 694 1579 #define SMB2_NOTIFY_BREAK_LEASE_FLAG_ACK_REQUIRED cpu_to_le32(0x01) 695 1580 696 1581 struct smb2_lease_break { 697 - struct smb2_sync_hdr sync_hdr; 1582 + struct smb2_hdr hdr; 698 1583 __le16 StructureSize; /* Must be 44 */ 699 1584 __le16 Epoch; 700 1585 __le32 Flags; ··· 707 1592 } __packed; 708 1593 709 1594 struct smb2_lease_ack { 710 - struct smb2_sync_hdr sync_hdr; 1595 + struct smb2_hdr hdr; 711 1596 __le16 StructureSize; /* Must be 36 */ 712 1597 __le16 Reserved; 713 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 &&
+71
fs/cifs/trace.h
··· 11 11 #define _CIFS_TRACE_H 12 12 13 13 #include <linux/tracepoint.h> 14 + #include <linux/net.h> 15 + #include <linux/inet.h> 14 16 15 17 /* 16 18 * Please use this 3-part article as a reference for writing new tracepoints: ··· 855 853 TP_ARGS(lease_state, tid, sesid, lease_key_low, lease_key_high, rc)) 856 854 857 855 DEFINE_SMB3_LEASE_ERR_EVENT(lease_err); 856 + 857 + DECLARE_EVENT_CLASS(smb3_connect_class, 858 + TP_PROTO(char *hostname, 859 + __u64 conn_id, 860 + const struct __kernel_sockaddr_storage *dst_addr), 861 + TP_ARGS(hostname, conn_id, dst_addr), 862 + TP_STRUCT__entry( 863 + __string(hostname, hostname) 864 + __field(__u64, conn_id) 865 + __array(__u8, dst_addr, sizeof(struct sockaddr_storage)) 866 + ), 867 + TP_fast_assign( 868 + struct sockaddr_storage *pss = NULL; 869 + 870 + __entry->conn_id = conn_id; 871 + pss = (struct sockaddr_storage *)__entry->dst_addr; 872 + *pss = *dst_addr; 873 + __assign_str(hostname, hostname); 874 + ), 875 + TP_printk("conn_id=0x%llx server=%s addr=%pISpsfc", 876 + __entry->conn_id, 877 + __get_str(hostname), 878 + __entry->dst_addr) 879 + ) 880 + 881 + #define DEFINE_SMB3_CONNECT_EVENT(name) \ 882 + DEFINE_EVENT(smb3_connect_class, smb3_##name, \ 883 + TP_PROTO(char *hostname, \ 884 + __u64 conn_id, \ 885 + const struct __kernel_sockaddr_storage *addr), \ 886 + TP_ARGS(hostname, conn_id, addr)) 887 + 888 + DEFINE_SMB3_CONNECT_EVENT(connect_done); 889 + 890 + DECLARE_EVENT_CLASS(smb3_connect_err_class, 891 + TP_PROTO(char *hostname, __u64 conn_id, 892 + const struct __kernel_sockaddr_storage *dst_addr, int rc), 893 + TP_ARGS(hostname, conn_id, dst_addr, rc), 894 + TP_STRUCT__entry( 895 + __string(hostname, hostname) 896 + __field(__u64, conn_id) 897 + __array(__u8, dst_addr, sizeof(struct sockaddr_storage)) 898 + __field(int, rc) 899 + ), 900 + TP_fast_assign( 901 + struct sockaddr_storage *pss = NULL; 902 + 903 + __entry->conn_id = conn_id; 904 + __entry->rc = rc; 905 + pss = (struct sockaddr_storage *)__entry->dst_addr; 906 + *pss = *dst_addr; 907 + __assign_str(hostname, hostname); 908 + ), 909 + TP_printk("rc=%d conn_id=0x%llx server=%s addr=%pISpsfc", 910 + __entry->rc, 911 + __entry->conn_id, 912 + __get_str(hostname), 913 + __entry->dst_addr) 914 + ) 915 + 916 + #define DEFINE_SMB3_CONNECT_ERR_EVENT(name) \ 917 + DEFINE_EVENT(smb3_connect_err_class, smb3_##name, \ 918 + TP_PROTO(char *hostname, \ 919 + __u64 conn_id, \ 920 + const struct __kernel_sockaddr_storage *addr, \ 921 + int rc), \ 922 + TP_ARGS(hostname, conn_id, addr, rc)) 923 + 924 + DEFINE_SMB3_CONNECT_ERR_EVENT(connect_err); 858 925 859 926 DECLARE_EVENT_CLASS(smb3_reconnect_class, 860 927 TP_PROTO(__u64 currmid,
+989
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 + /* 319 + * SMB2_NEGOTIATE_PROTOCOL See MS-SMB2 section 2.2.3 320 + */ 321 + /* SecurityMode flags */ 322 + #define SMB2_NEGOTIATE_SIGNING_ENABLED 0x0001 323 + #define SMB2_NEGOTIATE_SIGNING_ENABLED_LE cpu_to_le16(0x0001) 324 + #define SMB2_NEGOTIATE_SIGNING_REQUIRED 0x0002 325 + #define SMB2_NEGOTIATE_SIGNING_REQUIRED_LE cpu_to_le16(0x0002) 326 + #define SMB2_SEC_MODE_FLAGS_ALL 0x0003 327 + 328 + /* Capabilities flags */ 329 + #define SMB2_GLOBAL_CAP_DFS 0x00000001 330 + #define SMB2_GLOBAL_CAP_LEASING 0x00000002 /* Resp only New to SMB2.1 */ 331 + #define SMB2_GLOBAL_CAP_LARGE_MTU 0X00000004 /* Resp only New to SMB2.1 */ 332 + #define SMB2_GLOBAL_CAP_MULTI_CHANNEL 0x00000008 /* New to SMB3 */ 333 + #define SMB2_GLOBAL_CAP_PERSISTENT_HANDLES 0x00000010 /* New to SMB3 */ 334 + #define SMB2_GLOBAL_CAP_DIRECTORY_LEASING 0x00000020 /* New to SMB3 */ 335 + #define SMB2_GLOBAL_CAP_ENCRYPTION 0x00000040 /* New to SMB3 */ 336 + /* Internal types */ 337 + #define SMB2_NT_FIND 0x00100000 338 + #define SMB2_LARGE_FILES 0x00200000 339 + 340 + #define SMB2_CLIENT_GUID_SIZE 16 341 + #define SMB2_CREATE_GUID_SIZE 16 342 + 343 + /* Dialects */ 344 + #define SMB10_PROT_ID 0x0000 /* local only, not sent on wire w/CIFS negprot */ 345 + #define SMB20_PROT_ID 0x0202 346 + #define SMB21_PROT_ID 0x0210 347 + #define SMB2X_PROT_ID 0x02FF 348 + #define SMB30_PROT_ID 0x0300 349 + #define SMB302_PROT_ID 0x0302 350 + #define SMB311_PROT_ID 0x0311 351 + #define BAD_PROT_ID 0xFFFF 352 + 353 + #define SMB311_SALT_SIZE 32 354 + /* Hash Algorithm Types */ 355 + #define SMB2_PREAUTH_INTEGRITY_SHA512 cpu_to_le16(0x0001) 356 + #define SMB2_PREAUTH_HASH_SIZE 64 357 + 358 + /* Negotiate Contexts - ContextTypes. See MS-SMB2 section 2.2.3.1 for details */ 359 + #define SMB2_PREAUTH_INTEGRITY_CAPABILITIES cpu_to_le16(1) 360 + #define SMB2_ENCRYPTION_CAPABILITIES cpu_to_le16(2) 361 + #define SMB2_COMPRESSION_CAPABILITIES cpu_to_le16(3) 362 + #define SMB2_NETNAME_NEGOTIATE_CONTEXT_ID cpu_to_le16(5) 363 + #define SMB2_TRANSPORT_CAPABILITIES cpu_to_le16(6) 364 + #define SMB2_RDMA_TRANSFORM_CAPABILITIES cpu_to_le16(7) 365 + #define SMB2_SIGNING_CAPABILITIES cpu_to_le16(8) 366 + #define SMB2_POSIX_EXTENSIONS_AVAILABLE cpu_to_le16(0x100) 367 + 368 + struct smb2_neg_context { 369 + __le16 ContextType; 370 + __le16 DataLength; 371 + __le32 Reserved; 372 + /* Followed by array of data. NOTE: some servers require padding to 8 byte boundary */ 373 + } __packed; 374 + 375 + /* 376 + * SaltLength that the server send can be zero, so the only three required 377 + * fields (all __le16) end up six bytes total, so the minimum context data len 378 + * in the response is six bytes which accounts for 379 + * 380 + * HashAlgorithmCount, SaltLength, and 1 HashAlgorithm. 381 + */ 382 + #define MIN_PREAUTH_CTXT_DATA_LEN 6 383 + 384 + struct smb2_preauth_neg_context { 385 + __le16 ContextType; /* 1 */ 386 + __le16 DataLength; 387 + __le32 Reserved; 388 + __le16 HashAlgorithmCount; /* 1 */ 389 + __le16 SaltLength; 390 + __le16 HashAlgorithms; /* HashAlgorithms[0] since only one defined */ 391 + __u8 Salt[SMB311_SALT_SIZE]; 392 + } __packed; 393 + 394 + /* Encryption Algorithms Ciphers */ 395 + #define SMB2_ENCRYPTION_AES128_CCM cpu_to_le16(0x0001) 396 + #define SMB2_ENCRYPTION_AES128_GCM cpu_to_le16(0x0002) 397 + #define SMB2_ENCRYPTION_AES256_CCM cpu_to_le16(0x0003) 398 + #define SMB2_ENCRYPTION_AES256_GCM cpu_to_le16(0x0004) 399 + 400 + /* Min encrypt context data is one cipher so 2 bytes + 2 byte count field */ 401 + #define MIN_ENCRYPT_CTXT_DATA_LEN 4 402 + struct smb2_encryption_neg_context { 403 + __le16 ContextType; /* 2 */ 404 + __le16 DataLength; 405 + __le32 Reserved; 406 + /* CipherCount usally 2, but can be 3 when AES256-GCM enabled */ 407 + __le16 CipherCount; /* AES128-GCM and AES128-CCM by default */ 408 + __le16 Ciphers[]; 409 + } __packed; 410 + 411 + /* See MS-SMB2 2.2.3.1.3 */ 412 + #define SMB3_COMPRESS_NONE cpu_to_le16(0x0000) 413 + #define SMB3_COMPRESS_LZNT1 cpu_to_le16(0x0001) 414 + #define SMB3_COMPRESS_LZ77 cpu_to_le16(0x0002) 415 + #define SMB3_COMPRESS_LZ77_HUFF cpu_to_le16(0x0003) 416 + /* Pattern scanning algorithm See MS-SMB2 3.1.4.4.1 */ 417 + #define SMB3_COMPRESS_PATTERN cpu_to_le16(0x0004) /* Pattern_V1 */ 418 + 419 + /* Compression Flags */ 420 + #define SMB2_COMPRESSION_CAPABILITIES_FLAG_NONE cpu_to_le32(0x00000000) 421 + #define SMB2_COMPRESSION_CAPABILITIES_FLAG_CHAINED cpu_to_le32(0x00000001) 422 + 423 + struct smb2_compression_capabilities_context { 424 + __le16 ContextType; /* 3 */ 425 + __le16 DataLength; 426 + __le32 Reserved; 427 + __le16 CompressionAlgorithmCount; 428 + __le16 Padding; 429 + __le32 Flags; 430 + __le16 CompressionAlgorithms[3]; 431 + __u16 Pad; /* Some servers require pad to DataLen multiple of 8 */ 432 + /* Check if pad needed */ 433 + } __packed; 434 + 435 + /* 436 + * For smb2_netname_negotiate_context_id See MS-SMB2 2.2.3.1.4. 437 + * Its struct simply contains NetName, an array of Unicode characters 438 + */ 439 + struct smb2_netname_neg_context { 440 + __le16 ContextType; /* 5 */ 441 + __le16 DataLength; 442 + __le32 Reserved; 443 + __le16 NetName[]; /* hostname of target converted to UCS-2 */ 444 + } __packed; 445 + 446 + /* 447 + * For smb2_transport_capabilities context see MS-SMB2 2.2.3.1.5 448 + * and 2.2.4.1.5 449 + */ 450 + 451 + /* Flags */ 452 + #define SMB2_ACCEPT_TRANSFORM_LEVEL_SECURITY 0x00000001 453 + 454 + struct smb2_transport_capabilities_context { 455 + __le16 ContextType; /* 6 */ 456 + __le16 DataLength; 457 + __u32 Reserved; 458 + __le32 Flags; 459 + __u32 Pad; 460 + } __packed; 461 + 462 + /* 463 + * For rdma transform capabilities context see MS-SMB2 2.2.3.1.6 464 + * and 2.2.4.1.6 465 + */ 466 + 467 + /* RDMA Transform IDs */ 468 + #define SMB2_RDMA_TRANSFORM_NONE 0x0000 469 + #define SMB2_RDMA_TRANSFORM_ENCRYPTION 0x0001 470 + #define SMB2_RDMA_TRANSFORM_SIGNING 0x0002 471 + 472 + struct smb2_rdma_transform_capabilities_context { 473 + __le16 ContextType; /* 7 */ 474 + __le16 DataLength; 475 + __u32 Reserved; 476 + __le16 TransformCount; 477 + __u16 Reserved1; 478 + __u32 Reserved2; 479 + __le16 RDMATransformIds[]; 480 + } __packed; 481 + 482 + /* 483 + * For signing capabilities context see MS-SMB2 2.2.3.1.7 484 + * and 2.2.4.1.7 485 + */ 486 + 487 + /* Signing algorithms */ 488 + #define SIGNING_ALG_HMAC_SHA256 0 489 + #define SIGNING_ALG_HMAC_SHA256_LE cpu_to_le16(0) 490 + #define SIGNING_ALG_AES_CMAC 1 491 + #define SIGNING_ALG_AES_CMAC_LE cpu_to_le16(1) 492 + #define SIGNING_ALG_AES_GMAC 2 493 + #define SIGNING_ALG_AES_GMAC_LE cpu_to_le16(2) 494 + 495 + struct smb2_signing_capabilities { 496 + __le16 ContextType; /* 8 */ 497 + __le16 DataLength; 498 + __le32 Reserved; 499 + __le16 SigningAlgorithmCount; 500 + __le16 SigningAlgorithms[]; 501 + /* Followed by padding to 8 byte boundary (required by some servers) */ 502 + } __packed; 503 + 504 + #define POSIX_CTXT_DATA_LEN 16 505 + struct smb2_posix_neg_context { 506 + __le16 ContextType; /* 0x100 */ 507 + __le16 DataLength; 508 + __le32 Reserved; 509 + __u8 Name[16]; /* POSIX ctxt GUID 93AD25509CB411E7B42383DE968BCD7C */ 510 + } __packed; 511 + 512 + struct smb2_negotiate_req { 513 + struct smb2_hdr hdr; 514 + __le16 StructureSize; /* Must be 36 */ 515 + __le16 DialectCount; 516 + __le16 SecurityMode; 517 + __le16 Reserved; /* MBZ */ 518 + __le32 Capabilities; 519 + __u8 ClientGUID[SMB2_CLIENT_GUID_SIZE]; 520 + /* In SMB3.02 and earlier next three were MBZ le64 ClientStartTime */ 521 + __le32 NegotiateContextOffset; /* SMB3.1.1 only. MBZ earlier */ 522 + __le16 NegotiateContextCount; /* SMB3.1.1 only. MBZ earlier */ 523 + __le16 Reserved2; 524 + __le16 Dialects[]; 525 + } __packed; 526 + 527 + struct smb2_negotiate_rsp { 528 + struct smb2_hdr hdr; 529 + __le16 StructureSize; /* Must be 65 */ 530 + __le16 SecurityMode; 531 + __le16 DialectRevision; 532 + __le16 NegotiateContextCount; /* Prior to SMB3.1.1 was Reserved & MBZ */ 533 + __u8 ServerGUID[16]; 534 + __le32 Capabilities; 535 + __le32 MaxTransactSize; 536 + __le32 MaxReadSize; 537 + __le32 MaxWriteSize; 538 + __le64 SystemTime; /* MBZ */ 539 + __le64 ServerStartTime; 540 + __le16 SecurityBufferOffset; 541 + __le16 SecurityBufferLength; 542 + __le32 NegotiateContextOffset; /* Pre:SMB3.1.1 was reserved/ignored */ 543 + __u8 Buffer[1]; /* variable length GSS security buffer */ 544 + } __packed; 545 + 546 + 547 + /* 548 + * SMB2_SESSION_SETUP See MS-SMB2 section 2.2.5 549 + */ 550 + /* Flags */ 551 + #define SMB2_SESSION_REQ_FLAG_BINDING 0x01 552 + #define SMB2_SESSION_REQ_FLAG_ENCRYPT_DATA 0x04 553 + 554 + struct smb2_sess_setup_req { 555 + struct smb2_hdr hdr; 556 + __le16 StructureSize; /* Must be 25 */ 557 + __u8 Flags; 558 + __u8 SecurityMode; 559 + __le32 Capabilities; 560 + __le32 Channel; 561 + __le16 SecurityBufferOffset; 562 + __le16 SecurityBufferLength; 563 + __le64 PreviousSessionId; 564 + __u8 Buffer[1]; /* variable length GSS security buffer */ 565 + } __packed; 566 + 567 + /* Currently defined SessionFlags */ 568 + #define SMB2_SESSION_FLAG_IS_GUEST 0x0001 569 + #define SMB2_SESSION_FLAG_IS_GUEST_LE cpu_to_le16(0x0001) 570 + #define SMB2_SESSION_FLAG_IS_NULL 0x0002 571 + #define SMB2_SESSION_FLAG_IS_NULL_LE cpu_to_le16(0x0002) 572 + #define SMB2_SESSION_FLAG_ENCRYPT_DATA 0x0004 573 + #define SMB2_SESSION_FLAG_ENCRYPT_DATA_LE cpu_to_le16(0x0004) 574 + 575 + struct smb2_sess_setup_rsp { 576 + struct smb2_hdr hdr; 577 + __le16 StructureSize; /* Must be 9 */ 578 + __le16 SessionFlags; 579 + __le16 SecurityBufferOffset; 580 + __le16 SecurityBufferLength; 581 + __u8 Buffer[1]; /* variable length GSS security buffer */ 582 + } __packed; 583 + 584 + 585 + /* 586 + * SMB2_LOGOFF See MS-SMB2 section 2.2.7 587 + */ 588 + struct smb2_logoff_req { 589 + struct smb2_hdr hdr; 590 + __le16 StructureSize; /* Must be 4 */ 591 + __le16 Reserved; 592 + } __packed; 593 + 594 + struct smb2_logoff_rsp { 595 + struct smb2_hdr hdr; 596 + __le16 StructureSize; /* Must be 4 */ 597 + __le16 Reserved; 598 + } __packed; 599 + 600 + 601 + /* 602 + * SMB2_CLOSE See MS-SMB2 section 2.2.15 603 + */ 604 + /* Currently defined values for close flags */ 605 + #define SMB2_CLOSE_FLAG_POSTQUERY_ATTRIB cpu_to_le16(0x0001) 606 + struct smb2_close_req { 607 + struct smb2_hdr hdr; 608 + __le16 StructureSize; /* Must be 24 */ 609 + __le16 Flags; 610 + __le32 Reserved; 611 + __le64 PersistentFileId; /* opaque endianness */ 612 + __le64 VolatileFileId; /* opaque endianness */ 613 + } __packed; 614 + 615 + /* 616 + * Maximum size of a SMB2_CLOSE response is 64 (smb2 header) + 60 (data) 617 + */ 618 + #define MAX_SMB2_CLOSE_RESPONSE_SIZE 124 619 + 620 + struct smb2_close_rsp { 621 + struct smb2_hdr hdr; 622 + __le16 StructureSize; /* 60 */ 623 + __le16 Flags; 624 + __le32 Reserved; 625 + __le64 CreationTime; 626 + __le64 LastAccessTime; 627 + __le64 LastWriteTime; 628 + __le64 ChangeTime; 629 + __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */ 630 + __le64 EndOfFile; 631 + __le32 Attributes; 632 + } __packed; 633 + 634 + 635 + /* 636 + * SMB2_READ See MS-SMB2 section 2.2.19 637 + */ 638 + /* For read request Flags field below, following flag is defined for SMB3.02 */ 639 + #define SMB2_READFLAG_READ_UNBUFFERED 0x01 640 + #define SMB2_READFLAG_REQUEST_COMPRESSED 0x02 /* See MS-SMB2 2.2.19 */ 641 + 642 + /* Channel field for read and write: exactly one of following flags can be set*/ 643 + #define SMB2_CHANNEL_NONE cpu_to_le32(0x00000000) 644 + #define SMB2_CHANNEL_RDMA_V1 cpu_to_le32(0x00000001) 645 + #define SMB2_CHANNEL_RDMA_V1_INVALIDATE cpu_to_le32(0x00000002) 646 + #define SMB2_CHANNEL_RDMA_TRANSFORM cpu_to_le32(0x00000003) 647 + 648 + /* SMB2 read request without RFC1001 length at the beginning */ 649 + struct smb2_read_req { 650 + struct smb2_hdr hdr; 651 + __le16 StructureSize; /* Must be 49 */ 652 + __u8 Padding; /* offset from start of SMB2 header to place read */ 653 + __u8 Flags; /* MBZ unless SMB3.02 or later */ 654 + __le32 Length; 655 + __le64 Offset; 656 + __le64 PersistentFileId; 657 + __le64 VolatileFileId; 658 + __le32 MinimumCount; 659 + __le32 Channel; /* MBZ except for SMB3 or later */ 660 + __le32 RemainingBytes; 661 + __le16 ReadChannelInfoOffset; 662 + __le16 ReadChannelInfoLength; 663 + __u8 Buffer[1]; 664 + } __packed; 665 + 666 + /* Read flags */ 667 + #define SMB2_READFLAG_RESPONSE_NONE cpu_to_le32(0x00000000) 668 + #define SMB2_READFLAG_RESPONSE_RDMA_TRANSFORM cpu_to_le32(0x00000001) 669 + 670 + struct smb2_read_rsp { 671 + struct smb2_hdr hdr; 672 + __le16 StructureSize; /* Must be 17 */ 673 + __u8 DataOffset; 674 + __u8 Reserved; 675 + __le32 DataLength; 676 + __le32 DataRemaining; 677 + __le32 Flags; 678 + __u8 Buffer[1]; 679 + } __packed; 680 + 681 + 682 + /* 683 + * SMB2_WRITE See MS-SMB2 section 2.2.21 684 + */ 685 + /* For write request Flags field below the following flags are defined: */ 686 + #define SMB2_WRITEFLAG_WRITE_THROUGH 0x00000001 /* SMB2.1 or later */ 687 + #define SMB2_WRITEFLAG_WRITE_UNBUFFERED 0x00000002 /* SMB3.02 or later */ 688 + 689 + struct smb2_write_req { 690 + struct smb2_hdr hdr; 691 + __le16 StructureSize; /* Must be 49 */ 692 + __le16 DataOffset; /* offset from start of SMB2 header to write data */ 693 + __le32 Length; 694 + __le64 Offset; 695 + __le64 PersistentFileId; /* opaque endianness */ 696 + __le64 VolatileFileId; /* opaque endianness */ 697 + __le32 Channel; /* MBZ unless SMB3.02 or later */ 698 + __le32 RemainingBytes; 699 + __le16 WriteChannelInfoOffset; 700 + __le16 WriteChannelInfoLength; 701 + __le32 Flags; 702 + __u8 Buffer[1]; 703 + } __packed; 704 + 705 + struct smb2_write_rsp { 706 + struct smb2_hdr hdr; 707 + __le16 StructureSize; /* Must be 17 */ 708 + __u8 DataOffset; 709 + __u8 Reserved; 710 + __le32 DataLength; 711 + __le32 DataRemaining; 712 + __u32 Reserved2; 713 + __u8 Buffer[1]; 714 + } __packed; 715 + 716 + 717 + /* 718 + * SMB2_FLUSH See MS-SMB2 section 2.2.17 719 + */ 720 + struct smb2_flush_req { 721 + struct smb2_hdr hdr; 722 + __le16 StructureSize; /* Must be 24 */ 723 + __le16 Reserved1; 724 + __le32 Reserved2; 725 + __le64 PersistentFileId; 726 + __le64 VolatileFileId; 727 + } __packed; 728 + 729 + struct smb2_flush_rsp { 730 + struct smb2_hdr hdr; 731 + __le16 StructureSize; 732 + __le16 Reserved; 733 + } __packed; 734 + 735 + 736 + /* 737 + * SMB2_NOTIFY See MS-SMB2 section 2.2.35 738 + */ 739 + /* notify flags */ 740 + #define SMB2_WATCH_TREE 0x0001 741 + 742 + /* notify completion filter flags. See MS-FSCC 2.6 and MS-SMB2 2.2.35 */ 743 + #define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001 744 + #define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002 745 + #define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004 746 + #define FILE_NOTIFY_CHANGE_SIZE 0x00000008 747 + #define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010 748 + #define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020 749 + #define FILE_NOTIFY_CHANGE_CREATION 0x00000040 750 + #define FILE_NOTIFY_CHANGE_EA 0x00000080 751 + #define FILE_NOTIFY_CHANGE_SECURITY 0x00000100 752 + #define FILE_NOTIFY_CHANGE_STREAM_NAME 0x00000200 753 + #define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400 754 + #define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800 755 + 756 + /* SMB2 Notify Action Flags */ 757 + #define FILE_ACTION_ADDED 0x00000001 758 + #define FILE_ACTION_REMOVED 0x00000002 759 + #define FILE_ACTION_MODIFIED 0x00000003 760 + #define FILE_ACTION_RENAMED_OLD_NAME 0x00000004 761 + #define FILE_ACTION_RENAMED_NEW_NAME 0x00000005 762 + #define FILE_ACTION_ADDED_STREAM 0x00000006 763 + #define FILE_ACTION_REMOVED_STREAM 0x00000007 764 + #define FILE_ACTION_MODIFIED_STREAM 0x00000008 765 + #define FILE_ACTION_REMOVED_BY_DELETE 0x00000009 766 + 767 + struct smb2_change_notify_req { 768 + struct smb2_hdr hdr; 769 + __le16 StructureSize; 770 + __le16 Flags; 771 + __le32 OutputBufferLength; 772 + __le64 PersistentFileId; /* opaque endianness */ 773 + __le64 VolatileFileId; /* opaque endianness */ 774 + __le32 CompletionFilter; 775 + __u32 Reserved; 776 + } __packed; 777 + 778 + struct smb2_change_notify_rsp { 779 + struct smb2_hdr hdr; 780 + __le16 StructureSize; /* Must be 9 */ 781 + __le16 OutputBufferOffset; 782 + __le32 OutputBufferLength; 783 + __u8 Buffer[1]; /* array of file notify structs */ 784 + } __packed; 785 + 786 + 787 + /* 788 + * SMB2_CREATE See MS-SMB2 section 2.2.13 789 + */ 790 + /* Oplock levels */ 791 + #define SMB2_OPLOCK_LEVEL_NONE 0x00 792 + #define SMB2_OPLOCK_LEVEL_II 0x01 793 + #define SMB2_OPLOCK_LEVEL_EXCLUSIVE 0x08 794 + #define SMB2_OPLOCK_LEVEL_BATCH 0x09 795 + #define SMB2_OPLOCK_LEVEL_LEASE 0xFF 796 + /* Non-spec internal type */ 797 + #define SMB2_OPLOCK_LEVEL_NOCHANGE 0x99 798 + 799 + /* Impersonation Levels. See MS-WPO section 9.7 and MSDN-IMPERS */ 800 + #define IL_ANONYMOUS cpu_to_le32(0x00000000) 801 + #define IL_IDENTIFICATION cpu_to_le32(0x00000001) 802 + #define IL_IMPERSONATION cpu_to_le32(0x00000002) 803 + #define IL_DELEGATE cpu_to_le32(0x00000003) 804 + 805 + /* File Attrubutes */ 806 + #define FILE_ATTRIBUTE_READONLY 0x00000001 807 + #define FILE_ATTRIBUTE_HIDDEN 0x00000002 808 + #define FILE_ATTRIBUTE_SYSTEM 0x00000004 809 + #define FILE_ATTRIBUTE_DIRECTORY 0x00000010 810 + #define FILE_ATTRIBUTE_ARCHIVE 0x00000020 811 + #define FILE_ATTRIBUTE_NORMAL 0x00000080 812 + #define FILE_ATTRIBUTE_TEMPORARY 0x00000100 813 + #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200 814 + #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400 815 + #define FILE_ATTRIBUTE_COMPRESSED 0x00000800 816 + #define FILE_ATTRIBUTE_OFFLINE 0x00001000 817 + #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000 818 + #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000 819 + #define FILE_ATTRIBUTE_INTEGRITY_STREAM 0x00008000 820 + #define FILE_ATTRIBUTE_NO_SCRUB_DATA 0x00020000 821 + #define FILE_ATTRIBUTE__MASK 0x00007FB7 822 + 823 + #define FILE_ATTRIBUTE_READONLY_LE cpu_to_le32(0x00000001) 824 + #define FILE_ATTRIBUTE_HIDDEN_LE cpu_to_le32(0x00000002) 825 + #define FILE_ATTRIBUTE_SYSTEM_LE cpu_to_le32(0x00000004) 826 + #define FILE_ATTRIBUTE_DIRECTORY_LE cpu_to_le32(0x00000010) 827 + #define FILE_ATTRIBUTE_ARCHIVE_LE cpu_to_le32(0x00000020) 828 + #define FILE_ATTRIBUTE_NORMAL_LE cpu_to_le32(0x00000080) 829 + #define FILE_ATTRIBUTE_TEMPORARY_LE cpu_to_le32(0x00000100) 830 + #define FILE_ATTRIBUTE_SPARSE_FILE_LE cpu_to_le32(0x00000200) 831 + #define FILE_ATTRIBUTE_REPARSE_POINT_LE cpu_to_le32(0x00000400) 832 + #define FILE_ATTRIBUTE_COMPRESSED_LE cpu_to_le32(0x00000800) 833 + #define FILE_ATTRIBUTE_OFFLINE_LE cpu_to_le32(0x00001000) 834 + #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED_LE cpu_to_le32(0x00002000) 835 + #define FILE_ATTRIBUTE_ENCRYPTED_LE cpu_to_le32(0x00004000) 836 + #define FILE_ATTRIBUTE_INTEGRITY_STREAM_LE cpu_to_le32(0x00008000) 837 + #define FILE_ATTRIBUTE_NO_SCRUB_DATA_LE cpu_to_le32(0x00020000) 838 + #define FILE_ATTRIBUTE_MASK_LE cpu_to_le32(0x00007FB7) 839 + 840 + /* Desired Access Flags */ 841 + #define FILE_READ_DATA_LE cpu_to_le32(0x00000001) 842 + #define FILE_LIST_DIRECTORY_LE cpu_to_le32(0x00000001) 843 + #define FILE_WRITE_DATA_LE cpu_to_le32(0x00000002) 844 + #define FILE_APPEND_DATA_LE cpu_to_le32(0x00000004) 845 + #define FILE_ADD_SUBDIRECTORY_LE cpu_to_le32(0x00000004) 846 + #define FILE_READ_EA_LE cpu_to_le32(0x00000008) 847 + #define FILE_WRITE_EA_LE cpu_to_le32(0x00000010) 848 + #define FILE_EXECUTE_LE cpu_to_le32(0x00000020) 849 + #define FILE_DELETE_CHILD_LE cpu_to_le32(0x00000040) 850 + #define FILE_READ_ATTRIBUTES_LE cpu_to_le32(0x00000080) 851 + #define FILE_WRITE_ATTRIBUTES_LE cpu_to_le32(0x00000100) 852 + #define FILE_DELETE_LE cpu_to_le32(0x00010000) 853 + #define FILE_READ_CONTROL_LE cpu_to_le32(0x00020000) 854 + #define FILE_WRITE_DAC_LE cpu_to_le32(0x00040000) 855 + #define FILE_WRITE_OWNER_LE cpu_to_le32(0x00080000) 856 + #define FILE_SYNCHRONIZE_LE cpu_to_le32(0x00100000) 857 + #define FILE_ACCESS_SYSTEM_SECURITY_LE cpu_to_le32(0x01000000) 858 + #define FILE_MAXIMAL_ACCESS_LE cpu_to_le32(0x02000000) 859 + #define FILE_GENERIC_ALL_LE cpu_to_le32(0x10000000) 860 + #define FILE_GENERIC_EXECUTE_LE cpu_to_le32(0x20000000) 861 + #define FILE_GENERIC_WRITE_LE cpu_to_le32(0x40000000) 862 + #define FILE_GENERIC_READ_LE cpu_to_le32(0x80000000) 863 + #define DESIRED_ACCESS_MASK cpu_to_le32(0xF21F01FF) 864 + 865 + 866 + #define FILE_READ_DESIRED_ACCESS_LE (FILE_READ_DATA_LE | \ 867 + FILE_READ_EA_LE | \ 868 + FILE_GENERIC_READ_LE) 869 + #define FILE_WRITE_DESIRE_ACCESS_LE (FILE_WRITE_DATA_LE | \ 870 + FILE_APPEND_DATA_LE | \ 871 + FILE_WRITE_EA_LE | \ 872 + FILE_WRITE_ATTRIBUTES_LE | \ 873 + FILE_GENERIC_WRITE_LE) 874 + 875 + /* ShareAccess Flags */ 876 + #define FILE_SHARE_READ_LE cpu_to_le32(0x00000001) 877 + #define FILE_SHARE_WRITE_LE cpu_to_le32(0x00000002) 878 + #define FILE_SHARE_DELETE_LE cpu_to_le32(0x00000004) 879 + #define FILE_SHARE_ALL_LE cpu_to_le32(0x00000007) 880 + 881 + /* CreateDisposition Flags */ 882 + #define FILE_SUPERSEDE_LE cpu_to_le32(0x00000000) 883 + #define FILE_OPEN_LE cpu_to_le32(0x00000001) 884 + #define FILE_CREATE_LE cpu_to_le32(0x00000002) 885 + #define FILE_OPEN_IF_LE cpu_to_le32(0x00000003) 886 + #define FILE_OVERWRITE_LE cpu_to_le32(0x00000004) 887 + #define FILE_OVERWRITE_IF_LE cpu_to_le32(0x00000005) 888 + #define FILE_CREATE_MASK_LE cpu_to_le32(0x00000007) 889 + 890 + #define FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA \ 891 + | FILE_READ_ATTRIBUTES) 892 + #define FILE_WRITE_RIGHTS (FILE_WRITE_DATA | FILE_APPEND_DATA \ 893 + | FILE_WRITE_EA | FILE_WRITE_ATTRIBUTES) 894 + #define FILE_EXEC_RIGHTS (FILE_EXECUTE) 895 + 896 + /* CreateOptions Flags */ 897 + #define FILE_DIRECTORY_FILE_LE cpu_to_le32(0x00000001) 898 + /* same as #define CREATE_NOT_FILE_LE cpu_to_le32(0x00000001) */ 899 + #define FILE_WRITE_THROUGH_LE cpu_to_le32(0x00000002) 900 + #define FILE_SEQUENTIAL_ONLY_LE cpu_to_le32(0x00000004) 901 + #define FILE_NO_INTERMEDIATE_BUFFERING_LE cpu_to_le32(0x00000008) 902 + #define FILE_NON_DIRECTORY_FILE_LE cpu_to_le32(0x00000040) 903 + #define FILE_COMPLETE_IF_OPLOCKED_LE cpu_to_le32(0x00000100) 904 + #define FILE_NO_EA_KNOWLEDGE_LE cpu_to_le32(0x00000200) 905 + #define FILE_RANDOM_ACCESS_LE cpu_to_le32(0x00000800) 906 + #define FILE_DELETE_ON_CLOSE_LE cpu_to_le32(0x00001000) 907 + #define FILE_OPEN_BY_FILE_ID_LE cpu_to_le32(0x00002000) 908 + #define FILE_OPEN_FOR_BACKUP_INTENT_LE cpu_to_le32(0x00004000) 909 + #define FILE_NO_COMPRESSION_LE cpu_to_le32(0x00008000) 910 + #define FILE_OPEN_REPARSE_POINT_LE cpu_to_le32(0x00200000) 911 + #define FILE_OPEN_NO_RECALL_LE cpu_to_le32(0x00400000) 912 + #define CREATE_OPTIONS_MASK_LE cpu_to_le32(0x00FFFFFF) 913 + 914 + #define FILE_READ_RIGHTS_LE (FILE_READ_DATA_LE | FILE_READ_EA_LE \ 915 + | FILE_READ_ATTRIBUTES_LE) 916 + #define FILE_WRITE_RIGHTS_LE (FILE_WRITE_DATA_LE | FILE_APPEND_DATA_LE \ 917 + | FILE_WRITE_EA_LE | FILE_WRITE_ATTRIBUTES_LE) 918 + #define FILE_EXEC_RIGHTS_LE (FILE_EXECUTE_LE) 919 + 920 + /* Create Context Values */ 921 + #define SMB2_CREATE_EA_BUFFER "ExtA" /* extended attributes */ 922 + #define SMB2_CREATE_SD_BUFFER "SecD" /* security descriptor */ 923 + #define SMB2_CREATE_DURABLE_HANDLE_REQUEST "DHnQ" 924 + #define SMB2_CREATE_DURABLE_HANDLE_RECONNECT "DHnC" 925 + #define SMB2_CREATE_ALLOCATION_SIZE "AISi" 926 + #define SMB2_CREATE_QUERY_MAXIMAL_ACCESS_REQUEST "MxAc" 927 + #define SMB2_CREATE_TIMEWARP_REQUEST "TWrp" 928 + #define SMB2_CREATE_QUERY_ON_DISK_ID "QFid" 929 + #define SMB2_CREATE_REQUEST_LEASE "RqLs" 930 + #define SMB2_CREATE_DURABLE_HANDLE_REQUEST_V2 "DH2Q" 931 + #define SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2 "DH2C" 932 + #define SMB2_CREATE_TAG_POSIX "\x93\xAD\x25\x50\x9C\xB4\x11\xE7\xB4\x23\x83\xDE\x96\x8B\xCD\x7C" 933 + 934 + /* Flag (SMB3 open response) values */ 935 + #define SMB2_CREATE_FLAG_REPARSEPOINT 0x01 936 + 937 + struct create_context { 938 + __le32 Next; 939 + __le16 NameOffset; 940 + __le16 NameLength; 941 + __le16 Reserved; 942 + __le16 DataOffset; 943 + __le32 DataLength; 944 + __u8 Buffer[]; 945 + } __packed; 946 + 947 + struct smb2_create_req { 948 + struct smb2_hdr hdr; 949 + __le16 StructureSize; /* Must be 57 */ 950 + __u8 SecurityFlags; 951 + __u8 RequestedOplockLevel; 952 + __le32 ImpersonationLevel; 953 + __le64 SmbCreateFlags; 954 + __le64 Reserved; 955 + __le32 DesiredAccess; 956 + __le32 FileAttributes; 957 + __le32 ShareAccess; 958 + __le32 CreateDisposition; 959 + __le32 CreateOptions; 960 + __le16 NameOffset; 961 + __le16 NameLength; 962 + __le32 CreateContextsOffset; 963 + __le32 CreateContextsLength; 964 + __u8 Buffer[]; 965 + } __packed; 966 + 967 + struct smb2_create_rsp { 968 + struct smb2_hdr hdr; 969 + __le16 StructureSize; /* Must be 89 */ 970 + __u8 OplockLevel; 971 + __u8 Flags; /* 0x01 if reparse point */ 972 + __le32 CreateAction; 973 + __le64 CreationTime; 974 + __le64 LastAccessTime; 975 + __le64 LastWriteTime; 976 + __le64 ChangeTime; 977 + __le64 AllocationSize; 978 + __le64 EndofFile; 979 + __le32 FileAttributes; 980 + __le32 Reserved2; 981 + __le64 PersistentFileId; 982 + __le64 VolatileFileId; 983 + __le32 CreateContextsOffset; 984 + __le32 CreateContextsLength; 985 + __u8 Buffer[1]; 986 + } __packed; 987 + 988 + 989 + #endif /* _COMMON_SMB2PDU_H */