smb: fix some bugs, move duplicate definitions into common header file, part 2
Subsystems (2)
v5 cover smb: fix some bugs, move duplicate definitions into common header file, part 2
From: ZhangGuoDong <[email protected]>
v4->v5:
- Add patch #01 #02 #03
- Patch #06: keep vol_serial_number as u32 in smb_mnt_fs_info and cifs_tcon
- Patch #07:
- Add new flexible array member sids_and_name[] to file_posix_info
- smb311_posix_qinfo -> file_posix_info
v4: https://lore.kernel.org/linux-cifs/[email protected]/
v1: https://lore.kernel.org/all/[email protected]/
v2: https://lore.kernel.org/linux-cifs/[email protected]/
The following patches from v1 and v2 have already been merged into mainline:
- 94d5b8dbc5d9 smb: move some SMB1 definitions into common/smb1pdu.h
- 2b6abb893e71 smb: move File Attributes definitions into common/fscc.h
- c97503321ed3 smb: update struct duplicate_extents_to_file_ex
- 2e0d224d8988 smb/server: add comment to FileSystemName of FileFsAttributeInformation
- ab0347e67dac smb/client: remove DeviceType Flags and Device Characteristics definitions
- 08c2a7d2bae9 smb: move file_notify_information to common/fscc.h
- 6539e18517b6 smb: move SMB2 Notify Action Flags into common/smb2pdu.h
- 9ec7629b430a smb: move notify completion filter flags into common/smb2pdu.h
- bcdd6cfaf2ec smb: add documentation references for smb2 change notify definitions
The following patches from v4 have already been merged into cifs-2.6.git for-next:
- smb: update some doc references
This is a continuous effort to move duplicated definitions in both client and server into common header files, which makes the code easier to maintain.
The previous work is here:
- part 1: https://lore.kernel.org/linux-cifs/[email protected]/
ZhangGuoDong (7):
smb/client: fix buffer size for smb311_posix_qinfo in
smb2_compound_op()
smb/client: fix buffer size for smb311_posix_qinfo in
SMB311_posix_query_info() smb/client: remove unused SMB311_posix_query_info()
smb: move some definitions from common/smb2pdu.h into common/fscc.h
smb: move file_basic_info into common/fscc.h
smb: move filesystem_vol_info into common/fscc.h
smb: introduce struct file_posix_info
fs/smb/client/cifsglob.h | 2 +- fs/smb/client/inode.c | 2 +- fs/smb/client/readdir.c | 28 +-- fs/smb/client/reparse.h | 2 +- fs/smb/client/smb1pdu.h | 9 - fs/smb/client/smb2inode.c | 4 +- fs/smb/client/smb2pdu.c | 26 +-- fs/smb/client/smb2pdu.h | 21 +-- fs/smb/client/smb2proto.h | 3 - fs/smb/common/fscc.h | 371 ++++++++++++++++++++++++++++++++++++- fs/smb/common/smb2pdu.h | 343 ---------------------------------- fs/smb/server/smb2pdu.c | 65 +++---- fs/smb/server/smb2pdu.h | 30 +-- fs/smb/server/smb_common.h | 8 - 14 files changed, 428 insertions(+), 486 deletions(-)
Signature · 1 line
2.52.0
PATCH v5 1/7 smb/client: fix buffer size for smb311_posix_qinfo in smb2_compound_op()
From: ZhangGuoDong <[email protected]>
Use sizeof(struct smb311_posix_qinfo) instead of sizeof its pointer, so the allocated buffer matches the actual struct size.
--- fs/smb/client/smb2inode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/smb/client/smb2inode.c +2 -2
@@ -325,7 +325,7 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon, cfile->fid.volatile_fid,SMB_FIND_FILE_POSIX_INFO ,SMB2_O_INFO_FILE ,0 , -sizeof (struct smb311_posix_qinfo *) + +sizeof (struct smb311_posix_qinfo ) + (PATH_MAX *2 ) + (sizeof(struct smb_sid) * 2), 0, NULL); }else {
@@ -335,7 +335,7 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,COMPOUND_FID ,SMB_FIND_FILE_POSIX_INFO ,SMB2_O_INFO_FILE ,0 , -sizeof (struct smb311_posix_qinfo *) + +sizeof (struct smb311_posix_qinfo ) + (PATH_MAX *2 ) + (sizeof(struct smb_sid) * 2), 0, NULL); }
Signature · 1 line
2.52.0
Re: [PATCH v5 1/7] smb/client: fix buffer size for smb311_posix_qinfo in smb2_compound_op()
Good catch - were you able to repro a crash or other bug when running without the patch?
Quoted 39 lines · On Tue, Mar 3, 2026 at 9:14 AM <[email protected]> wrote:
From: ZhangGuoDong <[email protected]>
Use
sizeof(struct smb311_posix_qinfo)instead of sizeof its pointer, so the allocated buffer matches the actual struct size.Fixes 6a5f6592a0b6 ("SMB311: Add support for query info using posix extensions (level 100)")Reported-by ChenXiaoSong <[email protected]>Signed-off-by ZhangGuoDong <[email protected]>Reviewed-by ChenXiaoSong <[email protected]>--- fs/smb/client/smb2inode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)fs/smb/client/smb2inode.c +2
-3@@ -325,7 +325,7 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon, cfile->fid.volatile_fid,SMB_FIND_FILE_POSIX_INFO ,SMB2_O_INFO_FILE ,0 , -sizeof (struct smb311_posix_qinfo *) + +sizeof (struct smb311_posix_qinfo ) + (PATH_MAX *2 ) + (sizeof(struct smb_sid) * 2), 0, NULL); }else {@@ -335,7 +335,7 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,COMPOUND_FID ,SMB_FIND_FILE_POSIX_INFO ,SMB2_O_INFO_FILE ,0 , -sizeof (struct smb311_posix_qinfo *) + +sizeof (struct smb311_posix_qinfo ) + (PATH_MAX *2 ) + (sizeof(struct smb_sid) * 2), 0, NULL); } --2.52.0
Signature · 3 lines
Thanks, Steve
Re: [PATCH v5 1/7] smb/client: fix buffer size for smb311_posix_qinfo in smb2_compound_op()
I will try to test it, but this is a very obvious bug.
Quoted 2 lines · Steve French
Good catch - were you able to repro a crash or other bug when running without the patch?
Re: [PATCH v5 1/7] smb/client: fix buffer size for smb311_posix_qinfo in smb2_compound_op()
In reply to [email protected]merged into cifs-2.6.git for-next pending more testing
Quoted 39 lines · On Tue, Mar 3, 2026 at 9:14 AM <[email protected]> wrote:
From: ZhangGuoDong <[email protected]>
Use
sizeof(struct smb311_posix_qinfo)instead of sizeof its pointer, so the allocated buffer matches the actual struct size.Fixes 6a5f6592a0b6 ("SMB311: Add support for query info using posix extensions (level 100)")Reported-by ChenXiaoSong <[email protected]>Signed-off-by ZhangGuoDong <[email protected]>Reviewed-by ChenXiaoSong <[email protected]>--- fs/smb/client/smb2inode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)fs/smb/client/smb2inode.c +2
-3@@ -325,7 +325,7 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon, cfile->fid.volatile_fid,SMB_FIND_FILE_POSIX_INFO ,SMB2_O_INFO_FILE ,0 , -sizeof (struct smb311_posix_qinfo *) + +sizeof (struct smb311_posix_qinfo ) + (PATH_MAX *2 ) + (sizeof(struct smb_sid) * 2), 0, NULL); }else {@@ -335,7 +335,7 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,COMPOUND_FID ,SMB_FIND_FILE_POSIX_INFO ,SMB2_O_INFO_FILE ,0 , -sizeof (struct smb311_posix_qinfo *) + +sizeof (struct smb311_posix_qinfo ) + (PATH_MAX *2 ) + (sizeof(struct smb_sid) * 2), 0, NULL); } --2.52.0
Signature · 3 lines
Thanks, Steve
PATCH v5 2/7 smb/client: fix buffer size for smb311_posix_qinfo in SMB311_posix_query_info()
In reply to [email protected]From: ZhangGuoDong <[email protected]>
SMB311_posix_query_info() is currently unused, but it may still be used in some stable versions, so these changes are submitted as a separate patch.
Use sizeof(struct smb311_posix_qinfo) instead of sizeof its pointer, so the allocated buffer matches the actual struct size.
--- fs/smb/client/smb2pdu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/smb/client/smb2pdu.c +1 -1
@@ -3996,7 +3996,7 @@ SMB311_posix_query_info(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, u64 volatile_fid, struct smb311_posix_qinfo *data, u32 *plen) { - size_t output_len = sizeof(struct smb311_posix_qinfo *) + + size_t output_len = sizeof(struct smb311_posix_qinfo) + (sizeof (struct smb_sid ) *2 ) + (PATH_MAX *2 ); *plen =0 ;
Signature · 1 line
2.52.0
Re: [PATCH v5 2/7] smb/client: fix buffer size for smb311_posix_qinfo in SMB311_posix_query_info()
merged into cifs-2.6.git for-next pending more testing
Quoted 33 lines · On Tue, Mar 3, 2026 at 9:14 AM <[email protected]> wrote:
From: ZhangGuoDong <[email protected]>
SMB311_posix_query_info()is currently unused, but it may still be used in some stable versions, so these changes are submitted as a separate patch.Use
sizeof(struct smb311_posix_qinfo)instead of sizeof its pointer, so the allocated buffer matches the actual struct size.Fixes b1bc1874b885 ("smb311: Add support for SMB311 query info (non-compounded)")Reported-by ChenXiaoSong <[email protected]>Signed-off-by ZhangGuoDong <[email protected]>Reviewed-by ChenXiaoSong <[email protected]>--- fs/smb/client/smb2pdu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/smb/client/smb2pdu.c +1
-2@@ -3996,7 +3996,7 @@ SMB311_posix_query_info(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, u64 volatile_fid, struct smb311_posix_qinfo *data, u32 *plen) { - size_t output_len = sizeof(struct smb311_posix_qinfo *) + + size_t output_len = sizeof(struct smb311_posix_qinfo) + (sizeof (struct smb_sid ) *2 ) + (PATH_MAX *2 ); *plen =0 ; --2.52.0
Signature · 3 lines
Thanks, Steve
PATCH v5 3/7 smb/client: remove unused SMB311_posix_query_info()
In reply to [email protected]From: ZhangGuoDong <[email protected]>
It is currently unused, as now we are doing compounding instead (see smb2_query_path_info()).
--- fs/smb/client/smb2pdu.c | 18 ------------------ fs/smb/client/smb2proto.h | 3 --- 2 files changed, 21 deletions(-)
fs/smb/client/smb2pdu.c +0 -18
@@ -3989,24 +3989,6 @@ int SMB2_query_info(const unsigned int xid, struct cifs_tcon *tcon, NULL); } -#if 0 -/* currently unused, as now we are doing compounding instead (see smb311_posix_query_path_info) */ -int -SMB311_posix_query_info (const unsigned int xid,struct cifs_tcon *tcon, -u64 persistent_fid,u64 volatile_fid, -struct smb311_posix_qinfo *data,u32 *plen) -{ -size_t output_len =sizeof (struct smb311_posix_qinfo ) + - (sizeof (struct smb_sid ) *2 ) + (PATH_MAX *2 ); - *plen =0 ; - -return query_info (xid, tcon, persistent_fid, volatile_fid, -SMB_FIND_FILE_POSIX_INFO ,SMB2_O_INFO_FILE ,0 , - output_len,sizeof (struct smb311_posix_qinfo ), (void **)&data, plen); -/* Note caller must free "data" (passed in above). It may be allocated in query_info call */ -} -#endif - int SMB2_query_acl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, u64 volatile_fid,
fs/smb/client/smb2proto.h +0 -3
@@ -167,9 +167,6 @@ int SMB2_flush_init(const unsigned int xid, struct smb_rqst *rqst, struct cifs_tcon *tcon, struct TCP_Server_Info *server, u64 persistent_fid, u64 volatile_fid);void SMB2_flush_free (struct smb_rqst *rqst); -int SMB311_posix_query_info (const unsigned int xid,struct cifs_tcon *tcon, -u64 persistent_fid,u64 volatile_fid, -struct smb311_posix_qinfo *data,u32 *plen);int SMB2_query_info (const unsigned int xid,struct cifs_tcon *tcon,u64 persistent_fid,u64 volatile_fid,struct smb2_file_all_info *data);
Signature · 1 line
2.52.0
Re: [PATCH v5 3/7] smb/client: remove unused SMB311_posix_query_info()
merged into cifs-2.6.git for-next pending more testing
Quoted 59 lines · On Tue, Mar 3, 2026 at 9:14 AM <[email protected]> wrote:
From: ZhangGuoDong <[email protected]>
It is currently unused, as now we are doing compounding instead (see
smb2_query_path_info()).Signed-off-by ZhangGuoDong <[email protected]>Reviewed-by ChenXiaoSong <[email protected]>--- fs/smb/client/smb2pdu.c | 18 ------------------ fs/smb/client/smb2proto.h | 3 --- 2 files changed, 21 deletions(-)fs/smb/client/smb2pdu.c +0
-18@@ -3989,24 +3989,6 @@ int SMB2_query_info(const unsigned int xid, struct cifs_tcon *tcon, NULL); } -#if 0 -/* currently unused, as now we are doing compounding instead (see smb311_posix_query_path_info) */ -int -SMB311_posix_query_info (const unsigned int xid,struct cifs_tcon *tcon, -u64 persistent_fid,u64 volatile_fid, -struct smb311_posix_qinfo *data,u32 *plen) -{ -size_t output_len =sizeof (struct smb311_posix_qinfo ) + - (sizeof (struct smb_sid ) *2 ) + (PATH_MAX *2 ); - *plen =0 ; - -return query_info (xid, tcon, persistent_fid, volatile_fid, -SMB_FIND_FILE_POSIX_INFO ,SMB2_O_INFO_FILE ,0 , - output_len,sizeof (struct smb311_posix_qinfo ), (void **)&data, plen); -/* Note caller must free "data" (passed in above). It may be allocated in query_info call */ -} -#endif - int SMB2_query_acl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, u64 volatile_fid,fs/smb/client/smb2proto.h +0
-4@@ -167,9 +167,6 @@ int SMB2_flush_init(const unsigned int xid, struct smb_rqst *rqst, struct cifs_tcon *tcon, struct TCP_Server_Info *server, u64 persistent_fid, u64 volatile_fid);void SMB2_flush_free (struct smb_rqst *rqst); -int SMB311_posix_query_info (const unsigned int xid,struct cifs_tcon *tcon, -u64 persistent_fid,u64 volatile_fid, -struct smb311_posix_qinfo *data,u32 *plen);int SMB2_query_info (const unsigned int xid,struct cifs_tcon *tcon,u64 persistent_fid,u64 volatile_fid,struct smb2_file_all_info *data); --2.52.0
Signature · 3 lines
Thanks, Steve
PATCH v5 4/7 smb: move some definitions from common/smb2pdu.h into common/fscc.h
In reply to [email protected]From: ZhangGuoDong <[email protected]>
These definitions are specified in MS-FSCC, so move them into fscc.h.
Only add some documentation references, no other changes.
--- fs/smb/common/fscc.h | 315 ++++++++++++++++++++++++++++++++++++++++ fs/smb/common/smb2pdu.h | 307 --------------------------------------- 2 files changed, 315 insertions(+), 307 deletions(-)
fs/smb/common/fscc.h +315 -0
@@ -12,6 +12,210 @@ #ifndef _COMMON_SMB_FSCC_H #define _COMMON_SMB_FSCC_H +/* Reparse structures - see MS-FSCC 2.1.2 */ + +/* struct fsctl_reparse_info_req is empty, only response structs (see below) */ +struct reparse_data_buffer { + __le32 ReparseTag; + __le16 ReparseDataLength; + __u16 Reserved; + __u8 DataBuffer[]; /* Variable Length */ +} __packed; + +struct reparse_guid_data_buffer { + __le32 ReparseTag; + __le16 ReparseDataLength; + __u16 Reserved; + __u8 ReparseGuid[16]; + __u8 DataBuffer[]; /* Variable Length */ +} __packed; + +struct reparse_mount_point_data_buffer { + __le32 ReparseTag; + __le16 ReparseDataLength; + __u16 Reserved; + __le16 SubstituteNameOffset; + __le16 SubstituteNameLength; + __le16 PrintNameOffset; + __le16 PrintNameLength; + __u8 PathBuffer[]; /* Variable Length */ +} __packed; + +#define SYMLINK_FLAG_RELATIVE 0x00000001 + +struct reparse_symlink_data_buffer { + __le32 ReparseTag; + __le16 ReparseDataLength; + __u16 Reserved; + __le16 SubstituteNameOffset; + __le16 SubstituteNameLength; + __le16 PrintNameOffset; + __le16 PrintNameLength; + __le32 Flags; + __u8 PathBuffer[]; /* Variable Length */ +} __packed; + +/* For IO_REPARSE_TAG_NFS - see MS-FSCC 2.1.2.6 */ +#define NFS_SPECFILE_LNK 0x00000000014B4E4C +#define NFS_SPECFILE_CHR 0x0000000000524843 +#define NFS_SPECFILE_BLK 0x00000000004B4C42 +#define NFS_SPECFILE_FIFO 0x000000004F464946 +#define NFS_SPECFILE_SOCK 0x000000004B434F53 +struct reparse_nfs_data_buffer { + __le32 ReparseTag; + __le16 ReparseDataLength; + __u16 Reserved; + __le64 InodeType; /* NFS_SPECFILE_* */ + __u8 DataBuffer[]; +} __packed; + +/* For IO_REPARSE_TAG_LX_SYMLINK - see MS-FSCC 2.1.2.7 */ +struct reparse_wsl_symlink_data_buffer { + __le32 ReparseTag; + __le16 ReparseDataLength; + __u16 Reserved; + __le32 Version; /* Always 2 */ + __u8 Target[]; /* Variable Length UTF-8 string without nul-term */ +} __packed; + +/* See MS-FSCC 2.3.7 */ +struct duplicate_extents_to_file { + __u64 PersistentFileHandle; /* source file handle, opaque endianness */ + __u64 VolatileFileHandle; + __le64 SourceFileOffset; + __le64 TargetFileOffset; + __le64 ByteCount; /* Bytes to be copied */ +} __packed; + +/* See MS-FSCC 2.3.9 */ +#define DUPLICATE_EXTENTS_DATA_EX_SOURCE_ATOMIC 0x00000001 +struct duplicate_extents_to_file_ex { + __le64 StructureSize; /* MUST be set to 0x30 */ + __u64 PersistentFileHandle; /* source file handle, opaque endianness */ + __u64 VolatileFileHandle; + __le64 SourceFileOffset; + __le64 TargetFileOffset; + __le64 ByteCount; /* Bytes to be copied */ + __le32 Flags; + __le32 Reserved; +} __packed; + +/* See MS-FSCC 2.3.20 */ +struct fsctl_get_integrity_information_rsp { + __le16 ChecksumAlgorithm; + __le16 Reserved; + __le32 Flags; + __le32 ChecksumChunkSizeInBytes; + __le32 ClusterSizeInBytes; +} __packed; + +/* See MS-FSCC 2.3.52 */ +struct file_allocated_range_buffer { + __le64 file_offset; + __le64 length; +} __packed; + +/* See MS-FSCC 2.3.55 */ +struct fsctl_query_file_regions_req { + __le64 FileOffset; + __le64 Length; + __le32 DesiredUsage; + __le32 Reserved; +} __packed; + +/* DesiredUsage flags see MS-FSCC 2.3.56.1 */ +#define FILE_USAGE_INVALID_RANGE 0x00000000 +#define FILE_USAGE_VALID_CACHED_DATA 0x00000001 +#define FILE_USAGE_NONCACHED_DATA 0x00000002 +struct file_region_info { + __le64 FileOffset; + __le64 Length; + __le32 DesiredUsage; + __le32 Reserved; +} __packed; + +/* See MS-FSCC 2.3.56 */ +struct fsctl_query_file_region_rsp { + __le32 Flags; + __le32 TotalRegionEntryCount; + __le32 RegionEntryCount; + __u32 Reserved; + struct file_region_info Regions[]; +} __packed; + +/* See MS-FSCC 2.3.58 */ +struct fsctl_query_on_disk_vol_info_rsp { + __le64 DirectoryCount; + __le64 FileCount; + __le16 FsFormatMajVersion; + __le16 FsFormatMinVersion; + __u8 FsFormatName[24]; + __le64 FormatTime; + __le64 LastUpdateTime; + __u8 CopyrightInfo[68]; + __u8 AbstractInfo[68]; + __u8 FormatImplInfo[68]; + __u8 LastModifyImplInfo[68]; +} __packed; + +/* See MS-FSCC 2.3.73 */ +struct fsctl_set_integrity_information_req { + __le16 ChecksumAlgorithm; + __le16 Reserved; + __le32 Flags; +} __packed; + +/* See MS-FSCC 2.3.75 */ +struct fsctl_set_integrity_info_ex_req { + __u8 EnableIntegrity; + __u8 KeepState; + __u16 Reserved; + __le32 Flags; + __u8 Version; + __u8 Reserved2[7]; +} __packed; + +/* + * this goes in the ioctl buffer when doing FSCTL_SET_ZERO_DATA + * See MS-FSCC 2.3.85 + */ +struct file_zero_data_information { + __le64 FileOffset; + __le64 BeyondFinalZero; +} __packed; + +/* + * This level 18, although with struct with same name is different from cifs + * level 0x107. Level 0x107 has an extra u64 between AccessFlags and + * CurrentByteOffset. + * See MS-FSCC 2.4.2 + */ +struct smb2_file_all_info { /* data block encoding of response to level 18 */ + __le64 CreationTime; /* Beginning of FILE_BASIC_INFO equivalent */ + __le64 LastAccessTime; + __le64 LastWriteTime; + __le64 ChangeTime; + __le32 Attributes; + __u32 Pad1; /* End of FILE_BASIC_INFO_INFO equivalent */ + __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */ + __le64 EndOfFile; /* size ie offset to first free byte in file */ + __le32 NumberOfLinks; /* hard links */ + __u8 DeletePending; + __u8 Directory; + __u16 Pad2; /* End of FILE_STANDARD_INFO equivalent */ + __le64 IndexNumber; + __le32 EASize; + __le32 AccessFlags; + __le64 CurrentByteOffset; + __le32 Mode; + __le32 AlignmentRequirement; + __le32 FileNameLength; + union { + char __pad; /* Legacy structure padding */ + DECLARE_FLEX_ARRAY(char, FileName); + }; +} __packed; /* level 18 Query */ + /* See MS-FSCC 2.4.8 */ typedef struct { __le32 NextEntryOffset;
@@ -46,6 +250,11 @@ typedef struct {char FileName[]; }__packed FILE_DIRECTORY_INFO ;/* level 0x101 FF resp data */ +/* See MS-FSCC 2.4.13 */ +struct smb2_file_eof_info {/* encoding of request for level 10 */ +__le64 EndOfFile;/* new end of file value */ +} __packed;/* level 20 Set */ +/* See MS-FSCC 2.4.14 */ typedef struct { __le32 NextEntryOffset;
@@ -80,6 +289,26 @@ typedef struct {char FileName[]; }__packed FILE_ID_FULL_DIR_INFO ;/* level 0x105 FF rsp data */ +/* See MS-FSCC 2.4.27 */ +struct smb2_file_internal_info { +__le64 IndexNumber; +} __packed;/* level 6 Query */ + +/* See MS-FSCC 2.4.28.2 */ +struct smb2_file_link_info {/* encoding of request for level 11 */ +/* New members MUST be added within the struct_group() macro below. */ + __struct_group(smb2_file_link_info_hdr, __hdr, __packed, + __u8 ReplaceIfExists; /* 1 = replace existing link with new */ +/* 0 = fail if link already exists */ +__u8 Reserved[7 ]; +__u64 RootDirectory;/* MBZ for network operations (why says spec?) */ +__le32 FileNameLength; + ); +char FileName[];/* Name to be assigned to new link */ +} __packed;/* level 11 Set */ +static_assert (offsetof(struct smb2_file_link_info , FileName) ==sizeof (struct smb2_file_link_info_hdr ), +"struct member likely outside of __struct_group()" ); +/* See MS-FSCC 2.4.34 */ struct smb2_file_network_open_info { struct_group_attr(network_open_info, __packed,
@@ -94,6 +323,37 @@ 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.4.42.2 */ +struct smb2_file_rename_info {/* encoding of request for level 10 */ +/* New members MUST be added within the struct_group() macro below. */ + __struct_group(smb2_file_rename_info_hdr, __hdr, __packed, + __u8 ReplaceIfExists; /* 1 = replace existing target with new */ +/* 0 = fail if target already exists */ +__u8 Reserved[7 ]; +__u64 RootDirectory;/* MBZ for network operations (why says spec?) */ +__le32 FileNameLength; + ); +char FileName[];/* New name to be assigned */ +/* padding - overall struct size must be >= 24 so filename + pad >= 6 */ +} __packed;/* level 10 Set */ +static_assert (offsetof(struct smb2_file_rename_info , FileName) ==sizeof (struct smb2_file_rename_info_hdr ), +"struct member likely outside of __struct_group()" ); + +/* File System Information Classes */ +/* See MS-FSCC 2.5 */ +#define FS_VOLUME_INFORMATION 1/* Query */ +#define FS_LABEL_INFORMATION 2/* Set */ +#define FS_SIZE_INFORMATION 3/* Query */ +#define FS_DEVICE_INFORMATION 4/* Query */ +#define FS_ATTRIBUTE_INFORMATION 5/* Query */ +#define FS_CONTROL_INFORMATION 6/* Query, Set */ +#define FS_FULL_SIZE_INFORMATION 7/* Query */ +#define FS_OBJECT_ID_INFORMATION 8/* Query, Set */ +#define FS_DRIVER_PATH_INFORMATION 9/* Query */ +#define FS_SECTOR_SIZE_INFORMATION 11/* SMB3 or later. Query */ +/* See POSIX Extensions to MS-FSCC 2.3.1.1 */ +#define FS_POSIX_INFORMATION 100/* SMB3.1.1 POSIX. Query */ +/* See MS-FSCC 2.5.1 */ #define MAX_FS_NAME_LEN 52 typedef struct {
@@ -130,6 +390,45 @@ typedef struct {#define FILE_CASE_PRESERVED_NAMES 0x00000002#define FILE_CASE_SENSITIVE_SEARCH 0x00000001 +/* +* File System Control Information +* See MS-FSCC 2.5.2 +*/ +struct smb2_fs_control_info { +__le64 FreeSpaceStartFiltering; +__le64 FreeSpaceThreshold; +__le64 FreeSpaceStopFiltering; +__le64 DefaultQuotaThreshold; +__le64 DefaultQuotaLimit; +__le32 FileSystemControlFlags; +__le32 Padding; +} __packed; + +/* See MS-FSCC 2.5.4 */ +struct smb2_fs_full_size_info { +__le64 TotalAllocationUnits; +__le64 CallerAvailableAllocationUnits; +__le64 ActualAvailableAllocationUnits; +__le32 SectorsPerAllocationUnit; +__le32 BytesPerSector; +} __packed; + +/* See MS-FSCC 2.5.7 */ +#define SSINFO_FLAGS_ALIGNED_DEVICE 0x00000001 +#define SSINFO_FLAGS_PARTITION_ALIGNED_ON_DEVICE 0x00000002 +#define SSINFO_FLAGS_NO_SEEK_PENALTY 0x00000004 +#define SSINFO_FLAGS_TRIM_ENABLED 0x00000008 +/* sector size info struct */ +struct smb3_fs_ss_info { +__le32 LogicalBytesPerSector; +__le32 PhysicalBytesPerSectorForAtomicity; +__le32 PhysicalBytesPerSectorForPerf; +__le32 FSEffPhysicalBytesPerSectorForAtomicity; +__le32 Flags; +__le32 ByteOffsetForSectorAlignment; +__le32 ByteOffsetForPartitionAlignment; +} __packed; +/* See MS-FSCC 2.5.8 */ typedef struct { __le64 TotalAllocationUnits;
@@ -189,6 +488,22 @@ typedef struct {#define FILE_ATTRIBUTE_NO_SCRUB_DATA_LE cpu_to_le32(FILE_ATTRIBUTE_NO_SCRUB_DATA)#define FILE_ATTRIBUTE_MASK_LE cpu_to_le32(FILE_ATTRIBUTE_MASK) +/* +* SMB2 Notify Action Flags +* See MS-FSCC 2.7.1 +*/ +#define FILE_ACTION_ADDED 0x00000001 +#define FILE_ACTION_REMOVED 0x00000002 +#define FILE_ACTION_MODIFIED 0x00000003 +#define FILE_ACTION_RENAMED_OLD_NAME 0x00000004 +#define FILE_ACTION_RENAMED_NEW_NAME 0x00000005 +#define FILE_ACTION_ADDED_STREAM 0x00000006 +#define FILE_ACTION_REMOVED_STREAM 0x00000007 +#define FILE_ACTION_MODIFIED_STREAM 0x00000008 +#define FILE_ACTION_REMOVED_BY_DELETE 0x00000009 +#define FILE_ACTION_ID_NOT_TUNNELLED 0x0000000A +#define FILE_ACTION_TUNNELLED_ID_COLLISION 0x0000000B +/* * Response contains array of the following structures * See MS-FSCC 2.7.1
fs/smb/common/smb2pdu.h +0 -307
337 lines not on this page · raw message
Signature · 1 line
2.52.0
PATCH v5 5/7 smb: move file_basic_info into common/fscc.h
In reply to [email protected]From: ZhangGuoDong <[email protected]>
This struct definition is specified in MS-FSCC, so move them into fscc.h.
Modify the following places:
- smb2_file_basic_info -> file_basic_info
- Pad1 -> Pad
--- fs/smb/client/smb1pdu.h | 9 --------- fs/smb/common/fscc.h | 10 ++++++++++ fs/smb/server/smb2pdu.c | 14 +++++++------- fs/smb/server/smb2pdu.h | 9 --------- 4 files changed, 17 insertions(+), 25 deletions(-)
fs/smb/client/smb1pdu.h +0 -9
@@ -2061,15 +2061,6 @@ typedef struct {__le32 EASize; }__packed FILE_INFO_STANDARD ;/* level 1 SetPath/FileInfo */ -typedef struct { -__le64 CreationTime; -__le64 LastAccessTime; -__le64 LastWriteTime; -__le64 ChangeTime; -__le32 Attributes; -__u32 Pad; -} __packed FILE_BASIC_INFO; /* size info, level 0x101 */ -struct file_allocation_info {__le64 AllocationSize;/* Note old Samba srvr rounds this up too much */ } __packed;/* size used on disk, for level 0x103 for set, 0x105 for query */
fs/smb/common/fscc.h +10 -0
@@ -216,6 +216,16 @@ struct smb2_file_all_info { /* data block encoding of response to level 18 */ }; } __packed;/* level 18 Query */ +/* See MS-FSCC 2.4.7 */ +typedef struct file_basic_info {/* data block encoding of response to level 18 */ +__le64 CreationTime; +__le64 LastAccessTime; +__le64 LastWriteTime; +__le64 ChangeTime; +__le32 Attributes; +__u32 Pad; +} __packed FILE_BASIC_INFO; /* size info, level 0x101 */ +/* See MS-FSCC 2.4.8 */ typedef struct { __le32 NextEntryOffset;
fs/smb/server/smb2pdu.c +7 -7
@@ -4839,7 +4839,7 @@ static void get_file_access_info(struct smb2_query_info_rsp *rsp,static int get_file_basic_info (struct smb2_query_info_rsp *rsp,struct ksmbd_file *fp,void *rsp_org) { -struct smb2_file_basic_info *basic_info; +struct file_basic_info *basic_info;struct kstat stat;u64 time;int ret;
@@ -4855,7 +4855,7 @@ static int get_file_basic_info(struct smb2_query_info_rsp *rsp,if (ret)return ret; - basic_info = (struct smb2_file_basic_info *)rsp->Buffer; + basic_info = (struct file_basic_info *)rsp->Buffer; basic_info->CreationTime =cpu_to_le64 (fp->create_time); time =ksmbd_UnixTimeToNT (stat.atime); basic_info->LastAccessTime =cpu_to_le64 (time);
@@ -4864,9 +4864,9 @@ static int get_file_basic_info(struct smb2_query_info_rsp *rsp, time =ksmbd_UnixTimeToNT (stat.ctime); basic_info->ChangeTime =cpu_to_le64 (time); basic_info->Attributes = fp->f_ci->m_fattr; - basic_info->Pad1 =0 ; + basic_info->Pad =0 ; rsp->OutputBufferLength = -cpu_to_le32 (sizeof (struct smb2_file_basic_info )); +cpu_to_le32 (sizeof (struct file_basic_info ));return 0 ; }
@@ -6137,7 +6137,7 @@ static int smb2_create_link(struct ksmbd_work *work, }static int set_file_basic_info (struct ksmbd_file *fp, -struct smb2_file_basic_info *file_info, +struct file_basic_info *file_info,struct ksmbd_share_config *share) {struct iattr attrs;
@@ -6419,10 +6419,10 @@ static int smb2_set_info_file(struct ksmbd_work *work, struct ksmbd_file *fp,switch (req->FileInfoClass) {case FILE_BASIC_INFORMATION : { -if (buf_len <sizeof (struct smb2_file_basic_info )) +if (buf_len <sizeof (struct file_basic_info ))return -EMSGSIZE ; -return set_file_basic_info (fp, (struct smb2_file_basic_info *)buffer, share); +return set_file_basic_info (fp, (struct file_basic_info *)buffer, share); }case FILE_ALLOCATION_INFORMATION : {
fs/smb/server/smb2pdu.h +0 -9
@@ -186,15 +186,6 @@ struct smb2_file_alignment_info {__le32 AlignmentRequirement; } __packed; -struct smb2_file_basic_info {/* data block encoding of response to level 18 */ -__le64 CreationTime;/* Beginning of FILE_BASIC_INFO equivalent */ -__le64 LastAccessTime; -__le64 LastWriteTime; -__le64 ChangeTime; -__le32 Attributes; -__u32 Pad1;/* End of FILE_BASIC_INFO_INFO equivalent */ -} __packed; -struct smb2_file_alt_name_info {__le32 FileNameLength;char FileName[];
Signature · 1 line
2.52.0
PATCH v5 6/7 smb: move filesystem_vol_info into common/fscc.h
In reply to [email protected]From: ZhangGuoDong <[email protected]>
The structure definition on the server side is specified in MS-CIFS 2.2.8.2.3, but we should instead refer to MS-FSCC 2.5.9, just as the client side does.
Modify the following places:
- smb3_fs_vol_info -> filesystem_vol_info
- SerialNumber -> VolumeSerialNumber
- VolumeLabelSize -> VolumeLabelLength
Then move it into common header file.
--- fs/smb/client/smb2pdu.c | 8 ++++---- fs/smb/common/fscc.h | 11 +++++++++++ fs/smb/common/smb2pdu.h | 11 ----------- fs/smb/server/smb2pdu.c | 5 +++-- fs/smb/server/smb_common.h | 8 -------- 5 files changed, 18 insertions(+), 25 deletions(-)
fs/smb/client/smb2pdu.c +4 -4
@@ -6144,8 +6144,8 @@ SMB2_QFS_attr(const unsigned int xid, struct cifs_tcon *tcon, max_len =sizeof (struct smb3_fs_ss_info ); min_len =sizeof (struct smb3_fs_ss_info ); }else if (level ==FS_VOLUME_INFORMATION ) { - max_len =sizeof (struct smb3_fs_vol_info ) +MAX_VOL_LABEL_LEN ; - min_len =sizeof (struct smb3_fs_vol_info ); + max_len =sizeof (struct filesystem_vol_info ) +MAX_VOL_LABEL_LEN ; + min_len =sizeof (struct filesystem_vol_info ); }else {cifs_dbg (FYI ,"Invalid qfsinfo level %d\n" , level);return -EINVAL ;
@@ -6200,9 +6200,9 @@ SMB2_QFS_attr(const unsigned int xid, struct cifs_tcon *tcon, tcon->perf_sector_size =le32_to_cpu (ss_info->PhysicalBytesPerSectorForPerf); }else if (level ==FS_VOLUME_INFORMATION ) { -struct smb3_fs_vol_info *vol_info = (struct smb3_fs_vol_info *) +struct filesystem_vol_info *vol_info = (struct filesystem_vol_info *) (offset + (char *)rsp); - tcon->vol_serial_number = vol_info->VolumeSerialNumber; + tcon->vol_serial_number =le32_to_cpu (vol_info->VolumeSerialNumber); tcon->vol_create_time = vol_info->VolumeCreationTime; }
fs/smb/common/fscc.h +11 -0
@@ -447,6 +447,17 @@ typedef struct {__le32 BytesPerSector; }__packed FILE_SYSTEM_SIZE_INFO ;/* size info, level 0x103 */ +/* volume info struct - see MS-FSCC 2.5.9 */ +#define MAX_VOL_LABEL_LEN 32 +struct filesystem_vol_info { +__le64 VolumeCreationTime; +__le32 VolumeSerialNumber; +__le32 VolumeLabelLength;/* includes trailing null */ +__u8 SupportsObjects;/* True if eg like NTFS, supports objects */ +__u8 Reserved; +__u8 VolumeLabel[];/* variable len */ +} __packed; +/* See MS-FSCC 2.5.10 */ typedef struct { __le32 DeviceType;
fs/smb/common/smb2pdu.h +0 -11
@@ -1635,17 +1635,6 @@ struct smb311_posix_qinfo {*/ } __packed; -/* volume info struct - see MS-FSCC 2.5.9 */ -#define MAX_VOL_LABEL_LEN 32 -struct smb3_fs_vol_info { -__le64 VolumeCreationTime; -__u32 VolumeSerialNumber; -__le32 VolumeLabelLength;/* includes trailing null */ -__u8 SupportsObjects;/* True if eg like NTFS, supports objects */ -__u8 Reserved; -__u8 VolumeLabel[];/* variable len */ -} __packed; -/* See MS-SMB2 2.2.23 through 2.2.25 */ struct smb2_oplock_break {struct smb2_hdr hdr;
fs/smb/server/smb2pdu.c +3 -2
@@ -5545,13 +5545,14 @@ static int smb2_get_info_filesystem(struct ksmbd_work *work, serial_crc =crc32_le (serial_crc,ksmbd_netbios_name (),strlen (ksmbd_netbios_name ()));/* Taking dummy value of serial number*/ - info->SerialNumber =cpu_to_le32 (serial_crc); + info->VolumeSerialNumber =cpu_to_le32 (serial_crc); len =smbConvertToUTF16 ((__le16 *)info->VolumeLabel, share->name,PATH_MAX , conn->local_nls,0 ); len = len *2 ; - info->VolumeLabelSize =cpu_to_le32 (len); + info->VolumeLabelLength =cpu_to_le32 (len); info->Reserved =0 ; + info->SupportsObjects =0 ; sz =sizeof (struct filesystem_vol_info ) + len; rsp->OutputBufferLength =cpu_to_le32 (sz);break ;
fs/smb/server/smb_common.h +0 -8
@@ -90,14 +90,6 @@ struct smb_negotiate_rsp {__le16 ByteCount; } __packed; -struct filesystem_vol_info { -__le64 VolumeCreationTime; -__le32 SerialNumber; -__le32 VolumeLabelSize; -__le16 Reserved; -__le16 VolumeLabel[]; -} __packed; -#define EXTENDED_INFO_MAGIC 0x43667364/* Cfsd */ #define STRING_LENGTH 28
Signature · 1 line
2.52.0
PATCH v5 7/7 smb: introduce struct file_posix_info
In reply to [email protected]From: ZhangGuoDong <[email protected]>
Extract the common part of struct smb311_posix_qinfo/file_posix_info into a new struct.
Modify the following places:
- introduce new struct file_posix_info
- smb311_posix_qinfo -> file_posix_info
- remove struct smb311_posix_qinfo
- some fields in "struct smb2_posix_info" -> "struct file_posix_info"
--- fs/smb/client/cifsglob.h | 2 +- fs/smb/client/inode.c | 2 +- fs/smb/client/readdir.c | 28 ++++++++++++------------ fs/smb/client/reparse.h | 2 +- fs/smb/client/smb2inode.c | 4 ++-- fs/smb/client/smb2pdu.h | 21 +----------------- fs/smb/common/fscc.h | 35 ++++++++++++++++++++++++++++- fs/smb/common/smb2pdu.h | 25 --------------------- fs/smb/server/smb2pdu.c | 46 +++++++++++++++++++-------------------- fs/smb/server/smb2pdu.h | 21 +----------------- 10 files changed, 78 insertions(+), 108 deletions(-)
fs/smb/client/cifsglob.h +1 -1
@@ -270,7 +270,7 @@ struct cifs_open_info_data {struct smb_sid posix_group;union {struct smb2_file_all_info fi; -struct smb311_posix_qinfo posix_fi; +struct file_posix_info posix_fi; }; };
fs/smb/client/inode.c +1 -1
@@ -835,7 +835,7 @@ static void smb311_posix_info_to_fattr(struct cifs_fattr *fattr,struct cifs_open_info_data *data, struct super_block *sb) { - struct smb311_posix_qinfo *info = &data->posix_fi; + struct file_posix_info *info = &data->posix_fi;struct cifs_sb_info *cifs_sb =CIFS_SB (sb);struct cifs_tcon *tcon =cifs_sb_master_tcon (cifs_sb);
fs/smb/client/readdir.c +14 -14
@@ -247,22 +247,22 @@ cifs_posix_to_fattr(struct cifs_fattr *fattr, struct smb2_posix_info *info,posix_info_parse (info,NULL , &parsed);memset (fattr,0 ,sizeof (*fattr)); - fattr->cf_uniqueid =le64_to_cpu (info->Inode); - fattr->cf_bytes =le64_to_cpu (info->AllocationSize); - fattr->cf_eof =le64_to_cpu (info->EndOfFile); + fattr->cf_uniqueid =le64_to_cpu (info->fpinfo.Inode); + fattr->cf_bytes =le64_to_cpu (info->fpinfo.AllocationSize); + fattr->cf_eof =le64_to_cpu (info->fpinfo.EndOfFile); - fattr->cf_atime =cifs_NTtimeToUnix (info->LastAccessTime); - fattr->cf_mtime =cifs_NTtimeToUnix (info->LastWriteTime); - fattr->cf_ctime =cifs_NTtimeToUnix (info->CreationTime); + fattr->cf_atime =cifs_NTtimeToUnix (info->fpinfo.LastAccessTime); + fattr->cf_mtime =cifs_NTtimeToUnix (info->fpinfo.LastWriteTime); + fattr->cf_ctime =cifs_NTtimeToUnix (info->fpinfo.CreationTime); - fattr->cf_nlink =le32_to_cpu (info->HardLinks); - fattr->cf_cifsattrs =le32_to_cpu (info->DosAttributes); + fattr->cf_nlink =le32_to_cpu (info->fpinfo.HardLinks); + fattr->cf_cifsattrs =le32_to_cpu (info->fpinfo.DosAttributes);if (fattr->cf_cifsattrs &ATTR_REPARSE_POINT ) - fattr->cf_cifstag =le32_to_cpu (info->ReparseTag); + fattr->cf_cifstag =le32_to_cpu (info->fpinfo.ReparseTag);/* The Mode field in the response can now include the file type as well */ - fattr->cf_mode =wire_mode_to_posix (le32_to_cpu (info->Mode), + fattr->cf_mode =wire_mode_to_posix (le32_to_cpu (info->fpinfo.Mode), fattr->cf_cifsattrs &ATTR_DIRECTORY ); fattr->cf_dtype =S_DT (fattr->cf_mode);
@@ -277,9 +277,9 @@ cifs_posix_to_fattr(struct cifs_fattr *fattr, struct smb2_posix_info *info, }cifs_dbg (FYI ,"posix fattr: dev %d, reparse %d, mode %o\n" , -le32_to_cpu (info->DeviceId), -le32_to_cpu (info->ReparseTag), -le32_to_cpu (info->Mode)); +le32_to_cpu (info->fpinfo.DeviceId), +le32_to_cpu (info->fpinfo.ReparseTag), +le32_to_cpu (info->fpinfo.Mode));sid_to_id (cifs_sb, &parsed.owner, fattr,SIDOWNER );sid_to_id (cifs_sb, &parsed.group, fattr,SIDGROUP );
@@ -517,7 +517,7 @@ static void cifs_fill_dirent_posix(struct cifs_dirent *de, de->name = parsed.name; de->namelen = parsed.name_len; de->resume_key = info->Ignored; - de->ino =le64_to_cpu (info->Inode); + de->ino =le64_to_cpu (info->fpinfo.Inode); } static void cifs_fill_dirent_unix(struct cifs_dirent *de,
fs/smb/client/reparse.h +1 -1
@@ -104,7 +104,7 @@ static inline bool cifs_open_data_reparse(struct cifs_open_info_data *data)bool ret;if (data->contains_posix_file_info) { -struct smb311_posix_qinfo *fi = &data->posix_fi; +struct file_posix_info *fi = &data->posix_fi; attrs =le32_to_cpu (fi->DosAttributes);if (data->reparse_point) {
fs/smb/client/smb2inode.c +2 -2
@@ -325,7 +325,7 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon, cfile->fid.volatile_fid,SMB_FIND_FILE_POSIX_INFO ,SMB2_O_INFO_FILE ,0 , -sizeof (struct smb311_posix_qinfo ) + +sizeof (struct file_posix_info ) + (PATH_MAX *2 ) + (sizeof(struct smb_sid) * 2), 0, NULL); }else {
@@ -335,7 +335,7 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,COMPOUND_FID ,SMB_FIND_FILE_POSIX_INFO ,SMB2_O_INFO_FILE ,0 , -sizeof (struct smb311_posix_qinfo ) + +sizeof (struct file_posix_info ) + (PATH_MAX *2 ) + (sizeof(struct smb_sid) * 2), 0, NULL); }
fs/smb/client/smb2pdu.h +1 -20
@@ -274,26 +274,7 @@ struct create_posix_rsp {struct smb2_posix_info {__le32 NextEntryOffset;__u32 Ignored; -__le64 CreationTime; -__le64 LastAccessTime; -__le64 LastWriteTime; -__le64 ChangeTime; -__le64 EndOfFile; -__le64 AllocationSize; -__le32 DosAttributes; -__le64 Inode; -__le32 DeviceId; -__le32 Zero; -/* beginning of POSIX Create Context Response */ -__le32 HardLinks; -__le32 ReparseTag; -__le32 Mode; -/* -* var sized owner SID -* var sized group SID -* le32 filenamelength -* u8 filename[] -*/ +struct file_posix_info fpinfo; } __packed;/*
fs/smb/common/fscc.h +34 -1
@@ -537,9 +537,42 @@ struct file_notify_information { } __packed;/* -* See POSIX Extensions to MS-FSCC 2.3.2.1 +* [POSIX-FSCC] POSIX Extensions to MS-FSCC * Link: https://gitlab.com/samba-team/smb3-posix-spec/-/blob/master/fscc_posix_extensions.md */ + +/* +* This information class is used to query file posix information. +* Level 100 query info +* See POSIX-FSCC 2.3.1.1 +*/ +struct file_posix_info { +__le64 CreationTime; +__le64 LastAccessTime; +__le64 LastWriteTime; +__le64 ChangeTime; +__le64 EndOfFile; +__le64 AllocationSize; +__le32 DosAttributes; +__le64 Inode; +__le32 DeviceId; +__le32 Zero; +/* +* Beginning of POSIX Create Context Response +* See POSIX-SMB2 2.2.14.2.16 +*/ +__le32 HardLinks; +__le32 ReparseTag; +__le32 Mode; +// var sized owner SID +// var sized group SID +/* End of POSIX Create Context Response */ +// le32 filenamelength +// u8 filename[] +u8 sids_and_name[]; +} __packed; + +/* See POSIX-FSCC 2.3.2.1 */ typedef struct { /* For undefined recommended transfer size return -1 in that field */ __le32 OptimalTransferSize; /* bsize on some os, iosize on other os */
fs/smb/common/smb2pdu.h +0 -25
@@ -1610,31 +1610,6 @@ struct smb2_query_info_rsp {__u8 Buffer[]; } __packed; -/* Level 100 query info */ -struct smb311_posix_qinfo { -__le64 CreationTime; -__le64 LastAccessTime; -__le64 LastWriteTime; -__le64 ChangeTime; -__le64 EndOfFile; -__le64 AllocationSize; -__le32 DosAttributes; -__le64 Inode; -__le32 DeviceId; -__le32 Zero; -/* beginning of POSIX Create Context Response */ -__le32 HardLinks; -__le32 ReparseTag; -__le32 Mode; -u8 Sids[]; -/* -* var sized owner SID -* var sized group SID -* le32 filenamelength -* u8 filename[] -*/ -} __packed; -/* See MS-SMB2 2.2.23 through 2.2.25 */ struct smb2_oplock_break {struct smb2_hdr hdr;
fs/smb/server/smb2pdu.c +23 -23
97 lines not on this page · raw message
fs/smb/server/smb2pdu.h +1 -20
@@ -281,30 +281,11 @@ struct create_sd_buf_req {struct smb2_posix_info {__le32 NextEntryOffset;__u32 Ignored; -__le64 CreationTime; -__le64 LastAccessTime; -__le64 LastWriteTime; -__le64 ChangeTime; -__le64 EndOfFile; -__le64 AllocationSize; -__le32 DosAttributes; -__le64 Inode; -__le32 DeviceId; -__le32 Zero; -/* beginning of POSIX Create Context Response */ -__le32 HardLinks; -__le32 ReparseTag; -__le32 Mode; +struct file_posix_info fpinfo;/* SidBuffer contain two sids (UNIX user sid(16), UNIX group sid(16)) */ u8 SidBuffer[32 ];__le32 name_len;u8 name[]; -/* -* var sized owner SID -* var sized group SID -* le32 filenamelength -* u8 filename[] -*/ } __packed;/* functions */
Signature · 1 line
2.52.0
Namjae Jeon
maintainerRe: [PATCH v5 7/7] smb: introduce struct file_posix_info
Quoted 17 lines
fs/smb/server/smb2pdu.h +0
-9@@ -281,30 +281,11 @@ struct create_sd_buf_req {struct smb2_posix_info {__le32 NextEntryOffset;__u32 Ignored; -__le64 CreationTime; -__le64 LastAccessTime; -__le64 LastWriteTime; -__le64 ChangeTime; -__le64 EndOfFile; -__le64 AllocationSize; -__le32 DosAttributes; -__le64 Inode; -__le32 DeviceId;
fs/smb/server/smb2pdu.h struct create_sd_buf_req { · line 288
Quoted 10 lines
fs/smb/server/smb2pdu.h +1
-5-__le32 Zero; -/* beginning of POSIX Create Context Response */ -__le32 HardLinks; -__le32 ReparseTag; -__le32 Mode; +struct file_posix_info fpinfo;/* SidBuffer contain two sids (UNIX user sid(16), UNIX group sid(16)) */ u8 SidBuffer[32 ];__le32 name_len;u8 name[];
These 3 fields should be removed and use flex array in struct file_posix_info. And why can't smb2_posix_info move to /smb/common?
Quoted 12 lines
fs/smb/server/smb2pdu.h +0
-7-/* -* var sized owner SID -* var sized group SID -* le32 filenamelength -* u8 filename[] -*/ } __packed;/* functions */ --2.52.0
Re: [PATCH v5 7/7] smb: introduce struct file_posix_info
Hi Namjae,
The client cannot use SidBuffer[32] because the size of SidBuffer[] on the client side is not necessarily 32.
Quoted 6 lines · Namjae Jeon
Quoted 4 lines
/* SidBuffer contain two sids (UNIX user sid(16), UNIX group sid(16)) */ u8 SidBuffer[32]; __le32 name_len; u8 name[];These 3 fields should be removed and use flex array in struct
file_posix_info. And why can'tsmb2_posix_infomove to /smb/common?
Namjae Jeon
maintainerRe: [PATCH v5 7/7] smb: introduce struct file_posix_info
Quoted 5 lines · ZhangGuoDong
Hi Namjae,
The client cannot use
SidBuffer[32]because the size ofSidBuffer[]on the client side is not necessarily 32.
I know, We need to change ksmbd to use flex arrays.
Re: [PATCH v5 7/7] smb: introduce struct file_posix_info
C structure cannot have two flexible array members.
If we make Sids[] a flexible array member, then there cannot be any members after it. However, this structure still has filenamelength and filename[] after it. And filename[] is also a flexible array member.
Do you have any suggestions for this?
Quoted 1 line · Namjae Jeon
I know, We need to change ksmbd to use flex arrays.
Namjae Jeon
maintainerQuoted 37 lines · On Wed, Mar 4, 2026 at 12:14 AM <[email protected]> wrote:
From: ZhangGuoDong <[email protected]>
v4->v5:
- Add patch #01 #02 #03
- Patch #06: keepvol_serial_numberas u32 insmb_mnt_fs_infoandcifs_tcon
- Patch #07:
- Add new flexible array membersids_and_name[]tofile_posix_info
-smb311_posix_qinfo->file_posix_infov4: https://lore.kernel.org/linux-cifs/[email protected]/
v1: https://lore.kernel.org/all/[email protected]/
v2: https://lore.kernel.org/linux-cifs/[email protected]/The following patches from v1 and v2 have already been merged into mainline:
-94d5b8dbc5d9smb: move some SMB1 definitions intocommon/smb1pdu.h
-2b6abb893e71smb: move File Attributes definitions intocommon/fscc.h
-c97503321ed3smb: update structduplicate_extents_to_file_ex
-2e0d224d8988smb/server: add comment to FileSystemName of FileFsAttributeInformation
-ab0347e67dacsmb/client: remove DeviceType Flags and Device Characteristics definitions
-08c2a7d2bae9smb: movefile_notify_informationtocommon/fscc.h
-6539e18517b6smb: move SMB2 Notify Action Flags intocommon/smb2pdu.h
-9ec7629b430asmb: move notify completion filter flags intocommon/smb2pdu.h
-bcdd6cfaf2ecsmb: add documentation references for smb2 change notify definitionsThe following patches from v4 have already been merged into cifs-2.6.git for-next:
- smb: update some doc referencesThis is a continuous effort to move duplicated definitions in both client and server into common header files, which makes the code easier to maintain.
The previous work is here:
- part 1: https://lore.kernel.org/linux-cifs/[email protected]/ZhangGuoDong (7):
smb/client: fix buffer size forsmb311_posix_qinfoin
Quoted 8 lines
smb2_compound_op() smb/client: fix buffer size for smb311_posix_qinfo in SMB311_posix_query_info()smb/client: remove unused
SMB311_posix_query_info()
smb: move some definitions fromcommon/smb2pdu.hintocommon/fscc.h
smb: movefile_basic_infointocommon/fscc.h
smb: movefilesystem_vol_infointocommon/fscc.h
smb: introduce structfile_posix_info
Applied 0004~0006 patches to #ksmbd-for-next-next. Thanks!