* [PATCH v9 0/1] smb: move duplicate definitions to common header file
@ 2025-11-17 11:28 chenxiaosong.chenxiaosong
2025-11-17 11:28 ` [PATCH v9 1/1] smb: move FILE_SYSTEM_ATTRIBUTE_INFO to common/fscc.h chenxiaosong.chenxiaosong
0 siblings, 1 reply; 3+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-11-17 11:28 UTC (permalink / raw)
To: sfrench, smfrench, linkinjeon, linkinjeon, christophe.jaillet
Cc: linux-cifs, linux-kernel, chenxiaosong, ChenXiaoSong
From: ChenXiaoSong <chenxiaosong@kylinos.cn>
I have tested the relevant code related to FILE_SYSTEM_ATTRIBUTE_INFO: https://chenxiaosong.com/en/FILE_SYSTEM_ATTRIBUTE_INFO.html
I have tested all patches using xfstests and smbtorture, and no additional
test failures were observed in the results. The detailed test results can
be found in https://chenxiaosong.com/en/smb-test-20251117.html
v3: https://lore.kernel.org/all/20251014071917.3004573-1-chenxiaosong.chenxiaosong@linux.dev/
The following patches from v3 have already been merged into the mainline:
- d877470b5991 smb: move some duplicate definitions to common/cifsglob.h
- 379510a815cb smb/server: fix possible refcount leak in smb2_sess_setup()
- 6fced056d2cc smb/server: fix possible memory leak in smb2_read()
v4: https://lore.kernel.org/all/20251027071316.3468472-1-chenxiaosong.chenxiaosong@linux.dev/
v5: https://lore.kernel.org/all/20251102073059.3681026-1-chenxiaosong.chenxiaosong@linux.dev/
v7: https://lore.kernel.org/all/20251113133252.145867-1-chenxiaosong.chenxiaosong@linux.dev/
The following patches from v4 v5 v7 have been applied to the ksmbd-for-next-next branch: https://git.samba.org/?p=ksmbd.git;a=shortlog;h=refs/heads/ksmbd-for-next-next
- smb: move create_durable_reconn to common/smb2pdu.h
- smb: fix some warnings reported by scripts/checkpatch.pl
- smb: do some cleanups
- smb: move FILE_SYSTEM_SIZE_INFO to common/fscc.h
- smb: move some duplicate struct definitions to common/fscc.h
- smb: move list of FileSystemAttributes to common/fscc.h
- smb: move SMB_NEGOTIATE_REQ to common/smb2pdu.h
- smb: move some duplicate definitions to common/smb2pdu.h
- smb: move create_durable_rsp_v2 to common/smb2pdu.h
- smb: move create_durable_handle_reconnect_v2 to common/smb2pdu.h
- smb: move create_durable_req_v2 to common/smb2pdu.h
- smb: move MAX_CIFS_SMALL_BUFFER_SIZE to common/smbglob.h
- smb/client: fix CAP_BULK_TRANSFER value
- smb: move resume_key_ioctl_rsp to common/smb2pdu.h
- smb: move copychunk definitions to common/smb2pdu.h
- smb: move smb_sockaddr_in and smb_sockaddr_in6 to common/smb2pdu.h
- smb: move SMB1_PROTO_NUMBER to common/smbglob.h
- smb: move get_rfc1002_len() to common/smbglob.h
- smb: move smb_version_values to common/smbglob.h
- smb: rename common/cifsglob.h to common/smbglob.h
v8: https://lore.kernel.org/all/20251116065213.282598-1-chenxiaosong.chenxiaosong@linux.dev/
v8->v9:
- SMB2_QFS_attr(): memcpy(..., min_len)
- Fix typo: FS-FSCC -> MS-FSCC
ChenXiaoSong (1):
smb: move FILE_SYSTEM_ATTRIBUTE_INFO to common/fscc.h
fs/smb/client/cifspdu.h | 10 ----------
fs/smb/client/smb2pdu.c | 6 +++---
fs/smb/common/fscc.h | 9 +++++++++
fs/smb/server/smb2pdu.c | 6 +++---
fs/smb/server/smb_common.h | 7 -------
5 files changed, 15 insertions(+), 23 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v9 1/1] smb: move FILE_SYSTEM_ATTRIBUTE_INFO to common/fscc.h
2025-11-17 11:28 [PATCH v9 0/1] smb: move duplicate definitions to common header file chenxiaosong.chenxiaosong
@ 2025-11-17 11:28 ` chenxiaosong.chenxiaosong
2025-11-18 0:56 ` Namjae Jeon
0 siblings, 1 reply; 3+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-11-17 11:28 UTC (permalink / raw)
To: sfrench, smfrench, linkinjeon, linkinjeon, christophe.jaillet
Cc: linux-cifs, linux-kernel, chenxiaosong, ChenXiaoSong
From: ChenXiaoSong <chenxiaosong@kylinos.cn>
Modify the following places:
- struct filesystem_attribute_info -> FILE_SYSTEM_ATTRIBUTE_INFO
- Remove MIN_FS_ATTR_INFO_SIZE definition
- Introduce MAX_FS_NAME_LEN
- max_len of FileFsAttributeInformation -> sizeof(FILE_SYSTEM_ATTRIBUTE_INFO) + MAX_FS_NAME_LEN
- min_len of FileFsAttributeInformation -> sizeof(FILE_SYSTEM_ATTRIBUTE_INFO)
- SMB2_QFS_attr(): memcpy(..., min_len)
Then move FILE_SYSTEM_ATTRIBUTE_INFO to common header file.
I have tested the relevant code related to FILE_SYSTEM_ATTRIBUTE_INFO (Link[1]).
Link[1]: https://chenxiaosong.com/en/FILE_SYSTEM_ATTRIBUTE_INFO.html
Suggested-by: Namjae Jeon <linkinjeon@kernel.org>
Tested-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
fs/smb/client/cifspdu.h | 10 ----------
fs/smb/client/smb2pdu.c | 6 +++---
fs/smb/common/fscc.h | 9 +++++++++
fs/smb/server/smb2pdu.c | 6 +++---
fs/smb/server/smb_common.h | 7 -------
5 files changed, 15 insertions(+), 23 deletions(-)
diff --git a/fs/smb/client/cifspdu.h b/fs/smb/client/cifspdu.h
index d84e10b1477f..49f35cb3cf2e 100644
--- a/fs/smb/client/cifspdu.h
+++ b/fs/smb/client/cifspdu.h
@@ -2068,16 +2068,6 @@ typedef struct {
#define FILE_PORTABLE_DEVICE 0x00004000
#define FILE_DEVICE_ALLOW_APPCONTAINER_TRAVERSAL 0x00020000
-/* minimum includes first three fields, and empty FS Name */
-#define MIN_FS_ATTR_INFO_SIZE 12
-
-typedef struct {
- __le32 Attributes;
- __le32 MaxPathNameComponentLength;
- __le32 FileSystemNameLen;
- char FileSystemName[52]; /* do not have to save this - get subset? */
-} __attribute__((packed)) FILE_SYSTEM_ATTRIBUTE_INFO;
-
/******************************************************************************/
/* QueryFileInfo/QueryPathinfo (also for SetPath/SetFile) data buffer formats */
/******************************************************************************/
diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c
index 032b4b037f07..ef2c6ac500f7 100644
--- a/fs/smb/client/smb2pdu.c
+++ b/fs/smb/client/smb2pdu.c
@@ -5981,8 +5981,8 @@ SMB2_QFS_attr(const unsigned int xid, struct cifs_tcon *tcon,
max_len = sizeof(FILE_SYSTEM_DEVICE_INFO);
min_len = sizeof(FILE_SYSTEM_DEVICE_INFO);
} else if (level == FS_ATTRIBUTE_INFORMATION) {
- max_len = sizeof(FILE_SYSTEM_ATTRIBUTE_INFO);
- min_len = MIN_FS_ATTR_INFO_SIZE;
+ max_len = sizeof(FILE_SYSTEM_ATTRIBUTE_INFO) + MAX_FS_NAME_LEN;
+ min_len = sizeof(FILE_SYSTEM_ATTRIBUTE_INFO);
} else if (level == FS_SECTOR_SIZE_INFORMATION) {
max_len = sizeof(struct smb3_fs_ss_info);
min_len = sizeof(struct smb3_fs_ss_info);
@@ -6028,7 +6028,7 @@ SMB2_QFS_attr(const unsigned int xid, struct cifs_tcon *tcon,
if (level == FS_ATTRIBUTE_INFORMATION)
memcpy(&tcon->fsAttrInfo, offset
+ (char *)rsp, min_t(unsigned int,
- rsp_len, max_len));
+ rsp_len, min_len));
else if (level == FS_DEVICE_INFORMATION)
memcpy(&tcon->fsDevInfo, offset
+ (char *)rsp, sizeof(FILE_SYSTEM_DEVICE_INFO));
diff --git a/fs/smb/common/fscc.h b/fs/smb/common/fscc.h
index a0580a772a41..35dbacdbb902 100644
--- a/fs/smb/common/fscc.h
+++ b/fs/smb/common/fscc.h
@@ -94,6 +94,15 @@ struct smb2_file_network_open_info {
__le32 Reserved;
} __packed; /* level 34 Query also similar returned in close rsp and open rsp */
+/* See MS-FSCC 2.5.1 */
+#define MAX_FS_NAME_LEN 52
+typedef struct {
+ __le32 Attributes;
+ __le32 MaxPathNameComponentLength;
+ __le32 FileSystemNameLen;
+ __le16 FileSystemName[]; /* do not have to save this - get subset? */
+} __packed FILE_SYSTEM_ATTRIBUTE_INFO;
+
/* List of FileSystemAttributes - see MS-FSCC 2.5.1 */
#define FILE_SUPPORTS_SPARSE_VDL 0x10000000 /* faster nonsparse extend */
#define FILE_SUPPORTS_BLOCK_REFCOUNTING 0x08000000 /* allow ioctl dup extents */
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index c71f156cc64a..1c8935f61150 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -5492,10 +5492,10 @@ static int smb2_get_info_filesystem(struct ksmbd_work *work,
}
case FS_ATTRIBUTE_INFORMATION:
{
- struct filesystem_attribute_info *info;
+ FILE_SYSTEM_ATTRIBUTE_INFO *info;
size_t sz;
- info = (struct filesystem_attribute_info *)rsp->Buffer;
+ info = (FILE_SYSTEM_ATTRIBUTE_INFO *)rsp->Buffer;
info->Attributes = cpu_to_le32(FILE_SUPPORTS_OBJECT_IDS |
FILE_PERSISTENT_ACLS |
FILE_UNICODE_ON_DISK |
@@ -5514,7 +5514,7 @@ static int smb2_get_info_filesystem(struct ksmbd_work *work,
"NTFS", PATH_MAX, conn->local_nls, 0);
len = len * 2;
info->FileSystemNameLen = cpu_to_le32(len);
- sz = sizeof(struct filesystem_attribute_info) + len;
+ sz = sizeof(FILE_SYSTEM_ATTRIBUTE_INFO) + len;
rsp->OutputBufferLength = cpu_to_le32(sz);
break;
}
diff --git a/fs/smb/server/smb_common.h b/fs/smb/server/smb_common.h
index 4dd573c5f0b2..6c1607b43eb3 100644
--- a/fs/smb/server/smb_common.h
+++ b/fs/smb/server/smb_common.h
@@ -90,13 +90,6 @@ struct smb_negotiate_rsp {
__le16 ByteCount;
} __packed;
-struct filesystem_attribute_info {
- __le32 Attributes;
- __le32 MaxPathNameComponentLength;
- __le32 FileSystemNameLen;
- __le16 FileSystemName[]; /* do not have to save this - get subset? */
-} __packed;
-
struct filesystem_vol_info {
__le64 VolumeCreationTime;
__le32 SerialNumber;
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v9 1/1] smb: move FILE_SYSTEM_ATTRIBUTE_INFO to common/fscc.h
2025-11-17 11:28 ` [PATCH v9 1/1] smb: move FILE_SYSTEM_ATTRIBUTE_INFO to common/fscc.h chenxiaosong.chenxiaosong
@ 2025-11-18 0:56 ` Namjae Jeon
0 siblings, 0 replies; 3+ messages in thread
From: Namjae Jeon @ 2025-11-18 0:56 UTC (permalink / raw)
To: chenxiaosong.chenxiaosong
Cc: sfrench, smfrench, linkinjeon, christophe.jaillet, linux-cifs,
linux-kernel, chenxiaosong, ChenXiaoSong
On Mon, Nov 17, 2025 at 8:29 PM <chenxiaosong.chenxiaosong@linux.dev> wrote:
>
> From: ChenXiaoSong <chenxiaosong@kylinos.cn>
>
> Modify the following places:
>
> - struct filesystem_attribute_info -> FILE_SYSTEM_ATTRIBUTE_INFO
> - Remove MIN_FS_ATTR_INFO_SIZE definition
> - Introduce MAX_FS_NAME_LEN
> - max_len of FileFsAttributeInformation -> sizeof(FILE_SYSTEM_ATTRIBUTE_INFO) + MAX_FS_NAME_LEN
> - min_len of FileFsAttributeInformation -> sizeof(FILE_SYSTEM_ATTRIBUTE_INFO)
> - SMB2_QFS_attr(): memcpy(..., min_len)
>
> Then move FILE_SYSTEM_ATTRIBUTE_INFO to common header file.
>
> I have tested the relevant code related to FILE_SYSTEM_ATTRIBUTE_INFO (Link[1]).
>
> Link[1]: https://chenxiaosong.com/en/FILE_SYSTEM_ATTRIBUTE_INFO.html
> Suggested-by: Namjae Jeon <linkinjeon@kernel.org>
> Tested-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
> Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Applied it to #ksmbd-for-next-next.
Thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-11-18 0:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-17 11:28 [PATCH v9 0/1] smb: move duplicate definitions to common header file chenxiaosong.chenxiaosong
2025-11-17 11:28 ` [PATCH v9 1/1] smb: move FILE_SYSTEM_ATTRIBUTE_INFO to common/fscc.h chenxiaosong.chenxiaosong
2025-11-18 0:56 ` Namjae Jeon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).