File tree Expand file tree Collapse file tree 3 files changed +30
-30
lines changed Expand file tree Collapse file tree 3 files changed +30
-30
lines changed Original file line number Diff line number Diff line change @@ -319,13 +319,10 @@ int ksmbd_conn_handler_loop(void *p)
319
319
}
320
320
321
321
/*
322
- * Check if pdu size is valid (min : smb header size,
323
- * max : 0x00FFFFFF).
322
+ * Check maximum pdu size(0x00FFFFFF).
324
323
*/
325
- if (pdu_size < __SMB2_HEADER_STRUCTURE_SIZE ||
326
- pdu_size > MAX_STREAM_PROT_LEN ) {
324
+ if (pdu_size > MAX_STREAM_PROT_LEN )
327
325
break ;
328
- }
329
326
330
327
/* 4 for rfc1002 length field */
331
328
size = pdu_size + 4 ;
Original file line number Diff line number Diff line change @@ -442,9 +442,26 @@ static int smb_handle_negotiate(struct ksmbd_work *work)
442
442
{
443
443
struct smb_negotiate_rsp * neg_rsp = work -> response_buf ;
444
444
445
- ksmbd_debug (SMB , "Unsupported SMB protocol\n" );
446
- neg_rsp -> hdr .Status .CifsError = STATUS_INVALID_LOGON_TYPE ;
447
- return - EINVAL ;
445
+ ksmbd_debug (SMB , "Unsupported SMB1 protocol\n" );
446
+
447
+ /*
448
+ * Remove 4 byte direct TCP header, add 2 byte bcc and
449
+ * 2 byte DialectIndex.
450
+ */
451
+ * (__be32 * )work -> response_buf =
452
+ cpu_to_be32 (sizeof (struct smb_hdr ) - 4 + 2 + 2 );
453
+ neg_rsp -> hdr .Status .CifsError = STATUS_SUCCESS ;
454
+
455
+ neg_rsp -> hdr .Command = SMB_COM_NEGOTIATE ;
456
+ * (__le32 * )neg_rsp -> hdr .Protocol = SMB1_PROTO_NUMBER ;
457
+ neg_rsp -> hdr .Flags = SMBFLG_RESPONSE ;
458
+ neg_rsp -> hdr .Flags2 = SMBFLG2_UNICODE | SMBFLG2_ERR_STATUS |
459
+ SMBFLG2_EXT_SEC | SMBFLG2_IS_LONG_NAME ;
460
+
461
+ neg_rsp -> hdr .WordCount = 1 ;
462
+ neg_rsp -> DialectIndex = cpu_to_le16 (work -> conn -> dialect );
463
+ neg_rsp -> ByteCount = 0 ;
464
+ return 0 ;
448
465
}
449
466
450
467
int ksmbd_smb_negotiate_common (struct ksmbd_work * work , unsigned int command )
Original file line number Diff line number Diff line change 158
158
159
159
#define SMB1_PROTO_NUMBER cpu_to_le32(0x424d53ff)
160
160
#define SMB_COM_NEGOTIATE 0x72
161
-
162
161
#define SMB1_CLIENT_GUID_SIZE (16)
162
+
163
+ #define SMBFLG_RESPONSE 0x80 /* this PDU is a response from server */
164
+
165
+ #define SMBFLG2_IS_LONG_NAME cpu_to_le16(0x40)
166
+ #define SMBFLG2_EXT_SEC cpu_to_le16(0x800)
167
+ #define SMBFLG2_ERR_STATUS cpu_to_le16(0x4000)
168
+ #define SMBFLG2_UNICODE cpu_to_le16(0x8000)
169
+
163
170
struct smb_hdr {
164
171
__be32 smb_buf_length ;
165
172
__u8 Protocol [4 ];
@@ -199,28 +206,7 @@ struct smb_negotiate_req {
199
206
struct smb_negotiate_rsp {
200
207
struct smb_hdr hdr ; /* wct = 17 */
201
208
__le16 DialectIndex ; /* 0xFFFF = no dialect acceptable */
202
- __u8 SecurityMode ;
203
- __le16 MaxMpxCount ;
204
- __le16 MaxNumberVcs ;
205
- __le32 MaxBufferSize ;
206
- __le32 MaxRawSize ;
207
- __le32 SessionKey ;
208
- __le32 Capabilities ; /* see below */
209
- __le32 SystemTimeLow ;
210
- __le32 SystemTimeHigh ;
211
- __le16 ServerTimeZone ;
212
- __u8 EncryptionKeyLength ;
213
209
__le16 ByteCount ;
214
- union {
215
- unsigned char EncryptionKey [8 ]; /* cap extended security off */
216
- /* followed by Domain name - if extended security is off */
217
- /* followed by 16 bytes of server GUID */
218
- /* then security blob if cap_extended_security negotiated */
219
- struct {
220
- unsigned char GUID [SMB1_CLIENT_GUID_SIZE ];
221
- unsigned char SecurityBlob [1 ];
222
- } __packed extended_response ;
223
- } __packed u ;
224
210
} __packed ;
225
211
226
212
struct filesystem_attribute_info {
You can’t perform that action at this time.
0 commit comments