* [PATCH v4 1/2] smb/server: fix minimum SMB1 PDU size
2025-12-20 13:25 [PATCH v4 0/2] smb/server: fix minimum PDU size chenxiaosong.chenxiaosong
@ 2025-12-20 13:25 ` chenxiaosong.chenxiaosong
2025-12-20 13:25 ` [PATCH v4 2/2] smb/server: fix minimum SMB2 " chenxiaosong.chenxiaosong
2025-12-21 22:51 ` [PATCH v4 0/2] smb/server: fix minimum " Namjae Jeon
2 siblings, 0 replies; 7+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-12-20 13:25 UTC (permalink / raw)
To: sfrench, smfrench, linkinjeon, linkinjeon, pc, ronniesahlberg,
sprasad, tom, bharathsm, senozhatsky, dhowells
Cc: linux-cifs, ChenXiaoSong
From: ChenXiaoSong <chenxiaosong@kylinos.cn>
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")
Suggested-by: David Howells <dhowells@redhat.com>
Suggested-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
fs/smb/server/connection.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/fs/smb/server/connection.c b/fs/smb/server/connection.c
index b6b4f1286b9c..c801edd6f1ae 100644
--- a/fs/smb/server/connection.c
+++ b/fs/smb/server/connection.c
@@ -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 */
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH v4 2/2] smb/server: fix minimum SMB2 PDU size
2025-12-20 13:25 [PATCH v4 0/2] smb/server: fix minimum PDU size chenxiaosong.chenxiaosong
2025-12-20 13:25 ` [PATCH v4 1/2] smb/server: fix minimum SMB1 " chenxiaosong.chenxiaosong
@ 2025-12-20 13:25 ` chenxiaosong.chenxiaosong
2025-12-20 15:19 ` David Howells
2025-12-21 22:51 ` [PATCH v4 0/2] smb/server: fix minimum " Namjae Jeon
2 siblings, 1 reply; 7+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-12-20 13:25 UTC (permalink / raw)
To: sfrench, smfrench, linkinjeon, linkinjeon, pc, ronniesahlberg,
sprasad, tom, bharathsm, senozhatsky, dhowells
Cc: linux-cifs, ChenXiaoSong
From: ChenXiaoSong <chenxiaosong@kylinos.cn>
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>
---
fs/smb/server/connection.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/smb/server/connection.c b/fs/smb/server/connection.c
index c801edd6f1ae..22ee1a9b3f43 100644
--- a/fs/smb/server/connection.c
+++ b/fs/smb/server/connection.c
@@ -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;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH v4 2/2] smb/server: fix minimum SMB2 PDU size
2025-12-20 13:25 ` [PATCH v4 2/2] smb/server: fix minimum SMB2 " chenxiaosong.chenxiaosong
@ 2025-12-20 15:19 ` David Howells
2025-12-20 15:50 ` ChenXiaoSong
2025-12-20 15:59 ` ChenXiaoSong
0 siblings, 2 replies; 7+ messages in thread
From: David Howells @ 2025-12-20 15:19 UTC (permalink / raw)
To: chenxiaosong.chenxiaosong
Cc: dhowells, sfrench, smfrench, linkinjeon, linkinjeon, pc,
ronniesahlberg, sprasad, tom, bharathsm, senozhatsky, linux-cifs,
ChenXiaoSong
chenxiaosong.chenxiaosong@linux.dev 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:
Reviewed-by: David Howells <dhowells@redhat.com>
to both.
Do you actually need two patches for this? Though granted, only the first one
is an actual fix.
David
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v4 2/2] smb/server: fix minimum SMB2 PDU size
2025-12-20 15:19 ` David Howells
@ 2025-12-20 15:50 ` ChenXiaoSong
2025-12-20 15:59 ` ChenXiaoSong
1 sibling, 0 replies; 7+ messages in thread
From: ChenXiaoSong @ 2025-12-20 15:50 UTC (permalink / raw)
To: David Howells
Cc: sfrench, smfrench, linkinjeon, linkinjeon, pc, ronniesahlberg,
sprasad, tom, bharathsm, senozhatsky, linux-cifs, ChenXiaoSong
On 12/20/25 11:19 PM, David Howells wrote:
> chenxiaosong.chenxiaosong@linux.dev 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.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v4 2/2] smb/server: fix minimum SMB2 PDU size
2025-12-20 15:19 ` David Howells
2025-12-20 15:50 ` ChenXiaoSong
@ 2025-12-20 15:59 ` ChenXiaoSong
1 sibling, 0 replies; 7+ messages in thread
From: ChenXiaoSong @ 2025-12-20 15:59 UTC (permalink / raw)
To: David Howells
Cc: sfrench, smfrench, linkinjeon, linkinjeon, pc, ronniesahlberg,
sprasad, tom, bharathsm, senozhatsky, linux-cifs
On 12/20/25 11:19 PM, David Howells wrote:
> 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.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v4 0/2] smb/server: fix minimum PDU size
2025-12-20 13:25 [PATCH v4 0/2] smb/server: fix minimum PDU size chenxiaosong.chenxiaosong
2025-12-20 13:25 ` [PATCH v4 1/2] smb/server: fix minimum SMB1 " chenxiaosong.chenxiaosong
2025-12-20 13:25 ` [PATCH v4 2/2] smb/server: fix minimum SMB2 " chenxiaosong.chenxiaosong
@ 2025-12-21 22:51 ` Namjae Jeon
2 siblings, 0 replies; 7+ messages in thread
From: Namjae Jeon @ 2025-12-21 22:51 UTC (permalink / raw)
To: chenxiaosong.chenxiaosong
Cc: sfrench, smfrench, linkinjeon, pc, ronniesahlberg, sprasad, tom,
bharathsm, senozhatsky, dhowells, linux-cifs, ChenXiaoSong
On Sat, Dec 20, 2025 at 10:26 PM <chenxiaosong.chenxiaosong@linux.dev> wrote:
>
> From: ChenXiaoSong <chenxiaosong@kylinos.cn>
>
> v3: https://lore.kernel.org/linux-cifs/20251219235419.338880-1-chenxiaosong.chenxiaosong@linux.dev/
> v3->v4:
> - Patch #01: remove `struct smb_pdu`
>
> 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!
>
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 7+ messages in thread