File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -319,13 +319,10 @@ int ksmbd_conn_handler_loop(void *p)
319319 }
320320
321321 /*
322- * Check if pdu size is valid (min : smb header size,
323- * max : 0x00FFFFFF).
322+ * Check maximum pdu size(0x00FFFFFF).
324323 */
325- if (pdu_size < __SMB2_HEADER_STRUCTURE_SIZE ||
326- pdu_size > MAX_STREAM_PROT_LEN ) {
324+ if (pdu_size > MAX_STREAM_PROT_LEN )
327325 break ;
328- }
329326
330327 /* 4 for rfc1002 length field */
331328 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)
442442{
443443 struct smb_negotiate_rsp * neg_rsp = work -> response_buf ;
444444
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 ;
448465}
449466
450467int ksmbd_smb_negotiate_common (struct ksmbd_work * work , unsigned int command )
Original file line number Diff line number Diff line change 158158
159159#define SMB1_PROTO_NUMBER cpu_to_le32(0x424d53ff)
160160#define SMB_COM_NEGOTIATE 0x72
161-
162161#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+
163170struct smb_hdr {
164171 __be32 smb_buf_length ;
165172 __u8 Protocol [4 ];
@@ -199,28 +206,7 @@ struct smb_negotiate_req {
199206struct smb_negotiate_rsp {
200207 struct smb_hdr hdr ; /* wct = 17 */
201208 __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 ;
213209 __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 ;
224210} __packed ;
225211
226212struct filesystem_attribute_info {
You can’t perform that action at this time.
0 commit comments