All of lore.kernel.org
 help / color / mirror / Atom feed
From: chenxiaosong.chenxiaosong@linux.dev
To: sfrench@samba.org, smfrench@gmail.com, linkinjeon@kernel.org,
	linkinjeon@samba.org, pc@manguebit.org, ronniesahlberg@gmail.com,
	sprasad@microsoft.com, tom@talpey.com, bharathsm@microsoft.com,
	senozhatsky@chromium.org, dhowells@redhat.com
Cc: linux-cifs@vger.kernel.org, ChenXiaoSong <chenxiaosong@kylinos.cn>
Subject: [PATCH RFC v2 3/3] smb: use sizeof() to get __SMB2_HEADER_STRUCTURE_SIZE
Date: Sat, 20 Dec 2025 01:00:57 +0800	[thread overview]
Message-ID: <20251219170057.337496-4-chenxiaosong.chenxiaosong@linux.dev> (raw)
In-Reply-To: <20251219170057.337496-1-chenxiaosong.chenxiaosong@linux.dev>

From: ChenXiaoSong <chenxiaosong@kylinos.cn>

I have checked the size of the structure using GDB:

  gdb ./build/fs/smb/server/ksmbd.ko
  (gdb) p sizeof(struct smb2_hdr)
  $1 = 64

  gdb ./build/fs/smb/client/cifs.ko
  (gdb) p sizeof(struct smb2_hdr)
  $1 = 64

Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
 fs/smb/common/smb2pdu.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/smb/common/smb2pdu.h b/fs/smb/common/smb2pdu.h
index f5ebbe31384a..f2a6b7191f43 100644
--- a/fs/smb/common/smb2pdu.h
+++ b/fs/smb/common/smb2pdu.h
@@ -107,10 +107,6 @@
  *
  */
 
-#define __SMB2_HEADER_STRUCTURE_SIZE	64
-#define SMB2_HEADER_STRUCTURE_SIZE				\
-	cpu_to_le16(__SMB2_HEADER_STRUCTURE_SIZE)
-
 #define SMB2_PROTO_NUMBER cpu_to_le32(0x424d53fe)
 #define SMB2_TRANSFORM_PROTO_NUM cpu_to_le32(0x424d53fd)
 #define SMB2_COMPRESSION_TRANSFORM_ID cpu_to_le32(0x424d53fc)
@@ -157,6 +153,10 @@ struct smb2_hdr {
 	__u8   Signature[16];
 } __packed;
 
+#define __SMB2_HEADER_STRUCTURE_SIZE	(sizeof(struct smb2_hdr))
+#define SMB2_HEADER_STRUCTURE_SIZE				\
+	cpu_to_le16(__SMB2_HEADER_STRUCTURE_SIZE)
+
 struct smb3_hdr_req {
 	__le32 ProtocolId;	/* 0xFE 'S' 'M' 'B' */
 	__le16 StructureSize;	/* 64 */
-- 
2.43.0


      parent reply	other threads:[~2025-12-19 17:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-19 17:00 [PATCH RFC v2 0/3] smb: fix minimum PDU size chenxiaosong.chenxiaosong
2025-12-19 17:00 ` [PATCH RFC v2 1/3] smb/server: fix minimum SMB1 " chenxiaosong.chenxiaosong
2025-12-19 17:00 ` [PATCH RFC v2 2/3] smb/server: fix minimum SMB2 " chenxiaosong.chenxiaosong
2025-12-19 17:00 ` chenxiaosong.chenxiaosong [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251219170057.337496-4-chenxiaosong.chenxiaosong@linux.dev \
    --to=chenxiaosong.chenxiaosong@linux.dev \
    --cc=bharathsm@microsoft.com \
    --cc=chenxiaosong@kylinos.cn \
    --cc=dhowells@redhat.com \
    --cc=linkinjeon@kernel.org \
    --cc=linkinjeon@samba.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=pc@manguebit.org \
    --cc=ronniesahlberg@gmail.com \
    --cc=senozhatsky@chromium.org \
    --cc=sfrench@samba.org \
    --cc=smfrench@gmail.com \
    --cc=sprasad@microsoft.com \
    --cc=tom@talpey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.