]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
smb/server: fix minimum SMB2 PDU size
authorChenXiaoSong <chenxiaosong@kylinos.cn>
Sat, 20 Dec 2025 13:25:51 +0000 (21:25 +0800)
committerSteve French <stfrench@microsoft.com>
Mon, 22 Dec 2025 01:20:46 +0000 (19:20 -0600)
The minimum SMB2 PDU size should be updated to the size of
`struct smb2_pdu` (that is, the size of `struct smb2_hdr` + 2).

Suggested-by: David Howells <dhowells@redhat.com>
Suggested-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Reviewed-by: David Howells <dhowells@redhat.com>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/server/connection.c

index 487b5562c77114e6a1308ad9335a124662fde610..6cac48c8fbe8e3af7440d9aebb4dc427a699d9f3 100644 (file)
@@ -297,7 +297,7 @@ bool ksmbd_conn_alive(struct ksmbd_conn *conn)
 
 /* "+2" for BCC field (ByteCount, 2 bytes) */
 #define SMB1_MIN_SUPPORTED_PDU_SIZE (sizeof(struct smb_hdr) + 2)
-#define SMB2_MIN_SUPPORTED_HEADER_SIZE (sizeof(struct smb2_hdr) + 4)
+#define SMB2_MIN_SUPPORTED_PDU_SIZE (sizeof(struct smb2_pdu))
 
 /**
  * ksmbd_conn_handler_loop() - session thread to listen on new smb requests
@@ -397,7 +397,7 @@ recheck:
 
                if (((struct smb2_hdr *)smb_get_msg(conn->request_buf))->ProtocolId ==
                    SMB2_PROTO_NUMBER) {
-                       if (pdu_size < SMB2_MIN_SUPPORTED_HEADER_SIZE)
+                       if (pdu_size < SMB2_MIN_SUPPORTED_PDU_SIZE)
                                break;
                }