Skip to contentSkip to conversation

smb/server: fix minimum PDU size

PATCH Applied [email protected] 3 participants 7 messages Dec 20, 2025 – Dec 21, 2025

Subsystems (2)
lore
Share & tools
lore
#1 lore raw

PATCH v4 1/2 smb/server: fix minimum SMB1 PDU size

From: ChenXiaoSong <[email protected]>

Since the RFC1002 header has been removed from struct smb_hdr, the minimum SMB1 PDU size should be updated as well.

Fixes 83bfbd0bb902 ("cifs: Remove the RFC1002 header from smb_hdr")
---
 fs/smb/server/connection.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
fs/smb/server/connection.c +3 -2
index b6b4f1286b9c..c801edd6f1ae 100644
@@ -295,7 +295,8 @@ bool ksmbd_conn_alive(struct ksmbd_conn *conn)
 	return true;
 }
 
-#define SMB1_MIN_SUPPORTED_HEADER_SIZE (sizeof(struct smb_hdr))
+/* "+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)
 
 /**
@@ -363,7 +364,7 @@ int ksmbd_conn_handler_loop(void *p)
 		if (pdu_size > MAX_STREAM_PROT_LEN)
 			break;
 
-		if (pdu_size < SMB1_MIN_SUPPORTED_HEADER_SIZE)
+		if (pdu_size < SMB1_MIN_SUPPORTED_PDU_SIZE)
 			break;
 
 		/* 4 for rfc1002 length field */
Signature · 1 line
2.43.0
#2 lore raw

PATCH v4 2/2 smb/server: fix minimum SMB2 PDU size

In reply to [email protected]

From: ChenXiaoSong <[email protected]>

The minimum SMB2 PDU size should be updated to the size of struct smb2_pdu (that is, the size of struct smb2_hdr + 2).

---
 fs/smb/server/connection.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/smb/server/connection.c +2 -2
index c801edd6f1ae..22ee1a9b3f43 100644
@@ -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 @@ int ksmbd_conn_handler_loop(void *p)
 
 		if (((struct smb2_hdr *)smb2_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;
 		}
 
Signature · 1 line
2.43.0
Reviewed-by on v4 2/2
#3 lore raw

Re: [PATCH v4 2/2] smb/server: fix minimum SMB2 PDU size

Quoted 2 lines · [email protected] wrote:

The minimum SMB2 PDU size should be updated to the size of struct smb2_pdu (that is, the size of struct smb2_hdr + 2).

smb_hdr + 4.

but, apart from that:

to both.

Do you actually need two patches for this? Though granted, only the first one is an actual fix.

David

#4 lore raw

Re: [PATCH v4 2/2] smb/server: fix minimum SMB2 PDU size

Quoted 5 lines · David Howells
Quoted 2 lines · [email protected] wrote:

The minimum SMB2 PDU size should be updated to the size of struct smb2_pdu (that is, the size of struct smb2_hdr + 2).

smb_hdr + 4.

Thanks for your review.

Do you mean "smb_hdr2 + 4"?

Do you mean that the commit message should be changed to "the size of struct smb2_hdr + 4"?

struct smb2_pdu contains smb2_hdr and __le16 StructureSize2, and sizeof(StructureSize2) is 2.

Thanks,
ChenXiaoSong.

#5 lore raw

Re: [PATCH v4 2/2] smb/server: fix minimum SMB2 PDU size

In reply to David Howells
Quoted 2 lines · David Howells

Do you actually need two patches for this? Though granted, only the first one is an actual fix.

The first patch fixes an SMB1 issue we are currently encountering, and the second patch fixes a potential SMB2 issue.

Thanks,
ChenXiaoSong.

maintainer Applied
#6 lore raw
In reply to [email protected]
Quoted 7 lines · On Sat, Dec 20, 2025 at 10:26 PM <[email protected]> wrote:

From: ChenXiaoSong <[email protected]>

v3: https://lore.kernel.org/linux-cifs/[email protected]/
v3->v4:
- Patch #01: remove struct smb_pdu

Quoted 6 lines

ChenXiaoSong (2):
smb/server: fix minimum SMB1 PDU size
smb/server: fix minimum SMB2 PDU size

 fs/smb/server/connection.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Applied them to #ksmbd-for-next-next.
Thanks!

Quoted 4 lines

--
2.43.0