Skip to content

Commit fc0b384

Browse files
Ronnie Sahlbergsmfrench
authored andcommitted
cifs: move NEGOTIATE_PROTOCOL definitions out into the common area
Signed-off-by: Ronnie Sahlberg <[email protected]> Reviewed-by: Namjae Jeon <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 0d35e38 commit fc0b384

File tree

3 files changed

+231
-222
lines changed

3 files changed

+231
-222
lines changed

fs/cifs/smb2pdu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,8 +413,8 @@ build_preauth_ctxt(struct smb2_preauth_neg_context *pneg_ctxt)
413413
pneg_ctxt->ContextType = SMB2_PREAUTH_INTEGRITY_CAPABILITIES;
414414
pneg_ctxt->DataLength = cpu_to_le16(38);
415415
pneg_ctxt->HashAlgorithmCount = cpu_to_le16(1);
416-
pneg_ctxt->SaltLength = cpu_to_le16(SMB311_LINUX_CLIENT_SALT_SIZE);
417-
get_random_bytes(pneg_ctxt->Salt, SMB311_LINUX_CLIENT_SALT_SIZE);
416+
pneg_ctxt->SaltLength = cpu_to_le16(SMB311_SALT_SIZE);
417+
get_random_bytes(pneg_ctxt->Salt, SMB311_SALT_SIZE);
418418
pneg_ctxt->HashAlgorithms = SMB2_PREAUTH_INTEGRITY_SHA512;
419419
}
420420

fs/cifs/smb2pdu.h

Lines changed: 0 additions & 220 deletions
Original file line numberDiff line numberDiff line change
@@ -115,226 +115,6 @@ struct share_redirect_error_context_rsp {
115115
/* __u8 ResourceName[] */ /* Name of share as counted Unicode string */
116116
} __packed;
117117

