Steve French | ddfbefb | 2011-03-15 02:08:48 +0000 | [diff] [blame] | 1 | /* |
| 2 | * fs/cifs/smb2pdu.h |
| 3 | * |
Steve French | be7457d | 2013-06-19 17:41:10 -0500 | [diff] [blame] | 4 | * Copyright (c) International Business Machines Corp., 2009, 2013 |
Steve French | ddfbefb | 2011-03-15 02:08:48 +0000 | [diff] [blame] | 5 | * Etersoft, 2012 |
| 6 | * Author(s): Steve French (sfrench@us.ibm.com) |
| 7 | * Pavel Shilovsky (pshilovsky@samba.org) 2012 |
| 8 | * |
| 9 | * This library is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU Lesser General Public License as published |
| 11 | * by the Free Software Foundation; either version 2.1 of the License, or |
| 12 | * (at your option) any later version. |
| 13 | * |
| 14 | * This library is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See |
| 17 | * the GNU Lesser General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU Lesser General Public License |
| 20 | * along with this library; if not, write to the Free Software |
| 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 22 | */ |
| 23 | |
| 24 | #ifndef _SMB2PDU_H |
| 25 | #define _SMB2PDU_H |
| 26 | |
| 27 | #include <net/sock.h> |
Steve French | fdef665 | 2019-12-06 02:02:38 -0600 | [diff] [blame] | 28 | #include <cifsacl.h> |
Steve French | ddfbefb | 2011-03-15 02:08:48 +0000 | [diff] [blame] | 29 | |
| 30 | /* |
Pavel Shilovsky | 2dc7e1c | 2011-12-26 22:53:34 +0400 | [diff] [blame] | 31 | * Note that, due to trying to use names similar to the protocol specifications, |
| 32 | * there are many mixed case field names in the structures below. Although |
| 33 | * this does not match typical Linux kernel style, it is necessary to be |
Randy Dunlap | a03f507 | 2020-07-19 17:13:16 -0700 | [diff] [blame] | 34 | * able to match against the protocol specfication. |
Pavel Shilovsky | 2dc7e1c | 2011-12-26 22:53:34 +0400 | [diff] [blame] | 35 | * |
| 36 | * SMB2 commands |
| 37 | * Some commands have minimal (wct=0,bcc=0), or uninteresting, responses |
| 38 | * (ie no useful data other than the SMB error code itself) and are marked such. |
| 39 | * Knowing this helps avoid response buffer allocations and copy in some cases. |
| 40 | */ |
| 41 | |
| 42 | /* List of commands in host endian */ |
| 43 | #define SMB2_NEGOTIATE_HE 0x0000 |
| 44 | #define SMB2_SESSION_SETUP_HE 0x0001 |
| 45 | #define SMB2_LOGOFF_HE 0x0002 /* trivial request/resp */ |
| 46 | #define SMB2_TREE_CONNECT_HE 0x0003 |
| 47 | #define SMB2_TREE_DISCONNECT_HE 0x0004 /* trivial req/resp */ |
| 48 | #define SMB2_CREATE_HE 0x0005 |
| 49 | #define SMB2_CLOSE_HE 0x0006 |
| 50 | #define SMB2_FLUSH_HE 0x0007 /* trivial resp */ |
| 51 | #define SMB2_READ_HE 0x0008 |
| 52 | #define SMB2_WRITE_HE 0x0009 |
| 53 | #define SMB2_LOCK_HE 0x000A |
| 54 | #define SMB2_IOCTL_HE 0x000B |
| 55 | #define SMB2_CANCEL_HE 0x000C |
| 56 | #define SMB2_ECHO_HE 0x000D |
| 57 | #define SMB2_QUERY_DIRECTORY_HE 0x000E |
| 58 | #define SMB2_CHANGE_NOTIFY_HE 0x000F |
| 59 | #define SMB2_QUERY_INFO_HE 0x0010 |
| 60 | #define SMB2_SET_INFO_HE 0x0011 |
| 61 | #define SMB2_OPLOCK_BREAK_HE 0x0012 |
| 62 | |
| 63 | /* The same list in little endian */ |
| 64 | #define SMB2_NEGOTIATE cpu_to_le16(SMB2_NEGOTIATE_HE) |
| 65 | #define SMB2_SESSION_SETUP cpu_to_le16(SMB2_SESSION_SETUP_HE) |
| 66 | #define SMB2_LOGOFF cpu_to_le16(SMB2_LOGOFF_HE) |
| 67 | #define SMB2_TREE_CONNECT cpu_to_le16(SMB2_TREE_CONNECT_HE) |
| 68 | #define SMB2_TREE_DISCONNECT cpu_to_le16(SMB2_TREE_DISCONNECT_HE) |
| 69 | #define SMB2_CREATE cpu_to_le16(SMB2_CREATE_HE) |
| 70 | #define SMB2_CLOSE cpu_to_le16(SMB2_CLOSE_HE) |
| 71 | #define SMB2_FLUSH cpu_to_le16(SMB2_FLUSH_HE) |
| 72 | #define SMB2_READ cpu_to_le16(SMB2_READ_HE) |
| 73 | #define SMB2_WRITE cpu_to_le16(SMB2_WRITE_HE) |
| 74 | #define SMB2_LOCK cpu_to_le16(SMB2_LOCK_HE) |
| 75 | #define SMB2_IOCTL cpu_to_le16(SMB2_IOCTL_HE) |
| 76 | #define SMB2_CANCEL cpu_to_le16(SMB2_CANCEL_HE) |
| 77 | #define SMB2_ECHO cpu_to_le16(SMB2_ECHO_HE) |
| 78 | #define SMB2_QUERY_DIRECTORY cpu_to_le16(SMB2_QUERY_DIRECTORY_HE) |
| 79 | #define SMB2_CHANGE_NOTIFY cpu_to_le16(SMB2_CHANGE_NOTIFY_HE) |
| 80 | #define SMB2_QUERY_INFO cpu_to_le16(SMB2_QUERY_INFO_HE) |
| 81 | #define SMB2_SET_INFO cpu_to_le16(SMB2_SET_INFO_HE) |
| 82 | #define SMB2_OPLOCK_BREAK cpu_to_le16(SMB2_OPLOCK_BREAK_HE) |
| 83 | |
Pavel Shilovsky | 96a988f | 2016-11-29 11:31:23 -0800 | [diff] [blame] | 84 | #define SMB2_INTERNAL_CMD cpu_to_le16(0xFFFF) |
| 85 | |
Pavel Shilovsky | 2dc7e1c | 2011-12-26 22:53:34 +0400 | [diff] [blame] | 86 | #define NUMBER_OF_SMB2_COMMANDS 0x0013 |
| 87 | |
Ronnie Sahlberg | 58d15ed | 2019-01-29 12:46:16 +1000 | [diff] [blame] | 88 | /* 52 transform hdr + 64 hdr + 88 create rsp */ |
Ronnie Sahlberg | c4627e6 | 2019-01-29 12:46:17 +1000 | [diff] [blame] | 89 | #define SMB2_TRANSFORM_HEADER_SIZE 52 |
Ronnie Sahlberg | 58d15ed | 2019-01-29 12:46:16 +1000 | [diff] [blame] | 90 | #define MAX_SMB2_HDR_SIZE 204 |
Pavel Shilovsky | 2dc7e1c | 2011-12-26 22:53:34 +0400 | [diff] [blame] | 91 | |
Fabian Frederick | bc09d14 | 2014-12-10 15:41:15 -0800 | [diff] [blame] | 92 | #define SMB2_PROTO_NUMBER cpu_to_le32(0x424d53fe) |
Steve French | 373512e | 2015-12-18 13:05:30 -0600 | [diff] [blame] | 93 | #define SMB2_TRANSFORM_PROTO_NUM cpu_to_le32(0x424d53fd) |
Steve French | 8895c66 | 2020-03-17 01:53:39 -0500 | [diff] [blame] | 94 | #define SMB2_COMPRESSION_TRANSFORM_ID cpu_to_le32(0x424d53fc) |
Pavel Shilovsky | 093b2bd | 2011-06-08 15:51:07 +0400 | [diff] [blame] | 95 | |
Pavel Shilovsky | 2dc7e1c | 2011-12-26 22:53:34 +0400 | [diff] [blame] | 96 | /* |
Steve French | ddfbefb | 2011-03-15 02:08:48 +0000 | [diff] [blame] | 97 | * SMB2 Header Definition |
| 98 | * |
| 99 | * "MBZ" : Must be Zero |
| 100 | * "BB" : BugBug, Something to check/review/analyze later |
| 101 | * "PDU" : "Protocol Data Unit" (ie a network "frame") |
| 102 | * |
| 103 | */ |
Pavel Shilovsky | 7411286 | 2012-07-27 01:20:41 +0400 | [diff] [blame] | 104 | |
Fabian Frederick | bc09d14 | 2014-12-10 15:41:15 -0800 | [diff] [blame] | 105 | #define SMB2_HEADER_STRUCTURE_SIZE cpu_to_le16(64) |
Pavel Shilovsky | 7411286 | 2012-07-27 01:20:41 +0400 | [diff] [blame] | 106 | |
Pavel Shilovsky | 31473fc | 2016-10-24 15:33:04 -0700 | [diff] [blame] | 107 | struct smb2_sync_hdr { |
Steve French | 373512e | 2015-12-18 13:05:30 -0600 | [diff] [blame] | 108 | __le32 ProtocolId; /* 0xFE 'S' 'M' 'B' */ |
Steve French | ddfbefb | 2011-03-15 02:08:48 +0000 | [diff] [blame] | 109 | __le16 StructureSize; /* 64 */ |
| 110 | __le16 CreditCharge; /* MBZ */ |
| 111 | __le32 Status; /* Error from server */ |
| 112 | __le16 Command; |
| 113 | __le16 CreditRequest; /* CreditResponse */ |
| 114 | __le32 Flags; |
| 115 | __le32 NextCommand; |
Sachin Prabhu | 9235d09 | 2014-12-09 17:37:00 +0000 | [diff] [blame] | 116 | __le64 MessageId; |
Steve French | ddfbefb | 2011-03-15 02:08:48 +0000 | [diff] [blame] | 117 | __le32 ProcessId; |
| 118 | __u32 TreeId; /* opaque - so do not make little endian */ |
| 119 | __u64 SessionId; /* opaque - so do not make little endian */ |
| 120 | __u8 Signature[16]; |
| 121 | } __packed; |
| 122 | |
Long Li | f7950cb | 2020-03-26 19:42:24 -0700 | [diff] [blame] | 123 | /* The total header size for SMB2 read and write */ |
| 124 | #define SMB2_READWRITE_PDU_HEADER_SIZE (48 + sizeof(struct smb2_sync_hdr)) |
| 125 | |
Pavel Shilovsky | cb200bd | 2016-10-24 16:59:57 -0700 | [diff] [blame] | 126 | struct smb2_sync_pdu { |
| 127 | struct smb2_sync_hdr sync_hdr; |
| 128 | __le16 StructureSize2; /* size of wct area (varies, request specific) */ |
| 129 | } __packed; |
| 130 | |
Steve French | fd08f2d | 2020-10-15 00:25:02 -0500 | [diff] [blame] | 131 | #define SMB3_AES_CCM_NONCE 11 |
| 132 | #define SMB3_AES_GCM_NONCE 12 |
Pavel Shilovsky | 026e93d | 2016-11-03 16:47:37 -0700 | [diff] [blame] | 133 | |
Steve French | 8895c66 | 2020-03-17 01:53:39 -0500 | [diff] [blame] | 134 | /* Transform flags (for 3.0 dialect this flag indicates CCM */ |
| 135 | #define TRANSFORM_FLAG_ENCRYPTED 0x0001 |
Steve French | 0cbaa53 | 2013-11-15 23:50:24 -0600 | [diff] [blame] | 136 | struct smb2_transform_hdr { |
Pavel Shilovsky | 026e93d | 2016-11-03 16:47:37 -0700 | [diff] [blame] | 137 | __le32 ProtocolId; /* 0xFD 'S' 'M' 'B' */ |
Steve French | 0cbaa53 | 2013-11-15 23:50:24 -0600 | [diff] [blame] | 138 | __u8 Signature[16]; |
Steve French | 373512e | 2015-12-18 13:05:30 -0600 | [diff] [blame] | 139 | __u8 Nonce[16]; |
Steve French | 0cbaa53 | 2013-11-15 23:50:24 -0600 | [diff] [blame] | 140 | __le32 OriginalMessageSize; |
| 141 | __u16 Reserved1; |
Steve French | 8895c66 | 2020-03-17 01:53:39 -0500 | [diff] [blame] | 142 | __le16 Flags; /* EncryptionAlgorithm for 3.0, enc enabled for 3.1.1 */ |
Steve French | 0cbaa53 | 2013-11-15 23:50:24 -0600 | [diff] [blame] | 143 | __u64 SessionId; |
| 144 | } __packed; |
| 145 | |
Steve French | 3563a6f | 2020-05-30 17:10:16 -0500 | [diff] [blame] | 146 | /* See MS-SMB2 2.2.42 */ |
| 147 | struct smb2_compression_transform_hdr { |
| 148 | __le32 ProtocolId; /* 0xFC 'S' 'M' 'B' */ |
| 149 | __le32 OriginalCompressedSegmentSize; |
| 150 | __le16 CompressionAlgorithm; |
| 151 | __le16 Flags; |
| 152 | __le16 Length; /* if chained it is length, else offset */ |
| 153 | } __packed; |
| 154 | |
Steve French | 8f23343 | 2020-03-15 18:04:13 -0500 | [diff] [blame] | 155 | /* See MS-SMB2 2.2.42.1 */ |
Steve French | 3984bdc | 2020-10-04 17:42:27 -0500 | [diff] [blame] | 156 | #define SMB2_COMPRESSION_FLAG_NONE 0x0000 |
Steve French | 1af34fd | 2020-10-21 20:36:26 -0500 | [diff] [blame] | 157 | #define SMB2_COMPRESSION_FLAG_CHAINED 0x0001 |
Steve French | 3984bdc | 2020-10-04 17:42:27 -0500 | [diff] [blame] | 158 | |
Steve French | 3563a6f | 2020-05-30 17:10:16 -0500 | [diff] [blame] | 159 | struct compression_payload_header { |
Steve French | 3984bdc | 2020-10-04 17:42:27 -0500 | [diff] [blame] | 160 | __le16 CompressionAlgorithm; |
| 161 | __le16 Flags; |
| 162 | __le32 Length; /* length of compressed playload including field below if present */ |
| 163 | /* __le32 OriginalPayloadSize; */ /* optional */ |
Steve French | 8f23343 | 2020-03-15 18:04:13 -0500 | [diff] [blame] | 164 | } __packed; |
| 165 | |
| 166 | /* See MS-SMB2 2.2.42.2 */ |
| 167 | struct compression_pattern_payload_v1 { |
| 168 | __le16 Pattern; |
| 169 | __le16 Reserved1; |
| 170 | __le16 Reserved2; |
| 171 | __le32 Repetitions; |
| 172 | } __packed; |
| 173 | |
Steve French | 3984bdc | 2020-10-04 17:42:27 -0500 | [diff] [blame] | 174 | /* See MS-SMB2 2.2.43 */ |
| 175 | struct smb2_rdma_transform { |
| 176 | __le16 RdmaDescriptorOffset; |
| 177 | __le16 RdmaDescriptorLength; |
| 178 | __le32 Channel; /* for values see channel description in smb2 read above */ |
| 179 | __le16 TransformCount; |
| 180 | __le16 Reserved1; |
| 181 | __le32 Reserved2; |
| 182 | } __packed; |
| 183 | |
| 184 | struct smb2_rdma_encryption_transform { |
| 185 | __le16 TransformType; |
| 186 | __le16 SignatureLength; |
| 187 | __le16 NonceLength; |
| 188 | __u16 Reserved; |
| 189 | __u8 Signature[]; /* variable length */ |
| 190 | /* u8 Nonce[] */ |
| 191 | /* followed by padding */ |
| 192 | } __packed; |
| 193 | |
Pavel Shilovsky | 093b2bd | 2011-06-08 15:51:07 +0400 | [diff] [blame] | 194 | /* |
| 195 | * SMB2 flag definitions |
| 196 | */ |
Fabian Frederick | bc09d14 | 2014-12-10 15:41:15 -0800 | [diff] [blame] | 197 | #define SMB2_FLAGS_SERVER_TO_REDIR cpu_to_le32(0x00000001) |
| 198 | #define SMB2_FLAGS_ASYNC_COMMAND cpu_to_le32(0x00000002) |
| 199 | #define SMB2_FLAGS_RELATED_OPERATIONS cpu_to_le32(0x00000004) |
| 200 | #define SMB2_FLAGS_SIGNED cpu_to_le32(0x00000008) |
Steve French | 5951980 | 2019-07-25 18:19:42 -0500 | [diff] [blame] | 201 | #define SMB2_FLAGS_PRIORITY_MASK cpu_to_le32(0x00000070) /* SMB3.1.1 */ |
Fabian Frederick | bc09d14 | 2014-12-10 15:41:15 -0800 | [diff] [blame] | 202 | #define SMB2_FLAGS_DFS_OPERATIONS cpu_to_le32(0x10000000) |
Steve French | 5951980 | 2019-07-25 18:19:42 -0500 | [diff] [blame] | 203 | #define SMB2_FLAGS_REPLAY_OPERATION cpu_to_le32(0x20000000) /* SMB3 & up */ |
Pavel Shilovsky | 093b2bd | 2011-06-08 15:51:07 +0400 | [diff] [blame] | 204 | |
| 205 | /* |
| 206 | * Definitions for SMB2 Protocol Data Units (network frames) |
| 207 | * |
| 208 | * See MS-SMB2.PDF specification for protocol details. |
| 209 | * The Naming convention is the lower case version of the SMB2 |
| 210 | * command code name for the struct. Note that structures must be packed. |
| 211 | * |
| 212 | */ |
Pavel Shilovsky | 7411286 | 2012-07-27 01:20:41 +0400 | [diff] [blame] | 213 | |
Ronnie Sahlberg | 730928c | 2018-08-08 15:07:49 +1000 | [diff] [blame] | 214 | #define COMPOUND_FID 0xFFFFFFFFFFFFFFFFULL |
| 215 | |
Fabian Frederick | bc09d14 | 2014-12-10 15:41:15 -0800 | [diff] [blame] | 216 | #define SMB2_ERROR_STRUCTURE_SIZE2 cpu_to_le16(9) |
Pavel Shilovsky | 7411286 | 2012-07-27 01:20:41 +0400 | [diff] [blame] | 217 | |
Pavel Shilovsky | 093b2bd | 2011-06-08 15:51:07 +0400 | [diff] [blame] | 218 | struct smb2_err_rsp { |
Ronnie Sahlberg | 49f466b | 2018-06-01 10:53:06 +1000 | [diff] [blame] | 219 | struct smb2_sync_hdr sync_hdr; |
Pavel Shilovsky | 093b2bd | 2011-06-08 15:51:07 +0400 | [diff] [blame] | 220 | __le16 StructureSize; |
| 221 | __le16 Reserved; /* MBZ */ |
| 222 | __le32 ByteCount; /* even if zero, at least one byte follows */ |
| 223 | __u8 ErrorData[1]; /* variable length */ |
| 224 | } __packed; |
| 225 | |
Ronnie Sahlberg | df070af | 2019-07-09 18:41:11 +1000 | [diff] [blame] | 226 | #define SYMLINK_ERROR_TAG 0x4c4d5953 |
| 227 | |
Pavel Shilovsky | b42bf88 | 2013-08-14 19:25:21 +0400 | [diff] [blame] | 228 | struct smb2_symlink_err_rsp { |
| 229 | __le32 SymLinkLength; |
| 230 | __le32 SymLinkErrorTag; |
| 231 | __le32 ReparseTag; |
| 232 | __le16 ReparseDataLength; |
| 233 | __le16 UnparsedPathLength; |
| 234 | __le16 SubstituteNameOffset; |
| 235 | __le16 SubstituteNameLength; |
| 236 | __le16 PrintNameOffset; |
| 237 | __le16 PrintNameLength; |
| 238 | __le32 Flags; |
Gustavo A. R. Silva | cff2def | 2020-03-09 10:44:51 -0500 | [diff] [blame] | 239 | __u8 PathBuffer[]; |
Pavel Shilovsky | b42bf88 | 2013-08-14 19:25:21 +0400 | [diff] [blame] | 240 | } __packed; |
| 241 | |
Steve French | 5f60a56 | 2018-02-05 14:46:18 -0600 | [diff] [blame] | 242 | /* SMB 3.1.1 and later dialects. See MS-SMB2 section 2.2.2.1 */ |
| 243 | struct smb2_error_context_rsp { |
| 244 | __le32 ErrorDataLength; |
| 245 | __le32 ErrorId; |
| 246 | __u8 ErrorContextData; /* ErrorDataLength long array */ |
| 247 | } __packed; |
| 248 | |
Steve French | 8895c66 | 2020-03-17 01:53:39 -0500 | [diff] [blame] | 249 | /* ErrorId values */ |
| 250 | #define SMB2_ERROR_ID_DEFAULT 0x00000000 |
| 251 | #define SMB2_ERROR_ID_SHARE_REDIRECT cpu_to_le32(0x72645253) /* "rdRS" */ |
| 252 | |
Steve French | 5f60a56 | 2018-02-05 14:46:18 -0600 | [diff] [blame] | 253 | /* Defines for Type field below (see MS-SMB2 2.2.2.2.2.1) */ |
| 254 | #define MOVE_DST_IPADDR_V4 cpu_to_le32(0x00000001) |
| 255 | #define MOVE_DST_IPADDR_V6 cpu_to_le32(0x00000002) |
| 256 | |
| 257 | struct move_dst_ipaddr { |
| 258 | __le32 Type; |
| 259 | __u32 Reserved; |
| 260 | __u8 address[16]; /* IPv4 followed by 12 bytes rsvd or IPv6 address */ |
| 261 | } __packed; |
| 262 | |
| 263 | struct share_redirect_error_context_rsp { |
| 264 | __le32 StructureSize; |
| 265 | __le32 NotificationType; |
| 266 | __le32 ResourceNameOffset; |
| 267 | __le32 ResourceNameLength; |
| 268 | __le16 Flags; |
| 269 | __le16 TargetType; |
| 270 | __le32 IPAddrCount; |
Gustavo A. R. Silva | cff2def | 2020-03-09 10:44:51 -0500 | [diff] [blame] | 271 | struct move_dst_ipaddr IpAddrMoveList[]; |
Steve French | 5f60a56 | 2018-02-05 14:46:18 -0600 | [diff] [blame] | 272 | /* __u8 ResourceName[] */ /* Name of share as counted Unicode string */ |
| 273 | } __packed; |
| 274 | |
Pavel Shilovsky | b8c32db | 2012-09-19 06:22:44 -0700 | [diff] [blame] | 275 | #define SMB2_CLIENT_GUID_SIZE 16 |
| 276 | |
Pavel Shilovsky | ec2e452 | 2011-12-27 16:12:43 +0400 | [diff] [blame] | 277 | struct smb2_negotiate_req { |
Ronnie Sahlberg | 13cacea | 2017-11-20 11:24:30 +1100 | [diff] [blame] | 278 | struct smb2_sync_hdr sync_hdr; |
Pavel Shilovsky | ec2e452 | 2011-12-27 16:12:43 +0400 | [diff] [blame] | 279 | __le16 StructureSize; /* Must be 36 */ |
| 280 | __le16 DialectCount; |
| 281 | __le16 SecurityMode; |
| 282 | __le16 Reserved; /* MBZ */ |
| 283 | __le32 Capabilities; |
Pavel Shilovsky | b8c32db | 2012-09-19 06:22:44 -0700 | [diff] [blame] | 284 | __u8 ClientGUID[SMB2_CLIENT_GUID_SIZE]; |
Steve French | 5f7fbf7 | 2014-12-17 22:52:58 -0600 | [diff] [blame] | 285 | /* In SMB3.02 and earlier next three were MBZ le64 ClientStartTime */ |
| 286 | __le32 NegotiateContextOffset; /* SMB3.1.1 only. MBZ earlier */ |
| 287 | __le16 NegotiateContextCount; /* SMB3.1.1 only. MBZ earlier */ |
| 288 | __le16 Reserved2; |
Steve French | e4aa25e | 2012-10-01 12:26:22 -0500 | [diff] [blame] | 289 | __le16 Dialects[1]; /* One dialect (vers=) at a time for now */ |
Pavel Shilovsky | ec2e452 | 2011-12-27 16:12:43 +0400 | [diff] [blame] | 290 | } __packed; |
| 291 | |
Steve French | e4aa25e | 2012-10-01 12:26:22 -0500 | [diff] [blame] | 292 | /* Dialects */ |
Steve French | 43cdae8 | 2019-06-13 14:26:49 -0500 | [diff] [blame] | 293 | #define SMB10_PROT_ID 0x0000 /* local only, not sent on wire w/CIFS negprot */ |
Steve French | e4aa25e | 2012-10-01 12:26:22 -0500 | [diff] [blame] | 294 | #define SMB20_PROT_ID 0x0202 |
| 295 | #define SMB21_PROT_ID 0x0210 |
| 296 | #define SMB30_PROT_ID 0x0300 |
Steve French | 20b6d8b | 2013-06-12 22:48:41 -0500 | [diff] [blame] | 297 | #define SMB302_PROT_ID 0x0302 |
Steve French | 5f7fbf7 | 2014-12-17 22:52:58 -0600 | [diff] [blame] | 298 | #define SMB311_PROT_ID 0x0311 |
Steve French | e4aa25e | 2012-10-01 12:26:22 -0500 | [diff] [blame] | 299 | #define BAD_PROT_ID 0xFFFF |
| 300 | |
Pavel Shilovsky | ec2e452 | 2011-12-27 16:12:43 +0400 | [diff] [blame] | 301 | /* SecurityMode flags */ |
| 302 | #define SMB2_NEGOTIATE_SIGNING_ENABLED 0x0001 |
| 303 | #define SMB2_NEGOTIATE_SIGNING_REQUIRED 0x0002 |
Steve French | 07108d0 | 2018-04-01 20:15:55 -0500 | [diff] [blame] | 304 | #define SMB2_SEC_MODE_FLAGS_ALL 0x0003 |
| 305 | |
Pavel Shilovsky | ec2e452 | 2011-12-27 16:12:43 +0400 | [diff] [blame] | 306 | /* Capabilities flags */ |
| 307 | #define SMB2_GLOBAL_CAP_DFS 0x00000001 |
| 308 | #define SMB2_GLOBAL_CAP_LEASING 0x00000002 /* Resp only New to SMB2.1 */ |
| 309 | #define SMB2_GLOBAL_CAP_LARGE_MTU 0X00000004 /* Resp only New to SMB2.1 */ |
Steve French | e4aa25e | 2012-10-01 12:26:22 -0500 | [diff] [blame] | 310 | #define SMB2_GLOBAL_CAP_MULTI_CHANNEL 0x00000008 /* New to SMB3 */ |
| 311 | #define SMB2_GLOBAL_CAP_PERSISTENT_HANDLES 0x00000010 /* New to SMB3 */ |
| 312 | #define SMB2_GLOBAL_CAP_DIRECTORY_LEASING 0x00000020 /* New to SMB3 */ |
| 313 | #define SMB2_GLOBAL_CAP_ENCRYPTION 0x00000040 /* New to SMB3 */ |
Pavel Shilovsky | 29e20f9 | 2012-07-13 13:58:14 +0400 | [diff] [blame] | 314 | /* Internal types */ |
| 315 | #define SMB2_NT_FIND 0x00100000 |
| 316 | #define SMB2_LARGE_FILES 0x00200000 |
Pavel Shilovsky | ec2e452 | 2011-12-27 16:12:43 +0400 | [diff] [blame] | 317 | |
Steve French | d7bef4c | 2019-04-18 11:03:58 -0500 | [diff] [blame] | 318 | |
| 319 | /* Negotiate Contexts - ContextTypes. See MS-SMB2 section 2.2.3.1 for details */ |
| 320 | #define SMB2_PREAUTH_INTEGRITY_CAPABILITIES cpu_to_le16(1) |
| 321 | #define SMB2_ENCRYPTION_CAPABILITIES cpu_to_le16(2) |
| 322 | #define SMB2_COMPRESSION_CAPABILITIES cpu_to_le16(3) |
| 323 | #define SMB2_NETNAME_NEGOTIATE_CONTEXT_ID cpu_to_le16(5) |
Steve French | 3984bdc | 2020-10-04 17:42:27 -0500 | [diff] [blame] | 324 | #define SMB2_TRANSPORT_CAPABILITIES cpu_to_le16(6) |
| 325 | #define SMB2_RDMA_TRANSFORM_CAPABILITIES cpu_to_le16(7) |
Steve French | 6829554 | 2020-10-10 20:11:47 -0500 | [diff] [blame] | 326 | #define SMB2_SIGNING_CAPABILITIES cpu_to_le16(8) |
Steve French | d7bef4c | 2019-04-18 11:03:58 -0500 | [diff] [blame] | 327 | #define SMB2_POSIX_EXTENSIONS_AVAILABLE cpu_to_le16(0x100) |
| 328 | |
Steve French | 136ff1b | 2018-04-08 16:14:31 -0500 | [diff] [blame] | 329 | struct smb2_neg_context { |
| 330 | __le16 ContextType; |
| 331 | __le16 DataLength; |
| 332 | __le32 Reserved; |
| 333 | /* Followed by array of data */ |
| 334 | } __packed; |
| 335 | |
Steve French | 7955f10 | 2020-12-09 22:19:00 -0600 | [diff] [blame] | 336 | #define SMB311_LINUX_CLIENT_SALT_SIZE 32 |
Steve French | eed0e17 | 2015-02-06 00:03:52 -0600 | [diff] [blame] | 337 | /* Hash Algorithm Types */ |
Steve French | ebb3a9d | 2015-06-18 04:49:47 -0500 | [diff] [blame] | 338 | #define SMB2_PREAUTH_INTEGRITY_SHA512 cpu_to_le16(0x0001) |
Aurelien Aptel | 8bd68c6 | 2018-02-16 19:19:29 +0100 | [diff] [blame] | 339 | #define SMB2_PREAUTH_HASH_SIZE 64 |
Steve French | eed0e17 | 2015-02-06 00:03:52 -0600 | [diff] [blame] | 340 | |
Steve French | 7955f10 | 2020-12-09 22:19:00 -0600 | [diff] [blame] | 341 | /* |
| 342 | * SaltLength that the server send can be zero, so the only three required |
| 343 | * fields (all __le16) end up six bytes total, so the minimum context data len |
| 344 | * in the response is six bytes which accounts for |
| 345 | * |
| 346 | * HashAlgorithmCount, SaltLength, and 1 HashAlgorithm. |
| 347 | */ |
| 348 | #define MIN_PREAUTH_CTXT_DATA_LEN 6 |
| 349 | |
Steve French | eed0e17 | 2015-02-06 00:03:52 -0600 | [diff] [blame] | 350 | struct smb2_preauth_neg_context { |
| 351 | __le16 ContextType; /* 1 */ |
| 352 | __le16 DataLength; |
| 353 | __le32 Reserved; |
| 354 | __le16 HashAlgorithmCount; /* 1 */ |
| 355 | __le16 SaltLength; |
| 356 | __le16 HashAlgorithms; /* HashAlgorithms[0] since only one defined */ |
Steve French | 7955f10 | 2020-12-09 22:19:00 -0600 | [diff] [blame] | 357 | __u8 Salt[SMB311_LINUX_CLIENT_SALT_SIZE]; |
Steve French | eed0e17 | 2015-02-06 00:03:52 -0600 | [diff] [blame] | 358 | } __packed; |
| 359 | |
| 360 | /* Encryption Algorithms Ciphers */ |
| 361 | #define SMB2_ENCRYPTION_AES128_CCM cpu_to_le16(0x0001) |
| 362 | #define SMB2_ENCRYPTION_AES128_GCM cpu_to_le16(0x0002) |
Steve French | 63ca565 | 2020-10-15 23:41:40 -0500 | [diff] [blame] | 363 | /* we currently do not request AES256_CCM since presumably GCM faster */ |
Steve French | 119e489 | 2020-03-18 00:51:48 -0500 | [diff] [blame] | 364 | #define SMB2_ENCRYPTION_AES256_CCM cpu_to_le16(0x0003) |
| 365 | #define SMB2_ENCRYPTION_AES256_GCM cpu_to_le16(0x0004) |
Steve French | eed0e17 | 2015-02-06 00:03:52 -0600 | [diff] [blame] | 366 | |
Steve French | 5100d8a | 2018-04-09 10:47:14 -0500 | [diff] [blame] | 367 | /* Min encrypt context data is one cipher so 2 bytes + 2 byte count field */ |
| 368 | #define MIN_ENCRYPT_CTXT_DATA_LEN 4 |
Steve French | eed0e17 | 2015-02-06 00:03:52 -0600 | [diff] [blame] | 369 | struct smb2_encryption_neg_context { |
| 370 | __le16 ContextType; /* 2 */ |
| 371 | __le16 DataLength; |
| 372 | __le32 Reserved; |
Steve French | 29e2792 | 2020-10-14 20:24:09 -0500 | [diff] [blame] | 373 | /* CipherCount usally 2, but can be 3 when AES256-GCM enabled */ |
| 374 | __le16 CipherCount; /* AES128-GCM and AES128-CCM by default */ |
| 375 | __le16 Ciphers[3]; |
Steve French | eed0e17 | 2015-02-06 00:03:52 -0600 | [diff] [blame] | 376 | } __packed; |
| 377 | |
Steve French | d7bef4c | 2019-04-18 11:03:58 -0500 | [diff] [blame] | 378 | /* See MS-SMB2 2.2.3.1.3 */ |
Steve French | 26ea888 | 2019-04-26 20:36:08 -0700 | [diff] [blame] | 379 | #define SMB3_COMPRESS_NONE cpu_to_le16(0x0000) |
| 380 | #define SMB3_COMPRESS_LZNT1 cpu_to_le16(0x0001) |
| 381 | #define SMB3_COMPRESS_LZ77 cpu_to_le16(0x0002) |
| 382 | #define SMB3_COMPRESS_LZ77_HUFF cpu_to_le16(0x0003) |
Steve French | 2fe4f62 | 2020-03-15 17:42:41 -0500 | [diff] [blame] | 383 | /* Pattern scanning algorithm See MS-SMB2 3.1.4.4.1 */ |
Steve French | 3563a6f | 2020-05-30 17:10:16 -0500 | [diff] [blame] | 384 | #define SMB3_COMPRESS_PATTERN cpu_to_le16(0x0004) /* Pattern_V1 */ |
Steve French | 2fe4f62 | 2020-03-15 17:42:41 -0500 | [diff] [blame] | 385 | |
| 386 | /* Compression Flags */ |
| 387 | #define SMB2_COMPRESSION_CAPABILITIES_FLAG_NONE cpu_to_le32(0x00000000) |
| 388 | #define SMB2_COMPRESSION_CAPABILITIES_FLAG_CHAINED cpu_to_le32(0x00000001) |
Steve French | d7bef4c | 2019-04-18 11:03:58 -0500 | [diff] [blame] | 389 | |
| 390 | struct smb2_compression_capabilities_context { |
Steve French | 26ea888 | 2019-04-26 20:36:08 -0700 | [diff] [blame] | 391 | __le16 ContextType; /* 3 */ |
| 392 | __le16 DataLength; |
Steve French | 3984bdc | 2020-10-04 17:42:27 -0500 | [diff] [blame] | 393 | __u32 Reserved; |
Steve French | d7bef4c | 2019-04-18 11:03:58 -0500 | [diff] [blame] | 394 | __le16 CompressionAlgorithmCount; |
| 395 | __u16 Padding; |
Steve French | 3984bdc | 2020-10-04 17:42:27 -0500 | [diff] [blame] | 396 | __u32 Flags; |
Steve French | 26ea888 | 2019-04-26 20:36:08 -0700 | [diff] [blame] | 397 | __le16 CompressionAlgorithms[3]; |
Steve French | d7bef4c | 2019-04-18 11:03:58 -0500 | [diff] [blame] | 398 | } __packed; |
| 399 | |
| 400 | /* |
| 401 | * For smb2_netname_negotiate_context_id See MS-SMB2 2.2.3.1.4. |
| 402 | * Its struct simply contains NetName, an array of Unicode characters |
| 403 | */ |
Steve French | 96d3cca | 2019-06-25 04:39:51 -0500 | [diff] [blame] | 404 | struct smb2_netname_neg_context { |
Steve French | 3984bdc | 2020-10-04 17:42:27 -0500 | [diff] [blame] | 405 | __le16 ContextType; /* 5 */ |
Steve French | 96d3cca | 2019-06-25 04:39:51 -0500 | [diff] [blame] | 406 | __le16 DataLength; |
| 407 | __le32 Reserved; |
Gustavo A. R. Silva | cff2def | 2020-03-09 10:44:51 -0500 | [diff] [blame] | 408 | __le16 NetName[]; /* hostname of target converted to UCS-2 */ |
Steve French | 96d3cca | 2019-06-25 04:39:51 -0500 | [diff] [blame] | 409 | } __packed; |
Steve French | d7bef4c | 2019-04-18 11:03:58 -0500 | [diff] [blame] | 410 | |
Steve French | 3984bdc | 2020-10-04 17:42:27 -0500 | [diff] [blame] | 411 | /* |
| 412 | * For rdma transform capabilities context see MS-SMB2 2.2.3.1.6 |
| 413 | * and 2.2.4.1.5 |
| 414 | */ |
| 415 | |
| 416 | /* RDMA Transform IDs */ |
| 417 | #define SMB2_RDMA_TRANSFORM_NONE 0x0000 |
| 418 | #define SMB2_RDMA_TRANSFORM_ENCRYPTION 0x0001 |
| 419 | |
| 420 | struct smb2_rdma_transform_capabilities_context { |
| 421 | __le16 ContextType; /* 7 */ |
| 422 | __le16 DataLength; |
| 423 | __u32 Reserved; |
| 424 | __le16 TransformCount; |
| 425 | __u16 Reserved1; |
| 426 | __u32 Reserved2; |
| 427 | __le16 RDMATransformIds[1]; |
| 428 | } __packed; |
| 429 | |
Steve French | 6829554 | 2020-10-10 20:11:47 -0500 | [diff] [blame] | 430 | /* Signing algorithms */ |
| 431 | #define SIGNING_ALG_HMAC_SHA256 0 |
| 432 | #define SIGNING_ALG_AES_CMAC 1 |
| 433 | #define SIGNING_ALG_AES_GMAC 2 |
| 434 | |
| 435 | struct smb2_signing_capabilities { |
| 436 | __le16 ContextType; /* 8 */ |
| 437 | __le16 DataLength; |
| 438 | __u32 Reserved; |
| 439 | __le16 SigningAlgorithmCount; |
| 440 | __le16 SigningAlgorithms[]; |
| 441 | } __packed; |
| 442 | |
Steve French | 0d48132 | 2019-02-24 17:56:33 -0600 | [diff] [blame] | 443 | #define POSIX_CTXT_DATA_LEN 16 |
Steve French | fcef0db | 2018-05-19 20:45:27 -0500 | [diff] [blame] | 444 | struct smb2_posix_neg_context { |
| 445 | __le16 ContextType; /* 0x100 */ |
| 446 | __le16 DataLength; |
| 447 | __le32 Reserved; |
Steve French | 0d48132 | 2019-02-24 17:56:33 -0600 | [diff] [blame] | 448 | __u8 Name[16]; /* POSIX ctxt GUID 93AD25509CB411E7B42383DE968BCD7C */ |
Steve French | fcef0db | 2018-05-19 20:45:27 -0500 | [diff] [blame] | 449 | } __packed; |
| 450 | |
Pavel Shilovsky | ec2e452 | 2011-12-27 16:12:43 +0400 | [diff] [blame] | 451 | struct smb2_negotiate_rsp { |
Ronnie Sahlberg | 49f466b | 2018-06-01 10:53:06 +1000 | [diff] [blame] | 452 | struct smb2_sync_hdr sync_hdr; |
Pavel Shilovsky | ec2e452 | 2011-12-27 16:12:43 +0400 | [diff] [blame] | 453 | __le16 StructureSize; /* Must be 65 */ |
| 454 | __le16 SecurityMode; |
| 455 | __le16 DialectRevision; |
Steve French | 5f7fbf7 | 2014-12-17 22:52:58 -0600 | [diff] [blame] | 456 | __le16 NegotiateContextCount; /* Prior to SMB3.1.1 was Reserved & MBZ */ |
Pavel Shilovsky | ec2e452 | 2011-12-27 16:12:43 +0400 | [diff] [blame] | 457 | __u8 ServerGUID[16]; |
| 458 | __le32 Capabilities; |
| 459 | __le32 MaxTransactSize; |
| 460 | __le32 MaxReadSize; |
| 461 | __le32 MaxWriteSize; |
| 462 | __le64 SystemTime; /* MBZ */ |
| 463 | __le64 ServerStartTime; |
| 464 | __le16 SecurityBufferOffset; |
| 465 | __le16 SecurityBufferLength; |
Steve French | 5f7fbf7 | 2014-12-17 22:52:58 -0600 | [diff] [blame] | 466 | __le32 NegotiateContextOffset; /* Pre:SMB3.1.1 was reserved/ignored */ |
Pavel Shilovsky | ec2e452 | 2011-12-27 16:12:43 +0400 | [diff] [blame] | 467 | __u8 Buffer[1]; /* variable length GSS security buffer */ |
| 468 | } __packed; |
| 469 | |
Steve French | eed0e17 | 2015-02-06 00:03:52 -0600 | [diff] [blame] | 470 | /* Flags */ |
| 471 | #define SMB2_SESSION_REQ_FLAG_BINDING 0x01 |
| 472 | #define SMB2_SESSION_REQ_FLAG_ENCRYPT_DATA 0x04 |
| 473 | |
Pavel Shilovsky | 5478f9b | 2011-12-27 16:22:00 +0400 | [diff] [blame] | 474 | struct smb2_sess_setup_req { |
Ronnie Sahlberg | 88ea5cb | 2017-11-20 11:24:36 +1100 | [diff] [blame] | 475 | struct smb2_sync_hdr sync_hdr; |
Pavel Shilovsky | 5478f9b | 2011-12-27 16:22:00 +0400 | [diff] [blame] | 476 | __le16 StructureSize; /* Must be 25 */ |
Steve French | eed0e17 | 2015-02-06 00:03:52 -0600 | [diff] [blame] | 477 | __u8 Flags; |
Pavel Shilovsky | 5478f9b | 2011-12-27 16:22:00 +0400 | [diff] [blame] | 478 | __u8 SecurityMode; |
| 479 | __le32 Capabilities; |
| 480 | __le32 Channel; |
| 481 | __le16 SecurityBufferOffset; |
| 482 | __le16 SecurityBufferLength; |
Steve French | c2afb81 | 2016-09-20 22:56:13 -0500 | [diff] [blame] | 483 | __u64 PreviousSessionId; |
Pavel Shilovsky | 5478f9b | 2011-12-27 16:22:00 +0400 | [diff] [blame] | 484 | __u8 Buffer[1]; /* variable length GSS security buffer */ |
| 485 | } __packed; |
| 486 | |
| 487 | /* Currently defined SessionFlags */ |
| 488 | #define SMB2_SESSION_FLAG_IS_GUEST 0x0001 |
| 489 | #define SMB2_SESSION_FLAG_IS_NULL 0x0002 |
Steve French | 0cbaa53 | 2013-11-15 23:50:24 -0600 | [diff] [blame] | 490 | #define SMB2_SESSION_FLAG_ENCRYPT_DATA 0x0004 |
Pavel Shilovsky | 5478f9b | 2011-12-27 16:22:00 +0400 | [diff] [blame] | 491 | struct smb2_sess_setup_rsp { |
Ronnie Sahlberg | 49f466b | 2018-06-01 10:53:06 +1000 | [diff] [blame] | 492 | struct smb2_sync_hdr sync_hdr; |
Pavel Shilovsky | 5478f9b | 2011-12-27 16:22:00 +0400 | [diff] [blame] | 493 | __le16 StructureSize; /* Must be 9 */ |
| 494 | __le16 SessionFlags; |
| 495 | __le16 SecurityBufferOffset; |
| 496 | __le16 SecurityBufferLength; |
| 497 | __u8 Buffer[1]; /* variable length GSS security buffer */ |
| 498 | } __packed; |
| 499 | |
| 500 | struct smb2_logoff_req { |
Ronnie Sahlberg | 45305ed | 2017-11-09 12:14:17 +1100 | [diff] [blame] | 501 | struct smb2_sync_hdr sync_hdr; |
Pavel Shilovsky | 5478f9b | 2011-12-27 16:22:00 +0400 | [diff] [blame] | 502 | __le16 StructureSize; /* Must be 4 */ |
| 503 | __le16 Reserved; |
| 504 | } __packed; |
| 505 | |
| 506 | struct smb2_logoff_rsp { |
Ronnie Sahlberg | 49f466b | 2018-06-01 10:53:06 +1000 | [diff] [blame] | 507 | struct smb2_sync_hdr sync_hdr; |
Pavel Shilovsky | 5478f9b | 2011-12-27 16:22:00 +0400 | [diff] [blame] | 508 | __le16 StructureSize; /* Must be 4 */ |
| 509 | __le16 Reserved; |
| 510 | } __packed; |
| 511 | |
Steve French | eed0e17 | 2015-02-06 00:03:52 -0600 | [diff] [blame] | 512 | /* Flags/Reserved for SMB3.1.1 */ |
Steve French | 5f60a56 | 2018-02-05 14:46:18 -0600 | [diff] [blame] | 513 | #define SMB2_TREE_CONNECT_FLAG_CLUSTER_RECONNECT cpu_to_le16(0x0001) |
| 514 | #define SMB2_TREE_CONNECT_FLAG_REDIRECT_TO_OWNER cpu_to_le16(0x0002) |
| 515 | #define SMB2_TREE_CONNECT_FLAG_EXTENSION_PRESENT cpu_to_le16(0x0004) |
Steve French | eed0e17 | 2015-02-06 00:03:52 -0600 | [diff] [blame] | 516 | |
Pavel Shilovsky | faaf946 | 2011-12-27 16:04:00 +0400 | [diff] [blame] | 517 | struct smb2_tree_connect_req { |
Ronnie Sahlberg | 661bb943 | 2017-11-09 12:14:23 +1100 | [diff] [blame] | 518 | struct smb2_sync_hdr sync_hdr; |
Pavel Shilovsky | faaf946 | 2011-12-27 16:04:00 +0400 | [diff] [blame] | 519 | __le16 StructureSize; /* Must be 9 */ |
Steve French | 8895c66 | 2020-03-17 01:53:39 -0500 | [diff] [blame] | 520 | __le16 Flags; /* Reserved MBZ for dialects prior to SMB3.1.1 */ |
Pavel Shilovsky | faaf946 | 2011-12-27 16:04:00 +0400 | [diff] [blame] | 521 | __le16 PathOffset; |
| 522 | __le16 PathLength; |
| 523 | __u8 Buffer[1]; /* variable length */ |
| 524 | } __packed; |
| 525 | |
Steve French | 5f60a56 | 2018-02-05 14:46:18 -0600 | [diff] [blame] | 526 | /* See MS-SMB2 section 2.2.9.2 */ |
| 527 | /* Context Types */ |
| 528 | #define SMB2_RESERVED_TREE_CONNECT_CONTEXT_ID 0x0000 |
| 529 | #define SMB2_REMOTED_IDENTITY_TREE_CONNECT_CONTEXT_ID cpu_to_le16(0x0001) |
| 530 | |
| 531 | struct tree_connect_contexts { |
| 532 | __le16 ContextType; |
| 533 | __le16 DataLength; |
| 534 | __le32 Reserved; |
Gustavo A. R. Silva | cff2def | 2020-03-09 10:44:51 -0500 | [diff] [blame] | 535 | __u8 Data[]; |
Steve French | 5f60a56 | 2018-02-05 14:46:18 -0600 | [diff] [blame] | 536 | } __packed; |
| 537 | |
| 538 | /* Remoted identity tree connect context structures - see MS-SMB2 2.2.9.2.1 */ |
| 539 | struct smb3_blob_data { |
| 540 | __le16 BlobSize; |
Gustavo A. R. Silva | cff2def | 2020-03-09 10:44:51 -0500 | [diff] [blame] | 541 | __u8 BlobData[]; |
Steve French | 5f60a56 | 2018-02-05 14:46:18 -0600 | [diff] [blame] | 542 | } __packed; |
| 543 | |
| 544 | /* Valid values for Attr */ |
| 545 | #define SE_GROUP_MANDATORY 0x00000001 |
| 546 | #define SE_GROUP_ENABLED_BY_DEFAULT 0x00000002 |
| 547 | #define SE_GROUP_ENABLED 0x00000004 |
| 548 | #define SE_GROUP_OWNER 0x00000008 |
| 549 | #define SE_GROUP_USE_FOR_DENY_ONLY 0x00000010 |
| 550 | #define SE_GROUP_INTEGRITY 0x00000020 |
| 551 | #define SE_GROUP_INTEGRITY_ENABLED 0x00000040 |
| 552 | #define SE_GROUP_RESOURCE 0x20000000 |
| 553 | #define SE_GROUP_LOGON_ID 0xC0000000 |
| 554 | |
| 555 | /* struct sid_attr_data is SidData array in BlobData format then le32 Attr */ |
| 556 | |
| 557 | struct sid_array_data { |
| 558 | __le16 SidAttrCount; |
| 559 | /* SidAttrList - array of sid_attr_data structs */ |
| 560 | } __packed; |
| 561 | |
| 562 | struct luid_attr_data { |
| 563 | |
| 564 | } __packed; |
| 565 | |
| 566 | /* |
| 567 | * struct privilege_data is the same as BLOB_DATA - see MS-SMB2 2.2.9.2.1.5 |
| 568 | * but with size of LUID_ATTR_DATA struct and BlobData set to LUID_ATTR DATA |
| 569 | */ |
| 570 | |
| 571 | struct privilege_array_data { |
| 572 | __le16 PrivilegeCount; |
| 573 | /* array of privilege_data structs */ |
| 574 | } __packed; |
| 575 | |
| 576 | struct remoted_identity_tcon_context { |
| 577 | __le16 TicketType; /* must be 0x0001 */ |
| 578 | __le16 TicketSize; /* total size of this struct */ |
| 579 | __le16 User; /* offset to SID_ATTR_DATA struct with user info */ |
| 580 | __le16 UserName; /* offset to null terminated Unicode username string */ |
| 581 | __le16 Domain; /* offset to null terminated Unicode domain name */ |
| 582 | __le16 Groups; /* offset to SID_ARRAY_DATA struct with group info */ |
| 583 | __le16 RestrictedGroups; /* similar to above */ |
| 584 | __le16 Privileges; /* offset to PRIVILEGE_ARRAY_DATA struct */ |
| 585 | __le16 PrimaryGroup; /* offset to SID_ARRAY_DATA struct */ |
| 586 | __le16 Owner; /* offset to BLOB_DATA struct */ |
| 587 | __le16 DefaultDacl; /* offset to BLOB_DATA struct */ |
| 588 | __le16 DeviceGroups; /* offset to SID_ARRAY_DATA struct */ |
| 589 | __le16 UserClaims; /* offset to BLOB_DATA struct */ |
| 590 | __le16 DeviceClaims; /* offset to BLOB_DATA struct */ |
Gustavo A. R. Silva | cff2def | 2020-03-09 10:44:51 -0500 | [diff] [blame] | 591 | __u8 TicketInfo[]; /* variable length buf - remoted identity data */ |
Steve French | 5f60a56 | 2018-02-05 14:46:18 -0600 | [diff] [blame] | 592 | } __packed; |
| 593 | |
| 594 | struct smb2_tree_connect_req_extension { |
| 595 | __le32 TreeConnectContextOffset; |
| 596 | __le16 TreeConnectContextCount; |
| 597 | __u8 Reserved[10]; |
Gustavo A. R. Silva | cff2def | 2020-03-09 10:44:51 -0500 | [diff] [blame] | 598 | __u8 PathName[]; /* variable sized array */ |
Steve French | 5f60a56 | 2018-02-05 14:46:18 -0600 | [diff] [blame] | 599 | /* followed by array of TreeConnectContexts */ |
| 600 | } __packed; |
| 601 | |
Pavel Shilovsky | faaf946 | 2011-12-27 16:04:00 +0400 | [diff] [blame] | 602 | struct smb2_tree_connect_rsp { |
Ronnie Sahlberg | 49f466b | 2018-06-01 10:53:06 +1000 | [diff] [blame] | 603 | struct smb2_sync_hdr sync_hdr; |
Pavel Shilovsky | faaf946 | 2011-12-27 16:04:00 +0400 | [diff] [blame] | 604 | __le16 StructureSize; /* Must be 16 */ |
| 605 | __u8 ShareType; /* see below */ |
| 606 | __u8 Reserved; |
| 607 | __le32 ShareFlags; /* see below */ |
| 608 | __le32 Capabilities; /* see below */ |
| 609 | __le32 MaximalAccess; |
| 610 | } __packed; |
| 611 | |
| 612 | /* Possible ShareType values */ |
| 613 | #define SMB2_SHARE_TYPE_DISK 0x01 |
| 614 | #define SMB2_SHARE_TYPE_PIPE 0x02 |
| 615 | #define SMB2_SHARE_TYPE_PRINT 0x03 |
| 616 | |
| 617 | /* |
| 618 | * Possible ShareFlags - exactly one and only one of the first 4 caching flags |
| 619 | * must be set (any of the remaining, SHI1005, flags may be set individually |
| 620 | * or in combination. |
| 621 | */ |
| 622 | #define SMB2_SHAREFLAG_MANUAL_CACHING 0x00000000 |
| 623 | #define SMB2_SHAREFLAG_AUTO_CACHING 0x00000010 |
| 624 | #define SMB2_SHAREFLAG_VDO_CACHING 0x00000020 |
| 625 | #define SMB2_SHAREFLAG_NO_CACHING 0x00000030 |
| 626 | #define SHI1005_FLAGS_DFS 0x00000001 |
| 627 | #define SHI1005_FLAGS_DFS_ROOT 0x00000002 |
| 628 | #define SHI1005_FLAGS_RESTRICT_EXCLUSIVE_OPENS 0x00000100 |
| 629 | #define SHI1005_FLAGS_FORCE_SHARED_DELETE 0x00000200 |
| 630 | #define SHI1005_FLAGS_ALLOW_NAMESPACE_CACHING 0x00000400 |
| 631 | #define SHI1005_FLAGS_ACCESS_BASED_DIRECTORY_ENUM 0x00000800 |
| 632 | #define SHI1005_FLAGS_FORCE_LEVELII_OPLOCK 0x00001000 |
Steve French | c866473 | 2013-06-21 15:35:45 -0500 | [diff] [blame] | 633 | #define SHI1005_FLAGS_ENABLE_HASH_V1 0x00002000 |
| 634 | #define SHI1005_FLAGS_ENABLE_HASH_V2 0x00004000 |
| 635 | #define SHI1005_FLAGS_ENCRYPT_DATA 0x00008000 |
Steve French | 5f60a56 | 2018-02-05 14:46:18 -0600 | [diff] [blame] | 636 | #define SMB2_SHAREFLAG_IDENTITY_REMOTING 0x00040000 /* 3.1.1 */ |
| 637 | #define SHI1005_FLAGS_ALL 0x0004FF33 |
Pavel Shilovsky | faaf946 | 2011-12-27 16:04:00 +0400 | [diff] [blame] | 638 | |
| 639 | /* Possible share capabilities */ |
Steve French | 2b5dc28 | 2013-06-13 10:51:10 -0500 | [diff] [blame] | 640 | #define SMB2_SHARE_CAP_DFS cpu_to_le32(0x00000008) /* all dialects */ |
| 641 | #define SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY cpu_to_le32(0x00000010) /* 3.0 */ |
| 642 | #define SMB2_SHARE_CAP_SCALEOUT cpu_to_le32(0x00000020) /* 3.0 */ |
| 643 | #define SMB2_SHARE_CAP_CLUSTER cpu_to_le32(0x00000040) /* 3.0 */ |
| 644 | #define SMB2_SHARE_CAP_ASYMMETRIC cpu_to_le32(0x00000080) /* 3.02 */ |
Steve French | 5f60a56 | 2018-02-05 14:46:18 -0600 | [diff] [blame] | 645 | #define SMB2_SHARE_CAP_REDIRECT_TO_OWNER cpu_to_le32(0x00000100) /* 3.1.1 */ |
Pavel Shilovsky | faaf946 | 2011-12-27 16:04:00 +0400 | [diff] [blame] | 646 | |
| 647 | struct smb2_tree_disconnect_req { |
Ronnie Sahlberg | 4eecf4c | 2017-11-09 12:14:18 +1100 | [diff] [blame] | 648 | struct smb2_sync_hdr sync_hdr; |
Pavel Shilovsky | faaf946 | 2011-12-27 16:04:00 +0400 | [diff] [blame] | 649 | __le16 StructureSize; /* Must be 4 */ |
| 650 | __le16 Reserved; |
| 651 | } __packed; |
| 652 | |
| 653 | struct smb2_tree_disconnect_rsp { |
Ronnie Sahlberg | 49f466b | 2018-06-01 10:53:06 +1000 | [diff] [blame] | 654 | struct smb2_sync_hdr sync_hdr; |
Pavel Shilovsky | faaf946 | 2011-12-27 16:04:00 +0400 | [diff] [blame] | 655 | __le16 StructureSize; /* Must be 4 */ |
| 656 | __le16 Reserved; |
| 657 | } __packed; |
| 658 | |
Pavel Shilovsky | 2503a0d | 2011-12-26 22:58:46 +0400 | [diff] [blame] | 659 | /* File Attrubutes */ |
| 660 | #define FILE_ATTRIBUTE_READONLY 0x00000001 |
| 661 | #define FILE_ATTRIBUTE_HIDDEN 0x00000002 |
| 662 | #define FILE_ATTRIBUTE_SYSTEM 0x00000004 |
| 663 | #define FILE_ATTRIBUTE_DIRECTORY 0x00000010 |
| 664 | #define FILE_ATTRIBUTE_ARCHIVE 0x00000020 |
| 665 | #define FILE_ATTRIBUTE_NORMAL 0x00000080 |
| 666 | #define FILE_ATTRIBUTE_TEMPORARY 0x00000100 |
| 667 | #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200 |
| 668 | #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400 |
| 669 | #define FILE_ATTRIBUTE_COMPRESSED 0x00000800 |
| 670 | #define FILE_ATTRIBUTE_OFFLINE 0x00001000 |
| 671 | #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000 |
| 672 | #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000 |
Steve French | 7332297 | 2014-09-23 19:25:42 -0500 | [diff] [blame] | 673 | #define FILE_ATTRIBUTE_INTEGRITY_STREAM 0x00008000 |
| 674 | #define FILE_ATTRIBUTE_NO_SCRUB_DATA 0x00020000 |
Pavel Shilovsky | 2503a0d | 2011-12-26 22:58:46 +0400 | [diff] [blame] | 675 | |
| 676 | /* Oplock levels */ |
| 677 | #define SMB2_OPLOCK_LEVEL_NONE 0x00 |
| 678 | #define SMB2_OPLOCK_LEVEL_II 0x01 |
| 679 | #define SMB2_OPLOCK_LEVEL_EXCLUSIVE 0x08 |
| 680 | #define SMB2_OPLOCK_LEVEL_BATCH 0x09 |
| 681 | #define SMB2_OPLOCK_LEVEL_LEASE 0xFF |
Pavel Shilovsky | b8c32db | 2012-09-19 06:22:44 -0700 | [diff] [blame] | 682 | /* Non-spec internal type */ |
| 683 | #define SMB2_OPLOCK_LEVEL_NOCHANGE 0x99 |
Pavel Shilovsky | 2503a0d | 2011-12-26 22:58:46 +0400 | [diff] [blame] | 684 | |
| 685 | /* Desired Access Flags */ |
| 686 | #define FILE_READ_DATA_LE cpu_to_le32(0x00000001) |
| 687 | #define FILE_WRITE_DATA_LE cpu_to_le32(0x00000002) |
| 688 | #define FILE_APPEND_DATA_LE cpu_to_le32(0x00000004) |
| 689 | #define FILE_READ_EA_LE cpu_to_le32(0x00000008) |
| 690 | #define FILE_WRITE_EA_LE cpu_to_le32(0x00000010) |
| 691 | #define FILE_EXECUTE_LE cpu_to_le32(0x00000020) |
| 692 | #define FILE_READ_ATTRIBUTES_LE cpu_to_le32(0x00000080) |
| 693 | #define FILE_WRITE_ATTRIBUTES_LE cpu_to_le32(0x00000100) |
| 694 | #define FILE_DELETE_LE cpu_to_le32(0x00010000) |
| 695 | #define FILE_READ_CONTROL_LE cpu_to_le32(0x00020000) |
| 696 | #define FILE_WRITE_DAC_LE cpu_to_le32(0x00040000) |
| 697 | #define FILE_WRITE_OWNER_LE cpu_to_le32(0x00080000) |
| 698 | #define FILE_SYNCHRONIZE_LE cpu_to_le32(0x00100000) |
| 699 | #define FILE_ACCESS_SYSTEM_SECURITY_LE cpu_to_le32(0x01000000) |
| 700 | #define FILE_MAXIMAL_ACCESS_LE cpu_to_le32(0x02000000) |
| 701 | #define FILE_GENERIC_ALL_LE cpu_to_le32(0x10000000) |
| 702 | #define FILE_GENERIC_EXECUTE_LE cpu_to_le32(0x20000000) |
| 703 | #define FILE_GENERIC_WRITE_LE cpu_to_le32(0x40000000) |
| 704 | #define FILE_GENERIC_READ_LE cpu_to_le32(0x80000000) |
| 705 | |
| 706 | /* ShareAccess Flags */ |
| 707 | #define FILE_SHARE_READ_LE cpu_to_le32(0x00000001) |
| 708 | #define FILE_SHARE_WRITE_LE cpu_to_le32(0x00000002) |
| 709 | #define FILE_SHARE_DELETE_LE cpu_to_le32(0x00000004) |
| 710 | #define FILE_SHARE_ALL_LE cpu_to_le32(0x00000007) |
| 711 | |
| 712 | /* CreateDisposition Flags */ |
| 713 | #define FILE_SUPERSEDE_LE cpu_to_le32(0x00000000) |
| 714 | #define FILE_OPEN_LE cpu_to_le32(0x00000001) |
| 715 | #define FILE_CREATE_LE cpu_to_le32(0x00000002) |
| 716 | #define FILE_OPEN_IF_LE cpu_to_le32(0x00000003) |
| 717 | #define FILE_OVERWRITE_LE cpu_to_le32(0x00000004) |
| 718 | #define FILE_OVERWRITE_IF_LE cpu_to_le32(0x00000005) |
| 719 | |
| 720 | /* CreateOptions Flags */ |
| 721 | #define FILE_DIRECTORY_FILE_LE cpu_to_le32(0x00000001) |
| 722 | /* same as #define CREATE_NOT_FILE_LE cpu_to_le32(0x00000001) */ |
| 723 | #define FILE_WRITE_THROUGH_LE cpu_to_le32(0x00000002) |
| 724 | #define FILE_SEQUENTIAL_ONLY_LE cpu_to_le32(0x00000004) |
| 725 | #define FILE_NO_INTERMEDIATE_BUFFERRING_LE cpu_to_le32(0x00000008) |
| 726 | #define FILE_SYNCHRONOUS_IO_ALERT_LE cpu_to_le32(0x00000010) |
| 727 | #define FILE_SYNCHRONOUS_IO_NON_ALERT_LE cpu_to_le32(0x00000020) |
| 728 | #define FILE_NON_DIRECTORY_FILE_LE cpu_to_le32(0x00000040) |
| 729 | #define FILE_COMPLETE_IF_OPLOCKED_LE cpu_to_le32(0x00000100) |
| 730 | #define FILE_NO_EA_KNOWLEDGE_LE cpu_to_le32(0x00000200) |
| 731 | #define FILE_RANDOM_ACCESS_LE cpu_to_le32(0x00000800) |
| 732 | #define FILE_DELETE_ON_CLOSE_LE cpu_to_le32(0x00001000) |
| 733 | #define FILE_OPEN_BY_FILE_ID_LE cpu_to_le32(0x00002000) |
| 734 | #define FILE_OPEN_FOR_BACKUP_INTENT_LE cpu_to_le32(0x00004000) |
| 735 | #define FILE_NO_COMPRESSION_LE cpu_to_le32(0x00008000) |
| 736 | #define FILE_RESERVE_OPFILTER_LE cpu_to_le32(0x00100000) |
| 737 | #define FILE_OPEN_REPARSE_POINT_LE cpu_to_le32(0x00200000) |
| 738 | #define FILE_OPEN_NO_RECALL_LE cpu_to_le32(0x00400000) |
| 739 | #define FILE_OPEN_FOR_FREE_SPACE_QUERY_LE cpu_to_le32(0x00800000) |
| 740 | |
| 741 | #define FILE_READ_RIGHTS_LE (FILE_READ_DATA_LE | FILE_READ_EA_LE \ |
| 742 | | FILE_READ_ATTRIBUTES_LE) |
| 743 | #define FILE_WRITE_RIGHTS_LE (FILE_WRITE_DATA_LE | FILE_APPEND_DATA_LE \ |
| 744 | | FILE_WRITE_EA_LE | FILE_WRITE_ATTRIBUTES_LE) |
| 745 | #define FILE_EXEC_RIGHTS_LE (FILE_EXECUTE_LE) |
| 746 | |
Steve French | 8895c66 | 2020-03-17 01:53:39 -0500 | [diff] [blame] | 747 | /* Impersonation Levels. See MS-WPO section 9.7 and MSDN-IMPERS */ |
Pavel Shilovsky | 2503a0d | 2011-12-26 22:58:46 +0400 | [diff] [blame] | 748 | #define IL_ANONYMOUS cpu_to_le32(0x00000000) |
| 749 | #define IL_IDENTIFICATION cpu_to_le32(0x00000001) |
| 750 | #define IL_IMPERSONATION cpu_to_le32(0x00000002) |
| 751 | #define IL_DELEGATE cpu_to_le32(0x00000003) |
| 752 | |
| 753 | /* Create Context Values */ |
| 754 | #define SMB2_CREATE_EA_BUFFER "ExtA" /* extended attributes */ |
| 755 | #define SMB2_CREATE_SD_BUFFER "SecD" /* security descriptor */ |
| 756 | #define SMB2_CREATE_DURABLE_HANDLE_REQUEST "DHnQ" |
| 757 | #define SMB2_CREATE_DURABLE_HANDLE_RECONNECT "DHnC" |
Steve French | 12197a7 | 2014-05-14 05:29:40 -0700 | [diff] [blame] | 758 | #define SMB2_CREATE_ALLOCATION_SIZE "AISi" |
Pavel Shilovsky | 2503a0d | 2011-12-26 22:58:46 +0400 | [diff] [blame] | 759 | #define SMB2_CREATE_QUERY_MAXIMAL_ACCESS_REQUEST "MxAc" |
| 760 | #define SMB2_CREATE_TIMEWARP_REQUEST "TWrp" |
| 761 | #define SMB2_CREATE_QUERY_ON_DISK_ID "QFid" |
| 762 | #define SMB2_CREATE_REQUEST_LEASE "RqLs" |
Steve French | 12197a7 | 2014-05-14 05:29:40 -0700 | [diff] [blame] | 763 | #define SMB2_CREATE_DURABLE_HANDLE_REQUEST_V2 "DH2Q" |
| 764 | #define SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2 "DH2C" |
| 765 | #define SMB2_CREATE_APP_INSTANCE_ID 0x45BCA66AEFA7F74A9008FA462E144D74 |
Steve French | e7348e3 | 2019-06-28 02:35:10 -0500 | [diff] [blame] | 766 | #define SMB2_CREATE_APP_INSTANCE_VERSION 0xB982D0B73B56074FA07B524A8116A010 |
Steve French | fe04840 | 2018-05-30 17:10:25 -0500 | [diff] [blame] | 767 | #define SVHDX_OPEN_DEVICE_CONTEX 0x9CCBCF9E04C1E643980E158DA1F6EC83 |
| 768 | #define SMB2_CREATE_TAG_POSIX 0x93AD25509CB411E7B42383DE968BCD7C |
| 769 | |
Steve French | 37e6a70 | 2018-09-19 02:02:58 -0500 | [diff] [blame] | 770 | /* Flag (SMB3 open response) values */ |
| 771 | #define SMB2_CREATE_FLAG_REPARSEPOINT 0x01 |
Pavel Shilovsky | 2503a0d | 2011-12-26 22:58:46 +0400 | [diff] [blame] | 772 | |
Ronnie Sahlberg | 4d8dfaf | 2018-08-21 11:49:21 +1000 | [diff] [blame] | 773 | /* |
| 774 | * Maximum number of iovs we need for an open/create request. |
| 775 | * [0] : struct smb2_create_req |
| 776 | * [1] : path |
| 777 | * [2] : lease context |
| 778 | * [3] : durable context |
| 779 | * [4] : posix context |
| 780 | * [5] : time warp context |
Steve French | ff2a09e | 2019-07-06 14:41:38 -0500 | [diff] [blame] | 781 | * [6] : query id context |
| 782 | * [7] : compound padding |
Ronnie Sahlberg | 4d8dfaf | 2018-08-21 11:49:21 +1000 | [diff] [blame] | 783 | */ |
Steve French | ff2a09e | 2019-07-06 14:41:38 -0500 | [diff] [blame] | 784 | #define SMB2_CREATE_IOV_SIZE 8 |
Ronnie Sahlberg | 4d8dfaf | 2018-08-21 11:49:21 +1000 | [diff] [blame] | 785 | |
Pavel Shilovsky | 2503a0d | 2011-12-26 22:58:46 +0400 | [diff] [blame] | 786 | struct smb2_create_req { |
Ronnie Sahlberg | 4f33bc3 | 2017-11-20 11:24:38 +1100 | [diff] [blame] | 787 | struct smb2_sync_hdr sync_hdr; |
Pavel Shilovsky | 2503a0d | 2011-12-26 22:58:46 +0400 | [diff] [blame] | 788 | __le16 StructureSize; /* Must be 57 */ |
| 789 | __u8 SecurityFlags; |
| 790 | __u8 RequestedOplockLevel; |
| 791 | __le32 ImpersonationLevel; |
| 792 | __le64 SmbCreateFlags; |
| 793 | __le64 Reserved; |
| 794 | __le32 DesiredAccess; |
| 795 | __le32 FileAttributes; |
| 796 | __le32 ShareAccess; |
| 797 | __le32 CreateDisposition; |
| 798 | __le32 CreateOptions; |
| 799 | __le16 NameOffset; |
| 800 | __le16 NameLength; |
| 801 | __le32 CreateContextsOffset; |
| 802 | __le32 CreateContextsLength; |
Gustavo A. R. Silva | cff2def | 2020-03-09 10:44:51 -0500 | [diff] [blame] | 803 | __u8 Buffer[]; |
Pavel Shilovsky | 2503a0d | 2011-12-26 22:58:46 +0400 | [diff] [blame] | 804 | } __packed; |
| 805 | |
Ronnie Sahlberg | c4627e6 | 2019-01-29 12:46:17 +1000 | [diff] [blame] | 806 | /* |
| 807 | * Maximum size of a SMB2_CREATE response is 64 (smb2 header) + |
Steve French | ff2a09e | 2019-07-06 14:41:38 -0500 | [diff] [blame] | 808 | * 88 (fixed part of create response) + 520 (path) + 208 (contexts) + |
Ronnie Sahlberg | c4627e6 | 2019-01-29 12:46:17 +1000 | [diff] [blame] | 809 | * 2 bytes of padding. |
| 810 | */ |
Steve French | ff2a09e | 2019-07-06 14:41:38 -0500 | [diff] [blame] | 811 | #define MAX_SMB2_CREATE_RESPONSE_SIZE 880 |
Ronnie Sahlberg | c4627e6 | 2019-01-29 12:46:17 +1000 | [diff] [blame] | 812 | |
Pavel Shilovsky | 2503a0d | 2011-12-26 22:58:46 +0400 | [diff] [blame] | 813 | struct smb2_create_rsp { |
Ronnie Sahlberg | 49f466b | 2018-06-01 10:53:06 +1000 | [diff] [blame] | 814 | struct smb2_sync_hdr sync_hdr; |
Pavel Shilovsky | 2503a0d | 2011-12-26 22:58:46 +0400 | [diff] [blame] | 815 | __le16 StructureSize; /* Must be 89 */ |
| 816 | __u8 OplockLevel; |
Steve French | 37e6a70 | 2018-09-19 02:02:58 -0500 | [diff] [blame] | 817 | __u8 Flag; /* 0x01 if reparse point */ |
Pavel Shilovsky | 2503a0d | 2011-12-26 22:58:46 +0400 | [diff] [blame] | 818 | __le32 CreateAction; |
| 819 | __le64 CreationTime; |
| 820 | __le64 LastAccessTime; |
| 821 | __le64 LastWriteTime; |
| 822 | __le64 ChangeTime; |
| 823 | __le64 AllocationSize; |
| 824 | __le64 EndofFile; |
| 825 | __le32 FileAttributes; |
| 826 | __le32 Reserved2; |
| 827 | __u64 PersistentFileId; /* opaque endianness */ |
| 828 | __u64 VolatileFileId; /* opaque endianness */ |
| 829 | __le32 CreateContextsOffset; |
| 830 | __le32 CreateContextsLength; |
| 831 | __u8 Buffer[1]; |
| 832 | } __packed; |
| 833 | |
Pavel Shilovsky | b8c32db | 2012-09-19 06:22:44 -0700 | [diff] [blame] | 834 | struct create_context { |
| 835 | __le32 Next; |
| 836 | __le16 NameOffset; |
| 837 | __le16 NameLength; |
| 838 | __le16 Reserved; |
| 839 | __le16 DataOffset; |
| 840 | __le32 DataLength; |
Gustavo A. R. Silva | cff2def | 2020-03-09 10:44:51 -0500 | [diff] [blame] | 841 | __u8 Buffer[]; |
Pavel Shilovsky | b8c32db | 2012-09-19 06:22:44 -0700 | [diff] [blame] | 842 | } __packed; |
| 843 | |
Pavel Shilovsky | 53ef101 | 2013-09-05 16:11:28 +0400 | [diff] [blame] | 844 | #define SMB2_LEASE_READ_CACHING_HE 0x01 |
| 845 | #define SMB2_LEASE_HANDLE_CACHING_HE 0x02 |
| 846 | #define SMB2_LEASE_WRITE_CACHING_HE 0x04 |
| 847 | |
Fabian Frederick | bc09d14 | 2014-12-10 15:41:15 -0800 | [diff] [blame] | 848 | #define SMB2_LEASE_NONE cpu_to_le32(0x00) |
| 849 | #define SMB2_LEASE_READ_CACHING cpu_to_le32(0x01) |
| 850 | #define SMB2_LEASE_HANDLE_CACHING cpu_to_le32(0x02) |
| 851 | #define SMB2_LEASE_WRITE_CACHING cpu_to_le32(0x04) |
Pavel Shilovsky | b8c32db | 2012-09-19 06:22:44 -0700 | [diff] [blame] | 852 | |
Steve French | 8895c66 | 2020-03-17 01:53:39 -0500 | [diff] [blame] | 853 | #define SMB2_LEASE_FLAG_BREAK_IN_PROGRESS cpu_to_le32(0x00000002) |
Steve French | 5f60a56 | 2018-02-05 14:46:18 -0600 | [diff] [blame] | 854 | #define SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET cpu_to_le32(0x00000004) |
Pavel Shilovsky | b8c32db | 2012-09-19 06:22:44 -0700 | [diff] [blame] | 855 | |
| 856 | #define SMB2_LEASE_KEY_SIZE 16 |
| 857 | |
| 858 | struct lease_context { |
Stefano Brivio | 729c0c9 | 2018-07-05 15:10:02 +0200 | [diff] [blame] | 859 | u8 LeaseKey[SMB2_LEASE_KEY_SIZE]; |
Pavel Shilovsky | b8c32db | 2012-09-19 06:22:44 -0700 | [diff] [blame] | 860 | __le32 LeaseState; |
| 861 | __le32 LeaseFlags; |
| 862 | __le64 LeaseDuration; |
| 863 | } __packed; |
| 864 | |
Pavel Shilovsky | f047390 | 2013-09-04 13:44:05 +0400 | [diff] [blame] | 865 | struct lease_context_v2 { |
Stefano Brivio | 729c0c9 | 2018-07-05 15:10:02 +0200 | [diff] [blame] | 866 | u8 LeaseKey[SMB2_LEASE_KEY_SIZE]; |
Pavel Shilovsky | f047390 | 2013-09-04 13:44:05 +0400 | [diff] [blame] | 867 | __le32 LeaseState; |
| 868 | __le32 LeaseFlags; |
| 869 | __le64 LeaseDuration; |
| 870 | __le64 ParentLeaseKeyLow; |
| 871 | __le64 ParentLeaseKeyHigh; |
| 872 | __le16 Epoch; |
| 873 | __le16 Reserved; |
| 874 | } __packed; |
| 875 | |
Pavel Shilovsky | b8c32db | 2012-09-19 06:22:44 -0700 | [diff] [blame] | 876 | struct create_lease { |
| 877 | struct create_context ccontext; |
| 878 | __u8 Name[8]; |
| 879 | struct lease_context lcontext; |
| 880 | } __packed; |
| 881 | |
Pavel Shilovsky | f047390 | 2013-09-04 13:44:05 +0400 | [diff] [blame] | 882 | struct create_lease_v2 { |
| 883 | struct create_context ccontext; |
| 884 | __u8 Name[8]; |
| 885 | struct lease_context_v2 lcontext; |
| 886 | __u8 Pad[4]; |
| 887 | } __packed; |
| 888 | |
Pavel Shilovsky | 63eb3de | 2013-07-04 18:41:09 +0400 | [diff] [blame] | 889 | struct create_durable { |
| 890 | struct create_context ccontext; |
| 891 | __u8 Name[8]; |
Pavel Shilovsky | 9cbc0b7 | 2013-07-09 18:40:58 +0400 | [diff] [blame] | 892 | union { |
| 893 | __u8 Reserved[16]; |
| 894 | struct { |
| 895 | __u64 PersistentFileId; |
| 896 | __u64 VolatileFileId; |
| 897 | } Fid; |
| 898 | } Data; |
Pavel Shilovsky | 63eb3de | 2013-07-04 18:41:09 +0400 | [diff] [blame] | 899 | } __packed; |
| 900 | |
Steve French | fe04840 | 2018-05-30 17:10:25 -0500 | [diff] [blame] | 901 | struct create_posix { |
| 902 | struct create_context ccontext; |
| 903 | __u8 Name[16]; |
| 904 | __le32 Mode; |
| 905 | __u32 Reserved; |
| 906 | } __packed; |
| 907 | |
Steve French | b56eae4 | 2015-11-03 09:26:27 -0600 | [diff] [blame] | 908 | /* See MS-SMB2 2.2.13.2.11 */ |
| 909 | /* Flags */ |
| 910 | #define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002 |
| 911 | struct durable_context_v2 { |
| 912 | __le32 Timeout; |
| 913 | __le32 Flags; |
| 914 | __u64 Reserved; |
| 915 | __u8 CreateGuid[16]; |
| 916 | } __packed; |
| 917 | |
| 918 | struct create_durable_v2 { |
| 919 | struct create_context ccontext; |
| 920 | __u8 Name[8]; |
| 921 | struct durable_context_v2 dcontext; |
| 922 | } __packed; |
| 923 | |
| 924 | /* See MS-SMB2 2.2.13.2.12 */ |
| 925 | struct durable_reconnect_context_v2 { |
| 926 | struct { |
| 927 | __u64 PersistentFileId; |
| 928 | __u64 VolatileFileId; |
| 929 | } Fid; |
| 930 | __u8 CreateGuid[16]; |
| 931 | __le32 Flags; /* see above DHANDLE_FLAG_PERSISTENT */ |
| 932 | } __packed; |
| 933 | |
Steve French | e7348e3 | 2019-06-28 02:35:10 -0500 | [diff] [blame] | 934 | /* See MS-SMB2 2.2.14.2.9 */ |
Steve French | 89a5bfa | 2019-07-18 17:22:18 -0500 | [diff] [blame] | 935 | struct create_on_disk_id { |
| 936 | struct create_context ccontext; |
| 937 | __u8 Name[8]; |
Steve French | e7348e3 | 2019-06-28 02:35:10 -0500 | [diff] [blame] | 938 | __le64 DiskFileId; |
| 939 | __le64 VolumeId; |
Steve French | ff2a09e | 2019-07-06 14:41:38 -0500 | [diff] [blame] | 940 | __u32 Reserved[4]; |
Steve French | e7348e3 | 2019-06-28 02:35:10 -0500 | [diff] [blame] | 941 | } __packed; |
| 942 | |
Steve French | b56eae4 | 2015-11-03 09:26:27 -0600 | [diff] [blame] | 943 | /* See MS-SMB2 2.2.14.2.12 */ |
| 944 | struct durable_reconnect_context_v2_rsp { |
| 945 | __le32 Timeout; |
| 946 | __le32 Flags; /* see above DHANDLE_FLAG_PERSISTENT */ |
| 947 | } __packed; |
| 948 | |
| 949 | struct create_durable_handle_reconnect_v2 { |
| 950 | struct create_context ccontext; |
| 951 | __u8 Name[8]; |
| 952 | struct durable_reconnect_context_v2 dcontext; |
Pavel Shilovsky | d243af7 | 2019-11-06 13:58:15 -0800 | [diff] [blame] | 953 | __u8 Pad[4]; |
Steve French | b56eae4 | 2015-11-03 09:26:27 -0600 | [diff] [blame] | 954 | } __packed; |
| 955 | |
Steve French | cdeaf9d | 2018-08-10 02:25:06 -0500 | [diff] [blame] | 956 | /* See MS-SMB2 2.2.13.2.5 */ |
| 957 | struct crt_twarp_ctxt { |
| 958 | struct create_context ccontext; |
| 959 | __u8 Name[8]; |
| 960 | __le64 Timestamp; |
| 961 | |
| 962 | } __packed; |
| 963 | |
Steve French | ff2a09e | 2019-07-06 14:41:38 -0500 | [diff] [blame] | 964 | /* See MS-SMB2 2.2.13.2.9 */ |
| 965 | struct crt_query_id_ctxt { |
| 966 | struct create_context ccontext; |
| 967 | __u8 Name[8]; |
| 968 | } __packed; |
| 969 | |
Steve French | fdef665 | 2019-12-06 02:02:38 -0600 | [diff] [blame] | 970 | struct crt_sd_ctxt { |
| 971 | struct create_context ccontext; |
| 972 | __u8 Name[8]; |
| 973 | struct smb3_sd sd; |
Steve French | fdef665 | 2019-12-06 02:02:38 -0600 | [diff] [blame] | 974 | } __packed; |
| 975 | |
| 976 | |
Steve French | 41c1358 | 2013-11-14 00:05:36 -0600 | [diff] [blame] | 977 | #define COPY_CHUNK_RES_KEY_SIZE 24 |
| 978 | struct resume_key_req { |
| 979 | char ResumeKey[COPY_CHUNK_RES_KEY_SIZE]; |
| 980 | __le32 ContextLength; /* MBZ */ |
Gustavo A. R. Silva | cff2def | 2020-03-09 10:44:51 -0500 | [diff] [blame] | 981 | char Context[]; /* ignored, Windows sets to 4 bytes of zero */ |
Steve French | 41c1358 | 2013-11-14 00:05:36 -0600 | [diff] [blame] | 982 | } __packed; |
| 983 | |
Steve French | be7457d | 2013-06-19 17:41:10 -0500 | [diff] [blame] | 984 | /* this goes in the ioctl buffer when doing a copychunk request */ |
| 985 | struct copychunk_ioctl { |
Steve French | 41c1358 | 2013-11-14 00:05:36 -0600 | [diff] [blame] | 986 | char SourceKey[COPY_CHUNK_RES_KEY_SIZE]; |
Steve French | be7457d | 2013-06-19 17:41:10 -0500 | [diff] [blame] | 987 | __le32 ChunkCount; /* we are only sending 1 */ |
| 988 | __le32 Reserved; |
| 989 | /* array will only be one chunk long for us */ |
| 990 | __le64 SourceOffset; |
| 991 | __le64 TargetOffset; |
Steve French | c866473 | 2013-06-21 15:35:45 -0500 | [diff] [blame] | 992 | __le32 Length; /* how many bytes to copy */ |
Steve French | be7457d | 2013-06-19 17:41:10 -0500 | [diff] [blame] | 993 | __u32 Reserved2; |
| 994 | } __packed; |
| 995 | |
Steve French | 31742c5 | 2014-08-17 08:38:47 -0500 | [diff] [blame] | 996 | /* this goes in the ioctl buffer when doing FSCTL_SET_ZERO_DATA */ |
| 997 | struct file_zero_data_information { |
| 998 | __le64 FileOffset; |
| 999 | __le64 BeyondFinalZero; |
| 1000 | } __packed; |
| 1001 | |
Steve French | 41c1358 | 2013-11-14 00:05:36 -0600 | [diff] [blame] | 1002 | struct copychunk_ioctl_rsp { |
| 1003 | __le32 ChunksWritten; |
| 1004 | __le32 ChunkBytesWritten; |
| 1005 | __le32 TotalBytesWritten; |
| 1006 | } __packed; |
| 1007 | |
Steve French | 7d03ae4 | 2020-10-23 15:21:38 -0500 | [diff] [blame] | 1008 | /* See MS-FSCC 2.3.29 and 2.3.30 */ |
| 1009 | struct get_retrieval_pointer_count_req { |
| 1010 | __le64 StartingVcn; /* virtual cluster number (signed) */ |
| 1011 | } __packed; |
| 1012 | |
| 1013 | struct get_retrieval_pointer_count_rsp { |
| 1014 | __le32 ExtentCount; |
| 1015 | } __packed; |
| 1016 | |
| 1017 | /* |
| 1018 | * See MS-FSCC 2.3.33 and 2.3.34 |
| 1019 | * request is the same as get_retrieval_point_count_req struct above |
| 1020 | */ |
| 1021 | struct smb3_extents { |
| 1022 | __le64 NextVcn; |
| 1023 | __le64 Lcn; /* logical cluster number */ |
| 1024 | } __packed; |
| 1025 | |
| 1026 | struct get_retrieval_pointers_refcount_rsp { |
| 1027 | __le32 ExtentCount; |
| 1028 | __u32 Reserved; |
| 1029 | __le64 StartingVcn; |
| 1030 | struct smb3_extents extents[]; |
| 1031 | } __packed; |
| 1032 | |
Steve French | 9d1b066 | 2015-06-24 02:12:19 -0500 | [diff] [blame] | 1033 | struct fsctl_set_integrity_information_req { |
| 1034 | __le16 ChecksumAlgorithm; |
| 1035 | __le16 Reserved; |
| 1036 | __le32 Flags; |
| 1037 | } __packed; |
| 1038 | |
| 1039 | struct fsctl_get_integrity_information_rsp { |
| 1040 | __le16 ChecksumAlgorithm; |
| 1041 | __le16 Reserved; |
| 1042 | __le32 Flags; |
| 1043 | __le32 ChecksumChunkSizeInBytes; |
| 1044 | __le32 ClusterSizeInBytes; |
| 1045 | } __packed; |
| 1046 | |
Ronnie Sahlberg | 2f3ebab | 2019-04-25 16:45:29 +1000 | [diff] [blame] | 1047 | struct file_allocated_range_buffer { |
| 1048 | __le64 file_offset; |
| 1049 | __le64 length; |
| 1050 | } __packed; |
| 1051 | |
Steve French | 9d1b066 | 2015-06-24 02:12:19 -0500 | [diff] [blame] | 1052 | /* Integrity ChecksumAlgorithm choices for above */ |
| 1053 | #define CHECKSUM_TYPE_NONE 0x0000 |
| 1054 | #define CHECKSUM_TYPE_CRC64 0x0002 |
Steve French | b3152e2 | 2015-06-24 03:17:02 -0500 | [diff] [blame] | 1055 | #define CHECKSUM_TYPE_UNCHANGED 0xFFFF /* set only */ |
Steve French | 9d1b066 | 2015-06-24 02:12:19 -0500 | [diff] [blame] | 1056 | |
| 1057 | /* Integrity flags for above */ |
| 1058 | #define FSCTL_INTEGRITY_FLAG_CHECKSUM_ENFORCEMENT_OFF 0x00000001 |
| 1059 | |
Steve French | 0df444a | 2018-10-31 11:24:33 -0500 | [diff] [blame] | 1060 | /* Reparse structures - see MS-FSCC 2.1.2 */ |
| 1061 | |
| 1062 | /* struct fsctl_reparse_info_req is empty, only response structs (see below) */ |
| 1063 | |
| 1064 | struct reparse_data_buffer { |
| 1065 | __le32 ReparseTag; |
| 1066 | __le16 ReparseDataLength; |
| 1067 | __u16 Reserved; |
Gustavo A. R. Silva | cff2def | 2020-03-09 10:44:51 -0500 | [diff] [blame] | 1068 | __u8 DataBuffer[]; /* Variable Length */ |
Steve French | 0df444a | 2018-10-31 11:24:33 -0500 | [diff] [blame] | 1069 | } __packed; |
| 1070 | |
| 1071 | struct reparse_guid_data_buffer { |
| 1072 | __le32 ReparseTag; |
| 1073 | __le16 ReparseDataLength; |
| 1074 | __u16 Reserved; |
| 1075 | __u8 ReparseGuid[16]; |
Gustavo A. R. Silva | cff2def | 2020-03-09 10:44:51 -0500 | [diff] [blame] | 1076 | __u8 DataBuffer[]; /* Variable Length */ |
Steve French | 0df444a | 2018-10-31 11:24:33 -0500 | [diff] [blame] | 1077 | } __packed; |
| 1078 | |
| 1079 | struct reparse_mount_point_data_buffer { |
| 1080 | __le32 ReparseTag; |
| 1081 | __le16 ReparseDataLength; |
| 1082 | __u16 Reserved; |
| 1083 | __le16 SubstituteNameOffset; |
| 1084 | __le16 SubstituteNameLength; |
| 1085 | __le16 PrintNameOffset; |
| 1086 | __le16 PrintNameLength; |
Gustavo A. R. Silva | cff2def | 2020-03-09 10:44:51 -0500 | [diff] [blame] | 1087 | __u8 PathBuffer[]; /* Variable Length */ |
Steve French | 0df444a | 2018-10-31 11:24:33 -0500 | [diff] [blame] | 1088 | } __packed; |
| 1089 | |
Ronnie Sahlberg | 5de254d | 2019-06-27 14:57:02 +1000 | [diff] [blame] | 1090 | #define SYMLINK_FLAG_RELATIVE 0x00000001 |
| 1091 | |
| 1092 | struct reparse_symlink_data_buffer { |
| 1093 | __le32 ReparseTag; |
| 1094 | __le16 ReparseDataLength; |
| 1095 | __u16 Reserved; |
| 1096 | __le16 SubstituteNameOffset; |
| 1097 | __le16 SubstituteNameLength; |
| 1098 | __le16 PrintNameOffset; |
| 1099 | __le16 PrintNameLength; |
| 1100 | __le32 Flags; |
Gustavo A. R. Silva | cff2def | 2020-03-09 10:44:51 -0500 | [diff] [blame] | 1101 | __u8 PathBuffer[]; /* Variable Length */ |
Ronnie Sahlberg | 5de254d | 2019-06-27 14:57:02 +1000 | [diff] [blame] | 1102 | } __packed; |
Steve French | 0df444a | 2018-10-31 11:24:33 -0500 | [diff] [blame] | 1103 | |
| 1104 | /* See MS-FSCC 2.1.2.6 and cifspdu.h for struct reparse_posix_data */ |
| 1105 | |
| 1106 | |
Aurelien Aptel | 9d49640 | 2017-02-13 16:16:49 +0100 | [diff] [blame] | 1107 | /* See MS-DFSC 2.2.2 */ |
| 1108 | struct fsctl_get_dfs_referral_req { |
| 1109 | __le16 MaxReferralLevel; |
| 1110 | __u8 RequestFileName[]; |
| 1111 | } __packed; |
| 1112 | |
| 1113 | /* DFS response is struct get_dfs_refer_rsp */ |
| 1114 | |
Steve French | b56eae4 | 2015-11-03 09:26:27 -0600 | [diff] [blame] | 1115 | /* See MS-SMB2 2.2.31.3 */ |
| 1116 | struct network_resiliency_req { |
| 1117 | __le32 Timeout; |
| 1118 | __le32 Reserved; |
| 1119 | } __packed; |
| 1120 | /* There is no buffer for the response ie no struct network_resiliency_rsp */ |
| 1121 | |
Steve French | 9d1b066 | 2015-06-24 02:12:19 -0500 | [diff] [blame] | 1122 | |
Steve French | ff1c038 | 2013-11-19 23:44:46 -0600 | [diff] [blame] | 1123 | struct validate_negotiate_info_req { |
Steve French | 4a72daf | 2013-06-25 00:20:49 -0500 | [diff] [blame] | 1124 | __le32 Capabilities; |
| 1125 | __u8 Guid[SMB2_CLIENT_GUID_SIZE]; |
| 1126 | __le16 SecurityMode; |
| 1127 | __le16 DialectCount; |
Steve French | d5c7076 | 2019-01-03 02:37:21 -0600 | [diff] [blame] | 1128 | __le16 Dialects[4]; /* BB expand this if autonegotiate > 4 dialects */ |
Steve French | ff1c038 | 2013-11-19 23:44:46 -0600 | [diff] [blame] | 1129 | } __packed; |
| 1130 | |
| 1131 | struct validate_negotiate_info_rsp { |
| 1132 | __le32 Capabilities; |
| 1133 | __u8 Guid[SMB2_CLIENT_GUID_SIZE]; |
| 1134 | __le16 SecurityMode; |
| 1135 | __le16 Dialect; /* Dialect in use for the connection */ |
Steve French | 4a72daf | 2013-06-25 00:20:49 -0500 | [diff] [blame] | 1136 | } __packed; |
| 1137 | |
Aurelien Aptel | bead042 | 2018-06-14 15:43:17 +0200 | [diff] [blame] | 1138 | #define RSS_CAPABLE cpu_to_le32(0x00000001) |
| 1139 | #define RDMA_CAPABLE cpu_to_le32(0x00000002) |
| 1140 | |
| 1141 | #define INTERNETWORK cpu_to_le16(0x0002) |
| 1142 | #define INTERNETWORKV6 cpu_to_le16(0x0017) |
Steve French | 4a72daf | 2013-06-25 00:20:49 -0500 | [diff] [blame] | 1143 | |
| 1144 | struct network_interface_info_ioctl_rsp { |
| 1145 | __le32 Next; /* next interface. zero if this is last one */ |
| 1146 | __le32 IfIndex; |
| 1147 | __le32 Capability; /* RSS or RDMA Capable */ |
| 1148 | __le32 Reserved; |
| 1149 | __le64 LinkSpeed; |
Aurelien Aptel | bead042 | 2018-06-14 15:43:17 +0200 | [diff] [blame] | 1150 | __le16 Family; |
| 1151 | __u8 Buffer[126]; |
| 1152 | } __packed; |
| 1153 | |
| 1154 | struct iface_info_ipv4 { |
| 1155 | __be16 Port; |
| 1156 | __be32 IPv4Address; |
| 1157 | __be64 Reserved; |
| 1158 | } __packed; |
| 1159 | |
| 1160 | struct iface_info_ipv6 { |
| 1161 | __be16 Port; |
| 1162 | __be32 FlowInfo; |
| 1163 | __u8 IPv6Address[16]; |
| 1164 | __be32 ScopeId; |
Steve French | 4a72daf | 2013-06-25 00:20:49 -0500 | [diff] [blame] | 1165 | } __packed; |
| 1166 | |
| 1167 | #define NO_FILE_ID 0xFFFFFFFFFFFFFFFFULL /* general ioctls to srv not to file */ |
| 1168 | |
Steve French | 64a5cfa | 2013-10-14 15:31:32 -0500 | [diff] [blame] | 1169 | struct compress_ioctl { |
Steve French | c7f508a | 2013-10-14 15:27:32 -0500 | [diff] [blame] | 1170 | __le16 CompressionState; /* See cifspdu.h for possible flag values */ |
Steve French | 64a5cfa | 2013-10-14 15:31:32 -0500 | [diff] [blame] | 1171 | } __packed; |
| 1172 | |
Steve French | 02b1666 | 2015-06-27 21:18:36 -0700 | [diff] [blame] | 1173 | struct duplicate_extents_to_file { |
| 1174 | __u64 PersistentFileHandle; /* source file handle, opaque endianness */ |
| 1175 | __u64 VolatileFileHandle; |
| 1176 | __le64 SourceFileOffset; |
| 1177 | __le64 TargetFileOffset; |
| 1178 | __le64 ByteCount; /* Bytes to be copied */ |
| 1179 | } __packed; |
| 1180 | |
Ronnie Sahlberg | 72c419d | 2019-03-13 14:37:49 +1000 | [diff] [blame] | 1181 | /* |
| 1182 | * Maximum number of iovs we need for an ioctl request. |
| 1183 | * [0] : struct smb2_ioctl_req |
| 1184 | * [1] : in_data |
| 1185 | */ |
| 1186 | #define SMB2_IOCTL_IOV_SIZE 2 |
| 1187 | |
Steve French | be7457d | 2013-06-19 17:41:10 -0500 | [diff] [blame] | 1188 | struct smb2_ioctl_req { |
Ronnie Sahlberg | 9775468 | 2017-11-09 12:14:20 +1100 | [diff] [blame] | 1189 | struct smb2_sync_hdr sync_hdr; |
Steve French | be7457d | 2013-06-19 17:41:10 -0500 | [diff] [blame] | 1190 | __le16 StructureSize; /* Must be 57 */ |
| 1191 | __u16 Reserved; |
| 1192 | __le32 CtlCode; |
| 1193 | __u64 PersistentFileId; /* opaque endianness */ |
| 1194 | __u64 VolatileFileId; /* opaque endianness */ |
| 1195 | __le32 InputOffset; |
| 1196 | __le32 InputCount; |
| 1197 | __le32 MaxInputResponse; |
| 1198 | __le32 OutputOffset; |
| 1199 | __le32 OutputCount; |
| 1200 | __le32 MaxOutputResponse; |
| 1201 | __le32 Flags; |
| 1202 | __u32 Reserved2; |
Gustavo A. R. Silva | cff2def | 2020-03-09 10:44:51 -0500 | [diff] [blame] | 1203 | __u8 Buffer[]; |
Steve French | be7457d | 2013-06-19 17:41:10 -0500 | [diff] [blame] | 1204 | } __packed; |
| 1205 | |
| 1206 | struct smb2_ioctl_rsp { |
Ronnie Sahlberg | 49f466b | 2018-06-01 10:53:06 +1000 | [diff] [blame] | 1207 | struct smb2_sync_hdr sync_hdr; |
Steve French | be7457d | 2013-06-19 17:41:10 -0500 | [diff] [blame] | 1208 | __le16 StructureSize; /* Must be 57 */ |
| 1209 | __u16 Reserved; |
| 1210 | __le32 CtlCode; |
| 1211 | __u64 PersistentFileId; /* opaque endianness */ |
| 1212 | __u64 VolatileFileId; /* opaque endianness */ |
| 1213 | __le32 InputOffset; |
| 1214 | __le32 InputCount; |
| 1215 | __le32 OutputOffset; |
| 1216 | __le32 OutputCount; |
| 1217 | __le32 Flags; |
| 1218 | __u32 Reserved2; |
| 1219 | /* char * buffer[] */ |
| 1220 | } __packed; |
| 1221 | |
Pavel Shilovsky | 2503a0d | 2011-12-26 22:58:46 +0400 | [diff] [blame] | 1222 | /* Currently defined values for close flags */ |
| 1223 | #define SMB2_CLOSE_FLAG_POSTQUERY_ATTRIB cpu_to_le16(0x0001) |
| 1224 | struct smb2_close_req { |
Ronnie Sahlberg | afcccef | 2017-11-09 12:14:19 +1100 | [diff] [blame] | 1225 | struct smb2_sync_hdr sync_hdr; |
Pavel Shilovsky | 2503a0d | 2011-12-26 22:58:46 +0400 | [diff] [blame] | 1226 | __le16 StructureSize; /* Must be 24 */ |
| 1227 | __le16 Flags; |
| 1228 | __le32 Reserved; |
| 1229 | __u64 PersistentFileId; /* opaque endianness */ |
| 1230 | __u64 VolatileFileId; /* opaque endianness */ |
| 1231 | } __packed; |
| 1232 | |
Ronnie Sahlberg | c4627e6 | 2019-01-29 12:46:17 +1000 | [diff] [blame] | 1233 | /* |
| 1234 | * Maximum size of a SMB2_CLOSE response is 64 (smb2 header) + 60 (data) |
| 1235 | */ |
| 1236 | #define MAX_SMB2_CLOSE_RESPONSE_SIZE 124 |
| 1237 | |
Pavel Shilovsky | 2503a0d | 2011-12-26 22:58:46 +0400 | [diff] [blame] | 1238 | struct smb2_close_rsp { |
Ronnie Sahlberg | 49f466b | 2018-06-01 10:53:06 +1000 | [diff] [blame] | 1239 | struct smb2_sync_hdr sync_hdr; |
Pavel Shilovsky | 2503a0d | 2011-12-26 22:58:46 +0400 | [diff] [blame] | 1240 | __le16 StructureSize; /* 60 */ |
| 1241 | __le16 Flags; |
| 1242 | __le32 Reserved; |
| 1243 | __le64 CreationTime; |
| 1244 | __le64 LastAccessTime; |
| 1245 | __le64 LastWriteTime; |
| 1246 | __le64 ChangeTime; |
| 1247 | __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */ |
| 1248 | __le64 EndOfFile; |
| 1249 | __le32 Attributes; |
| 1250 | } __packed; |
| 1251 | |
Pavel Shilovsky | 7a5cfb1 | 2012-09-18 16:20:28 -0700 | [diff] [blame] | 1252 | struct smb2_flush_req { |
Ronnie Sahlberg | 1f444e4 | 2017-11-20 11:24:39 +1100 | [diff] [blame] | 1253 | struct smb2_sync_hdr sync_hdr; |
Pavel Shilovsky | 7a5cfb1 | 2012-09-18 16:20:28 -0700 | [diff] [blame] | 1254 | __le16 StructureSize; /* Must be 24 */ |
| 1255 | __le16 Reserved1; |
| 1256 | __le32 Reserved2; |
| 1257 | __u64 PersistentFileId; /* opaque endianness */ |
| 1258 | __u64 VolatileFileId; /* opaque endianness */ |
| 1259 | } __packed; |
| 1260 | |
| 1261 | struct smb2_flush_rsp { |
Ronnie Sahlberg | 49f466b | 2018-06-01 10:53:06 +1000 | [diff] [blame] | 1262 | struct smb2_sync_hdr sync_hdr; |
Pavel Shilovsky | 7a5cfb1 | 2012-09-18 16:20:28 -0700 | [diff] [blame] | 1263 | __le16 StructureSize; |
| 1264 | __le16 Reserved; |
| 1265 | } __packed; |
| 1266 | |
Steve French | 2b5dc28 | 2013-06-13 10:51:10 -0500 | [diff] [blame] | 1267 | /* For read request Flags field below, following flag is defined for SMB3.02 */ |
| 1268 | #define SMB2_READFLAG_READ_UNBUFFERED 0x01 |
Steve French | 0df7edd | 2019-04-27 02:06:20 -0500 | [diff] [blame] | 1269 | #define SMB2_READFLAG_REQUEST_COMPRESSED 0x02 /* See MS-SMB2 2.2.19 */ |
Steve French | 2b5dc28 | 2013-06-13 10:51:10 -0500 | [diff] [blame] | 1270 | |
| 1271 | /* Channel field for read and write: exactly one of following flags can be set*/ |
Steve French | 2026b06 | 2018-01-24 23:07:41 -0600 | [diff] [blame] | 1272 | #define SMB2_CHANNEL_NONE cpu_to_le32(0x00000000) |
| 1273 | #define SMB2_CHANNEL_RDMA_V1 cpu_to_le32(0x00000001) /* SMB3 or later */ |
| 1274 | #define SMB2_CHANNEL_RDMA_V1_INVALIDATE cpu_to_le32(0x00000002) /* >= SMB3.02 */ |
Steve French | 3984bdc | 2020-10-04 17:42:27 -0500 | [diff] [blame] | 1275 | #define SMB2_CHANNEL_RDMA_TRANSFORM cpu_to_le32(0x00000003) /* >= SMB3.02, only used on write */ |
Steve French | 2b5dc28 | 2013-06-13 10:51:10 -0500 | [diff] [blame] | 1276 | |
Pavel Shilovsky | b8f57ee | 2016-11-23 15:31:54 -0800 | [diff] [blame] | 1277 | /* SMB2 read request without RFC1001 length at the beginning */ |
| 1278 | struct smb2_read_plain_req { |
| 1279 | struct smb2_sync_hdr sync_hdr; |
Pavel Shilovsky | 09a4707 | 2012-09-18 16:20:29 -0700 | [diff] [blame] | 1280 | __le16 StructureSize; /* Must be 49 */ |
| 1281 | __u8 Padding; /* offset from start of SMB2 header to place read */ |
Steve French | 2b5dc28 | 2013-06-13 10:51:10 -0500 | [diff] [blame] | 1282 | __u8 Flags; /* MBZ unless SMB3.02 or later */ |
Pavel Shilovsky | 09a4707 | 2012-09-18 16:20:29 -0700 | [diff] [blame] | 1283 | __le32 Length; |
| 1284 | __le64 Offset; |
| 1285 | __u64 PersistentFileId; /* opaque endianness */ |
| 1286 | __u64 VolatileFileId; /* opaque endianness */ |
| 1287 | __le32 MinimumCount; |
Steve French | 2b5dc28 | 2013-06-13 10:51:10 -0500 | [diff] [blame] | 1288 | __le32 Channel; /* MBZ except for SMB3 or later */ |
Pavel Shilovsky | 09a4707 | 2012-09-18 16:20:29 -0700 | [diff] [blame] | 1289 | __le32 RemainingBytes; |
Steve French | 2026b06 | 2018-01-24 23:07:41 -0600 | [diff] [blame] | 1290 | __le16 ReadChannelInfoOffset; |
| 1291 | __le16 ReadChannelInfoLength; |
Pavel Shilovsky | 09a4707 | 2012-09-18 16:20:29 -0700 | [diff] [blame] | 1292 | __u8 Buffer[1]; |
| 1293 | } __packed; |
| 1294 | |
Steve French | 3984bdc | 2020-10-04 17:42:27 -0500 | [diff] [blame] | 1295 | /* Read flags */ |
| 1296 | #define SMB2_READFLAG_RESPONSE_NONE 0x00000000 |
| 1297 | #define SMB2_READFLAG_RESPONSE_RDMA_TRANSFORM 0x00000001 |
| 1298 | |
Pavel Shilovsky | 09a4707 | 2012-09-18 16:20:29 -0700 | [diff] [blame] | 1299 | struct smb2_read_rsp { |
Ronnie Sahlberg | 49f466b | 2018-06-01 10:53:06 +1000 | [diff] [blame] | 1300 | struct smb2_sync_hdr sync_hdr; |
Pavel Shilovsky | 09a4707 | 2012-09-18 16:20:29 -0700 | [diff] [blame] | 1301 | __le16 StructureSize; /* Must be 17 */ |
| 1302 | __u8 DataOffset; |
| 1303 | __u8 Reserved; |
| 1304 | __le32 DataLength; |
| 1305 | __le32 DataRemaining; |
Steve French | 3984bdc | 2020-10-04 17:42:27 -0500 | [diff] [blame] | 1306 | __u32 Flags; |
Pavel Shilovsky | 09a4707 | 2012-09-18 16:20:29 -0700 | [diff] [blame] | 1307 | __u8 Buffer[1]; |
| 1308 | } __packed; |
| 1309 | |
Steve French | 2b5dc28 | 2013-06-13 10:51:10 -0500 | [diff] [blame] | 1310 | /* For write request Flags field below the following flags are defined: */ |
| 1311 | #define SMB2_WRITEFLAG_WRITE_THROUGH 0x00000001 /* SMB2.1 or later */ |
| 1312 | #define SMB2_WRITEFLAG_WRITE_UNBUFFERED 0x00000002 /* SMB3.02 or later */ |
Pavel Shilovsky | 3331914 | 2012-09-18 16:20:29 -0700 | [diff] [blame] | 1313 | |
| 1314 | struct smb2_write_req { |
Ronnie Sahlberg | f5688a6 | 2017-11-20 11:24:41 +1100 | [diff] [blame] | 1315 | struct smb2_sync_hdr sync_hdr; |
Pavel Shilovsky | 3331914 | 2012-09-18 16:20:29 -0700 | [diff] [blame] | 1316 | __le16 StructureSize; /* Must be 49 */ |
| 1317 | __le16 DataOffset; /* offset from start of SMB2 header to write data */ |
| 1318 | __le32 Length; |
| 1319 | __le64 Offset; |
| 1320 | __u64 PersistentFileId; /* opaque endianness */ |
| 1321 | __u64 VolatileFileId; /* opaque endianness */ |
Steve French | 8f23343 | 2020-03-15 18:04:13 -0500 | [diff] [blame] | 1322 | __le32 Channel; /* MBZ unless SMB3.02 or later */ |
Pavel Shilovsky | 3331914 | 2012-09-18 16:20:29 -0700 | [diff] [blame] | 1323 | __le32 RemainingBytes; |
Steve French | 2026b06 | 2018-01-24 23:07:41 -0600 | [diff] [blame] | 1324 | __le16 WriteChannelInfoOffset; |
| 1325 | __le16 WriteChannelInfoLength; |
Pavel Shilovsky | 3331914 | 2012-09-18 16:20:29 -0700 | [diff] [blame] | 1326 | __le32 Flags; |
| 1327 | __u8 Buffer[1]; |
| 1328 | } __packed; |
| 1329 | |
| 1330 | struct smb2_write_rsp { |
Ronnie Sahlberg | 49f466b | 2018-06-01 10:53:06 +1000 | [diff] [blame] | 1331 | struct smb2_sync_hdr sync_hdr; |
Pavel Shilovsky | 3331914 | 2012-09-18 16:20:29 -0700 | [diff] [blame] | 1332 | __le16 StructureSize; /* Must be 17 */ |
| 1333 | __u8 DataOffset; |
| 1334 | __u8 Reserved; |
| 1335 | __le32 DataLength; |
| 1336 | __le32 DataRemaining; |
| 1337 | __u32 Reserved2; |
| 1338 | __u8 Buffer[1]; |
| 1339 | } __packed; |
| 1340 | |
Steve French | edf3ef3 | 2019-05-05 17:25:12 -0500 | [diff] [blame] | 1341 | /* notify flags */ |
| 1342 | #define SMB2_WATCH_TREE 0x0001 |
| 1343 | |
| 1344 | /* notify completion filter flags. See MS-FSCC 2.6 and MS-SMB2 2.2.35 */ |
| 1345 | #define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001 |
| 1346 | #define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002 |
| 1347 | #define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004 |
| 1348 | #define FILE_NOTIFY_CHANGE_SIZE 0x00000008 |
| 1349 | #define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010 |
| 1350 | #define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020 |
| 1351 | #define FILE_NOTIFY_CHANGE_CREATION 0x00000040 |
| 1352 | #define FILE_NOTIFY_CHANGE_EA 0x00000080 |
| 1353 | #define FILE_NOTIFY_CHANGE_SECURITY 0x00000100 |
| 1354 | #define FILE_NOTIFY_CHANGE_STREAM_NAME 0x00000200 |
| 1355 | #define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400 |
| 1356 | #define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800 |
| 1357 | |
| 1358 | struct smb2_change_notify_req { |
| 1359 | struct smb2_sync_hdr sync_hdr; |
| 1360 | __le16 StructureSize; |
| 1361 | __le16 Flags; |
| 1362 | __le32 OutputBufferLength; |
| 1363 | __u64 PersistentFileId; /* opaque endianness */ |
| 1364 | __u64 VolatileFileId; /* opaque endianness */ |
| 1365 | __le32 CompletionFilter; |
| 1366 | __u32 Reserved; |
| 1367 | } __packed; |
| 1368 | |
| 1369 | struct smb2_change_notify_rsp { |
| 1370 | struct smb2_sync_hdr sync_hdr; |
| 1371 | __le16 StructureSize; /* Must be 9 */ |
| 1372 | __le16 OutputBufferOffset; |
| 1373 | __le32 OutputBufferLength; |
| 1374 | __u8 Buffer[1]; /* array of file notify structs */ |
| 1375 | } __packed; |
| 1376 | |
Pavel Shilovsky | 027e8ee | 2012-09-19 06:22:43 -0700 | [diff] [blame] | 1377 | #define SMB2_LOCKFLAG_SHARED_LOCK 0x0001 |
| 1378 | #define SMB2_LOCKFLAG_EXCLUSIVE_LOCK 0x0002 |
| 1379 | #define SMB2_LOCKFLAG_UNLOCK 0x0004 |
| 1380 | #define SMB2_LOCKFLAG_FAIL_IMMEDIATELY 0x0010 |
| 1381 | |
Pavel Shilovsky | f7ba7fe | 2012-09-19 06:22:43 -0700 | [diff] [blame] | 1382 | struct smb2_lock_element { |
| 1383 | __le64 Offset; |
| 1384 | __le64 Length; |
| 1385 | __le32 Flags; |
| 1386 | __le32 Reserved; |
| 1387 | } __packed; |
| 1388 | |
| 1389 | struct smb2_lock_req { |
Ronnie Sahlberg | ced9367 | 2017-11-21 10:07:27 +1100 | [diff] [blame] | 1390 | struct smb2_sync_hdr sync_hdr; |
Pavel Shilovsky | f7ba7fe | 2012-09-19 06:22:43 -0700 | [diff] [blame] | 1391 | __le16 StructureSize; /* Must be 48 */ |
| 1392 | __le16 LockCount; |
| 1393 | __le32 Reserved; |
| 1394 | __u64 PersistentFileId; /* opaque endianness */ |
| 1395 | __u64 VolatileFileId; /* opaque endianness */ |
| 1396 | /* Followed by at least one */ |
| 1397 | struct smb2_lock_element locks[1]; |
| 1398 | } __packed; |
| 1399 | |
| 1400 | struct smb2_lock_rsp { |
Ronnie Sahlberg | 49f466b | 2018-06-01 10:53:06 +1000 | [diff] [blame] | 1401 | struct smb2_sync_hdr sync_hdr; |
Pavel Shilovsky | f7ba7fe | 2012-09-19 06:22:43 -0700 | [diff] [blame] | 1402 | __le16 StructureSize; /* Must be 4 */ |
| 1403 | __le16 Reserved; |
| 1404 | } __packed; |
| 1405 | |
Pavel Shilovsky | 9094fad | 2012-07-12 18:30:44 +0400 | [diff] [blame] | 1406 | struct smb2_echo_req { |
Ronnie Sahlberg | 7f7ae75 | 2017-11-09 12:14:21 +1100 | [diff] [blame] | 1407 | struct smb2_sync_hdr sync_hdr; |
Pavel Shilovsky | 9094fad | 2012-07-12 18:30:44 +0400 | [diff] [blame] | 1408 | __le16 StructureSize; /* Must be 4 */ |
| 1409 | __u16 Reserved; |
| 1410 | } __packed; |
| 1411 | |
| 1412 | struct smb2_echo_rsp { |
Ronnie Sahlberg | 49f466b | 2018-06-01 10:53:06 +1000 | [diff] [blame] | 1413 | struct smb2_sync_hdr sync_hdr; |
Pavel Shilovsky | 9094fad | 2012-07-12 18:30:44 +0400 | [diff] [blame] | 1414 | __le16 StructureSize; /* Must be 4 */ |
| 1415 | __u16 Reserved; |
| 1416 | } __packed; |
| 1417 | |
Pavel Shilovsky | d324f08d | 2012-09-18 16:20:33 -0700 | [diff] [blame] | 1418 | /* search (query_directory) Flags field */ |
| 1419 | #define SMB2_RESTART_SCANS 0x01 |
| 1420 | #define SMB2_RETURN_SINGLE_ENTRY 0x02 |
| 1421 | #define SMB2_INDEX_SPECIFIED 0x04 |
| 1422 | #define SMB2_REOPEN 0x10 |
| 1423 | |
Ronnie Sahlberg | 0a17799 | 2020-01-08 13:08:04 +1000 | [diff] [blame] | 1424 | #define SMB2_QUERY_DIRECTORY_IOV_SIZE 2 |
| 1425 | |
Pavel Shilovsky | d324f08d | 2012-09-18 16:20:33 -0700 | [diff] [blame] | 1426 | struct smb2_query_directory_req { |
Ronnie Sahlberg | 7c00c3a | 2017-11-20 11:24:45 +1100 | [diff] [blame] | 1427 | struct smb2_sync_hdr sync_hdr; |
Pavel Shilovsky | d324f08d | 2012-09-18 16:20:33 -0700 | [diff] [blame] | 1428 | __le16 StructureSize; /* Must be 33 */ |
| 1429 | __u8 FileInformationClass; |
| 1430 | __u8 Flags; |
| 1431 | __le32 FileIndex; |
| 1432 | __u64 PersistentFileId; /* opaque endianness */ |
| 1433 | __u64 VolatileFileId; /* opaque endianness */ |
| 1434 | __le16 FileNameOffset; |
| 1435 | __le16 FileNameLength; |
| 1436 | __le32 OutputBufferLength; |
| 1437 | __u8 Buffer[1]; |
| 1438 | } __packed; |
| 1439 | |
| 1440 | struct smb2_query_directory_rsp { |
Ronnie Sahlberg | 49f466b | 2018-06-01 10:53:06 +1000 | [diff] [blame] | 1441 | struct smb2_sync_hdr sync_hdr; |
Pavel Shilovsky | d324f08d | 2012-09-18 16:20:33 -0700 | [diff] [blame] | 1442 | __le16 StructureSize; /* Must be 9 */ |
| 1443 | __le16 OutputBufferOffset; |
| 1444 | __le32 OutputBufferLength; |
| 1445 | __u8 Buffer[1]; |
| 1446 | } __packed; |
| 1447 | |
Pavel Shilovsky | be4cb9e | 2011-12-29 17:06:33 +0400 | [diff] [blame] | 1448 | /* Possible InfoType values */ |
| 1449 | #define SMB2_O_INFO_FILE 0x01 |
| 1450 | #define SMB2_O_INFO_FILESYSTEM 0x02 |
| 1451 | #define SMB2_O_INFO_SECURITY 0x03 |
| 1452 | #define SMB2_O_INFO_QUOTA 0x04 |
| 1453 | |
Steve French | 911a8df | 2014-10-19 19:18:05 -0500 | [diff] [blame] | 1454 | /* Security info type additionalinfo flags. See MS-SMB2 (2.2.37) or MS-DTYP */ |
| 1455 | #define OWNER_SECINFO 0x00000001 |
| 1456 | #define GROUP_SECINFO 0x00000002 |
| 1457 | #define DACL_SECINFO 0x00000004 |
| 1458 | #define SACL_SECINFO 0x00000008 |
| 1459 | #define LABEL_SECINFO 0x00000010 |
| 1460 | #define ATTRIBUTE_SECINFO 0x00000020 |
| 1461 | #define SCOPE_SECINFO 0x00000040 |
| 1462 | #define BACKUP_SECINFO 0x00010000 |
| 1463 | #define UNPROTECTED_SACL_SECINFO 0x10000000 |
| 1464 | #define UNPROTECTED_DACL_SECINFO 0x20000000 |
| 1465 | #define PROTECTED_SACL_SECINFO 0x40000000 |
| 1466 | #define PROTECTED_DACL_SECINFO 0x80000000 |
| 1467 | |
| 1468 | /* Flags used for FileFullEAinfo */ |
| 1469 | #define SL_RESTART_SCAN 0x00000001 |
| 1470 | #define SL_RETURN_SINGLE_ENTRY 0x00000002 |
| 1471 | #define SL_INDEX_SPECIFIED 0x00000004 |
| 1472 | |
Pavel Shilovsky | be4cb9e | 2011-12-29 17:06:33 +0400 | [diff] [blame] | 1473 | struct smb2_query_info_req { |
Ronnie Sahlberg | b2fb7fe | 2017-11-20 11:24:46 +1100 | [diff] [blame] | 1474 | struct smb2_sync_hdr sync_hdr; |
Pavel Shilovsky | be4cb9e | 2011-12-29 17:06:33 +0400 | [diff] [blame] | 1475 | __le16 StructureSize; /* Must be 41 */ |
| 1476 | __u8 InfoType; |
| 1477 | __u8 FileInfoClass; |
| 1478 | __le32 OutputBufferLength; |
| 1479 | __le16 InputBufferOffset; |
| 1480 | __u16 Reserved; |
| 1481 | __le32 InputBufferLength; |
| 1482 | __le32 AdditionalInformation; |
| 1483 | __le32 Flags; |
| 1484 | __u64 PersistentFileId; /* opaque endianness */ |
| 1485 | __u64 VolatileFileId; /* opaque endianness */ |
| 1486 | __u8 Buffer[1]; |
| 1487 | } __packed; |
| 1488 | |
| 1489 | struct smb2_query_info_rsp { |
Ronnie Sahlberg | 49f466b | 2018-06-01 10:53:06 +1000 | [diff] [blame] | 1490 | struct smb2_sync_hdr sync_hdr; |
Pavel Shilovsky | be4cb9e | 2011-12-29 17:06:33 +0400 | [diff] [blame] | 1491 | __le16 StructureSize; /* Must be 9 */ |
| 1492 | __le16 OutputBufferOffset; |
| 1493 | __le32 OutputBufferLength; |
| 1494 | __u8 Buffer[1]; |
| 1495 | } __packed; |
| 1496 | |
Ronnie Sahlberg | 14e562a | 2018-09-03 13:33:50 +1000 | [diff] [blame] | 1497 | /* |
| 1498 | * Maximum number of iovs we need for a set-info request. |
| 1499 | * The largest one is rename/hardlink |
| 1500 | * [0] : struct smb2_set_info_req + smb2_file_[rename|link]_info |
| 1501 | * [1] : path |
| 1502 | * [2] : compound padding |
| 1503 | */ |
| 1504 | #define SMB2_SET_INFO_IOV_SIZE 3 |
| 1505 | |
Pavel Shilovsky | 35143eb | 2012-09-18 16:20:31 -0700 | [diff] [blame] | 1506 | struct smb2_set_info_req { |
Ronnie Sahlberg | 2fc803e | 2017-11-20 11:24:44 +1100 | [diff] [blame] | 1507 | struct smb2_sync_hdr sync_hdr; |
Pavel Shilovsky | 35143eb | 2012-09-18 16:20:31 -0700 | [diff] [blame] | 1508 | __le16 StructureSize; /* Must be 33 */ |
| 1509 | __u8 InfoType; |
| 1510 | __u8 FileInfoClass; |
| 1511 | __le32 BufferLength; |
| 1512 | __le16 BufferOffset; |
| 1513 | __u16 Reserved; |
| 1514 | __le32 AdditionalInformation; |
| 1515 | __u64 PersistentFileId; /* opaque endianness */ |
| 1516 | __u64 VolatileFileId; /* opaque endianness */ |
| 1517 | __u8 Buffer[1]; |
| 1518 | } __packed; |
| 1519 | |
| 1520 | struct smb2_set_info_rsp { |
Ronnie Sahlberg | 49f466b | 2018-06-01 10:53:06 +1000 | [diff] [blame] | 1521 | struct smb2_sync_hdr sync_hdr; |
Pavel Shilovsky | 35143eb | 2012-09-18 16:20:31 -0700 | [diff] [blame] | 1522 | __le16 StructureSize; /* Must be 2 */ |
| 1523 | } __packed; |
| 1524 | |
Ronnie Sahlberg | 0d5a288 | 2018-06-01 10:53:03 +1000 | [diff] [blame] | 1525 | struct smb2_oplock_break { |
Ronnie Sahlberg | 21ad948 | 2017-11-20 11:24:43 +1100 | [diff] [blame] | 1526 | struct smb2_sync_hdr sync_hdr; |
| 1527 | __le16 StructureSize; /* Must be 24 */ |
| 1528 | __u8 OplockLevel; |
| 1529 | __u8 Reserved; |
| 1530 | __le32 Reserved2; |
| 1531 | __u64 PersistentFid; |
| 1532 | __u64 VolatileFid; |
| 1533 | } __packed; |
| 1534 | |
Pavel Shilovsky | 0822f51 | 2012-09-19 06:22:45 -0700 | [diff] [blame] | 1535 | #define SMB2_NOTIFY_BREAK_LEASE_FLAG_ACK_REQUIRED cpu_to_le32(0x01) |
| 1536 | |
| 1537 | struct smb2_lease_break { |
Ronnie Sahlberg | 49f466b | 2018-06-01 10:53:06 +1000 | [diff] [blame] | 1538 | struct smb2_sync_hdr sync_hdr; |
Pavel Shilovsky | 0822f51 | 2012-09-19 06:22:45 -0700 | [diff] [blame] | 1539 | __le16 StructureSize; /* Must be 44 */ |
Pavel Shilovsky | 9bd4540 | 2019-10-29 16:51:19 -0700 | [diff] [blame] | 1540 | __le16 Epoch; |
Pavel Shilovsky | 0822f51 | 2012-09-19 06:22:45 -0700 | [diff] [blame] | 1541 | __le32 Flags; |
| 1542 | __u8 LeaseKey[16]; |
| 1543 | __le32 CurrentLeaseState; |
| 1544 | __le32 NewLeaseState; |
| 1545 | __le32 BreakReason; |
| 1546 | __le32 AccessMaskHint; |
| 1547 | __le32 ShareMaskHint; |
| 1548 | } __packed; |
| 1549 | |
| 1550 | struct smb2_lease_ack { |
Ronnie Sahlberg | 8eb7998 | 2017-11-21 11:04:37 +1100 | [diff] [blame] | 1551 | struct smb2_sync_hdr sync_hdr; |
Pavel Shilovsky | 0822f51 | 2012-09-19 06:22:45 -0700 | [diff] [blame] | 1552 | __le16 StructureSize; /* Must be 36 */ |
| 1553 | __le16 Reserved; |
| 1554 | __le32 Flags; |
| 1555 | __u8 LeaseKey[16]; |
| 1556 | __le32 LeaseState; |
| 1557 | __le64 LeaseDuration; |
| 1558 | } __packed; |
| 1559 | |
Pavel Shilovsky | be4cb9e | 2011-12-29 17:06:33 +0400 | [diff] [blame] | 1560 | /* |
| 1561 | * PDU infolevel structure definitions |
| 1562 | * BB consider moving to a different header |
| 1563 | */ |
| 1564 | |
Pavel Shilovsky | 6fc05c2 | 2012-09-18 16:20:34 -0700 | [diff] [blame] | 1565 | /* File System Information Classes */ |
| 1566 | #define FS_VOLUME_INFORMATION 1 /* Query */ |
Steven French | af6a12e | 2013-10-09 20:55:53 -0500 | [diff] [blame] | 1567 | #define FS_LABEL_INFORMATION 2 /* Local only */ |
Pavel Shilovsky | 6fc05c2 | 2012-09-18 16:20:34 -0700 | [diff] [blame] | 1568 | #define FS_SIZE_INFORMATION 3 /* Query */ |
| 1569 | #define FS_DEVICE_INFORMATION 4 /* Query */ |
| 1570 | #define FS_ATTRIBUTE_INFORMATION 5 /* Query */ |
| 1571 | #define FS_CONTROL_INFORMATION 6 /* Query, Set */ |
| 1572 | #define FS_FULL_SIZE_INFORMATION 7 /* Query */ |
| 1573 | #define FS_OBJECT_ID_INFORMATION 8 /* Query, Set */ |
Steven French | af6a12e | 2013-10-09 20:55:53 -0500 | [diff] [blame] | 1574 | #define FS_DRIVER_PATH_INFORMATION 9 /* Local only */ |
| 1575 | #define FS_VOLUME_FLAGS_INFORMATION 10 /* Local only */ |
| 1576 | #define FS_SECTOR_SIZE_INFORMATION 11 /* SMB3 or later. Query */ |
Steve French | 2d30421 | 2018-06-24 23:28:12 -0500 | [diff] [blame] | 1577 | #define FS_POSIX_INFORMATION 100 /* SMB3.1.1 POSIX. Query */ |
Pavel Shilovsky | 6fc05c2 | 2012-09-18 16:20:34 -0700 | [diff] [blame] | 1578 | |
| 1579 | struct smb2_fs_full_size_info { |
| 1580 | __le64 TotalAllocationUnits; |
| 1581 | __le64 CallerAvailableAllocationUnits; |
| 1582 | __le64 ActualAvailableAllocationUnits; |
| 1583 | __le32 SectorsPerAllocationUnit; |
| 1584 | __le32 BytesPerSector; |
| 1585 | } __packed; |
| 1586 | |
Steven French | af6a12e | 2013-10-09 20:55:53 -0500 | [diff] [blame] | 1587 | #define SSINFO_FLAGS_ALIGNED_DEVICE 0x00000001 |
| 1588 | #define SSINFO_FLAGS_PARTITION_ALIGNED_ON_DEVICE 0x00000002 |
| 1589 | #define SSINFO_FLAGS_NO_SEEK_PENALTY 0x00000004 |
| 1590 | #define SSINFO_FLAGS_TRIM_ENABLED 0x00000008 |
| 1591 | |
| 1592 | /* sector size info struct */ |
| 1593 | struct smb3_fs_ss_info { |
| 1594 | __le32 LogicalBytesPerSector; |
| 1595 | __le32 PhysicalBytesPerSectorForAtomicity; |
| 1596 | __le32 PhysicalBytesPerSectorForPerf; |
| 1597 | __le32 FileSystemEffectivePhysicalBytesPerSectorForAtomicity; |
| 1598 | __le32 Flags; |
| 1599 | __le32 ByteOffsetForSectorAlignment; |
| 1600 | __le32 ByteOffsetForPartitionAlignment; |
| 1601 | } __packed; |
| 1602 | |
Steve French | 21ba384 | 2018-06-24 23:18:52 -0500 | [diff] [blame] | 1603 | /* volume info struct - see MS-FSCC 2.5.9 */ |
| 1604 | #define MAX_VOL_LABEL_LEN 32 |
| 1605 | struct smb3_fs_vol_info { |
| 1606 | __le64 VolumeCreationTime; |
| 1607 | __u32 VolumeSerialNumber; |
| 1608 | __le32 VolumeLabelLength; /* includes trailing null */ |
| 1609 | __u8 SupportsObjects; /* True if eg like NTFS, supports objects */ |
| 1610 | __u8 Reserved; |
Gustavo A. R. Silva | cff2def | 2020-03-09 10:44:51 -0500 | [diff] [blame] | 1611 | __u8 VolumeLabel[]; /* variable len */ |
Steve French | 21ba384 | 2018-06-24 23:18:52 -0500 | [diff] [blame] | 1612 | } __packed; |
| 1613 | |
Pavel Shilovsky | be4cb9e | 2011-12-29 17:06:33 +0400 | [diff] [blame] | 1614 | /* partial list of QUERY INFO levels */ |
| 1615 | #define FILE_DIRECTORY_INFORMATION 1 |
| 1616 | #define FILE_FULL_DIRECTORY_INFORMATION 2 |
| 1617 | #define FILE_BOTH_DIRECTORY_INFORMATION 3 |
| 1618 | #define FILE_BASIC_INFORMATION 4 |
| 1619 | #define FILE_STANDARD_INFORMATION 5 |
| 1620 | #define FILE_INTERNAL_INFORMATION 6 |
| 1621 | #define FILE_EA_INFORMATION 7 |
| 1622 | #define FILE_ACCESS_INFORMATION 8 |
| 1623 | #define FILE_NAME_INFORMATION 9 |
| 1624 | #define FILE_RENAME_INFORMATION 10 |
| 1625 | #define FILE_LINK_INFORMATION 11 |
| 1626 | #define FILE_NAMES_INFORMATION 12 |
| 1627 | #define FILE_DISPOSITION_INFORMATION 13 |
| 1628 | #define FILE_POSITION_INFORMATION 14 |
| 1629 | #define FILE_FULL_EA_INFORMATION 15 |
| 1630 | #define FILE_MODE_INFORMATION 16 |
| 1631 | #define FILE_ALIGNMENT_INFORMATION 17 |
| 1632 | #define FILE_ALL_INFORMATION 18 |
| 1633 | #define FILE_ALLOCATION_INFORMATION 19 |
| 1634 | #define FILE_END_OF_FILE_INFORMATION 20 |
| 1635 | #define FILE_ALTERNATE_NAME_INFORMATION 21 |
| 1636 | #define FILE_STREAM_INFORMATION 22 |
| 1637 | #define FILE_PIPE_INFORMATION 23 |
| 1638 | #define FILE_PIPE_LOCAL_INFORMATION 24 |
| 1639 | #define FILE_PIPE_REMOTE_INFORMATION 25 |
| 1640 | #define FILE_MAILSLOT_QUERY_INFORMATION 26 |
| 1641 | #define FILE_MAILSLOT_SET_INFORMATION 27 |
| 1642 | #define FILE_COMPRESSION_INFORMATION 28 |
| 1643 | #define FILE_OBJECT_ID_INFORMATION 29 |
| 1644 | /* Number 30 not defined in documents */ |
| 1645 | #define FILE_MOVE_CLUSTER_INFORMATION 31 |
| 1646 | #define FILE_QUOTA_INFORMATION 32 |
| 1647 | #define FILE_REPARSE_POINT_INFORMATION 33 |
| 1648 | #define FILE_NETWORK_OPEN_INFORMATION 34 |
| 1649 | #define FILE_ATTRIBUTE_TAG_INFORMATION 35 |
| 1650 | #define FILE_TRACKING_INFORMATION 36 |
| 1651 | #define FILEID_BOTH_DIRECTORY_INFORMATION 37 |
| 1652 | #define FILEID_FULL_DIRECTORY_INFORMATION 38 |
| 1653 | #define FILE_VALID_DATA_LENGTH_INFORMATION 39 |
| 1654 | #define FILE_SHORT_NAME_INFORMATION 40 |
| 1655 | #define FILE_SFIO_RESERVE_INFORMATION 44 |
| 1656 | #define FILE_SFIO_VOLUME_INFORMATION 45 |
| 1657 | #define FILE_HARD_LINK_INFORMATION 46 |
| 1658 | #define FILE_NORMALIZED_NAME_INFORMATION 48 |
| 1659 | #define FILEID_GLOBAL_TX_DIRECTORY_INFORMATION 50 |
| 1660 | #define FILE_STANDARD_LINK_INFORMATION 54 |
Steve French | 51d92d6 | 2020-02-06 12:32:03 -0600 | [diff] [blame] | 1661 | #define FILE_ID_INFORMATION 59 |
Pavel Shilovsky | be4cb9e | 2011-12-29 17:06:33 +0400 | [diff] [blame] | 1662 | |
Pavel Shilovsky | f0df737 | 2012-09-18 16:20:26 -0700 | [diff] [blame] | 1663 | struct smb2_file_internal_info { |
| 1664 | __le64 IndexNumber; |
| 1665 | } __packed; /* level 6 Query */ |
| 1666 | |
Pavel Shilovsky | 35143eb | 2012-09-18 16:20:31 -0700 | [diff] [blame] | 1667 | struct smb2_file_rename_info { /* encoding of request for level 10 */ |
| 1668 | __u8 ReplaceIfExists; /* 1 = replace existing target with new */ |
| 1669 | /* 0 = fail if target already exists */ |
| 1670 | __u8 Reserved[7]; |
| 1671 | __u64 RootDirectory; /* MBZ for network operations (why says spec?) */ |
| 1672 | __le32 FileNameLength; |
Gustavo A. R. Silva | cff2def | 2020-03-09 10:44:51 -0500 | [diff] [blame] | 1673 | char FileName[]; /* New name to be assigned */ |
Steve French | 7d03ae4 | 2020-10-23 15:21:38 -0500 | [diff] [blame] | 1674 | /* padding - overall struct size must be >= 24 so filename + pad >= 6 */ |
Pavel Shilovsky | 35143eb | 2012-09-18 16:20:31 -0700 | [diff] [blame] | 1675 | } __packed; /* level 10 Set */ |
| 1676 | |
Pavel Shilovsky | 568798c | 2012-09-18 16:20:31 -0700 | [diff] [blame] | 1677 | struct smb2_file_link_info { /* encoding of request for level 11 */ |
| 1678 | __u8 ReplaceIfExists; /* 1 = replace existing link with new */ |
| 1679 | /* 0 = fail if link already exists */ |
| 1680 | __u8 Reserved[7]; |
| 1681 | __u64 RootDirectory; /* MBZ for network operations (why says spec?) */ |
| 1682 | __le32 FileNameLength; |
Gustavo A. R. Silva | cff2def | 2020-03-09 10:44:51 -0500 | [diff] [blame] | 1683 | char FileName[]; /* Name to be assigned to new link */ |
Pavel Shilovsky | 568798c | 2012-09-18 16:20:31 -0700 | [diff] [blame] | 1684 | } __packed; /* level 11 Set */ |
| 1685 | |
Ronnie Sahlberg | 95907fe | 2017-08-24 11:24:55 +1000 | [diff] [blame] | 1686 | struct smb2_file_full_ea_info { /* encoding of response for level 15 */ |
| 1687 | __le32 next_entry_offset; |
| 1688 | __u8 flags; |
| 1689 | __u8 ea_name_length; |
| 1690 | __le16 ea_value_length; |
Gustavo A. R. Silva | cff2def | 2020-03-09 10:44:51 -0500 | [diff] [blame] | 1691 | char ea_data[]; /* \0 terminated name plus value */ |
Ronnie Sahlberg | 95907fe | 2017-08-24 11:24:55 +1000 | [diff] [blame] | 1692 | } __packed; /* level 15 Set */ |
| 1693 | |
Pavel Shilovsky | be4cb9e | 2011-12-29 17:06:33 +0400 | [diff] [blame] | 1694 | /* |
| 1695 | * This level 18, although with struct with same name is different from cifs |
| 1696 | * level 0x107. Level 0x107 has an extra u64 between AccessFlags and |
| 1697 | * CurrentByteOffset. |
| 1698 | */ |
| 1699 | struct smb2_file_all_info { /* data block encoding of response to level 18 */ |
| 1700 | __le64 CreationTime; /* Beginning of FILE_BASIC_INFO equivalent */ |
| 1701 | __le64 LastAccessTime; |
| 1702 | __le64 LastWriteTime; |
| 1703 | __le64 ChangeTime; |
| 1704 | __le32 Attributes; |
| 1705 | __u32 Pad1; /* End of FILE_BASIC_INFO_INFO equivalent */ |
| 1706 | __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */ |
| 1707 | __le64 EndOfFile; /* size ie offset to first free byte in file */ |
| 1708 | __le32 NumberOfLinks; /* hard links */ |
| 1709 | __u8 DeletePending; |
| 1710 | __u8 Directory; |
| 1711 | __u16 Pad2; /* End of FILE_STANDARD_INFO equivalent */ |
| 1712 | __le64 IndexNumber; |
| 1713 | __le32 EASize; |
| 1714 | __le32 AccessFlags; |
| 1715 | __le64 CurrentByteOffset; |
| 1716 | __le32 Mode; |
| 1717 | __le32 AlignmentRequirement; |
| 1718 | __le32 FileNameLength; |
| 1719 | char FileName[1]; |
| 1720 | } __packed; /* level 18 Query */ |
| 1721 | |
Pavel Shilovsky | c839ff2 | 2012-09-18 16:20:32 -0700 | [diff] [blame] | 1722 | struct smb2_file_eof_info { /* encoding of request for level 10 */ |
| 1723 | __le64 EndOfFile; /* new end of file value */ |
| 1724 | } __packed; /* level 20 Set */ |
| 1725 | |
Steve French | 2e4564b | 2020-10-22 22:03:14 -0500 | [diff] [blame] | 1726 | struct smb2_file_reparse_point_info { |
| 1727 | __le64 IndexNumber; |
| 1728 | __le32 Tag; |
| 1729 | } __packed; |
| 1730 | |
Steve French | 43f8a6a | 2019-12-02 21:46:54 -0600 | [diff] [blame] | 1731 | struct smb2_file_network_open_info { |
| 1732 | __le64 CreationTime; |
| 1733 | __le64 LastAccessTime; |
| 1734 | __le64 LastWriteTime; |
| 1735 | __le64 ChangeTime; |
| 1736 | __le64 AllocationSize; |
| 1737 | __le64 EndOfFile; |
| 1738 | __le32 Attributes; |
| 1739 | __le32 Reserved; |
| 1740 | } __packed; /* level 34 Query also similar returned in close rsp and open rsp */ |
| 1741 | |
Steve French | 51d92d6 | 2020-02-06 12:32:03 -0600 | [diff] [blame] | 1742 | /* See MS-FSCC 2.4.43 */ |
| 1743 | struct smb2_file_id_information { |
| 1744 | __le64 VolumeSerialNumber; |
| 1745 | __u64 PersistentFileId; /* opaque endianness */ |
| 1746 | __u64 VolatileFileId; /* opaque endianness */ |
| 1747 | } __packed; /* level 59 */ |
| 1748 | |
Ronnie Sahlberg | 730928c | 2018-08-08 15:07:49 +1000 | [diff] [blame] | 1749 | extern char smb2_padding[7]; |
| 1750 | |
Steve French | ab3459d | 2020-02-06 17:31:56 -0600 | [diff] [blame] | 1751 | /* equivalent of the contents of SMB3.1.1 POSIX open context response */ |
Aurelien Aptel | 2e8af97 | 2020-02-08 15:50:56 +0100 | [diff] [blame] | 1752 | struct create_posix_rsp { |
Aurelien Aptel | 69dda30 | 2020-03-02 17:53:22 +0100 | [diff] [blame] | 1753 | u32 nlink; |
| 1754 | u32 reparse_tag; |
| 1755 | u32 mode; |
| 1756 | struct cifs_sid owner; /* var-sized on the wire */ |
| 1757 | struct cifs_sid group; /* var-sized on the wire */ |
Aurelien Aptel | 2e8af97 | 2020-02-08 15:50:56 +0100 | [diff] [blame] | 1758 | } __packed; |
Aurelien Aptel | 349e13a | 2020-02-08 15:50:57 +0100 | [diff] [blame] | 1759 | |
| 1760 | /* |
Steve French | 6a5f659 | 2020-06-11 19:25:47 -0500 | [diff] [blame] | 1761 | * SMB2-only POSIX info level for query dir |
Aurelien Aptel | 349e13a | 2020-02-08 15:50:57 +0100 | [diff] [blame] | 1762 | * |
| 1763 | * See posix_info_sid_size(), posix_info_extra_size() and |
| 1764 | * posix_info_parse() to help with the handling of this struct. |
| 1765 | */ |
| 1766 | struct smb2_posix_info { |
| 1767 | __le32 NextEntryOffset; |
| 1768 | __u32 Ignored; |
| 1769 | __le64 CreationTime; |
| 1770 | __le64 LastAccessTime; |
| 1771 | __le64 LastWriteTime; |
| 1772 | __le64 ChangeTime; |
| 1773 | __le64 EndOfFile; |
| 1774 | __le64 AllocationSize; |
| 1775 | __le32 DosAttributes; |
| 1776 | __le64 Inode; |
| 1777 | __le32 DeviceId; |
| 1778 | __le32 Zero; |
| 1779 | /* beginning of POSIX Create Context Response */ |
| 1780 | __le32 HardLinks; |
| 1781 | __le32 ReparseTag; |
| 1782 | __le32 Mode; |
| 1783 | /* |
| 1784 | * var sized owner SID |
| 1785 | * var sized group SID |
| 1786 | * le32 filenamelength |
| 1787 | * u8 filename[] |
| 1788 | */ |
| 1789 | } __packed; |
| 1790 | |
Steve French | 6a5f659 | 2020-06-11 19:25:47 -0500 | [diff] [blame] | 1791 | /* Level 100 query info */ |
| 1792 | struct smb311_posix_qinfo { |
| 1793 | __le64 CreationTime; |
| 1794 | __le64 LastAccessTime; |
| 1795 | __le64 LastWriteTime; |
| 1796 | __le64 ChangeTime; |
| 1797 | __le64 EndOfFile; |
| 1798 | __le64 AllocationSize; |
| 1799 | __le32 DosAttributes; |
| 1800 | __le64 Inode; |
| 1801 | __le32 DeviceId; |
| 1802 | __le32 Zero; |
| 1803 | /* beginning of POSIX Create Context Response */ |
| 1804 | __le32 HardLinks; |
| 1805 | __le32 ReparseTag; |
| 1806 | __le32 Mode; |
| 1807 | u8 Sids[]; |
| 1808 | /* |
| 1809 | * var sized owner SID |
| 1810 | * var sized group SID |
| 1811 | * le32 filenamelength |
| 1812 | * u8 filename[] |
| 1813 | */ |
| 1814 | } __packed; |
| 1815 | |
Aurelien Aptel | 349e13a | 2020-02-08 15:50:57 +0100 | [diff] [blame] | 1816 | /* |
| 1817 | * Parsed version of the above struct. Allows direct access to the |
| 1818 | * variable length fields |
| 1819 | */ |
| 1820 | struct smb2_posix_info_parsed { |
| 1821 | const struct smb2_posix_info *base; |
| 1822 | size_t size; |
| 1823 | struct cifs_sid owner; |
| 1824 | struct cifs_sid group; |
| 1825 | int name_len; |
| 1826 | const u8 *name; |
Steve French | ab3459d | 2020-02-06 17:31:56 -0600 | [diff] [blame] | 1827 | }; |
Aurelien Aptel | 349e13a | 2020-02-08 15:50:57 +0100 | [diff] [blame] | 1828 | |
Steve French | ddfbefb | 2011-03-15 02:08:48 +0000 | [diff] [blame] | 1829 | #endif /* _SMB2PDU_H */ |