118-
#define SMB2_CLIENT_GUID_SIZE 16
119-
120-
struct smb2_negotiate_req {
121-
struct smb2_hdr hdr;
122-
__le16 StructureSize; /* Must be 36 */
123-
__le16 DialectCount;
124-
__le16 SecurityMode;
125-
__le16 Reserved; /* MBZ */
126-
__le32 Capabilities;
127-
__u8 ClientGUID[SMB2_CLIENT_GUID_SIZE];
128-
/* In SMB3.02 and earlier next three were MBZ le64 ClientStartTime */
129-
__le32 NegotiateContextOffset; /* SMB3.1.1 only. MBZ earlier */
130-
__le16 NegotiateContextCount; /* SMB3.1.1 only. MBZ earlier */
131-
__le16 Reserved2;
132-
__le16 Dialects[4]; /* BB expand this if autonegotiate > 4 dialects */
133-
} __packed;
134-
135-
/* Dialects */
136-
#define SMB10_PROT_ID 0x0000 /* local only, not sent on wire w/CIFS negprot */
137-
#define SMB20_PROT_ID 0x0202
138-
#define SMB21_PROT_ID 0x0210
139-
#define SMB30_PROT_ID 0x0300
140-
#define SMB302_PROT_ID 0x0302
141-
#define SMB311_PROT_ID 0x0311
142-
#define BAD_PROT_ID 0xFFFF
143-
144-
/* SecurityMode flags */
145-
#define SMB2_NEGOTIATE_SIGNING_ENABLED 0x0001
146-
#define SMB2_NEGOTIATE_SIGNING_REQUIRED 0x0002
147-
#define SMB2_SEC_MODE_FLAGS_ALL 0x0003
148-
149-
/* Capabilities flags */
150-
#define SMB2_GLOBAL_CAP_DFS 0x00000001
151-
#define SMB2_GLOBAL_CAP_LEASING 0x00000002 /* Resp only New to SMB2.1 */
152-
#define SMB2_GLOBAL_CAP_LARGE_MTU 0X00000004 /* Resp only New to SMB2.1 */
153-
#define SMB2_GLOBAL_CAP_MULTI_CHANNEL 0x00000008 /* New to SMB3 */
154-
#define SMB2_GLOBAL_CAP_PERSISTENT_HANDLES 0x00000010 /* New to SMB3 */
155-
#define SMB2_GLOBAL_CAP_DIRECTORY_LEASING 0x00000020 /* New to SMB3 */
156-
#define SMB2_GLOBAL_CAP_ENCRYPTION 0x00000040 /* New to SMB3 */
157-
/* Internal types */
158-
#define SMB2_NT_FIND 0x00100000
159-
#define SMB2_LARGE_FILES 0x00200000
160-
161-
162-
/* Negotiate Contexts - ContextTypes. See MS-SMB2 section 2.2.3.1 for details */
163-
#define SMB2_PREAUTH_INTEGRITY_CAPABILITIES cpu_to_le16(1)
164-
#define SMB2_ENCRYPTION_CAPABILITIES cpu_to_le16(2)
165-
#define SMB2_COMPRESSION_CAPABILITIES cpu_to_le16(3)
166-
#define SMB2_NETNAME_NEGOTIATE_CONTEXT_ID cpu_to_le16(5)
167-
#define SMB2_TRANSPORT_CAPABILITIES cpu_to_le16(6)
168-
#define SMB2_RDMA_TRANSFORM_CAPABILITIES cpu_to_le16(7)
169-
#define SMB2_SIGNING_CAPABILITIES cpu_to_le16(8)
170-
#define SMB2_POSIX_EXTENSIONS_AVAILABLE cpu_to_le16(0x100)
171-
172-
struct smb2_neg_context {
173-
__le16 ContextType;
174-
__le16 DataLength;
175-
__le32 Reserved;
176-
/* Followed by array of data. NOTE: some servers require padding to 8 byte boundary */
177-
} __packed;
178-
179-
#define SMB311_LINUX_CLIENT_SALT_SIZE 32
180-
/* Hash Algorithm Types */
181-
#define SMB2_PREAUTH_INTEGRITY_SHA512 cpu_to_le16(0x0001)
182-
#define SMB2_PREAUTH_HASH_SIZE 64
183-
184-
/*
185-
* SaltLength that the server send can be zero, so the only three required
186-
* fields (all __le16) end up six bytes total, so the minimum context data len
187-
* in the response is six bytes which accounts for
188-
*
189-
* HashAlgorithmCount, SaltLength, and 1 HashAlgorithm.
190-
*/
191-
#define MIN_PREAUTH_CTXT_DATA_LEN 6
192-
193-
struct smb2_preauth_neg_context {
194-
__le16 ContextType; /* 1 */
195-
__le16 DataLength;
196-
__le32 Reserved;
197-
__le16 HashAlgorithmCount; /* 1 */
198-
__le16 SaltLength;
199-
__le16 HashAlgorithms; /* HashAlgorithms[0] since only one defined */
200-
__u8 Salt[SMB311_LINUX_CLIENT_SALT_SIZE];
201-
} __packed;
202-
203-
/* Encryption Algorithms Ciphers */
204-
#define SMB2_ENCRYPTION_AES128_CCM cpu_to_le16(0x0001)
205-
#define SMB2_ENCRYPTION_AES128_GCM cpu_to_le16(0x0002)
206-
/* we currently do not request AES256_CCM since presumably GCM faster */
207-
#define SMB2_ENCRYPTION_AES256_CCM cpu_to_le16(0x0003)
208-
#define SMB2_ENCRYPTION_AES256_GCM cpu_to_le16(0x0004)
209-
210-
/* Min encrypt context data is one cipher so 2 bytes + 2 byte count field */
211-
#define MIN_ENCRYPT_CTXT_DATA_LEN 4
212-
struct smb2_encryption_neg_context {
213-
__le16 ContextType; /* 2 */
214-
__le16 DataLength;
215-
__le32 Reserved;
216-
/* CipherCount usally 2, but can be 3 when AES256-GCM enabled */
217-
__le16 CipherCount; /* AES128-GCM and AES128-CCM by default */
218-
__le16 Ciphers[3];
219-
} __packed;
220-
221-
/* See MS-SMB2 2.2.3.1.3 */
222-
#define SMB3_COMPRESS_NONE cpu_to_le16(0x0000)
223-
#define SMB3_COMPRESS_LZNT1 cpu_to_le16(0x0001)
224-
#define SMB3_COMPRESS_LZ77 cpu_to_le16(0x0002)
225-
#define SMB3_COMPRESS_LZ77_HUFF cpu_to_le16(0x0003)
226-
/* Pattern scanning algorithm See MS-SMB2 3.1.4.4.1 */
227-
#define SMB3_COMPRESS_PATTERN cpu_to_le16(0x0004) /* Pattern_V1 */
228-
229-
/* Compression Flags */
230-
#define SMB2_COMPRESSION_CAPABILITIES_FLAG_NONE cpu_to_le32(0x00000000)
231-
#define SMB2_COMPRESSION_CAPABILITIES_FLAG_CHAINED cpu_to_le32(0x00000001)
232-
233-
struct smb2_compression_capabilities_context {
234-
__le16 ContextType; /* 3 */
235-
__le16 DataLength;
236-
__u32 Reserved;
237-
__le16 CompressionAlgorithmCount;
238-
__u16 Padding;
239-
__u32 Flags;
240-
__le16 CompressionAlgorithms[3];
241-
__u16 Pad; /* Some servers require pad to DataLen multiple of 8 */
242-
/* Check if pad needed */
243-
} __packed;
244-
245-
/*
246-
* For smb2_netname_negotiate_context_id See MS-SMB2 2.2.3.1.4.
247-
* Its struct simply contains NetName, an array of Unicode characters
248-
*/
249-
struct smb2_netname_neg_context {
250-
__le16 ContextType; /* 5 */
251-
__le16 DataLength;
252-
__le32 Reserved;
253-
__le16 NetName[]; /* hostname of target converted to UCS-2 */
254-
} __packed;
255-
256-
/*
257-
* For smb2_transport_capabilities context see MS-SMB2 2.2.3.1.5
258-
* and 2.2.4.1.5
259-
*/
260-
261-
/* Flags */
262-
#define SMB2_ACCEPT_TRANSFORM_LEVEL_SECURITY 0x00000001
263-
264-
struct smb2_transport_capabilities_context {
265-
__le16 ContextType; /* 6 */
266-
__le16 DataLength;
267-
__u32 Reserved;
268-
__le32 Flags;
269-
__u32 Pad;
270-
} __packed;
271-
272-
/*
273-
* For rdma transform capabilities context see MS-SMB2 2.2.3.1.6
274-
* and 2.2.4.1.6
275-
*/
276-
277-
/* RDMA Transform IDs */
278-
#define SMB2_RDMA_TRANSFORM_NONE 0x0000
279-
#define SMB2_RDMA_TRANSFORM_ENCRYPTION 0x0001
280-
#define SMB2_RDMA_TRANSFORM_SIGNING 0x0002
281-
282-
struct smb2_rdma_transform_capabilities_context {
283-
__le16 ContextType; /* 7 */
284-
__le16 DataLength;
285-
__u32 Reserved;
286-
__le16 TransformCount;
287-
__u16 Reserved1;
288-
__u32 Reserved2;
289-
__le16 RDMATransformIds[];
290-
} __packed;
291-
292-
/*
293-
* For signing capabilities context see MS-SMB2 2.2.3.1.7
294-
* and 2.2.4.1.7
295-
*/
296-
297-
/* Signing algorithms */
298-
#define SIGNING_ALG_HMAC_SHA256 0
299-
#define SIGNING_ALG_AES_CMAC 1
300-
#define SIGNING_ALG_AES_GMAC 2
301-
302-
struct smb2_signing_capabilities {
303-
__le16 ContextType; /* 8 */
304-
__le16 DataLength;
305-
__u32 Reserved;
306-
__le16 SigningAlgorithmCount;
307-
__le16 SigningAlgorithms[];
308-
/* Followed by padding to 8 byte boundary (required by some servers) */
309-
} __packed;
310-
311-
#define POSIX_CTXT_DATA_LEN 16
312-
struct smb2_posix_neg_context {
313-
__le16 ContextType; /* 0x100 */
314-
__le16 DataLength;
315-
__le32 Reserved;
316-
__u8 Name[16]; /* POSIX ctxt GUID 93AD25509CB411E7B42383DE968BCD7C */
317-
} __packed;
318-
319-
struct smb2_negotiate_rsp {
320-
struct smb2_hdr hdr;
321-
__le16 StructureSize; /* Must be 65 */
322-
__le16 SecurityMode;
323-
__le16 DialectRevision;
324-
__le16 NegotiateContextCount; /* Prior to SMB3.1.1 was Reserved & MBZ */
325-
__u8 ServerGUID[16];
326-
__le32 Capabilities;
327-
__le32 MaxTransactSize;
328-
__le32 MaxReadSize;
329-
__le32 MaxWriteSize;
330-
__le64 SystemTime; /* MBZ */
331-
__le64 ServerStartTime;
332-
__le16 SecurityBufferOffset;
333-
__le16 SecurityBufferLength;
334-
__le32 NegotiateContextOffset; /* Pre:SMB3.1.1 was reserved/ignored */
335-
__u8 Buffer[1]; /* variable length GSS security buffer */
336-
} __packed;
337-
338118
/* Flags */
339119
#define SMB2_SESSION_REQ_FLAG_BINDING 0x01
340120
#define SMB2_SESSION_REQ_FLAG_ENCRYPT_DATA 0x04

0 commit comments

Comments
 (0)