* [PATCH v3 00/22] smb: fix some bugs, move duplicate definitions to common header file
@ 2025-10-14 7:18 chenxiaosong.chenxiaosong
2025-10-14 7:18 ` [PATCH v3 01/22] smb/server: fix possible memory leak in smb2_read() chenxiaosong.chenxiaosong
` (11 more replies)
0 siblings, 12 replies; 37+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-10-14 7:18 UTC (permalink / raw)
To: stfrench, metze, pali, linkinjeon, smfrench, sfrench, senozhatsky,
tom, pc, ronniesahlberg, sprasad, bharathsm, christophe.jaillet,
zhangguodong
Cc: linux-cifs, linux-kernel, ChenXiaoSong
From: ChenXiaoSong <chenxiaosong@kylinos.cn>
Emails from previous address were often not received (went to the spam
folder or other reasons), and the cover letter wasn't linked to the
patches. So yesterday I requested chenxiaosong.chenxiaosong@linux.dev
account and have now sent v3.
Fix some bugs of smb server.
In order to maintain the code more easily, move some duplicate definitions
to common header file.
Add some MS documentation references for macro and struct definitions.
v2->v3:
- Update patch #06: use "Suggested-by:" instead of "Reviewed-by:"
v1->v2:
- Update patch #06 according to Christophe JAILLET's suggestions: https://lore.kernel.org/all/d03c64d2-46c0-42d8-8f88-28669e921c95@wanadoo.fr/
v2:
- cover-letter: https://lore.kernel.org/all/40F04A8E2145E761+20251012161749.2994033-1-chenxiaosong@chenxiaosong.com/
- patches: https://lore.kernel.org/all/47508024F79AE36C+20251012161749.2994033-2-chenxiaosong@chenxiaosong.com/
v1:
- cover-letter: https://lore.kernel.org/all/76A15C078023E21F+20251012150915.2992220-1-chenxiaosong@chenxiaosong.com/
- patches: https://lore.kernel.org/all/029014EF18C9D322+20251012150915.2992220-2-chenxiaosong@chenxiaosong.com/
- RESEND cover-letter: https://lore.kernel.org/all/37DF3D711BAD3621+20251012152247.2992573-1-chenxiaosong@chenxiaosong.com/
- RESEND patches: https://lore.kernel.org/all/9836A3F274B62345+20251012152247.2992573-2-chenxiaosong@chenxiaosong.com/
ZhangGuoDong (10):
smb/server: fix possible memory leak in smb2_read()
smb/server: fix possible refcount leak in smb2_sess_setup()
smb: move some duplicate definitions to common/cifsglob.h
smb: move smb_version_values to common/cifsglob.h
smb: move get_rfc1002_len() to common/cifsglob.h
smb: move SMB1_PROTO_NUMBER to common/cifsglob.h
smb: move some duplicate definitions to common/smb2pdu.h
smb: move smb_sockaddr_in and smb_sockaddr_in6 to common/smb2pdu.h
smb: move copychunk definitions to common/smb2pdu.h
smb: move resume_key_ioctl_rsp to common/smb2pdu.h
ChenXiaoSong (12):
smb: move smb2_file_network_open_info to common/smb2pdu.h
smb: move some duplicate definitions to common/cifspdu.h
smb: move file access permission bits definitions to common/cifspdu.h
smb: move SMB frame definitions to common/cifspdu.h
smb: move FILE_SYSTEM_ATTRIBUTE_INFO to common/cifspdu.h
smb: move FILE_SYSTEM_DEVICE_INFO to common/cifspdu.h
smb: move FILE_SYSTEM_INFO to common/cifspdu.h
smb: move FILE_DIRECTORY_INFO to common/cifspdu.h
smb: move FILE_FULL_DIRECTORY_INFO to common/cifspdu.h
smb: move FILE_BOTH_DIRECTORY_INFO to common/cifspdu.h
smb: move SEARCH_ID_FULL_DIR_INFO to common/cifspdu.h
smb: move FILE_SYSTEM_POSIX_INFO to common/cifspdu.h
fs/smb/client/cifsacl.c | 4 +-
fs/smb/client/cifsglob.h | 47 +---
fs/smb/client/cifspdu.h | 436 +-------------------------------
fs/smb/client/cifssmb.c | 10 +-
fs/smb/client/cifstransport.c | 8 +-
fs/smb/client/connect.c | 2 +-
fs/smb/client/misc.c | 2 +-
fs/smb/client/smb2ops.c | 18 +-
fs/smb/client/smb2pdu.h | 80 +-----
fs/smb/common/cifsglob.h | 68 +++++
fs/smb/common/cifspdu.h | 464 ++++++++++++++++++++++++++++++++++
fs/smb/common/smb2pdu.h | 98 ++++++-
fs/smb/server/smb2misc.c | 2 +-
fs/smb/server/smb2ops.c | 32 +--
fs/smb/server/smb2pdu.c | 114 +++++----
fs/smb/server/smb2pdu.h | 67 -----
fs/smb/server/smb_common.c | 10 +-
fs/smb/server/smb_common.h | 304 +---------------------
fs/smb/server/smbacl.c | 2 +-
fs/smb/server/vfs.c | 2 +-
20 files changed, 735 insertions(+), 1035 deletions(-)
create mode 100644 fs/smb/common/cifsglob.h
create mode 100644 fs/smb/common/cifspdu.h
--
2.43.0
^ permalink raw reply [flat|nested] 37+ messages in thread
* [PATCH v3 01/22] smb/server: fix possible memory leak in smb2_read()
2025-10-14 7:18 [PATCH v3 00/22] smb: fix some bugs, move duplicate definitions to common header file chenxiaosong.chenxiaosong
@ 2025-10-14 7:18 ` chenxiaosong.chenxiaosong
2025-10-14 7:18 ` [PATCH v3 02/22] smb/server: fix possible refcount leak in smb2_sess_setup() chenxiaosong.chenxiaosong
` (10 subsequent siblings)
11 siblings, 0 replies; 37+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-10-14 7:18 UTC (permalink / raw)
To: stfrench, metze, pali, linkinjeon, smfrench, sfrench, senozhatsky,
tom, pc, ronniesahlberg, sprasad, bharathsm, christophe.jaillet,
zhangguodong
Cc: linux-cifs, linux-kernel, ChenXiaoSong
From: ZhangGuoDong <zhangguodong@kylinos.cn>
Memory leak occurs when ksmbd_vfs_read() fails.
Fix this by adding the missing kvfree().
Co-developed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn>
---
fs/smb/server/smb2pdu.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index ab1d45fcebde..e81e615f322a 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -6824,6 +6824,7 @@ int smb2_read(struct ksmbd_work *work)
nbytes = ksmbd_vfs_read(work, fp, length, &offset, aux_payload_buf);
if (nbytes < 0) {
+ kvfree(aux_payload_buf);
err = nbytes;
goto out;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH v3 02/22] smb/server: fix possible refcount leak in smb2_sess_setup()
2025-10-14 7:18 [PATCH v3 00/22] smb: fix some bugs, move duplicate definitions to common header file chenxiaosong.chenxiaosong
2025-10-14 7:18 ` [PATCH v3 01/22] smb/server: fix possible memory leak in smb2_read() chenxiaosong.chenxiaosong
@ 2025-10-14 7:18 ` chenxiaosong.chenxiaosong
2025-10-14 7:18 ` [PATCH v3 03/22] smb: move some duplicate definitions to common/cifsglob.h chenxiaosong.chenxiaosong
` (9 subsequent siblings)
11 siblings, 0 replies; 37+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-10-14 7:18 UTC (permalink / raw)
To: stfrench, metze, pali, linkinjeon, smfrench, sfrench, senozhatsky,
tom, pc, ronniesahlberg, sprasad, bharathsm, christophe.jaillet,
zhangguodong
Cc: linux-cifs, linux-kernel, ChenXiaoSong
From: ZhangGuoDong <zhangguodong@kylinos.cn>
Reference count of ksmbd_session will leak when session need reconnect.
Fix this by adding the missing ksmbd_user_session_put().
Co-developed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn>
---
fs/smb/server/smb2pdu.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index e81e615f322a..b731d9b09408 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -1806,6 +1806,7 @@ int smb2_sess_setup(struct ksmbd_work *work)
if (ksmbd_conn_need_reconnect(conn)) {
rc = -EFAULT;
+ ksmbd_user_session_put(sess);
sess = NULL;
goto out_err;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH v3 03/22] smb: move some duplicate definitions to common/cifsglob.h
2025-10-14 7:18 [PATCH v3 00/22] smb: fix some bugs, move duplicate definitions to common header file chenxiaosong.chenxiaosong
2025-10-14 7:18 ` [PATCH v3 01/22] smb/server: fix possible memory leak in smb2_read() chenxiaosong.chenxiaosong
2025-10-14 7:18 ` [PATCH v3 02/22] smb/server: fix possible refcount leak in smb2_sess_setup() chenxiaosong.chenxiaosong
@ 2025-10-14 7:18 ` chenxiaosong.chenxiaosong
2025-10-20 4:39 ` Namjae Jeon
2025-10-14 7:18 ` [PATCH v3 04/22] smb: move smb_version_values " chenxiaosong.chenxiaosong
` (8 subsequent siblings)
11 siblings, 1 reply; 37+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-10-14 7:18 UTC (permalink / raw)
To: stfrench, metze, pali, linkinjeon, smfrench, sfrench, senozhatsky,
tom, pc, ronniesahlberg, sprasad, bharathsm, christophe.jaillet,
zhangguodong
Cc: linux-cifs, linux-kernel, ChenXiaoSong
From: ZhangGuoDong <zhangguodong@kylinos.cn>
In order to maintain the code more easily, move duplicate definitions to
new common header file.
Co-developed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn>
---
fs/smb/client/cifsglob.h | 19 +------------------
fs/smb/common/cifsglob.h | 30 ++++++++++++++++++++++++++++++
fs/smb/server/smb_common.h | 14 +-------------
3 files changed, 32 insertions(+), 31 deletions(-)
create mode 100644 fs/smb/common/cifsglob.h
diff --git a/fs/smb/client/cifsglob.h b/fs/smb/client/cifsglob.h
index 8f6f567d7474..c5034cf9ac9e 100644
--- a/fs/smb/client/cifsglob.h
+++ b/fs/smb/client/cifsglob.h
@@ -24,6 +24,7 @@
#include "cifsacl.h"
#include <crypto/internal/hash.h>
#include <uapi/linux/cifs/cifs_mount.h>
+#include "../common/cifsglob.h"
#include "../common/smb2pdu.h"
#include "smb2pdu.h"
#include <linux/filelock.h>
@@ -702,12 +703,6 @@ get_rfc1002_length(void *buf)
return be32_to_cpu(*((__be32 *)buf)) & 0xffffff;
}
-static inline void
-inc_rfc1001_len(void *buf, int count)
-{
- be32_add_cpu((__be32 *)buf, count);
-}
-
struct TCP_Server_Info {
struct list_head tcp_ses_list;
struct list_head smb_ses_list;
@@ -1021,8 +1016,6 @@ compare_mid(__u16 mid, const struct smb_hdr *smb)
#define CIFS_MAX_RFC1002_WSIZE ((1<<17) - 1 - sizeof(WRITE_REQ) + 4)
#define CIFS_MAX_RFC1002_RSIZE ((1<<17) - 1 - sizeof(READ_RSP) + 4)
-#define CIFS_DEFAULT_IOSIZE (1024 * 1024)
-
/*
* Windows only supports a max of 60kb reads and 65535 byte writes. Default to
* those values when posix extensions aren't in force. In actuality here, we
@@ -2148,30 +2141,20 @@ extern mempool_t cifs_io_request_pool;
extern mempool_t cifs_io_subrequest_pool;
/* Operations for different SMB versions */
-#define SMB1_VERSION_STRING "1.0"
-#define SMB20_VERSION_STRING "2.0"
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
extern struct smb_version_operations smb1_operations;
extern struct smb_version_values smb1_values;
extern struct smb_version_operations smb20_operations;
extern struct smb_version_values smb20_values;
#endif /* CIFS_ALLOW_INSECURE_LEGACY */
-#define SMB21_VERSION_STRING "2.1"
extern struct smb_version_operations smb21_operations;
extern struct smb_version_values smb21_values;
-#define SMBDEFAULT_VERSION_STRING "default"
extern struct smb_version_values smbdefault_values;
-#define SMB3ANY_VERSION_STRING "3"
extern struct smb_version_values smb3any_values;
-#define SMB30_VERSION_STRING "3.0"
extern struct smb_version_operations smb30_operations;
extern struct smb_version_values smb30_values;
-#define SMB302_VERSION_STRING "3.02"
-#define ALT_SMB302_VERSION_STRING "3.0.2"
/*extern struct smb_version_operations smb302_operations;*/ /* not needed yet */
extern struct smb_version_values smb302_values;
-#define SMB311_VERSION_STRING "3.1.1"
-#define ALT_SMB311_VERSION_STRING "3.11"
extern struct smb_version_operations smb311_operations;
extern struct smb_version_values smb311_values;
diff --git a/fs/smb/common/cifsglob.h b/fs/smb/common/cifsglob.h
new file mode 100644
index 000000000000..00fd215e3eb5
--- /dev/null
+++ b/fs/smb/common/cifsglob.h
@@ -0,0 +1,30 @@
+/* SPDX-License-Identifier: LGPL-2.1 */
+/*
+ *
+ * Copyright (C) International Business Machines Corp., 2002,2008
+ * Author(s): Steve French (sfrench@us.ibm.com)
+ * Jeremy Allison (jra@samba.org)
+ *
+ */
+#ifndef _COMMON_CIFS_GLOB_H
+#define _COMMON_CIFS_GLOB_H
+
+static inline void inc_rfc1001_len(void *buf, int count)
+{
+ be32_add_cpu((__be32 *)buf, count);
+}
+
+#define SMB1_VERSION_STRING "1.0"
+#define SMB20_VERSION_STRING "2.0"
+#define SMB21_VERSION_STRING "2.1"
+#define SMBDEFAULT_VERSION_STRING "default"
+#define SMB3ANY_VERSION_STRING "3"
+#define SMB30_VERSION_STRING "3.0"
+#define SMB302_VERSION_STRING "3.02"
+#define ALT_SMB302_VERSION_STRING "3.0.2"
+#define SMB311_VERSION_STRING "3.1.1"
+#define ALT_SMB311_VERSION_STRING "3.11"
+
+#define CIFS_DEFAULT_IOSIZE (1024 * 1024)
+
+#endif /* _COMMON_CIFS_GLOB_H */
diff --git a/fs/smb/server/smb_common.h b/fs/smb/server/smb_common.h
index d742ba754348..863716207a0d 100644
--- a/fs/smb/server/smb_common.h
+++ b/fs/smb/server/smb_common.h
@@ -10,6 +10,7 @@
#include "glob.h"
#include "nterr.h"
+#include "../common/cifsglob.h"
#include "../common/smb2pdu.h"
#include "smb2pdu.h"
@@ -26,16 +27,8 @@
#define SMB311_PROT 6
#define BAD_PROT 0xFFFF
-#define SMB1_VERSION_STRING "1.0"
-#define SMB20_VERSION_STRING "2.0"
-#define SMB21_VERSION_STRING "2.1"
-#define SMB30_VERSION_STRING "3.0"
-#define SMB302_VERSION_STRING "3.02"
-#define SMB311_VERSION_STRING "3.1.1"
-
#define SMB_ECHO_INTERVAL (60 * HZ)
-#define CIFS_DEFAULT_IOSIZE (64 * 1024)
#define MAX_CIFS_SMALL_BUFFER_SIZE 448 /* big enough for most */
#define MAX_STREAM_PROT_LEN 0x00FFFFFF
@@ -464,9 +457,4 @@ static inline unsigned int get_rfc1002_len(void *buf)
{
return be32_to_cpu(*((__be32 *)buf)) & 0xffffff;
}
-
-static inline void inc_rfc1001_len(void *buf, int count)
-{
- be32_add_cpu((__be32 *)buf, count);
-}
#endif /* __SMB_COMMON_H__ */
--
2.43.0
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH v3 04/22] smb: move smb_version_values to common/cifsglob.h
2025-10-14 7:18 [PATCH v3 00/22] smb: fix some bugs, move duplicate definitions to common header file chenxiaosong.chenxiaosong
` (2 preceding siblings ...)
2025-10-14 7:18 ` [PATCH v3 03/22] smb: move some duplicate definitions to common/cifsglob.h chenxiaosong.chenxiaosong
@ 2025-10-14 7:18 ` chenxiaosong.chenxiaosong
2025-10-14 7:19 ` [PATCH v3 05/22] smb: move get_rfc1002_len() " chenxiaosong.chenxiaosong
` (7 subsequent siblings)
11 siblings, 0 replies; 37+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-10-14 7:18 UTC (permalink / raw)
To: stfrench, metze, pali, linkinjeon, smfrench, sfrench, senozhatsky,
tom, pc, ronniesahlberg, sprasad, bharathsm, christophe.jaillet,
zhangguodong
Cc: linux-cifs, linux-kernel, ChenXiaoSong
From: ZhangGuoDong <zhangguodong@kylinos.cn>
Merge the struct members of the server and the client, then move duplicate
definitions to common header file.
Co-developed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn>
---
fs/smb/client/cifsglob.h | 22 ----------------------
fs/smb/common/cifsglob.h | 31 +++++++++++++++++++++++++++++++
fs/smb/server/smb2misc.c | 2 +-
fs/smb/server/smb2ops.c | 32 ++++++++++++++++----------------
fs/smb/server/smb2pdu.c | 10 +++++-----
fs/smb/server/smb_common.h | 29 -----------------------------
6 files changed, 53 insertions(+), 73 deletions(-)
diff --git a/fs/smb/client/cifsglob.h b/fs/smb/client/cifsglob.h
index c5034cf9ac9e..88a428e3903a 100644
--- a/fs/smb/client/cifsglob.h
+++ b/fs/smb/client/cifsglob.h
@@ -638,28 +638,6 @@ struct smb_version_operations {
struct kvec *xattr_iov);
};
-struct smb_version_values {
- char *version_string;
- __u16 protocol_id;
- __u32 req_capabilities;
- __u32 large_lock_type;
- __u32 exclusive_lock_type;
- __u32 shared_lock_type;
- __u32 unlock_lock_type;
- size_t header_preamble_size;
- size_t header_size;
- size_t max_header_size;
- size_t read_rsp_size;
- __le16 lock_cmd;
- unsigned int cap_unix;
- unsigned int cap_nt_find;
- unsigned int cap_large_files;
- unsigned int cap_unicode;
- __u16 signing_enabled;
- __u16 signing_required;
- size_t create_lease_size;
-};
-
#define HEADER_SIZE(server) (server->vals->header_size)
#define MAX_HEADER_SIZE(server) (server->vals->max_header_size)
#define HEADER_PREAMBLE_SIZE(server) (server->vals->header_preamble_size)
diff --git a/fs/smb/common/cifsglob.h b/fs/smb/common/cifsglob.h
index 00fd215e3eb5..eda5e666a761 100644
--- a/fs/smb/common/cifsglob.h
+++ b/fs/smb/common/cifsglob.h
@@ -9,6 +9,37 @@
#ifndef _COMMON_CIFS_GLOB_H
#define _COMMON_CIFS_GLOB_H
+struct smb_version_values {
+ char *version_string;
+ __u16 protocol_id;
+ __le16 lock_cmd;
+ __u32 req_capabilities;
+ __u32 max_read_size;
+ __u32 max_write_size;
+ __u32 max_trans_size;
+ __u32 max_credits;
+ __u32 large_lock_type;
+ __u32 exclusive_lock_type;
+ __u32 shared_lock_type;
+ __u32 unlock_lock_type;
+ size_t header_preamble_size;
+ size_t header_size;
+ size_t max_header_size;
+ size_t read_rsp_size;
+ unsigned int cap_unix;
+ unsigned int cap_nt_find;
+ unsigned int cap_large_files;
+ unsigned int cap_unicode;
+ __u16 signing_enabled;
+ __u16 signing_required;
+ size_t create_lease_size;
+ size_t create_durable_size;
+ size_t create_durable_v2_size;
+ size_t create_mxac_size;
+ size_t create_disk_id_size;
+ size_t create_posix_size;
+};
+
static inline void inc_rfc1001_len(void *buf, int count)
{
be32_add_cpu((__be32 *)buf, count);
diff --git a/fs/smb/server/smb2misc.c b/fs/smb/server/smb2misc.c
index ae501024665e..67a2d7a793f6 100644
--- a/fs/smb/server/smb2misc.c
+++ b/fs/smb/server/smb2misc.c
@@ -460,7 +460,7 @@ int ksmbd_smb2_check_message(struct ksmbd_work *work)
}
validate_credit:
- if ((work->conn->vals->capabilities & SMB2_GLOBAL_CAP_LARGE_MTU) &&
+ if ((work->conn->vals->req_capabilities & SMB2_GLOBAL_CAP_LARGE_MTU) &&
smb2_validate_credit_charge(work->conn, hdr))
return 1;
diff --git a/fs/smb/server/smb2ops.c b/fs/smb/server/smb2ops.c
index 606aa3c5189a..bcf05caa2304 100644
--- a/fs/smb/server/smb2ops.c
+++ b/fs/smb/server/smb2ops.c
@@ -15,7 +15,7 @@
static struct smb_version_values smb21_server_values = {
.version_string = SMB21_VERSION_STRING,
.protocol_id = SMB21_PROT_ID,
- .capabilities = SMB2_GLOBAL_CAP_LARGE_MTU,
+ .req_capabilities = SMB2_GLOBAL_CAP_LARGE_MTU,
.max_read_size = SMB21_DEFAULT_IOSIZE,
.max_write_size = SMB21_DEFAULT_IOSIZE,
.max_trans_size = SMB21_DEFAULT_IOSIZE,
@@ -41,7 +41,7 @@ static struct smb_version_values smb21_server_values = {
static struct smb_version_values smb30_server_values = {
.version_string = SMB30_VERSION_STRING,
.protocol_id = SMB30_PROT_ID,
- .capabilities = SMB2_GLOBAL_CAP_LARGE_MTU,
+ .req_capabilities = SMB2_GLOBAL_CAP_LARGE_MTU,
.max_read_size = SMB3_DEFAULT_IOSIZE,
.max_write_size = SMB3_DEFAULT_IOSIZE,
.max_trans_size = SMB3_DEFAULT_TRANS_SIZE,
@@ -68,7 +68,7 @@ static struct smb_version_values smb30_server_values = {
static struct smb_version_values smb302_server_values = {
.version_string = SMB302_VERSION_STRING,
.protocol_id = SMB302_PROT_ID,
- .capabilities = SMB2_GLOBAL_CAP_LARGE_MTU,
+ .req_capabilities = SMB2_GLOBAL_CAP_LARGE_MTU,
.max_read_size = SMB3_DEFAULT_IOSIZE,
.max_write_size = SMB3_DEFAULT_IOSIZE,
.max_trans_size = SMB3_DEFAULT_TRANS_SIZE,
@@ -95,7 +95,7 @@ static struct smb_version_values smb302_server_values = {
static struct smb_version_values smb311_server_values = {
.version_string = SMB311_VERSION_STRING,
.protocol_id = SMB311_PROT_ID,
- .capabilities = SMB2_GLOBAL_CAP_LARGE_MTU,
+ .req_capabilities = SMB2_GLOBAL_CAP_LARGE_MTU,
.max_read_size = SMB3_DEFAULT_IOSIZE,
.max_write_size = SMB3_DEFAULT_IOSIZE,
.max_trans_size = SMB3_DEFAULT_TRANS_SIZE,
@@ -204,7 +204,7 @@ void init_smb2_1_server(struct ksmbd_conn *conn)
conn->signing_algorithm = SIGNING_ALG_HMAC_SHA256_LE;
if (server_conf.flags & KSMBD_GLOBAL_FLAG_SMB2_LEASES)
- conn->vals->capabilities |= SMB2_GLOBAL_CAP_LEASING;
+ conn->vals->req_capabilities |= SMB2_GLOBAL_CAP_LEASING;
}
/**
@@ -221,20 +221,20 @@ void init_smb3_0_server(struct ksmbd_conn *conn)
conn->signing_algorithm = SIGNING_ALG_AES_CMAC_LE;
if (server_conf.flags & KSMBD_GLOBAL_FLAG_SMB2_LEASES)
- conn->vals->capabilities |= SMB2_GLOBAL_CAP_LEASING |
+ conn->vals->req_capabilities |= SMB2_GLOBAL_CAP_LEASING |
SMB2_GLOBAL_CAP_DIRECTORY_LEASING;
if (server_conf.flags & KSMBD_GLOBAL_FLAG_SMB2_ENCRYPTION &&
conn->cli_cap & SMB2_GLOBAL_CAP_ENCRYPTION)
- conn->vals->capabilities |= SMB2_GLOBAL_CAP_ENCRYPTION;
+ conn->vals->req_capabilities |= SMB2_GLOBAL_CAP_ENCRYPTION;
if (server_conf.flags & KSMBD_GLOBAL_FLAG_SMB2_ENCRYPTION ||
(!(server_conf.flags & KSMBD_GLOBAL_FLAG_SMB2_ENCRYPTION_OFF) &&
conn->cli_cap & SMB2_GLOBAL_CAP_ENCRYPTION))
- conn->vals->capabilities |= SMB2_GLOBAL_CAP_ENCRYPTION;
+ conn->vals->req_capabilities |= SMB2_GLOBAL_CAP_ENCRYPTION;
if (server_conf.flags & KSMBD_GLOBAL_FLAG_SMB3_MULTICHANNEL)
- conn->vals->capabilities |= SMB2_GLOBAL_CAP_MULTI_CHANNEL;
+ conn->vals->req_capabilities |= SMB2_GLOBAL_CAP_MULTI_CHANNEL;
}
/**
@@ -251,19 +251,19 @@ void init_smb3_02_server(struct ksmbd_conn *conn)
conn->signing_algorithm = SIGNING_ALG_AES_CMAC_LE;
if (server_conf.flags & KSMBD_GLOBAL_FLAG_SMB2_LEASES)
- conn->vals->capabilities |= SMB2_GLOBAL_CAP_LEASING |
+ conn->vals->req_capabilities |= SMB2_GLOBAL_CAP_LEASING |
SMB2_GLOBAL_CAP_DIRECTORY_LEASING;
if (server_conf.flags & KSMBD_GLOBAL_FLAG_SMB2_ENCRYPTION ||
(!(server_conf.flags & KSMBD_GLOBAL_FLAG_SMB2_ENCRYPTION_OFF) &&
conn->cli_cap & SMB2_GLOBAL_CAP_ENCRYPTION))
- conn->vals->capabilities |= SMB2_GLOBAL_CAP_ENCRYPTION;
+ conn->vals->req_capabilities |= SMB2_GLOBAL_CAP_ENCRYPTION;
if (server_conf.flags & KSMBD_GLOBAL_FLAG_SMB3_MULTICHANNEL)
- conn->vals->capabilities |= SMB2_GLOBAL_CAP_MULTI_CHANNEL;
+ conn->vals->req_capabilities |= SMB2_GLOBAL_CAP_MULTI_CHANNEL;
if (server_conf.flags & KSMBD_GLOBAL_FLAG_DURABLE_HANDLE)
- conn->vals->capabilities |= SMB2_GLOBAL_CAP_PERSISTENT_HANDLES;
+ conn->vals->req_capabilities |= SMB2_GLOBAL_CAP_PERSISTENT_HANDLES;
}
/**
@@ -280,14 +280,14 @@ int init_smb3_11_server(struct ksmbd_conn *conn)
conn->signing_algorithm = SIGNING_ALG_AES_CMAC_LE;
if (server_conf.flags & KSMBD_GLOBAL_FLAG_SMB2_LEASES)
- conn->vals->capabilities |= SMB2_GLOBAL_CAP_LEASING |
+ conn->vals->req_capabilities |= SMB2_GLOBAL_CAP_LEASING |
SMB2_GLOBAL_CAP_DIRECTORY_LEASING;
if (server_conf.flags & KSMBD_GLOBAL_FLAG_SMB3_MULTICHANNEL)
- conn->vals->capabilities |= SMB2_GLOBAL_CAP_MULTI_CHANNEL;
+ conn->vals->req_capabilities |= SMB2_GLOBAL_CAP_MULTI_CHANNEL;
if (server_conf.flags & KSMBD_GLOBAL_FLAG_DURABLE_HANDLE)
- conn->vals->capabilities |= SMB2_GLOBAL_CAP_PERSISTENT_HANDLES;
+ conn->vals->req_capabilities |= SMB2_GLOBAL_CAP_PERSISTENT_HANDLES;
INIT_LIST_HEAD(&conn->preauth_sess_table);
return 0;
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index b731d9b09408..8a615e8c600f 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -282,7 +282,7 @@ int init_smb2_neg_rsp(struct ksmbd_work *work)
/* Not setting conn guid rsp->ServerGUID, as it
* not used by client for identifying connection
*/
- rsp->Capabilities = cpu_to_le32(conn->vals->capabilities);
+ rsp->Capabilities = cpu_to_le32(conn->vals->req_capabilities);
/* Default Max Message Size till SMB2.0, 64K*/
rsp->MaxTransactSize = cpu_to_le32(conn->vals->max_trans_size);
rsp->MaxReadSize = cpu_to_le32(conn->vals->max_read_size);
@@ -956,7 +956,7 @@ bool smb3_encryption_negotiated(struct ksmbd_conn *conn)
* SMB 3.0 and 3.0.2 dialects use the SMB2_GLOBAL_CAP_ENCRYPTION flag.
* SMB 3.1.1 uses the cipher_type field.
*/
- return (conn->vals->capabilities & SMB2_GLOBAL_CAP_ENCRYPTION) ||
+ return (conn->vals->req_capabilities & SMB2_GLOBAL_CAP_ENCRYPTION) ||
conn->cipher_type;
}
@@ -1210,7 +1210,7 @@ int smb2_handle_negotiate(struct ksmbd_work *work)
rc = -EINVAL;
goto err_out;
}
- rsp->Capabilities = cpu_to_le32(conn->vals->capabilities);
+ rsp->Capabilities = cpu_to_le32(conn->vals->req_capabilities);
/* For stats */
conn->connection_type = conn->dialect;
@@ -3474,7 +3474,7 @@ int smb2_open(struct ksmbd_work *work)
share_ret = ksmbd_smb_check_shared_mode(fp->filp, fp);
if (!test_share_config_flag(work->tcon->share_conf, KSMBD_SHARE_FLAG_OPLOCKS) ||
(req_op_level == SMB2_OPLOCK_LEVEL_LEASE &&
- !(conn->vals->capabilities & SMB2_GLOBAL_CAP_LEASING))) {
+ !(conn->vals->req_capabilities & SMB2_GLOBAL_CAP_LEASING))) {
if (share_ret < 0 && !S_ISDIR(file_inode(fp->filp)->i_mode)) {
rc = share_ret;
goto err_out1;
@@ -7977,7 +7977,7 @@ static int fsctl_validate_negotiate_info(struct ksmbd_conn *conn,
goto err_out;
}
- neg_rsp->Capabilities = cpu_to_le32(conn->vals->capabilities);
+ neg_rsp->Capabilities = cpu_to_le32(conn->vals->req_capabilities);
memset(neg_rsp->Guid, 0, SMB2_CLIENT_GUID_SIZE);
neg_rsp->SecurityMode = cpu_to_le16(conn->srv_sec_mode);
neg_rsp->Dialect = cpu_to_le16(conn->dialect);
diff --git a/fs/smb/server/smb_common.h b/fs/smb/server/smb_common.h
index 863716207a0d..dac783b46545 100644
--- a/fs/smb/server/smb_common.h
+++ b/fs/smb/server/smb_common.h
@@ -338,35 +338,6 @@ struct file_id_full_dir_info {
char FileName[];
} __packed; /* level 0x105 FF rsp data */
-struct smb_version_values {
- char *version_string;
- __u16 protocol_id;
- __le16 lock_cmd;
- __u32 capabilities;
- __u32 max_read_size;
- __u32 max_write_size;
- __u32 max_trans_size;
- __u32 max_credits;
- __u32 large_lock_type;
- __u32 exclusive_lock_type;
- __u32 shared_lock_type;
- __u32 unlock_lock_type;
- size_t header_size;
- size_t max_header_size;
- size_t read_rsp_size;
- unsigned int cap_unix;
- unsigned int cap_nt_find;
- unsigned int cap_large_files;
- __u16 signing_enabled;
- __u16 signing_required;
- size_t create_lease_size;
- size_t create_durable_size;
- size_t create_durable_v2_size;
- size_t create_mxac_size;
- size_t create_disk_id_size;
- size_t create_posix_size;
-};
-
struct filesystem_posix_info {
/* For undefined recommended transfer size return -1 in that field */
__le32 OptimalTransferSize; /* bsize on some os, iosize on other os */
--
2.43.0
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH v3 05/22] smb: move get_rfc1002_len() to common/cifsglob.h
2025-10-14 7:18 [PATCH v3 00/22] smb: fix some bugs, move duplicate definitions to common header file chenxiaosong.chenxiaosong
` (3 preceding siblings ...)
2025-10-14 7:18 ` [PATCH v3 04/22] smb: move smb_version_values " chenxiaosong.chenxiaosong
@ 2025-10-14 7:19 ` chenxiaosong.chenxiaosong
2025-10-14 7:19 ` [PATCH v3 06/22] smb: move SMB1_PROTO_NUMBER " chenxiaosong.chenxiaosong
` (6 subsequent siblings)
11 siblings, 0 replies; 37+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-10-14 7:19 UTC (permalink / raw)
To: stfrench, metze, pali, linkinjeon, smfrench, sfrench, senozhatsky,
tom, pc, ronniesahlberg, sprasad, bharathsm, christophe.jaillet,
zhangguodong
Cc: linux-cifs, linux-kernel, ChenXiaoSong
From: ZhangGuoDong <zhangguodong@kylinos.cn>
Rename get_rfc1002_length() to get_rfc1002_len(), then move duplicate
definitions to common header file.
Co-developed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn>
---
fs/smb/client/cifsglob.h | 6 ------
fs/smb/client/cifssmb.c | 6 +++---
fs/smb/client/cifstransport.c | 8 ++++----
fs/smb/client/connect.c | 2 +-
fs/smb/common/cifsglob.h | 5 +++++
fs/smb/server/smb_common.h | 5 -----
6 files changed, 13 insertions(+), 19 deletions(-)
diff --git a/fs/smb/client/cifsglob.h b/fs/smb/client/cifsglob.h
index 88a428e3903a..81f77eb9a01e 100644
--- a/fs/smb/client/cifsglob.h
+++ b/fs/smb/client/cifsglob.h
@@ -675,12 +675,6 @@ struct cifs_mnt_data {
int flags;
};
-static inline unsigned int
-get_rfc1002_length(void *buf)
-{
- return be32_to_cpu(*((__be32 *)buf)) & 0xffffff;
-}
-
struct TCP_Server_Info {
struct list_head tcp_ses_list;
struct list_head smb_ses_list;
diff --git a/fs/smb/client/cifssmb.c b/fs/smb/client/cifssmb.c
index 2881efcbe09a..9a346d67e298 100644
--- a/fs/smb/client/cifssmb.c
+++ b/fs/smb/client/cifssmb.c
@@ -614,7 +614,7 @@ CIFSSMBEcho(struct TCP_Server_Info *server)
iov[0].iov_len = 4;
iov[0].iov_base = smb;
- iov[1].iov_len = get_rfc1002_length(smb);
+ iov[1].iov_len = get_rfc1002_len(smb);
iov[1].iov_base = (char *)smb + 4;
rc = cifs_call_async(server, &rqst, NULL, cifs_echo_callback, NULL,
@@ -1435,7 +1435,7 @@ cifs_async_readv(struct cifs_io_subrequest *rdata)
rdata->iov[0].iov_base = smb;
rdata->iov[0].iov_len = 4;
rdata->iov[1].iov_base = (char *)smb + 4;
- rdata->iov[1].iov_len = get_rfc1002_length(smb);
+ rdata->iov[1].iov_len = get_rfc1002_len(smb);
rc = cifs_call_async(tcon->ses->server, &rqst, cifs_readv_receive,
cifs_readv_callback, NULL, rdata, 0, NULL);
@@ -1800,7 +1800,7 @@ cifs_async_writev(struct cifs_io_subrequest *wdata)
/* 4 for RFC1001 length + 1 for BCC */
iov[0].iov_len = 4;
iov[0].iov_base = smb;
- iov[1].iov_len = get_rfc1002_length(smb) + 1;
+ iov[1].iov_len = get_rfc1002_len(smb) + 1;
iov[1].iov_base = (char *)smb + 4;
rqst.rq_iov = iov;
diff --git a/fs/smb/client/cifstransport.c b/fs/smb/client/cifstransport.c
index e98b95eff8c9..4c4f5befb6d3 100644
--- a/fs/smb/client/cifstransport.c
+++ b/fs/smb/client/cifstransport.c
@@ -165,7 +165,7 @@ SendReceiveNoRsp(const unsigned int xid, struct cifs_ses *ses,
int resp_buf_type;
iov[0].iov_base = in_buf;
- iov[0].iov_len = get_rfc1002_length(in_buf) + 4;
+ iov[0].iov_len = get_rfc1002_len(in_buf) + 4;
flags |= CIFS_NO_RSP_BUF;
rc = SendReceive2(xid, ses, iov, 1, &resp_buf_type, flags, &rsp_iov);
cifs_dbg(NOISY, "SendRcvNoRsp flags %d rc %d\n", flags, rc);
@@ -177,7 +177,7 @@ int
cifs_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server,
bool log_error)
{
- unsigned int len = get_rfc1002_length(mid->resp_buf) + 4;
+ unsigned int len = get_rfc1002_len(mid->resp_buf) + 4;
dump_smb(mid->resp_buf, min_t(u32, 92, len));
@@ -370,7 +370,7 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses,
goto out;
}
- *pbytes_returned = get_rfc1002_length(midQ->resp_buf);
+ *pbytes_returned = get_rfc1002_len(midQ->resp_buf);
memcpy(out_buf, midQ->resp_buf, *pbytes_returned + 4);
rc = cifs_check_receive(midQ, server, 0);
out:
@@ -554,7 +554,7 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon,
goto out;
}
- *pbytes_returned = get_rfc1002_length(midQ->resp_buf);
+ *pbytes_returned = get_rfc1002_len(midQ->resp_buf);
memcpy(out_buf, midQ->resp_buf, *pbytes_returned + 4);
rc = cifs_check_receive(midQ, server, 0);
out:
diff --git a/fs/smb/client/connect.c b/fs/smb/client/connect.c
index dd12f3eb61dc..22f37ae7a66a 100644
--- a/fs/smb/client/connect.c
+++ b/fs/smb/client/connect.c
@@ -1299,7 +1299,7 @@ cifs_demultiplex_thread(void *p)
* The right amount was read from socket - 4 bytes,
* so we can now interpret the length field.
*/
- pdu_length = get_rfc1002_length(buf);
+ pdu_length = get_rfc1002_len(buf);
cifs_dbg(FYI, "RFC1002 header 0x%x\n", pdu_length);
if (!is_smb_response(server, buf[0]))
diff --git a/fs/smb/common/cifsglob.h b/fs/smb/common/cifsglob.h
index eda5e666a761..371160fec1cd 100644
--- a/fs/smb/common/cifsglob.h
+++ b/fs/smb/common/cifsglob.h
@@ -40,6 +40,11 @@ struct smb_version_values {
size_t create_posix_size;
};
+static inline unsigned int get_rfc1002_len(void *buf)
+{
+ return be32_to_cpu(*((__be32 *)buf)) & 0xffffff;
+}
+
static inline void inc_rfc1001_len(void *buf, int count)
{
be32_add_cpu((__be32 *)buf, count);
diff --git a/fs/smb/server/smb_common.h b/fs/smb/server/smb_common.h
index dac783b46545..9c0db206624b 100644
--- a/fs/smb/server/smb_common.h
+++ b/fs/smb/server/smb_common.h
@@ -423,9 +423,4 @@ unsigned int ksmbd_server_side_copy_max_chunk_size(void);
unsigned int ksmbd_server_side_copy_max_total_size(void);
bool is_asterisk(char *p);
__le32 smb_map_generic_desired_access(__le32 daccess);
-
-static inline unsigned int get_rfc1002_len(void *buf)
-{
- return be32_to_cpu(*((__be32 *)buf)) & 0xffffff;
-}
#endif /* __SMB_COMMON_H__ */
--
2.43.0
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH v3 06/22] smb: move SMB1_PROTO_NUMBER to common/cifsglob.h
2025-10-14 7:18 [PATCH v3 00/22] smb: fix some bugs, move duplicate definitions to common header file chenxiaosong.chenxiaosong
` (4 preceding siblings ...)
2025-10-14 7:19 ` [PATCH v3 05/22] smb: move get_rfc1002_len() " chenxiaosong.chenxiaosong
@ 2025-10-14 7:19 ` chenxiaosong.chenxiaosong
2025-10-14 7:19 ` [PATCH v3 07/22] smb: move some duplicate definitions to common/smb2pdu.h chenxiaosong.chenxiaosong
` (5 subsequent siblings)
11 siblings, 0 replies; 37+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-10-14 7:19 UTC (permalink / raw)
To: stfrench, metze, pali, linkinjeon, smfrench, sfrench, senozhatsky,
tom, pc, ronniesahlberg, sprasad, bharathsm, christophe.jaillet,
zhangguodong
Cc: linux-cifs, linux-kernel, ChenXiaoSong
From: ZhangGuoDong <zhangguodong@kylinos.cn>
Replace the constant of client with SMB1_PROTO_NUMBER, then move the
macro definition from server/smb_common.h to common/cifsglob.h.
Co-developed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn>
Suggested-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
fs/smb/client/misc.c | 2 +-
fs/smb/common/cifsglob.h | 2 ++
fs/smb/server/smb_common.h | 1 -
3 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/fs/smb/client/misc.c b/fs/smb/client/misc.c
index dda6dece802a..68607b7a68ca 100644
--- a/fs/smb/client/misc.c
+++ b/fs/smb/client/misc.c
@@ -318,7 +318,7 @@ static int
check_smb_hdr(struct smb_hdr *smb)
{
/* does it have the right SMB "signature" ? */
- if (*(__le32 *) smb->Protocol != cpu_to_le32(0x424d53ff)) {
+ if (*(__le32 *) smb->Protocol != SMB1_PROTO_NUMBER) {
cifs_dbg(VFS, "Bad protocol string signature header 0x%x\n",
*(unsigned int *)smb->Protocol);
return 1;
diff --git a/fs/smb/common/cifsglob.h b/fs/smb/common/cifsglob.h
index 371160fec1cd..5928d35c7f30 100644
--- a/fs/smb/common/cifsglob.h
+++ b/fs/smb/common/cifsglob.h
@@ -9,6 +9,8 @@
#ifndef _COMMON_CIFS_GLOB_H
#define _COMMON_CIFS_GLOB_H
+#define SMB1_PROTO_NUMBER cpu_to_le32(0x424d53ff)
+
struct smb_version_values {
char *version_string;
__u16 protocol_id;
diff --git a/fs/smb/server/smb_common.h b/fs/smb/server/smb_common.h
index 9c0db206624b..6d427dbed5fd 100644
--- a/fs/smb/server/smb_common.h
+++ b/fs/smb/server/smb_common.h
@@ -151,7 +151,6 @@
FILE_EXECUTE | FILE_DELETE_CHILD | \
FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES)
-#define SMB1_PROTO_NUMBER cpu_to_le32(0x424d53ff)
#define SMB_COM_NEGOTIATE 0x72
#define SMB1_CLIENT_GUID_SIZE (16)
--
2.43.0
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH v3 07/22] smb: move some duplicate definitions to common/smb2pdu.h
2025-10-14 7:18 [PATCH v3 00/22] smb: fix some bugs, move duplicate definitions to common header file chenxiaosong.chenxiaosong
` (5 preceding siblings ...)
2025-10-14 7:19 ` [PATCH v3 06/22] smb: move SMB1_PROTO_NUMBER " chenxiaosong.chenxiaosong
@ 2025-10-14 7:19 ` chenxiaosong.chenxiaosong
2025-10-20 4:52 ` Namjae Jeon
2025-10-14 7:19 ` [PATCH v3 08/22] smb: move smb_sockaddr_in and smb_sockaddr_in6 " chenxiaosong.chenxiaosong
` (4 subsequent siblings)
11 siblings, 1 reply; 37+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-10-14 7:19 UTC (permalink / raw)
To: stfrench, metze, pali, linkinjeon, smfrench, sfrench, senozhatsky,
tom, pc, ronniesahlberg, sprasad, bharathsm, christophe.jaillet,
zhangguodong
Cc: linux-cifs, linux-kernel, ChenXiaoSong
From: ZhangGuoDong <zhangguodong@kylinos.cn>
In order to maintain the code more easily, move duplicate definitions to
new common header file.
Co-developed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn>
---
fs/smb/client/smb2pdu.h | 24 +++---------------------
fs/smb/common/smb2pdu.h | 24 ++++++++++++++++++++++++
fs/smb/server/smb2pdu.c | 8 ++++----
fs/smb/server/smb2pdu.h | 17 -----------------
4 files changed, 31 insertions(+), 42 deletions(-)
diff --git a/fs/smb/client/smb2pdu.h b/fs/smb/client/smb2pdu.h
index 101024f8f725..c013560bcfa1 100644
--- a/fs/smb/client/smb2pdu.h
+++ b/fs/smb/client/smb2pdu.h
@@ -135,11 +135,9 @@ struct share_redirect_error_context_rsp {
/* See MS-SMB2 2.2.13.2.11 */
-/* Flags */
-#define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002
struct durable_context_v2 {
__le32 Timeout;
- __le32 Flags;
+ __le32 Flags; /* see SMB2_DHANDLE_FLAG_PERSISTENT */
__u64 Reserved;
__u8 CreateGuid[16];
} __packed;
@@ -157,13 +155,13 @@ struct durable_reconnect_context_v2 {
__u64 VolatileFileId;
} Fid;
__u8 CreateGuid[16];
- __le32 Flags; /* see above DHANDLE_FLAG_PERSISTENT */
+ __le32 Flags; /* see SMB2_DHANDLE_FLAG_PERSISTENT */
} __packed;
/* See MS-SMB2 2.2.14.2.12 */
struct durable_reconnect_context_v2_rsp {
__le32 Timeout;
- __le32 Flags; /* see above DHANDLE_FLAG_PERSISTENT */
+ __le32 Flags; /* see SMB2_DHANDLE_FLAG_PERSISTENT */
} __packed;
struct create_durable_handle_reconnect_v2 {
@@ -263,22 +261,6 @@ struct network_resiliency_req {
} __packed;
/* There is no buffer for the response ie no struct network_resiliency_rsp */
-#define RSS_CAPABLE cpu_to_le32(0x00000001)
-#define RDMA_CAPABLE cpu_to_le32(0x00000002)
-
-#define INTERNETWORK cpu_to_le16(0x0002)
-#define INTERNETWORKV6 cpu_to_le16(0x0017)
-
-struct network_interface_info_ioctl_rsp {
- __le32 Next; /* next interface. zero if this is last one */
- __le32 IfIndex;
- __le32 Capability; /* RSS or RDMA Capable */
- __le32 Reserved;
- __le64 LinkSpeed;
- __le16 Family;
- __u8 Buffer[126];
-} __packed;
-
struct iface_info_ipv4 {
__be16 Port;
__be32 IPv4Address;
diff --git a/fs/smb/common/smb2pdu.h b/fs/smb/common/smb2pdu.h
index f79a5165a7cc..25e8ece283c4 100644
--- a/fs/smb/common/smb2pdu.h
+++ b/fs/smb/common/smb2pdu.h
@@ -1290,6 +1290,10 @@ struct create_mxac_req {
__le64 Timestamp;
} __packed;
+/* See MS-SMB2 2.2.13.2.11 and MS-SMB2 2.2.13.2.12 and MS-SMB2 2.2.14.2.12 */
+/* Flags */
+#define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002
+
/* See MS-SMB2 2.2.14.2.5 */
struct create_mxac_rsp {
struct create_context_hdr ccontext;
@@ -1404,6 +1408,26 @@ struct smb2_ioctl_rsp {
__u8 Buffer[];
} __packed;
+/* See MS-SMB2 2.2.32.5 and MS-SMB2 2.2.32.5.1 */
+#define RSS_CAPABLE cpu_to_le32(0x00000001)
+#define RDMA_CAPABLE cpu_to_le32(0x00000002)
+#define INTERNETWORK cpu_to_le16(0x0002)
+#define INTERNETWORKV6 cpu_to_le16(0x0017)
+struct network_interface_info_ioctl_rsp {
+ __le32 Next; /* next interface. zero if this is last one */
+ __le32 IfIndex;
+ __le32 Capability; /* RSS or RDMA Capable */
+ __le32 Reserved;
+ __le64 LinkSpeed;
+ union {
+ char SockAddr_Storage[128];
+ struct {
+ __le16 Family;
+ __u8 Buffer[126];
+ };
+ };
+} __packed;
+
/* this goes in the ioctl buffer when doing FSCTL_SET_ZERO_DATA */
struct file_zero_data_information {
__le64 FileOffset;
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index 8a615e8c600f..169fbec03cfd 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -7869,9 +7869,9 @@ static int fsctl_query_iface_info_ioctl(struct ksmbd_conn *conn,
nii_rsp->Capability = 0;
if (netdev->real_num_tx_queues > 1)
- nii_rsp->Capability |= cpu_to_le32(RSS_CAPABLE);
+ nii_rsp->Capability |= RSS_CAPABLE;
if (ksmbd_rdma_capable_netdev(netdev))
- nii_rsp->Capability |= cpu_to_le32(RDMA_CAPABLE);
+ nii_rsp->Capability |= RDMA_CAPABLE;
nii_rsp->Next = cpu_to_le32(152);
nii_rsp->Reserved = 0;
@@ -7897,7 +7897,7 @@ static int fsctl_query_iface_info_ioctl(struct ksmbd_conn *conn,
if (!ipv4_set) {
struct in_device *idev;
- sockaddr_storage->Family = cpu_to_le16(INTERNETWORK);
+ sockaddr_storage->Family = INTERNETWORK;
sockaddr_storage->addr4.Port = 0;
idev = __in_dev_get_rtnl(netdev);
@@ -7913,7 +7913,7 @@ static int fsctl_query_iface_info_ioctl(struct ksmbd_conn *conn,
struct inet6_ifaddr *ifa;
__u8 *ipv6_addr = sockaddr_storage->addr6.IPv6address;
- sockaddr_storage->Family = cpu_to_le16(INTERNETWORKV6);
+ sockaddr_storage->Family = INTERNETWORKV6;
sockaddr_storage->addr6.Port = 0;
sockaddr_storage->addr6.FlowInfo = 0;
diff --git a/fs/smb/server/smb2pdu.h b/fs/smb/server/smb2pdu.h
index 5163d5241b90..fe92bfeb415a 100644
--- a/fs/smb/server/smb2pdu.h
+++ b/fs/smb/server/smb2pdu.h
@@ -116,8 +116,6 @@ struct create_durable_rsp {
} __packed;
/* See MS-SMB2 2.2.13.2.11 */
-/* Flags */
-#define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002
struct create_durable_v2_rsp {
struct create_context_hdr ccontext;
__u8 Name[8];
@@ -151,9 +149,6 @@ struct smb_sockaddr_in6 {
__be32 ScopeId;
} __packed;
-#define INTERNETWORK 0x0002
-#define INTERNETWORKV6 0x0017
-
struct sockaddr_storage_rsp {
__le16 Family;
union {
@@ -162,18 +157,6 @@ struct sockaddr_storage_rsp {
};
} __packed;
-#define RSS_CAPABLE 0x00000001
-#define RDMA_CAPABLE 0x00000002
-
-struct network_interface_info_ioctl_rsp {
- __le32 Next; /* next interface. zero if this is last one */
- __le32 IfIndex;
- __le32 Capability; /* RSS or RDMA Capable */
- __le32 Reserved;
- __le64 LinkSpeed;
- char SockAddr_Storage[128];
-} __packed;
-
struct file_object_buf_type1_ioctl_rsp {
__u8 ObjectId[16];
__u8 BirthVolumeId[16];
--
2.43.0
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH v3 08/22] smb: move smb_sockaddr_in and smb_sockaddr_in6 to common/smb2pdu.h
2025-10-14 7:18 [PATCH v3 00/22] smb: fix some bugs, move duplicate definitions to common header file chenxiaosong.chenxiaosong
` (6 preceding siblings ...)
2025-10-14 7:19 ` [PATCH v3 07/22] smb: move some duplicate definitions to common/smb2pdu.h chenxiaosong.chenxiaosong
@ 2025-10-14 7:19 ` chenxiaosong.chenxiaosong
2025-10-14 7:19 ` [PATCH v3 09/22] smb: move copychunk definitions " chenxiaosong.chenxiaosong
` (3 subsequent siblings)
11 siblings, 0 replies; 37+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-10-14 7:19 UTC (permalink / raw)
To: stfrench, metze, pali, linkinjeon, smfrench, sfrench, senozhatsky,
tom, pc, ronniesahlberg, sprasad, bharathsm, christophe.jaillet,
zhangguodong
Cc: linux-cifs, linux-kernel, ChenXiaoSong
From: ZhangGuoDong <zhangguodong@kylinos.cn>
Rename 4 places:
- iface_info_ipv4 -> smb_sockaddr_in
- iface_info_ipv6 -> smb_sockaddr_in6
- IPv4address -> IPv4Address
- IPv6address -> IPv6Address
Then move duplicate definitions to common header file.
Co-developed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn>
---
fs/smb/client/smb2ops.c | 8 ++++----
fs/smb/client/smb2pdu.h | 13 -------------
fs/smb/common/smb2pdu.h | 15 +++++++++++++++
fs/smb/server/smb2pdu.c | 4 ++--
fs/smb/server/smb2pdu.h | 13 -------------
5 files changed, 21 insertions(+), 32 deletions(-)
diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c
index 7c392cf5940b..e90ca77d2ac7 100644
--- a/fs/smb/client/smb2ops.c
+++ b/fs/smb/client/smb2ops.c
@@ -624,8 +624,8 @@ parse_server_interfaces(struct network_interface_info_ioctl_rsp *buf,
struct network_interface_info_ioctl_rsp *p;
struct sockaddr_in *addr4;
struct sockaddr_in6 *addr6;
- struct iface_info_ipv4 *p4;
- struct iface_info_ipv6 *p6;
+ struct smb_sockaddr_in *p4;
+ struct smb_sockaddr_in6 *p6;
struct cifs_server_iface *info = NULL, *iface = NULL, *niface = NULL;
struct cifs_server_iface tmp_iface;
ssize_t bytes_left;
@@ -685,7 +685,7 @@ parse_server_interfaces(struct network_interface_info_ioctl_rsp *buf,
*/
case INTERNETWORK:
addr4 = (struct sockaddr_in *)&tmp_iface.sockaddr;
- p4 = (struct iface_info_ipv4 *)p->Buffer;
+ p4 = (struct smb_sockaddr_in *)p->Buffer;
addr4->sin_family = AF_INET;
memcpy(&addr4->sin_addr, &p4->IPv4Address, 4);
@@ -697,7 +697,7 @@ parse_server_interfaces(struct network_interface_info_ioctl_rsp *buf,
break;
case INTERNETWORKV6:
addr6 = (struct sockaddr_in6 *)&tmp_iface.sockaddr;
- p6 = (struct iface_info_ipv6 *)p->Buffer;
+ p6 = (struct smb_sockaddr_in6 *)p->Buffer;
addr6->sin6_family = AF_INET6;
memcpy(&addr6->sin6_addr, &p6->IPv6Address, 16);
diff --git a/fs/smb/client/smb2pdu.h b/fs/smb/client/smb2pdu.h
index c013560bcfa1..0be63c00f848 100644
--- a/fs/smb/client/smb2pdu.h
+++ b/fs/smb/client/smb2pdu.h
@@ -261,19 +261,6 @@ struct network_resiliency_req {
} __packed;
/* There is no buffer for the response ie no struct network_resiliency_rsp */
-struct iface_info_ipv4 {
- __be16 Port;
- __be32 IPv4Address;
- __be64 Reserved;
-} __packed;
-
-struct iface_info_ipv6 {
- __be16 Port;
- __be32 FlowInfo;
- __u8 IPv6Address[16];
- __be32 ScopeId;
-} __packed;
-
#define NO_FILE_ID 0xFFFFFFFFFFFFFFFFULL /* general ioctls to srv not to file */
struct compress_ioctl {
diff --git a/fs/smb/common/smb2pdu.h b/fs/smb/common/smb2pdu.h
index 25e8ece283c4..b01114108d23 100644
--- a/fs/smb/common/smb2pdu.h
+++ b/fs/smb/common/smb2pdu.h
@@ -1428,6 +1428,21 @@ struct network_interface_info_ioctl_rsp {
};
} __packed;
+/* See MS-SMB2 2.2.32.5.1.1 */
+struct smb_sockaddr_in {
+ __be16 Port;
+ __be32 IPv4Address;
+ __u8 Reserved[8];
+} __packed;
+
+/* See MS-SMB2 2.2.32.5.1.2 */
+struct smb_sockaddr_in6 {
+ __be16 Port;
+ __be32 FlowInfo;
+ __u8 IPv6Address[16];
+ __be32 ScopeId;
+} __packed;
+
/* this goes in the ioctl buffer when doing FSCTL_SET_ZERO_DATA */
struct file_zero_data_information {
__le64 FileOffset;
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index 169fbec03cfd..dd6f1375a833 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -7903,7 +7903,7 @@ static int fsctl_query_iface_info_ioctl(struct ksmbd_conn *conn,
idev = __in_dev_get_rtnl(netdev);
if (!idev)
continue;
- sockaddr_storage->addr4.IPv4address =
+ sockaddr_storage->addr4.IPv4Address =
idev_ipv4_address(idev);
nbytes += sizeof(struct network_interface_info_ioctl_rsp);
ipv4_set = true;
@@ -7911,7 +7911,7 @@ static int fsctl_query_iface_info_ioctl(struct ksmbd_conn *conn,
} else {
struct inet6_dev *idev6;
struct inet6_ifaddr *ifa;
- __u8 *ipv6_addr = sockaddr_storage->addr6.IPv6address;
+ __u8 *ipv6_addr = sockaddr_storage->addr6.IPv6Address;
sockaddr_storage->Family = INTERNETWORKV6;
sockaddr_storage->addr6.Port = 0;
diff --git a/fs/smb/server/smb2pdu.h b/fs/smb/server/smb2pdu.h
index fe92bfeb415a..5a76b706ccd9 100644
--- a/fs/smb/server/smb2pdu.h
+++ b/fs/smb/server/smb2pdu.h
@@ -136,19 +136,6 @@ struct create_posix_rsp {
#define SMB2_0_IOCTL_IS_FSCTL 0x00000001
-struct smb_sockaddr_in {
- __be16 Port;
- __be32 IPv4address;
- __u8 Reserved[8];
-} __packed;
-
-struct smb_sockaddr_in6 {
- __be16 Port;
- __be32 FlowInfo;
- __u8 IPv6address[16];
- __be32 ScopeId;
-} __packed;
-
struct sockaddr_storage_rsp {
__le16 Family;
union {
--
2.43.0
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH v3 09/22] smb: move copychunk definitions to common/smb2pdu.h
2025-10-14 7:18 [PATCH v3 00/22] smb: fix some bugs, move duplicate definitions to common header file chenxiaosong.chenxiaosong
` (7 preceding siblings ...)
2025-10-14 7:19 ` [PATCH v3 08/22] smb: move smb_sockaddr_in and smb_sockaddr_in6 " chenxiaosong.chenxiaosong
@ 2025-10-14 7:19 ` chenxiaosong.chenxiaosong
2025-10-20 5:03 ` Namjae Jeon
2025-10-14 7:19 ` [PATCH v3 10/22] smb: move resume_key_ioctl_rsp " chenxiaosong.chenxiaosong
` (2 subsequent siblings)
11 siblings, 1 reply; 37+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-10-14 7:19 UTC (permalink / raw)
To: stfrench, metze, pali, linkinjeon, smfrench, sfrench, senozhatsky,
tom, pc, ronniesahlberg, sprasad, bharathsm, christophe.jaillet,
zhangguodong
Cc: linux-cifs, linux-kernel, ChenXiaoSong
From: ZhangGuoDong <zhangguodong@kylinos.cn>
Rename 3 places:
- copychunk_ioctl -> copychunk_ioctl_req
- copychunk -> srv_copychunk
- server: ResumeKey -> SourceKeyU64
Merge the struct members of the server and the client, then move duplicate
definitions to common header file.
Co-developed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn>
---
fs/smb/client/cifspdu.h | 8 --------
fs/smb/client/smb2ops.c | 6 +++---
fs/smb/client/smb2pdu.h | 24 ------------------------
fs/smb/common/smb2pdu.h | 29 +++++++++++++++++++++++++++++
fs/smb/server/smb2pdu.c | 4 ++--
fs/smb/server/smb2pdu.h | 20 --------------------
6 files changed, 34 insertions(+), 57 deletions(-)
diff --git a/fs/smb/client/cifspdu.h b/fs/smb/client/cifspdu.h
index d9cf7db0ac35..c86a329e5822 100644
--- a/fs/smb/client/cifspdu.h
+++ b/fs/smb/client/cifspdu.h
@@ -1323,14 +1323,6 @@ typedef struct smb_com_ntransact_rsp {
/* parms and data follow */
} __attribute__((packed)) NTRANSACT_RSP;
-/* See MS-SMB 2.2.7.2.1.1 */
-struct srv_copychunk {
- __le64 SourceOffset;
- __le64 DestinationOffset;
- __le32 CopyLength;
- __u32 Reserved;
-} __packed;
-
typedef struct smb_com_transaction_ioctl_req {
struct smb_hdr hdr; /* wct = 23 */
__u8 MaxSetupCount;
diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c
index e90ca77d2ac7..ea9709d81851 100644
--- a/fs/smb/client/smb2ops.c
+++ b/fs/smb/client/smb2ops.c
@@ -1524,7 +1524,7 @@ smb2_close_getattr(const unsigned int xid, struct cifs_tcon *tcon,
static int
SMB2_request_res_key(const unsigned int xid, struct cifs_tcon *tcon,
u64 persistent_fid, u64 volatile_fid,
- struct copychunk_ioctl *pcchunk)
+ struct copychunk_ioctl_req *pcchunk)
{
int rc;
unsigned int ret_data_len;
@@ -1857,10 +1857,10 @@ smb2_copychunk_range(const unsigned int xid,
{
int rc = 0;
unsigned int ret_data_len = 0;
- struct copychunk_ioctl *cc_req = NULL;
+ struct copychunk_ioctl_req *cc_req = NULL;
struct copychunk_ioctl_rsp *cc_rsp = NULL;
struct cifs_tcon *tcon;
- struct copychunk *chunk;
+ struct srv_copychunk *chunk;
u32 chunks, chunk_count, chunk_bytes;
u32 copy_bytes, copy_bytes_left;
u32 chunks_written, bytes_written;
diff --git a/fs/smb/client/smb2pdu.h b/fs/smb/client/smb2pdu.h
index 0be63c00f848..9b5880e60a4e 100644
--- a/fs/smb/client/smb2pdu.h
+++ b/fs/smb/client/smb2pdu.h
@@ -191,36 +191,12 @@ struct crt_sd_ctxt {
struct smb3_sd sd;
} __packed;
-
-#define COPY_CHUNK_RES_KEY_SIZE 24
struct resume_key_req {
char ResumeKey[COPY_CHUNK_RES_KEY_SIZE];
__le32 ContextLength; /* MBZ */
char Context[]; /* ignored, Windows sets to 4 bytes of zero */
} __packed;
-
-struct copychunk {
- __le64 SourceOffset;
- __le64 TargetOffset;
- __le32 Length;
- __le32 Reserved;
-} __packed;
-
-/* this goes in the ioctl buffer when doing a copychunk request */
-struct copychunk_ioctl {
- char SourceKey[COPY_CHUNK_RES_KEY_SIZE];
- __le32 ChunkCount;
- __le32 Reserved;
- struct copychunk Chunks[];
-} __packed;
-
-struct copychunk_ioctl_rsp {
- __le32 ChunksWritten;
- __le32 ChunkBytesWritten;
- __le32 TotalBytesWritten;
-} __packed;
-
/* See MS-FSCC 2.3.29 and 2.3.30 */
struct get_retrieval_pointer_count_req {
__le64 StartingVcn; /* virtual cluster number (signed) */
diff --git a/fs/smb/common/smb2pdu.h b/fs/smb/common/smb2pdu.h
index b01114108d23..857e6a577e84 100644
--- a/fs/smb/common/smb2pdu.h
+++ b/fs/smb/common/smb2pdu.h
@@ -1392,6 +1392,35 @@ struct smb2_ioctl_req {
__u8 Buffer[];
} __packed;
+/* See MS-SMB2 2.2.31.1.1 */
+struct srv_copychunk {
+ __le64 SourceOffset;
+ __le64 TargetOffset;
+ __le32 Length;
+ __le32 Reserved;
+} __packed;
+
+#define COPY_CHUNK_RES_KEY_SIZE 24
+
+/* See MS-SMB2 2.2.31.1 */
+/* this goes in the ioctl buffer when doing a copychunk request */
+struct copychunk_ioctl_req {
+ union {
+ char SourceKey[COPY_CHUNK_RES_KEY_SIZE];
+ __le64 SourceKeyU64[3];
+ };
+ __le32 ChunkCount;
+ __le32 Reserved;
+ struct srv_copychunk Chunks[] __counted_by_le(ChunkCount);
+} __packed;
+
+/* See MS-SMB2 2.2.32.1 */
+struct copychunk_ioctl_rsp {
+ __le32 ChunksWritten;
+ __le32 ChunkBytesWritten;
+ __le32 TotalBytesWritten;
+} __packed;
+
struct smb2_ioctl_rsp {
struct smb2_hdr hdr;
__le16 StructureSize; /* Must be 49 */
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index dd6f1375a833..846cca45195b 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -7757,11 +7757,11 @@ static int fsctl_copychunk(struct ksmbd_work *work,
}
src_fp = ksmbd_lookup_foreign_fd(work,
- le64_to_cpu(ci_req->ResumeKey[0]));
+ le64_to_cpu(ci_req->SourceKeyU64[0]));
dst_fp = ksmbd_lookup_fd_slow(work, volatile_id, persistent_id);
ret = -EINVAL;
if (!src_fp ||
- src_fp->persistent_id != le64_to_cpu(ci_req->ResumeKey[1])) {
+ src_fp->persistent_id != le64_to_cpu(ci_req->SourceKeyU64[1])) {
rsp->hdr.Status = STATUS_OBJECT_NAME_NOT_FOUND;
goto out;
}
diff --git a/fs/smb/server/smb2pdu.h b/fs/smb/server/smb2pdu.h
index 5a76b706ccd9..eecd1f1f5505 100644
--- a/fs/smb/server/smb2pdu.h
+++ b/fs/smb/server/smb2pdu.h
@@ -157,26 +157,6 @@ struct resume_key_ioctl_rsp {
__u8 Context[4]; /* ignored, Windows sets to 4 bytes of zero */
} __packed;
-struct srv_copychunk {
- __le64 SourceOffset;
- __le64 TargetOffset;
- __le32 Length;
- __le32 Reserved;
-} __packed;
-
-struct copychunk_ioctl_req {
- __le64 ResumeKey[3];
- __le32 ChunkCount;
- __le32 Reserved;
- struct srv_copychunk Chunks[] __counted_by_le(ChunkCount);
-} __packed;
-
-struct copychunk_ioctl_rsp {
- __le32 ChunksWritten;
- __le32 ChunkBytesWritten;
- __le32 TotalBytesWritten;
-} __packed;
-
struct file_sparse {
__u8 SetSparse;
} __packed;
--
2.43.0
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH v3 10/22] smb: move resume_key_ioctl_rsp to common/smb2pdu.h
2025-10-14 7:18 [PATCH v3 00/22] smb: fix some bugs, move duplicate definitions to common header file chenxiaosong.chenxiaosong
` (8 preceding siblings ...)
2025-10-14 7:19 ` [PATCH v3 09/22] smb: move copychunk definitions " chenxiaosong.chenxiaosong
@ 2025-10-14 7:19 ` chenxiaosong.chenxiaosong
2025-10-14 7:28 ` [PATCH v3 11/22] smb: move smb2_file_network_open_info " chenxiaosong.chenxiaosong
2025-10-15 5:43 ` [PATCH v3 00/22] smb: fix some bugs, move duplicate definitions to common header file Namjae Jeon
11 siblings, 0 replies; 37+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-10-14 7:19 UTC (permalink / raw)
To: stfrench, metze, pali, linkinjeon, smfrench, sfrench, senozhatsky,
tom, pc, ronniesahlberg, sprasad, bharathsm, christophe.jaillet,
zhangguodong
Cc: linux-cifs, linux-kernel, ChenXiaoSong
From: ZhangGuoDong <zhangguodong@kylinos.cn>
Rename 2 places:
- resume_key_req -> resume_key_ioctl_rsp
- server: ResumeKey -> ResumeKeyU64
Merge the struct members of the server and the client, then move duplicate
definitions to common header file.
Co-developed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn>
---
fs/smb/client/smb2ops.c | 4 ++--
fs/smb/client/smb2pdu.h | 6 ------
fs/smb/common/smb2pdu.h | 10 ++++++++++
fs/smb/server/smb2pdu.c | 4 ++--
fs/smb/server/smb2pdu.h | 6 ------
5 files changed, 14 insertions(+), 16 deletions(-)
diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c
index ea9709d81851..8da5fe4efa2d 100644
--- a/fs/smb/client/smb2ops.c
+++ b/fs/smb/client/smb2ops.c
@@ -1528,7 +1528,7 @@ SMB2_request_res_key(const unsigned int xid, struct cifs_tcon *tcon,
{
int rc;
unsigned int ret_data_len;
- struct resume_key_req *res_key;
+ struct resume_key_ioctl_rsp *res_key;
rc = SMB2_ioctl(xid, tcon, persistent_fid, volatile_fid,
FSCTL_SRV_REQUEST_RESUME_KEY, NULL, 0 /* no input */,
@@ -1541,7 +1541,7 @@ SMB2_request_res_key(const unsigned int xid, struct cifs_tcon *tcon,
cifs_tcon_dbg(VFS, "refcpy ioctl error %d getting resume key\n", rc);
goto req_res_key_exit;
}
- if (ret_data_len < sizeof(struct resume_key_req)) {
+ if (ret_data_len < sizeof(struct resume_key_ioctl_rsp)) {
cifs_tcon_dbg(VFS, "Invalid refcopy resume key length\n");
rc = -EINVAL;
goto req_res_key_exit;
diff --git a/fs/smb/client/smb2pdu.h b/fs/smb/client/smb2pdu.h
index 9b5880e60a4e..77dceca20240 100644
--- a/fs/smb/client/smb2pdu.h
+++ b/fs/smb/client/smb2pdu.h
@@ -191,12 +191,6 @@ struct crt_sd_ctxt {
struct smb3_sd sd;
} __packed;
-struct resume_key_req {
- char ResumeKey[COPY_CHUNK_RES_KEY_SIZE];
- __le32 ContextLength; /* MBZ */
- char Context[]; /* ignored, Windows sets to 4 bytes of zero */
-} __packed;
-
/* See MS-FSCC 2.3.29 and 2.3.30 */
struct get_retrieval_pointer_count_req {
__le64 StartingVcn; /* virtual cluster number (signed) */
diff --git a/fs/smb/common/smb2pdu.h b/fs/smb/common/smb2pdu.h
index 857e6a577e84..15932ee05c98 100644
--- a/fs/smb/common/smb2pdu.h
+++ b/fs/smb/common/smb2pdu.h
@@ -1421,6 +1421,16 @@ struct copychunk_ioctl_rsp {
__le32 TotalBytesWritten;
} __packed;
+/* See MS-SMB2 2.2.32.3 */
+struct resume_key_ioctl_rsp {
+ union {
+ char ResumeKey[COPY_CHUNK_RES_KEY_SIZE];
+ __u64 ResumeKeyU64[3];
+ };
+ __le32 ContextLength; /* MBZ */
+ char Context[]; /* ignored, Windows sets to 4 bytes of zero */
+} __packed;
+
struct smb2_ioctl_rsp {
struct smb2_hdr hdr;
__le16 StructureSize; /* Must be 49 */
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index 846cca45195b..200bce13b467 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -8115,8 +8115,8 @@ static int fsctl_request_resume_key(struct ksmbd_work *work,
return -ENOENT;
memset(key_rsp, 0, sizeof(*key_rsp));
- key_rsp->ResumeKey[0] = req->VolatileFileId;
- key_rsp->ResumeKey[1] = req->PersistentFileId;
+ key_rsp->ResumeKeyU64[0] = req->VolatileFileId;
+ key_rsp->ResumeKeyU64[1] = req->PersistentFileId;
ksmbd_fd_put(work, fp);
return 0;
diff --git a/fs/smb/server/smb2pdu.h b/fs/smb/server/smb2pdu.h
index eecd1f1f5505..3d000c5d964b 100644
--- a/fs/smb/server/smb2pdu.h
+++ b/fs/smb/server/smb2pdu.h
@@ -151,12 +151,6 @@ struct file_object_buf_type1_ioctl_rsp {
__u8 DomainId[16];
} __packed;
-struct resume_key_ioctl_rsp {
- __u64 ResumeKey[3];
- __le32 ContextLength;
- __u8 Context[4]; /* ignored, Windows sets to 4 bytes of zero */
-} __packed;
-
struct file_sparse {
__u8 SetSparse;
} __packed;
--
2.43.0
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH v3 11/22] smb: move smb2_file_network_open_info to common/smb2pdu.h
2025-10-14 7:18 [PATCH v3 00/22] smb: fix some bugs, move duplicate definitions to common header file chenxiaosong.chenxiaosong
` (9 preceding siblings ...)
2025-10-14 7:19 ` [PATCH v3 10/22] smb: move resume_key_ioctl_rsp " chenxiaosong.chenxiaosong
@ 2025-10-14 7:28 ` chenxiaosong.chenxiaosong
2025-10-14 7:28 ` [PATCH v3 12/22] smb: move some duplicate definitions to common/cifspdu.h chenxiaosong.chenxiaosong
` (10 more replies)
2025-10-15 5:43 ` [PATCH v3 00/22] smb: fix some bugs, move duplicate definitions to common header file Namjae Jeon
11 siblings, 11 replies; 37+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-10-14 7:28 UTC (permalink / raw)
To: stfrench, metze, pali, linkinjeon, smfrench, sfrench, senozhatsky,
tom, pc, ronniesahlberg, sprasad, bharathsm, christophe.jaillet
Cc: linux-cifs, linux-kernel
From: ChenXiaoSong <chenxiaosong@kylinos.cn>
Rename smb2_file_ntwrk_info to smb2_file_network_open_info,
then move duplicate definitions to common header file.
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
fs/smb/client/smb2pdu.h | 13 -------------
fs/smb/common/smb2pdu.h | 14 ++++++++++++++
fs/smb/server/smb2pdu.c | 6 +++---
fs/smb/server/smb2pdu.h | 11 -----------
4 files changed, 17 insertions(+), 27 deletions(-)
diff --git a/fs/smb/client/smb2pdu.h b/fs/smb/client/smb2pdu.h
index 77dceca20240..70976a212128 100644
--- a/fs/smb/client/smb2pdu.h
+++ b/fs/smb/client/smb2pdu.h
@@ -262,19 +262,6 @@ struct smb2_file_reparse_point_info {
__le32 Tag;
} __packed;
-struct smb2_file_network_open_info {
- struct_group_attr(network_open_info, __packed,
- __le64 CreationTime;
- __le64 LastAccessTime;
- __le64 LastWriteTime;
- __le64 ChangeTime;
- __le64 AllocationSize;
- __le64 EndOfFile;
- __le32 Attributes;
- );
- __le32 Reserved;
-} __packed; /* level 34 Query also similar returned in close rsp and open rsp */
-
/* See MS-FSCC 2.4.21 */
struct smb2_file_id_information {
__le64 VolumeSerialNumber;
diff --git a/fs/smb/common/smb2pdu.h b/fs/smb/common/smb2pdu.h
index 15932ee05c98..f5c8c72b8959 100644
--- a/fs/smb/common/smb2pdu.h
+++ b/fs/smb/common/smb2pdu.h
@@ -1971,6 +1971,20 @@ struct smb2_lease_ack {
__le64 LeaseDuration;
} __packed;
+/* See MS-FSCC 2.4.34 */
+struct smb2_file_network_open_info {
+ struct_group_attr(network_open_info, __packed,
+ __le64 CreationTime;
+ __le64 LastAccessTime;
+ __le64 LastWriteTime;
+ __le64 ChangeTime;
+ __le64 AllocationSize;
+ __le64 EndOfFile;
+ __le32 Attributes;
+ );
+ __le32 Reserved;
+} __packed; /* level 34 Query also similar returned in close rsp and open rsp */
+
#define OP_BREAK_STRUCT_SIZE_20 24
#define OP_BREAK_STRUCT_SIZE_21 36
#endif /* _COMMON_SMB2PDU_H */
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index 200bce13b467..a46d4ddade9e 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -5126,7 +5126,7 @@ static int get_file_internal_info(struct smb2_query_info_rsp *rsp,
static int get_file_network_open_info(struct smb2_query_info_rsp *rsp,
struct ksmbd_file *fp, void *rsp_org)
{
- struct smb2_file_ntwrk_info *file_info;
+ struct smb2_file_network_open_info *file_info;
struct kstat stat;
u64 time;
int ret;
@@ -5142,7 +5142,7 @@ static int get_file_network_open_info(struct smb2_query_info_rsp *rsp,
if (ret)
return ret;
- file_info = (struct smb2_file_ntwrk_info *)rsp->Buffer;
+ file_info = (struct smb2_file_network_open_info *)rsp->Buffer;
file_info->CreationTime = cpu_to_le64(fp->create_time);
time = ksmbd_UnixTimeToNT(stat.atime);
@@ -5161,7 +5161,7 @@ static int get_file_network_open_info(struct smb2_query_info_rsp *rsp,
}
file_info->Reserved = cpu_to_le32(0);
rsp->OutputBufferLength =
- cpu_to_le32(sizeof(struct smb2_file_ntwrk_info));
+ cpu_to_le32(sizeof(struct smb2_file_network_open_info));
return 0;
}
diff --git a/fs/smb/server/smb2pdu.h b/fs/smb/server/smb2pdu.h
index 3d000c5d964b..8c8e775b601e 100644
--- a/fs/smb/server/smb2pdu.h
+++ b/fs/smb/server/smb2pdu.h
@@ -245,17 +245,6 @@ struct smb2_file_stream_info {
char StreamName[];
} __packed;
-struct smb2_file_ntwrk_info {
- __le64 CreationTime;
- __le64 LastAccessTime;
- __le64 LastWriteTime;
- __le64 ChangeTime;
- __le64 AllocationSize;
- __le64 EndOfFile;
- __le32 Attributes;
- __le32 Reserved;
-} __packed;
-
struct smb2_file_standard_info {
__le64 AllocationSize;
__le64 EndOfFile;
--
2.43.0
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH v3 12/22] smb: move some duplicate definitions to common/cifspdu.h
2025-10-14 7:28 ` [PATCH v3 11/22] smb: move smb2_file_network_open_info " chenxiaosong.chenxiaosong
@ 2025-10-14 7:28 ` chenxiaosong.chenxiaosong
2025-10-20 5:22 ` Namjae Jeon
2025-10-14 7:28 ` [PATCH v3 13/22] smb: move file access permission bits " chenxiaosong.chenxiaosong
` (9 subsequent siblings)
10 siblings, 1 reply; 37+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-10-14 7:28 UTC (permalink / raw)
To: stfrench, metze, pali, linkinjeon, smfrench, sfrench, senozhatsky,
tom, pc, ronniesahlberg, sprasad, bharathsm, christophe.jaillet
Cc: linux-cifs, linux-kernel
From: ChenXiaoSong <chenxiaosong@kylinos.cn>
In order to maintain the code more easily, move duplicate definitions to
new common header file.
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
fs/smb/client/cifspdu.h | 153 +---------------------------------
fs/smb/common/cifspdu.h | 165 +++++++++++++++++++++++++++++++++++++
fs/smb/server/smb_common.h | 80 +-----------------
3 files changed, 167 insertions(+), 231 deletions(-)
create mode 100644 fs/smb/common/cifspdu.h
diff --git a/fs/smb/client/cifspdu.h b/fs/smb/client/cifspdu.h
index c86a329e5822..9f42b0469d1a 100644
--- a/fs/smb/client/cifspdu.h
+++ b/fs/smb/client/cifspdu.h
@@ -12,43 +12,10 @@
#include <net/sock.h>
#include <linux/unaligned.h>
#include "../common/smbfsctl.h"
+#include "../common/cifspdu.h"
#define CIFS_PROT 0
#define POSIX_PROT (CIFS_PROT+1)
-#define BAD_PROT 0xFFFF
-
-/* SMB command codes:
- * Note some commands have minimal (wct=0,bcc=0), or uninteresting, responses
- * (ie which include no useful data other than the SMB error code itself).
- * This can allow us to avoid response buffer allocations and copy in some cases
- */
-#define SMB_COM_CREATE_DIRECTORY 0x00 /* trivial response */
-#define SMB_COM_DELETE_DIRECTORY 0x01 /* trivial response */
-#define SMB_COM_CLOSE 0x04 /* triv req/rsp, timestamp ignored */
-#define SMB_COM_FLUSH 0x05 /* triv req/rsp */
-#define SMB_COM_DELETE 0x06 /* trivial response */
-#define SMB_COM_RENAME 0x07 /* trivial response */
-#define SMB_COM_QUERY_INFORMATION 0x08 /* aka getattr */
-#define SMB_COM_SETATTR 0x09 /* trivial response */
-#define SMB_COM_LOCKING_ANDX 0x24 /* trivial response */
-#define SMB_COM_COPY 0x29 /* trivial rsp, fail filename ignrd*/
-#define SMB_COM_ECHO 0x2B /* echo request */
-#define SMB_COM_OPEN_ANDX 0x2D /* Legacy open for old servers */
-#define SMB_COM_READ_ANDX 0x2E
-#define SMB_COM_WRITE_ANDX 0x2F
-#define SMB_COM_TRANSACTION2 0x32
-#define SMB_COM_TRANSACTION2_SECONDARY 0x33
-#define SMB_COM_FIND_CLOSE2 0x34 /* trivial response */
-#define SMB_COM_TREE_DISCONNECT 0x71 /* trivial response */
-#define SMB_COM_NEGOTIATE 0x72
-#define SMB_COM_SESSION_SETUP_ANDX 0x73
-#define SMB_COM_LOGOFF_ANDX 0x74 /* trivial response */
-#define SMB_COM_TREE_CONNECT_ANDX 0x75
-#define SMB_COM_NT_TRANSACT 0xA0
-#define SMB_COM_NT_TRANSACT_SECONDARY 0xA1
-#define SMB_COM_NT_CREATE_ANDX 0xA2
-#define SMB_COM_NT_CANCEL 0xA4 /* no response */
-#define SMB_COM_NT_RENAME 0xA5 /* trivial response */
/* Transact2 subcommand codes */
#define TRANS2_OPEN 0x00
@@ -86,7 +53,6 @@
#define NT_TRANSACT_GET_USER_QUOTA 0x07
#define NT_TRANSACT_SET_USER_QUOTA 0x08
-#define MAX_CIFS_SMALL_BUFFER_SIZE 448 /* big enough for most */
/* future chained NTCreateXReadX bigger, but for time being NTCreateX biggest */
/* among the requests (NTCreateX response is bigger with wct of 34) */
#define MAX_CIFS_HDR_SIZE 0x58 /* 4 len + 32 hdr + (2*24 wct) + 2 bct + 2 pad */
@@ -150,36 +116,6 @@
#define SMBOPEN_OTRUNC 0x0002
#define SMBOPEN_OAPPEND 0x0001
-/*
- * SMB flag definitions
- */
-#define SMBFLG_EXTD_LOCK 0x01 /* server supports lock-read write-unlock smb */
-#define SMBFLG_RCV_POSTED 0x02 /* obsolete */
-#define SMBFLG_RSVD 0x04
-#define SMBFLG_CASELESS 0x08 /* all pathnames treated as caseless (off
- implies case sensitive file handling request) */
-#define SMBFLG_CANONICAL_PATH_FORMAT 0x10 /* obsolete */
-#define SMBFLG_OLD_OPLOCK 0x20 /* obsolete */
-#define SMBFLG_OLD_OPLOCK_NOTIFY 0x40 /* obsolete */
-#define SMBFLG_RESPONSE 0x80 /* this PDU is a response from server */
-
-/*
- * SMB flag2 definitions
- */
-#define SMBFLG2_KNOWS_LONG_NAMES cpu_to_le16(1) /* can send long (non-8.3)
- path names in response */
-#define SMBFLG2_KNOWS_EAS cpu_to_le16(2)
-#define SMBFLG2_SECURITY_SIGNATURE cpu_to_le16(4)
-#define SMBFLG2_COMPRESSED (8)
-#define SMBFLG2_SECURITY_SIGNATURE_REQUIRED (0x10)
-#define SMBFLG2_IS_LONG_NAME cpu_to_le16(0x40)
-#define SMBFLG2_REPARSE_PATH (0x400)
-#define SMBFLG2_EXT_SEC cpu_to_le16(0x800)
-#define SMBFLG2_DFS cpu_to_le16(0x1000)
-#define SMBFLG2_PAGING_IO cpu_to_le16(0x2000)
-#define SMBFLG2_ERR_STATUS cpu_to_le16(0x4000)
-#define SMBFLG2_UNICODE cpu_to_le16(0x8000)
-
/*
* These are the file access permission bits defined in CIFS for the
* NTCreateAndX as well as the level 0x107
@@ -292,7 +228,6 @@
#define SET_MINIMUM_RIGHTS (FILE_READ_EA | FILE_READ_ATTRIBUTES \
| READ_CONTROL | SYNCHRONIZE)
-
/*
* Invalid readdir handle
*/
@@ -322,33 +257,6 @@
#define CIFS_ALIAS_TYPE_FILE 0x0001
#define CIFS_SHARE_TYPE_FILE 0x0000
-/*
- * File Attribute flags
- */
-#define ATTR_READONLY 0x0001
-#define ATTR_HIDDEN 0x0002
-#define ATTR_SYSTEM 0x0004
-#define ATTR_VOLUME 0x0008
-#define ATTR_DIRECTORY 0x0010
-#define ATTR_ARCHIVE 0x0020
-#define ATTR_DEVICE 0x0040
-#define ATTR_NORMAL 0x0080
-#define ATTR_TEMPORARY 0x0100
-#define ATTR_SPARSE 0x0200
-#define ATTR_REPARSE 0x0400
-#define ATTR_COMPRESSED 0x0800
-#define ATTR_OFFLINE 0x1000 /* ie file not immediately available -
- on offline storage */
-#define ATTR_NOT_CONTENT_INDEXED 0x2000
-#define ATTR_ENCRYPTED 0x4000
-#define ATTR_POSIX_SEMANTICS 0x01000000
-#define ATTR_BACKUP_SEMANTICS 0x02000000
-#define ATTR_DELETE_ON_CLOSE 0x04000000
-#define ATTR_SEQUENTIAL_SCAN 0x08000000
-#define ATTR_RANDOM_ACCESS 0x10000000
-#define ATTR_NO_BUFFERING 0x20000000
-#define ATTR_WRITE_THROUGH 0x80000000
-
/* ShareAccess flags */
#define FILE_NO_SHARE 0x00000000
#define FILE_SHARE_READ 0x00000001
@@ -417,38 +325,6 @@
#define GETU16(var) (*((__u16 *)var)) /* BB check for endian issues */
#define GETU32(var) (*((__u32 *)var)) /* BB check for endian issues */
-struct smb_hdr {
- __be32 smb_buf_length; /* BB length is only two (rarely three) bytes,
- with one or two byte "type" preceding it that will be
- zero - we could mask the type byte off */
- __u8 Protocol[4];
- __u8 Command;
- union {
- struct {
- __u8 ErrorClass;
- __u8 Reserved;
- __le16 Error;
- } __attribute__((packed)) DosError;
- __le32 CifsError;
- } __attribute__((packed)) Status;
- __u8 Flags;
- __le16 Flags2; /* note: le */
- __le16 PidHigh;
- union {
- struct {
- __le32 SequenceNumber; /* le */
- __u32 Reserved; /* zero */
- } __attribute__((packed)) Sequence;
- __u8 SecuritySignature[8]; /* le */
- } __attribute__((packed)) Signature;
- __u8 pad[2];
- __u16 Tid;
- __le16 Pid;
- __u16 Uid;
- __le16 Mid;
- __u8 WordCount;
-} __attribute__((packed));
-
/* given a pointer to an smb_hdr, retrieve a void pointer to the ByteCount */
static inline void *
BCC(struct smb_hdr *smb)
@@ -2231,33 +2107,6 @@ typedef struct {
/* minimum includes first three fields, and empty FS Name */
#define MIN_FS_ATTR_INFO_SIZE 12
-
-/* List of FileSystemAttributes - see 2.5.1 of MS-FSCC */
-#define FILE_SUPPORTS_SPARSE_VDL 0x10000000 /* faster nonsparse extend */
-#define FILE_SUPPORTS_BLOCK_REFCOUNTING 0x08000000 /* allow ioctl dup extents */
-#define FILE_SUPPORT_INTEGRITY_STREAMS 0x04000000
-#define FILE_SUPPORTS_USN_JOURNAL 0x02000000
-#define FILE_SUPPORTS_OPEN_BY_FILE_ID 0x01000000
-#define FILE_SUPPORTS_EXTENDED_ATTRIBUTES 0x00800000
-#define FILE_SUPPORTS_HARD_LINKS 0x00400000
-#define FILE_SUPPORTS_TRANSACTIONS 0x00200000
-#define FILE_SEQUENTIAL_WRITE_ONCE 0x00100000
-#define FILE_READ_ONLY_VOLUME 0x00080000
-#define FILE_NAMED_STREAMS 0x00040000
-#define FILE_SUPPORTS_ENCRYPTION 0x00020000
-#define FILE_SUPPORTS_OBJECT_IDS 0x00010000
-#define FILE_VOLUME_IS_COMPRESSED 0x00008000
-#define FILE_SUPPORTS_POSIX_UNLINK_RENAME 0x00000400
-#define FILE_RETURNS_CLEANUP_RESULT_INFO 0x00000200
-#define FILE_SUPPORTS_REMOTE_STORAGE 0x00000100
-#define FILE_SUPPORTS_REPARSE_POINTS 0x00000080
-#define FILE_SUPPORTS_SPARSE_FILES 0x00000040
-#define FILE_VOLUME_QUOTAS 0x00000020
-#define FILE_FILE_COMPRESSION 0x00000010
-#define FILE_PERSISTENT_ACLS 0x00000008
-#define FILE_UNICODE_ON_DISK 0x00000004
-#define FILE_CASE_PRESERVED_NAMES 0x00000002
-#define FILE_CASE_SENSITIVE_SEARCH 0x00000001
typedef struct {
__le32 Attributes;
__le32 MaxPathNameComponentLength;
diff --git a/fs/smb/common/cifspdu.h b/fs/smb/common/cifspdu.h
new file mode 100644
index 000000000000..ca16741b5947
--- /dev/null
+++ b/fs/smb/common/cifspdu.h
@@ -0,0 +1,165 @@
+/* SPDX-License-Identifier: LGPL-2.1 */
+/*
+ *
+ * Copyright (c) International Business Machines Corp., 2002,2009
+ * Author(s): Steve French (sfrench@us.ibm.com)
+ *
+ */
+
+#ifndef _COMMON_CIFSPDU_H
+#define _COMMON_CIFSPDU_H
+
+#define BAD_PROT 0xFFFF
+
+/* SMB command codes:
+ * Note some commands have minimal (wct=0,bcc=0), or uninteresting, responses
+ * (ie which include no useful data other than the SMB error code itself).
+ * This can allow us to avoid response buffer allocations and copy in some cases
+ */
+#define SMB_COM_CREATE_DIRECTORY 0x00 /* trivial response */
+#define SMB_COM_DELETE_DIRECTORY 0x01 /* trivial response */
+#define SMB_COM_CLOSE 0x04 /* triv req/rsp, timestamp ignored */
+#define SMB_COM_FLUSH 0x05 /* triv req/rsp */
+#define SMB_COM_DELETE 0x06 /* trivial response */
+#define SMB_COM_RENAME 0x07 /* trivial response */
+#define SMB_COM_QUERY_INFORMATION 0x08 /* aka getattr */
+#define SMB_COM_SETATTR 0x09 /* trivial response */
+#define SMB_COM_LOCKING_ANDX 0x24 /* trivial response */
+#define SMB_COM_COPY 0x29 /* trivial rsp, fail filename ignrd*/
+#define SMB_COM_ECHO 0x2B /* echo request */
+#define SMB_COM_OPEN_ANDX 0x2D /* Legacy open for old servers */
+#define SMB_COM_READ_ANDX 0x2E
+#define SMB_COM_WRITE_ANDX 0x2F
+#define SMB_COM_TRANSACTION2 0x32
+#define SMB_COM_TRANSACTION2_SECONDARY 0x33
+#define SMB_COM_FIND_CLOSE2 0x34 /* trivial response */
+#define SMB_COM_TREE_DISCONNECT 0x71 /* trivial response */
+#define SMB_COM_NEGOTIATE 0x72
+#define SMB_COM_SESSION_SETUP_ANDX 0x73
+#define SMB_COM_LOGOFF_ANDX 0x74 /* trivial response */
+#define SMB_COM_TREE_CONNECT_ANDX 0x75
+#define SMB_COM_NT_TRANSACT 0xA0
+#define SMB_COM_NT_TRANSACT_SECONDARY 0xA1
+#define SMB_COM_NT_CREATE_ANDX 0xA2
+#define SMB_COM_NT_CANCEL 0xA4 /* no response */
+#define SMB_COM_NT_RENAME 0xA5 /* trivial response */
+
+#define MAX_CIFS_SMALL_BUFFER_SIZE 448 /* big enough for most */
+
+/*
+ * SMB flag definitions
+ */
+#define SMBFLG_EXTD_LOCK 0x01 /* server supports lock-read write-unlock smb */
+#define SMBFLG_RCV_POSTED 0x02 /* obsolete */
+#define SMBFLG_RSVD 0x04
+#define SMBFLG_CASELESS 0x08 /* all pathnames treated as caseless (off
+ implies case sensitive file handling request) */
+#define SMBFLG_CANONICAL_PATH_FORMAT 0x10 /* obsolete */
+#define SMBFLG_OLD_OPLOCK 0x20 /* obsolete */
+#define SMBFLG_OLD_OPLOCK_NOTIFY 0x40 /* obsolete */
+#define SMBFLG_RESPONSE 0x80 /* this PDU is a response from server */
+
+/*
+ * SMB flag2 definitions
+ */
+#define SMBFLG2_KNOWS_LONG_NAMES cpu_to_le16(1) /* can send long (non-8.3)
+ path names in response */
+#define SMBFLG2_KNOWS_EAS cpu_to_le16(2)
+#define SMBFLG2_SECURITY_SIGNATURE cpu_to_le16(4)
+#define SMBFLG2_COMPRESSED (8)
+#define SMBFLG2_SECURITY_SIGNATURE_REQUIRED (0x10)
+#define SMBFLG2_IS_LONG_NAME cpu_to_le16(0x40)
+#define SMBFLG2_REPARSE_PATH (0x400)
+#define SMBFLG2_EXT_SEC cpu_to_le16(0x800)
+#define SMBFLG2_DFS cpu_to_le16(0x1000)
+#define SMBFLG2_PAGING_IO cpu_to_le16(0x2000)
+#define SMBFLG2_ERR_STATUS cpu_to_le16(0x4000)
+#define SMBFLG2_UNICODE cpu_to_le16(0x8000)
+
+/*
+ * File Attribute flags
+ */
+#define ATTR_READONLY 0x0001
+#define ATTR_HIDDEN 0x0002
+#define ATTR_SYSTEM 0x0004
+#define ATTR_VOLUME 0x0008
+#define ATTR_DIRECTORY 0x0010
+#define ATTR_ARCHIVE 0x0020
+#define ATTR_DEVICE 0x0040
+#define ATTR_NORMAL 0x0080
+#define ATTR_TEMPORARY 0x0100
+#define ATTR_SPARSE 0x0200
+#define ATTR_REPARSE 0x0400
+#define ATTR_COMPRESSED 0x0800
+#define ATTR_OFFLINE 0x1000 /* ie file not immediately available -
+ on offline storage */
+#define ATTR_NOT_CONTENT_INDEXED 0x2000
+#define ATTR_ENCRYPTED 0x4000
+#define ATTR_POSIX_SEMANTICS 0x01000000
+#define ATTR_BACKUP_SEMANTICS 0x02000000
+#define ATTR_DELETE_ON_CLOSE 0x04000000
+#define ATTR_SEQUENTIAL_SCAN 0x08000000
+#define ATTR_RANDOM_ACCESS 0x10000000
+#define ATTR_NO_BUFFERING 0x20000000
+#define ATTR_WRITE_THROUGH 0x80000000
+
+struct smb_hdr {
+ __be32 smb_buf_length; /* BB length is only two (rarely three) bytes,
+ with one or two byte "type" preceding it that will be
+ zero - we could mask the type byte off */
+ __u8 Protocol[4];
+ __u8 Command;
+ union {
+ struct {
+ __u8 ErrorClass;
+ __u8 Reserved;
+ __le16 Error;
+ } __attribute__((packed)) DosError;
+ __le32 CifsError;
+ } __attribute__((packed)) Status;
+ __u8 Flags;
+ __le16 Flags2; /* note: le */
+ __le16 PidHigh;
+ union {
+ struct {
+ __le32 SequenceNumber; /* le */
+ __u32 Reserved; /* zero */
+ } __attribute__((packed)) Sequence;
+ __u8 SecuritySignature[8]; /* le */
+ } __attribute__((packed)) Signature;
+ __u8 pad[2];
+ __u16 Tid;
+ __le16 Pid;
+ __u16 Uid;
+ __le16 Mid;
+ __u8 WordCount;
+} __attribute__((packed));
+
+/* List of FileSystemAttributes - see 2.5.1 of MS-FSCC */
+#define FILE_SUPPORTS_SPARSE_VDL 0x10000000 /* faster nonsparse extend */
+#define FILE_SUPPORTS_BLOCK_REFCOUNTING 0x08000000 /* allow ioctl dup extents */
+#define FILE_SUPPORT_INTEGRITY_STREAMS 0x04000000
+#define FILE_SUPPORTS_USN_JOURNAL 0x02000000
+#define FILE_SUPPORTS_OPEN_BY_FILE_ID 0x01000000
+#define FILE_SUPPORTS_EXTENDED_ATTRIBUTES 0x00800000
+#define FILE_SUPPORTS_HARD_LINKS 0x00400000
+#define FILE_SUPPORTS_TRANSACTIONS 0x00200000
+#define FILE_SEQUENTIAL_WRITE_ONCE 0x00100000
+#define FILE_READ_ONLY_VOLUME 0x00080000
+#define FILE_NAMED_STREAMS 0x00040000
+#define FILE_SUPPORTS_ENCRYPTION 0x00020000
+#define FILE_SUPPORTS_OBJECT_IDS 0x00010000
+#define FILE_VOLUME_IS_COMPRESSED 0x00008000
+#define FILE_SUPPORTS_POSIX_UNLINK_RENAME 0x00000400
+#define FILE_RETURNS_CLEANUP_RESULT_INFO 0x00000200
+#define FILE_SUPPORTS_REMOTE_STORAGE 0x00000100
+#define FILE_SUPPORTS_REPARSE_POINTS 0x00000080
+#define FILE_SUPPORTS_SPARSE_FILES 0x00000040
+#define FILE_VOLUME_QUOTAS 0x00000020
+#define FILE_FILE_COMPRESSION 0x00000010
+#define FILE_PERSISTENT_ACLS 0x00000008
+#define FILE_UNICODE_ON_DISK 0x00000004
+#define FILE_CASE_PRESERVED_NAMES 0x00000002
+#define FILE_CASE_SENSITIVE_SEARCH 0x00000001
+
+#endif /* _COMMON_CIFSPDU_H */
diff --git a/fs/smb/server/smb_common.h b/fs/smb/server/smb_common.h
index 6d427dbed5fd..a326809f7765 100644
--- a/fs/smb/server/smb_common.h
+++ b/fs/smb/server/smb_common.h
@@ -11,6 +11,7 @@
#include "glob.h"
#include "nterr.h"
#include "../common/cifsglob.h"
+#include "../common/cifspdu.h"
#include "../common/smb2pdu.h"
#include "smb2pdu.h"
@@ -25,12 +26,9 @@
#define SMB30_PROT 4
#define SMB302_PROT 5
#define SMB311_PROT 6
-#define BAD_PROT 0xFFFF
#define SMB_ECHO_INTERVAL (60 * HZ)
-#define MAX_CIFS_SMALL_BUFFER_SIZE 448 /* big enough for most */
-
#define MAX_STREAM_PROT_LEN 0x00FFFFFF
/* Responses when opening a file. */
@@ -39,44 +37,6 @@
#define F_CREATED 2
#define F_OVERWRITTEN 3
-/*
- * File Attribute flags
- */
-#define ATTR_POSIX_SEMANTICS 0x01000000
-#define ATTR_BACKUP_SEMANTICS 0x02000000
-#define ATTR_DELETE_ON_CLOSE 0x04000000
-#define ATTR_SEQUENTIAL_SCAN 0x08000000
-#define ATTR_RANDOM_ACCESS 0x10000000
-#define ATTR_NO_BUFFERING 0x20000000
-#define ATTR_WRITE_THROUGH 0x80000000
-
-/* List of FileSystemAttributes - see 2.5.1 of MS-FSCC */
-#define FILE_SUPPORTS_SPARSE_VDL 0x10000000 /* faster nonsparse extend */
-#define FILE_SUPPORTS_BLOCK_REFCOUNTING 0x08000000 /* allow ioctl dup extents */
-#define FILE_SUPPORT_INTEGRITY_STREAMS 0x04000000
-#define FILE_SUPPORTS_USN_JOURNAL 0x02000000
-#define FILE_SUPPORTS_OPEN_BY_FILE_ID 0x01000000
-#define FILE_SUPPORTS_EXTENDED_ATTRIBUTES 0x00800000
-#define FILE_SUPPORTS_HARD_LINKS 0x00400000
-#define FILE_SUPPORTS_TRANSACTIONS 0x00200000
-#define FILE_SEQUENTIAL_WRITE_ONCE 0x00100000
-#define FILE_READ_ONLY_VOLUME 0x00080000
-#define FILE_NAMED_STREAMS 0x00040000
-#define FILE_SUPPORTS_ENCRYPTION 0x00020000
-#define FILE_SUPPORTS_OBJECT_IDS 0x00010000
-#define FILE_VOLUME_IS_COMPRESSED 0x00008000
-#define FILE_SUPPORTS_POSIX_UNLINK_RENAME 0x00000400
-#define FILE_RETURNS_CLEANUP_RESULT_INFO 0x00000200
-#define FILE_SUPPORTS_REMOTE_STORAGE 0x00000100
-#define FILE_SUPPORTS_REPARSE_POINTS 0x00000080
-#define FILE_SUPPORTS_SPARSE_FILES 0x00000040
-#define FILE_VOLUME_QUOTAS 0x00000020
-#define FILE_FILE_COMPRESSION 0x00000010
-#define FILE_PERSISTENT_ACLS 0x00000008
-#define FILE_UNICODE_ON_DISK 0x00000004
-#define FILE_CASE_PRESERVED_NAMES 0x00000002
-#define FILE_CASE_SENSITIVE_SEARCH 0x00000001
-
#define FILE_READ_DATA 0x00000001 /* Data can be read from the file */
#define FILE_WRITE_DATA 0x00000002 /* Data can be written to the file */
#define FILE_APPEND_DATA 0x00000004 /* Data can be appended to the file */
@@ -151,46 +111,8 @@
FILE_EXECUTE | FILE_DELETE_CHILD | \
FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES)
-#define SMB_COM_NEGOTIATE 0x72
#define SMB1_CLIENT_GUID_SIZE (16)
-#define SMBFLG_RESPONSE 0x80 /* this PDU is a response from server */
-
-#define SMBFLG2_IS_LONG_NAME cpu_to_le16(0x40)
-#define SMBFLG2_EXT_SEC cpu_to_le16(0x800)
-#define SMBFLG2_ERR_STATUS cpu_to_le16(0x4000)
-#define SMBFLG2_UNICODE cpu_to_le16(0x8000)
-
-struct smb_hdr {
- __be32 smb_buf_length;
- __u8 Protocol[4];
- __u8 Command;
- union {
- struct {
- __u8 ErrorClass;
- __u8 Reserved;
- __le16 Error;
- } __packed DosError;
- __le32 CifsError;
- } __packed Status;
- __u8 Flags;
- __le16 Flags2; /* note: le */
- __le16 PidHigh;
- union {
- struct {
- __le32 SequenceNumber; /* le */
- __u32 Reserved; /* zero */
- } __packed Sequence;
- __u8 SecuritySignature[8]; /* le */
- } __packed Signature;
- __u8 pad[2];
- __le16 Tid;
- __le16 Pid;
- __le16 Uid;
- __le16 Mid;
- __u8 WordCount;
-} __packed;
-
struct smb_negotiate_req {
struct smb_hdr hdr; /* wct = 0 */
__le16 ByteCount;
--
2.43.0
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH v3 13/22] smb: move file access permission bits definitions to common/cifspdu.h
2025-10-14 7:28 ` [PATCH v3 11/22] smb: move smb2_file_network_open_info " chenxiaosong.chenxiaosong
2025-10-14 7:28 ` [PATCH v3 12/22] smb: move some duplicate definitions to common/cifspdu.h chenxiaosong.chenxiaosong
@ 2025-10-14 7:28 ` chenxiaosong.chenxiaosong
2025-10-20 5:27 ` Namjae Jeon
2025-10-14 7:28 ` [PATCH v3 14/22] smb: move SMB frame " chenxiaosong.chenxiaosong
` (8 subsequent siblings)
10 siblings, 1 reply; 37+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-10-14 7:28 UTC (permalink / raw)
To: stfrench, metze, pali, linkinjeon, smfrench, sfrench, senozhatsky,
tom, pc, ronniesahlberg, sprasad, bharathsm, christophe.jaillet
Cc: linux-cifs, linux-kernel
From: ChenXiaoSong <chenxiaosong@kylinos.cn>
There are only 2 different definitions between the client and server:
- SET_FILE_READ_RIGHTS
- SET_FILE_WRITE_RIGHTS
Perhaps in the future we can change them to be the same.
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
fs/smb/client/cifsacl.c | 4 +-
fs/smb/client/cifspdu.h | 112 ---------------------------------
fs/smb/common/cifspdu.h | 123 ++++++++++++++++++++++++++++++++++++-
fs/smb/common/smb2pdu.h | 6 --
fs/smb/server/smb_common.h | 55 -----------------
fs/smb/server/smbacl.c | 2 +-
6 files changed, 125 insertions(+), 177 deletions(-)
diff --git a/fs/smb/client/cifsacl.c b/fs/smb/client/cifsacl.c
index 63b3b1290bed..ef12ae0fddb3 100644
--- a/fs/smb/client/cifsacl.c
+++ b/fs/smb/client/cifsacl.c
@@ -655,9 +655,9 @@ static void mode_to_access_flags(umode_t mode, umode_t bits_to_use,
is this but we have cleared all the bits sans RWX for
either user or group or other as per bits_to_use */
if (mode & S_IRUGO)
- *pace_flags |= SET_FILE_READ_RIGHTS;
+ *pace_flags |= CLIENT_SET_FILE_READ_RIGHTS;
if (mode & S_IWUGO)
- *pace_flags |= SET_FILE_WRITE_RIGHTS;
+ *pace_flags |= CLIENT_SET_FILE_WRITE_RIGHTS;
if (mode & S_IXUGO)
*pace_flags |= SET_FILE_EXEC_RIGHTS;
diff --git a/fs/smb/client/cifspdu.h b/fs/smb/client/cifspdu.h
index 9f42b0469d1a..a0883b1fda16 100644
--- a/fs/smb/client/cifspdu.h
+++ b/fs/smb/client/cifspdu.h
@@ -116,118 +116,6 @@
#define SMBOPEN_OTRUNC 0x0002
#define SMBOPEN_OAPPEND 0x0001
-/*
- * These are the file access permission bits defined in CIFS for the
- * NTCreateAndX as well as the level 0x107
- * TRANS2_QUERY_PATH_INFORMATION API. The level 0x107, SMB_QUERY_FILE_ALL_INFO
- * responds with the AccessFlags.
- * The AccessFlags specifies the access permissions a caller has to the
- * file and can have any suitable combination of the following values:
- */
-
-#define FILE_READ_DATA 0x00000001 /* Data can be read from the file */
- /* or directory child entries can */
- /* be listed together with the */
- /* associated child attributes */
- /* (so the FILE_READ_ATTRIBUTES on */
- /* the child entry is not needed) */
-#define FILE_WRITE_DATA 0x00000002 /* Data can be written to the file */
- /* or new file can be created in */
- /* the directory */
-#define FILE_APPEND_DATA 0x00000004 /* Data can be appended to the file */
- /* (for non-local files over SMB it */
- /* is same as FILE_WRITE_DATA) */
- /* or new subdirectory can be */
- /* created in the directory */
-#define FILE_READ_EA 0x00000008 /* Extended attributes associated */
- /* with the file can be read */
-#define FILE_WRITE_EA 0x00000010 /* Extended attributes associated */
- /* with the file can be written */
-#define FILE_EXECUTE 0x00000020 /*Data can be read into memory from */
- /* the file using system paging I/O */
- /* for executing the file / script */
- /* or right to traverse directory */
- /* (but by default all users have */
- /* directory bypass traverse */
- /* privilege and do not need this */
- /* permission on directories at all)*/
-#define FILE_DELETE_CHILD 0x00000040 /* Child entry can be deleted from */
- /* the directory (so the DELETE on */
- /* the child entry is not needed) */
-#define FILE_READ_ATTRIBUTES 0x00000080 /* Attributes associated with the */
- /* file or directory can be read */
-#define FILE_WRITE_ATTRIBUTES 0x00000100 /* Attributes associated with the */
- /* file or directory can be written */
-#define DELETE 0x00010000 /* The file or dir can be deleted */
-#define READ_CONTROL 0x00020000 /* The discretionary access control */
- /* list and ownership associated */
- /* with the file or dir can be read */
-#define WRITE_DAC 0x00040000 /* The discretionary access control */
- /* list associated with the file or */
- /* directory can be written */
-#define WRITE_OWNER 0x00080000 /* Ownership information associated */
- /* with the file/dir can be written */
-#define SYNCHRONIZE 0x00100000 /* The file handle can waited on to */
- /* synchronize with the completion */
- /* of an input/output request */
-#define SYSTEM_SECURITY 0x01000000 /* The system access control list */
- /* associated with the file or */
- /* directory can be read or written */
- /* (cannot be in DACL, can in SACL) */
-#define MAXIMUM_ALLOWED 0x02000000 /* Maximal subset of GENERIC_ALL */
- /* permissions which can be granted */
- /* (cannot be in DACL nor SACL) */
-#define GENERIC_ALL 0x10000000 /* Same as: GENERIC_EXECUTE | */
- /* GENERIC_WRITE | */
- /* GENERIC_READ | */
- /* FILE_DELETE_CHILD | */
- /* DELETE | */
- /* WRITE_DAC | */
- /* WRITE_OWNER */
- /* So GENERIC_ALL contains all bits */
- /* mentioned above except these two */
- /* SYSTEM_SECURITY MAXIMUM_ALLOWED */
-#define GENERIC_EXECUTE 0x20000000 /* Same as: FILE_EXECUTE | */
- /* FILE_READ_ATTRIBUTES | */
- /* READ_CONTROL | */
- /* SYNCHRONIZE */
-#define GENERIC_WRITE 0x40000000 /* Same as: FILE_WRITE_DATA | */
- /* FILE_APPEND_DATA | */
- /* FILE_WRITE_EA | */
- /* FILE_WRITE_ATTRIBUTES | */
- /* READ_CONTROL | */
- /* SYNCHRONIZE */
-#define GENERIC_READ 0x80000000 /* Same as: FILE_READ_DATA | */
- /* FILE_READ_EA | */
- /* FILE_READ_ATTRIBUTES | */
- /* READ_CONTROL | */
- /* SYNCHRONIZE */
-
-#define FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA | FILE_READ_ATTRIBUTES)
-#define FILE_WRITE_RIGHTS (FILE_WRITE_DATA | FILE_APPEND_DATA \
- | FILE_WRITE_EA | FILE_WRITE_ATTRIBUTES)
-#define FILE_EXEC_RIGHTS (FILE_EXECUTE)
-
-#define SET_FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA | FILE_WRITE_EA \
- | FILE_READ_ATTRIBUTES \
- | FILE_WRITE_ATTRIBUTES \
- | DELETE | READ_CONTROL | WRITE_DAC \
- | WRITE_OWNER | SYNCHRONIZE)
-#define SET_FILE_WRITE_RIGHTS (FILE_WRITE_DATA | FILE_APPEND_DATA \
- | FILE_READ_EA | FILE_WRITE_EA \
- | FILE_READ_ATTRIBUTES \
- | FILE_WRITE_ATTRIBUTES \
- | DELETE | READ_CONTROL | WRITE_DAC \
- | WRITE_OWNER | SYNCHRONIZE)
-#define SET_FILE_EXEC_RIGHTS (FILE_READ_EA | FILE_WRITE_EA | FILE_EXECUTE \
- | FILE_READ_ATTRIBUTES \
- | FILE_WRITE_ATTRIBUTES \
- | DELETE | READ_CONTROL | WRITE_DAC \
- | WRITE_OWNER | SYNCHRONIZE)
-
-#define SET_MINIMUM_RIGHTS (FILE_READ_EA | FILE_READ_ATTRIBUTES \
- | READ_CONTROL | SYNCHRONIZE)
-
/*
* Invalid readdir handle
*/
diff --git a/fs/smb/common/cifspdu.h b/fs/smb/common/cifspdu.h
index ca16741b5947..59e5425cdc8d 100644
--- a/fs/smb/common/cifspdu.h
+++ b/fs/smb/common/cifspdu.h
@@ -77,7 +77,128 @@
#define SMBFLG2_UNICODE cpu_to_le16(0x8000)
/*
- * File Attribute flags
+ * These are the file access permission bits defined in CIFS for the
+ * NTCreateAndX as well as the level 0x107
+ * TRANS2_QUERY_PATH_INFORMATION API. The level 0x107, SMB_QUERY_FILE_ALL_INFO
+ * responds with the AccessFlags.
+ * The AccessFlags specifies the access permissions a caller has to the
+ * file and can have any suitable combination of the following values:
+ */
+
+#define FILE_READ_DATA 0x00000001 /* Data can be read from the file */
+ /* or directory child entries can */
+ /* be listed together with the */
+ /* associated child attributes */
+ /* (so the FILE_READ_ATTRIBUTES on */
+ /* the child entry is not needed) */
+#define FILE_WRITE_DATA 0x00000002 /* Data can be written to the file */
+ /* or new file can be created in */
+ /* the directory */
+#define FILE_APPEND_DATA 0x00000004 /* Data can be appended to the file */
+ /* (for non-local files over SMB it */
+ /* is same as FILE_WRITE_DATA) */
+ /* or new subdirectory can be */
+ /* created in the directory */
+#define FILE_READ_EA 0x00000008 /* Extended attributes associated */
+ /* with the file can be read */
+#define FILE_WRITE_EA 0x00000010 /* Extended attributes associated */
+ /* with the file can be written */
+#define FILE_EXECUTE 0x00000020 /*Data can be read into memory from */
+ /* the file using system paging I/O */
+ /* for executing the file / script */
+ /* or right to traverse directory */
+ /* (but by default all users have */
+ /* directory bypass traverse */
+ /* privilege and do not need this */
+ /* permission on directories at all)*/
+#define FILE_DELETE_CHILD 0x00000040 /* Child entry can be deleted from */
+ /* the directory (so the DELETE on */
+ /* the child entry is not needed) */
+#define FILE_READ_ATTRIBUTES 0x00000080 /* Attributes associated with the */
+ /* file or directory can be read */
+#define FILE_WRITE_ATTRIBUTES 0x00000100 /* Attributes associated with the */
+ /* file or directory can be written */
+#define DELETE 0x00010000 /* The file or dir can be deleted */
+#define READ_CONTROL 0x00020000 /* The discretionary access control */
+ /* list and ownership associated */
+ /* with the file or dir can be read */
+#define WRITE_DAC 0x00040000 /* The discretionary access control */
+ /* list associated with the file or */
+ /* directory can be written */
+#define WRITE_OWNER 0x00080000 /* Ownership information associated */
+ /* with the file/dir can be written */
+#define SYNCHRONIZE 0x00100000 /* The file handle can waited on to */
+ /* synchronize with the completion */
+ /* of an input/output request */
+#define SYSTEM_SECURITY 0x01000000 /* The system access control list */
+ /* associated with the file or */
+ /* directory can be read or written */
+ /* (cannot be in DACL, can in SACL) */
+#define MAXIMUM_ALLOWED 0x02000000 /* Maximal subset of GENERIC_ALL */
+ /* permissions which can be granted */
+ /* (cannot be in DACL nor SACL) */
+#define GENERIC_ALL 0x10000000 /* Same as: GENERIC_EXECUTE | */
+ /* GENERIC_WRITE | */
+ /* GENERIC_READ | */
+ /* FILE_DELETE_CHILD | */
+ /* DELETE | */
+ /* WRITE_DAC | */
+ /* WRITE_OWNER */
+ /* So GENERIC_ALL contains all bits */
+ /* mentioned above except these two */
+ /* SYSTEM_SECURITY MAXIMUM_ALLOWED */
+#define GENERIC_EXECUTE 0x20000000 /* Same as: FILE_EXECUTE | */
+ /* FILE_READ_ATTRIBUTES | */
+ /* READ_CONTROL | */
+ /* SYNCHRONIZE */
+#define GENERIC_WRITE 0x40000000 /* Same as: FILE_WRITE_DATA | */
+ /* FILE_APPEND_DATA | */
+ /* FILE_WRITE_EA | */
+ /* FILE_WRITE_ATTRIBUTES | */
+ /* READ_CONTROL | */
+ /* SYNCHRONIZE */
+#define GENERIC_READ 0x80000000 /* Same as: FILE_READ_DATA | */
+ /* FILE_READ_EA | */
+ /* FILE_READ_ATTRIBUTES | */
+ /* READ_CONTROL | */
+ /* SYNCHRONIZE */
+
+#define FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA | FILE_READ_ATTRIBUTES)
+#define FILE_WRITE_RIGHTS (FILE_WRITE_DATA | FILE_APPEND_DATA \
+ | FILE_WRITE_EA | FILE_WRITE_ATTRIBUTES)
+#define FILE_EXEC_RIGHTS (FILE_EXECUTE)
+
+#define CLIENT_SET_FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA | FILE_WRITE_EA \
+ | FILE_READ_ATTRIBUTES \
+ | FILE_WRITE_ATTRIBUTES \
+ | DELETE | READ_CONTROL | WRITE_DAC \
+ | WRITE_OWNER | SYNCHRONIZE)
+#define SERVER_SET_FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA \
+ | FILE_READ_ATTRIBUTES \
+ | DELETE | READ_CONTROL | WRITE_DAC \
+ | WRITE_OWNER | SYNCHRONIZE)
+#define CLIENT_SET_FILE_WRITE_RIGHTS (FILE_WRITE_DATA | FILE_APPEND_DATA \
+ | FILE_READ_EA | FILE_WRITE_EA \
+ | FILE_READ_ATTRIBUTES \
+ | FILE_WRITE_ATTRIBUTES \
+ | DELETE | READ_CONTROL | WRITE_DAC \
+ | WRITE_OWNER | SYNCHRONIZE)
+#define SERVER_SET_FILE_WRITE_RIGHTS (FILE_WRITE_DATA | FILE_APPEND_DATA \
+ | FILE_WRITE_EA \
+ | FILE_DELETE_CHILD \
+ | FILE_WRITE_ATTRIBUTES \
+ | DELETE | READ_CONTROL | WRITE_DAC \
+ | WRITE_OWNER | SYNCHRONIZE)
+#define SET_FILE_EXEC_RIGHTS (FILE_READ_EA | FILE_WRITE_EA | FILE_EXECUTE \
+ | FILE_READ_ATTRIBUTES \
+ | FILE_WRITE_ATTRIBUTES \
+ | DELETE | READ_CONTROL | WRITE_DAC \
+ | WRITE_OWNER | SYNCHRONIZE)
+#define SET_MINIMUM_RIGHTS (FILE_READ_EA | FILE_READ_ATTRIBUTES \
+ | READ_CONTROL | SYNCHRONIZE)
+
+/*
+ * File Attribute flags - see MS-SMB 2.2.1.4.1
*/
#define ATTR_READONLY 0x0001
#define ATTR_HIDDEN 0x0002
diff --git a/fs/smb/common/smb2pdu.h b/fs/smb/common/smb2pdu.h
index f5c8c72b8959..40689c11e97a 100644
--- a/fs/smb/common/smb2pdu.h
+++ b/fs/smb/common/smb2pdu.h
@@ -1149,12 +1149,6 @@ struct smb2_server_client_notification {
#define FILE_OVERWRITE_IF_LE cpu_to_le32(0x00000005)
#define FILE_CREATE_MASK_LE cpu_to_le32(0x00000007)
-#define FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA \
- | FILE_READ_ATTRIBUTES)
-#define FILE_WRITE_RIGHTS (FILE_WRITE_DATA | FILE_APPEND_DATA \
- | FILE_WRITE_EA | FILE_WRITE_ATTRIBUTES)
-#define FILE_EXEC_RIGHTS (FILE_EXECUTE)
-
/* CreateOptions Flags */
#define FILE_DIRECTORY_FILE_LE cpu_to_le32(0x00000001)
/* same as #define CREATE_NOT_FILE_LE cpu_to_le32(0x00000001) */
diff --git a/fs/smb/server/smb_common.h b/fs/smb/server/smb_common.h
index a326809f7765..90015cd8fe4e 100644
--- a/fs/smb/server/smb_common.h
+++ b/fs/smb/server/smb_common.h
@@ -37,61 +37,6 @@
#define F_CREATED 2
#define F_OVERWRITTEN 3
-#define FILE_READ_DATA 0x00000001 /* Data can be read from the file */
-#define FILE_WRITE_DATA 0x00000002 /* Data can be written to the file */
-#define FILE_APPEND_DATA 0x00000004 /* Data can be appended to the file */
-#define FILE_READ_EA 0x00000008 /* Extended attributes associated */
-/* with the file can be read */
-#define FILE_WRITE_EA 0x00000010 /* Extended attributes associated */
-/* with the file can be written */
-#define FILE_EXECUTE 0x00000020 /*Data can be read into memory from */
-/* the file using system paging I/O */
-#define FILE_DELETE_CHILD 0x00000040
-#define FILE_READ_ATTRIBUTES 0x00000080 /* Attributes associated with the */
-/* file can be read */
-#define FILE_WRITE_ATTRIBUTES 0x00000100 /* Attributes associated with the */
-/* file can be written */
-#define DELETE 0x00010000 /* The file can be deleted */
-#define READ_CONTROL 0x00020000 /* The access control list and */
-/* ownership associated with the */
-/* file can be read */
-#define WRITE_DAC 0x00040000 /* The access control list and */
-/* ownership associated with the */
-/* file can be written. */
-#define WRITE_OWNER 0x00080000 /* Ownership information associated */
-/* with the file can be written */
-#define SYNCHRONIZE 0x00100000 /* The file handle can waited on to */
-/* synchronize with the completion */
-/* of an input/output request */
-#define GENERIC_ALL 0x10000000
-#define GENERIC_EXECUTE 0x20000000
-#define GENERIC_WRITE 0x40000000
-#define GENERIC_READ 0x80000000
-/* In summary - Relevant file */
-/* access flags from CIFS are */
-/* file_read_data, file_write_data */
-/* file_execute, file_read_attributes*/
-/* write_dac, and delete. */
-
-#define SET_FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA \
- | FILE_READ_ATTRIBUTES \
- | DELETE | READ_CONTROL | WRITE_DAC \
- | WRITE_OWNER | SYNCHRONIZE)
-#define SET_FILE_WRITE_RIGHTS (FILE_WRITE_DATA | FILE_APPEND_DATA \
- | FILE_WRITE_EA \
- | FILE_DELETE_CHILD \
- | FILE_WRITE_ATTRIBUTES \
- | DELETE | READ_CONTROL | WRITE_DAC \
- | WRITE_OWNER | SYNCHRONIZE)
-#define SET_FILE_EXEC_RIGHTS (FILE_READ_EA | FILE_WRITE_EA | FILE_EXECUTE \
- | FILE_READ_ATTRIBUTES \
- | FILE_WRITE_ATTRIBUTES \
- | DELETE | READ_CONTROL | WRITE_DAC \
- | WRITE_OWNER | SYNCHRONIZE)
-
-#define SET_MINIMUM_RIGHTS (FILE_READ_EA | FILE_READ_ATTRIBUTES \
- | READ_CONTROL | SYNCHRONIZE)
-
/* generic flags for file open */
#define GENERIC_READ_FLAGS (READ_CONTROL | FILE_READ_DATA | \
FILE_READ_ATTRIBUTES | \
diff --git a/fs/smb/server/smbacl.c b/fs/smb/server/smbacl.c
index 5aa7a66334d9..b70ba50f1f10 100644
--- a/fs/smb/server/smbacl.c
+++ b/fs/smb/server/smbacl.c
@@ -180,7 +180,7 @@ static void mode_to_access_flags(umode_t mode, umode_t bits_to_use,
* either user or group or other as per bits_to_use
*/
if (mode & 0444)
- *pace_flags |= SET_FILE_READ_RIGHTS;
+ *pace_flags |= SERVER_SET_FILE_READ_RIGHTS;
if (mode & 0222)
*pace_flags |= FILE_WRITE_RIGHTS;
if (mode & 0111)
--
2.43.0
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH v3 14/22] smb: move SMB frame definitions to common/cifspdu.h
2025-10-14 7:28 ` [PATCH v3 11/22] smb: move smb2_file_network_open_info " chenxiaosong.chenxiaosong
2025-10-14 7:28 ` [PATCH v3 12/22] smb: move some duplicate definitions to common/cifspdu.h chenxiaosong.chenxiaosong
2025-10-14 7:28 ` [PATCH v3 13/22] smb: move file access permission bits " chenxiaosong.chenxiaosong
@ 2025-10-14 7:28 ` chenxiaosong.chenxiaosong
2025-10-14 7:28 ` [PATCH v3 15/22] smb: move FILE_SYSTEM_ATTRIBUTE_INFO " chenxiaosong.chenxiaosong
` (7 subsequent siblings)
10 siblings, 0 replies; 37+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-10-14 7:28 UTC (permalink / raw)
To: stfrench, metze, pali, linkinjeon, smfrench, sfrench, senozhatsky,
tom, pc, ronniesahlberg, sprasad, bharathsm, christophe.jaillet
Cc: linux-cifs, linux-kernel
From: ChenXiaoSong <chenxiaosong@kylinos.cn>
The client and server have different struct negotiate_rsp, perhaps in the
future we can change them to be the same.
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
fs/smb/client/cifspdu.h | 58 ----------------------------------
fs/smb/client/cifssmb.c | 4 +--
fs/smb/common/cifspdu.h | 65 ++++++++++++++++++++++++++++++++++++++
fs/smb/server/smb_common.c | 10 +++---
fs/smb/server/smb_common.h | 14 --------
5 files changed, 72 insertions(+), 79 deletions(-)
diff --git a/fs/smb/client/cifspdu.h b/fs/smb/client/cifspdu.h
index a0883b1fda16..07eb821654e1 100644
--- a/fs/smb/client/cifspdu.h
+++ b/fs/smb/client/cifspdu.h
@@ -266,64 +266,6 @@ put_bcc(__u16 count, struct smb_hdr *hdr)
*/
#define MAX_PATHCONF 256
-/*
- * SMB frame definitions (following must be packed structs)
- * See the SNIA CIFS Specification for details.
- *
- * The Naming convention is the lower case version of the
- * smb command code name for the struct and this is typedef to the
- * uppercase version of the same name with the prefix SMB_ removed
- * for brevity. Although typedefs are not commonly used for
- * structure definitions in the Linux kernel, their use in the
- * CIFS standards document, which this code is based on, may
- * make this one of the cases where typedefs for structures make
- * sense to improve readability for readers of the standards doc.
- * Typedefs can always be removed later if they are too distracting
- * and they are only used for the CIFSs PDUs themselves, not
- * internal cifs vfs structures
- *
- */
-
-typedef struct negotiate_req {
- struct smb_hdr hdr; /* wct = 0 */
- __le16 ByteCount;
- unsigned char DialectsArray[];
-} __attribute__((packed)) NEGOTIATE_REQ;
-
-#define MIN_TZ_ADJ (15 * 60) /* minimum grid for timezones in seconds */
-
-#define READ_RAW_ENABLE 1
-#define WRITE_RAW_ENABLE 2
-#define RAW_ENABLE (READ_RAW_ENABLE | WRITE_RAW_ENABLE)
-#define SMB1_CLIENT_GUID_SIZE (16)
-typedef struct negotiate_rsp {
- struct smb_hdr hdr; /* wct = 17 */
- __le16 DialectIndex; /* 0xFFFF = no dialect acceptable */
- __u8 SecurityMode;
- __le16 MaxMpxCount;
- __le16 MaxNumberVcs;
- __le32 MaxBufferSize;
- __le32 MaxRawSize;
- __le32 SessionKey;
- __le32 Capabilities; /* see below */
- __le32 SystemTimeLow;
- __le32 SystemTimeHigh;
- __le16 ServerTimeZone;
- __u8 EncryptionKeyLength;
- __u16 ByteCount;
- union {
- /* cap extended security off */
- DECLARE_FLEX_ARRAY(unsigned char, EncryptionKey);
- /* followed by Domain name - if extended security is off */
- /* followed by 16 bytes of server GUID */
- /* then security blob if cap_extended_security negotiated */
- struct {
- unsigned char GUID[SMB1_CLIENT_GUID_SIZE];
- unsigned char SecurityBlob[];
- } __attribute__((packed)) extended_response;
- } __attribute__((packed)) u;
-} __attribute__((packed)) NEGOTIATE_RSP;
-
/* SecurityMode bits */
#define SECMODE_USER 0x01 /* off indicates share level security */
#define SECMODE_PW_ENCRYPT 0x02
diff --git a/fs/smb/client/cifssmb.c b/fs/smb/client/cifssmb.c
index 9a346d67e298..e37a00c9251c 100644
--- a/fs/smb/client/cifssmb.c
+++ b/fs/smb/client/cifssmb.c
@@ -361,7 +361,7 @@ static int validate_t2(struct smb_t2_rsp *pSMB)
}
static int
-decode_ext_sec_blob(struct cifs_ses *ses, NEGOTIATE_RSP *pSMBr)
+decode_ext_sec_blob(struct cifs_ses *ses, CLIENT_NEGOTIATE_RSP *pSMBr)
{
int rc = 0;
u16 count;
@@ -420,7 +420,7 @@ CIFSSMBNegotiate(const unsigned int xid,
struct TCP_Server_Info *server)
{
NEGOTIATE_REQ *pSMB;
- NEGOTIATE_RSP *pSMBr;
+ CLIENT_NEGOTIATE_RSP *pSMBr;
int rc = 0;
int bytes_returned;
int i;
diff --git a/fs/smb/common/cifspdu.h b/fs/smb/common/cifspdu.h
index 59e5425cdc8d..1109c20f7bf8 100644
--- a/fs/smb/common/cifspdu.h
+++ b/fs/smb/common/cifspdu.h
@@ -256,6 +256,71 @@ struct smb_hdr {
__u8 WordCount;
} __attribute__((packed));
+/*
+ * SMB frame definitions (following must be packed structs)
+ * See the SNIA CIFS Specification for details.
+ *
+ * The Naming convention is the lower case version of the
+ * smb command code name for the struct and this is typedef to the
+ * uppercase version of the same name with the prefix SMB_ removed
+ * for brevity. Although typedefs are not commonly used for
+ * structure definitions in the Linux kernel, their use in the
+ * CIFS standards document, which this code is based on, may
+ * make this one of the cases where typedefs for structures make
+ * sense to improve readability for readers of the standards doc.
+ * Typedefs can always be removed later if they are too distracting
+ * and they are only used for the CIFSs PDUs themselves, not
+ * internal cifs vfs structures
+ *
+ */
+
+typedef struct negotiate_req {
+ struct smb_hdr hdr; /* wct = 0 */
+ __le16 ByteCount;
+ unsigned char DialectsArray[];
+} __attribute__((packed)) NEGOTIATE_REQ;
+
+#define MIN_TZ_ADJ (15 * 60) /* minimum grid for timezones in seconds */
+
+#define READ_RAW_ENABLE 1
+#define WRITE_RAW_ENABLE 2
+#define RAW_ENABLE (READ_RAW_ENABLE | WRITE_RAW_ENABLE)
+#define SMB1_CLIENT_GUID_SIZE (16)
+
+typedef struct client_negotiate_rsp {
+ struct smb_hdr hdr; /* wct = 17 */
+ __le16 DialectIndex; /* 0xFFFF = no dialect acceptable */
+ __u8 SecurityMode;
+ __le16 MaxMpxCount;
+ __le16 MaxNumberVcs;
+ __le32 MaxBufferSize;
+ __le32 MaxRawSize;
+ __le32 SessionKey;
+ __le32 Capabilities; /* see below */
+ __le32 SystemTimeLow;
+ __le32 SystemTimeHigh;
+ __le16 ServerTimeZone;
+ __u8 EncryptionKeyLength;
+ __u16 ByteCount;
+ union {
+ /* cap extended security off */
+ DECLARE_FLEX_ARRAY(unsigned char, EncryptionKey);
+ /* followed by Domain name - if extended security is off */
+ /* followed by 16 bytes of server GUID */
+ /* then security blob if cap_extended_security negotiated */
+ struct {
+ unsigned char GUID[SMB1_CLIENT_GUID_SIZE];
+ unsigned char SecurityBlob[];
+ } __attribute__((packed)) extended_response;
+ } __attribute__((packed)) u;
+} __attribute__((packed)) CLIENT_NEGOTIATE_RSP;
+
+typedef struct server_negotiate_rsp {
+ struct smb_hdr hdr; /* wct = 17 */
+ __le16 DialectIndex; /* 0xFFFF = no dialect acceptable */
+ __le16 ByteCount;
+} __attribute__((packed)) SERVER_NEGOTIATE_RSP;
+
/* List of FileSystemAttributes - see 2.5.1 of MS-FSCC */
#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/smb_common.c b/fs/smb/server/smb_common.c
index b23203a1c286..e1e89bc1c43f 100644
--- a/fs/smb/server/smb_common.c
+++ b/fs/smb/server/smb_common.c
@@ -280,13 +280,13 @@ static int ksmbd_negotiate_smb_dialect(void *buf)
proto = *(__le32 *)((struct smb_hdr *)buf)->Protocol;
if (proto == SMB1_PROTO_NUMBER) {
- struct smb_negotiate_req *req;
+ struct negotiate_req *req;
- req = (struct smb_negotiate_req *)buf;
+ req = (struct negotiate_req *)buf;
if (le16_to_cpu(req->ByteCount) < 2)
goto err_out;
- if (offsetof(struct smb_negotiate_req, DialectsArray) - 4 +
+ if (offsetof(struct negotiate_req, DialectsArray) - 4 +
le16_to_cpu(req->ByteCount) > smb_buf_length) {
goto err_out;
}
@@ -572,12 +572,12 @@ static int __smb2_negotiate(struct ksmbd_conn *conn)
static int smb_handle_negotiate(struct ksmbd_work *work)
{
- struct smb_negotiate_rsp *neg_rsp = work->response_buf;
+ struct server_negotiate_rsp *neg_rsp = work->response_buf;
ksmbd_debug(SMB, "Unsupported SMB1 protocol\n");
if (ksmbd_iov_pin_rsp(work, (void *)neg_rsp + 4,
- sizeof(struct smb_negotiate_rsp) - 4))
+ sizeof(struct server_negotiate_rsp) - 4))
return -ENOMEM;
neg_rsp->hdr.Status.CifsError = STATUS_SUCCESS;
diff --git a/fs/smb/server/smb_common.h b/fs/smb/server/smb_common.h
index 90015cd8fe4e..a5dd656c36f1 100644
--- a/fs/smb/server/smb_common.h
+++ b/fs/smb/server/smb_common.h
@@ -56,20 +56,6 @@
FILE_EXECUTE | FILE_DELETE_CHILD | \
FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES)
-#define SMB1_CLIENT_GUID_SIZE (16)
-
-struct smb_negotiate_req {
- struct smb_hdr hdr; /* wct = 0 */
- __le16 ByteCount;
- unsigned char DialectsArray[];
-} __packed;
-
-struct smb_negotiate_rsp {
- struct smb_hdr hdr; /* wct = 17 */
- __le16 DialectIndex; /* 0xFFFF = no dialect acceptable */
- __le16 ByteCount;
-} __packed;
-
struct filesystem_attribute_info {
__le32 Attributes;
__le32 MaxPathNameComponentLength;
--
2.43.0
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH v3 15/22] smb: move FILE_SYSTEM_ATTRIBUTE_INFO to common/cifspdu.h
2025-10-14 7:28 ` [PATCH v3 11/22] smb: move smb2_file_network_open_info " chenxiaosong.chenxiaosong
` (2 preceding siblings ...)
2025-10-14 7:28 ` [PATCH v3 14/22] smb: move SMB frame " chenxiaosong.chenxiaosong
@ 2025-10-14 7:28 ` chenxiaosong.chenxiaosong
2025-10-20 5:35 ` Namjae Jeon
2025-10-14 7:28 ` [PATCH v3 16/22] smb: move FILE_SYSTEM_DEVICE_INFO " chenxiaosong.chenxiaosong
` (6 subsequent siblings)
10 siblings, 1 reply; 37+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-10-14 7:28 UTC (permalink / raw)
To: stfrench, metze, pali, linkinjeon, smfrench, sfrench, senozhatsky,
tom, pc, ronniesahlberg, sprasad, bharathsm, christophe.jaillet
Cc: linux-cifs, linux-kernel
From: ChenXiaoSong <chenxiaosong@kylinos.cn>
Rename "struct filesystem_attribute_info" to "FILE_SYSTEM_ATTRIBUTE_INFO",
then move duplicate definitions to common header file.
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
fs/smb/client/cifspdu.h | 7 -------
fs/smb/common/cifspdu.h | 8 ++++++++
fs/smb/server/smb2pdu.c | 6 +++---
fs/smb/server/smb_common.h | 7 -------
4 files changed, 11 insertions(+), 17 deletions(-)
diff --git a/fs/smb/client/cifspdu.h b/fs/smb/client/cifspdu.h
index 07eb821654e1..a6f7e168961e 100644
--- a/fs/smb/client/cifspdu.h
+++ b/fs/smb/client/cifspdu.h
@@ -1937,13 +1937,6 @@ typedef struct {
/* 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/common/cifspdu.h b/fs/smb/common/cifspdu.h
index 1109c20f7bf8..560900617be7 100644
--- a/fs/smb/common/cifspdu.h
+++ b/fs/smb/common/cifspdu.h
@@ -348,4 +348,12 @@ typedef struct server_negotiate_rsp {
#define FILE_CASE_PRESERVED_NAMES 0x00000002
#define FILE_CASE_SENSITIVE_SEARCH 0x00000001
+/* See FS-FSCC 2.5.1 */
+typedef struct {
+ __le32 Attributes;
+ __le32 MaxPathNameComponentLength;
+ __le32 FileSystemNameLen;
+ __le16 FileSystemName[]; /* do not have to save this - get subset? */
+} __attribute__((packed)) FILE_SYSTEM_ATTRIBUTE_INFO;
+
#endif /* _COMMON_CIFSPDU_H */
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index a46d4ddade9e..a05b04799c0d 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -5485,10 +5485,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 |
@@ -5507,7 +5507,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 a5dd656c36f1..016ec93e6df4 100644
--- a/fs/smb/server/smb_common.h
+++ b/fs/smb/server/smb_common.h
@@ -56,13 +56,6 @@
FILE_EXECUTE | FILE_DELETE_CHILD | \
FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES)
-struct filesystem_attribute_info {
- __le32 Attributes;
- __le32 MaxPathNameComponentLength;
- __le32 FileSystemNameLen;
- __le16 FileSystemName[]; /* do not have to save this - get subset? */
-} __packed;
-
struct filesystem_device_info {
__le32 DeviceType;
__le32 DeviceCharacteristics;
--
2.43.0
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH v3 16/22] smb: move FILE_SYSTEM_DEVICE_INFO to common/cifspdu.h
2025-10-14 7:28 ` [PATCH v3 11/22] smb: move smb2_file_network_open_info " chenxiaosong.chenxiaosong
` (3 preceding siblings ...)
2025-10-14 7:28 ` [PATCH v3 15/22] smb: move FILE_SYSTEM_ATTRIBUTE_INFO " chenxiaosong.chenxiaosong
@ 2025-10-14 7:28 ` chenxiaosong.chenxiaosong
2025-10-14 7:28 ` [PATCH v3 17/22] smb: move FILE_SYSTEM_INFO " chenxiaosong.chenxiaosong
` (5 subsequent siblings)
10 siblings, 0 replies; 37+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-10-14 7:28 UTC (permalink / raw)
To: stfrench, metze, pali, linkinjeon, smfrench, sfrench, senozhatsky,
tom, pc, ronniesahlberg, sprasad, bharathsm, christophe.jaillet
Cc: linux-cifs, linux-kernel
From: ChenXiaoSong <chenxiaosong@kylinos.cn>
Rename "struct filesystem_device_info" to "FILE_SYSTEM_DEVICE_INFO",
then move duplicate definitions to common header file.
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
fs/smb/client/cifspdu.h | 5 -----
fs/smb/common/cifspdu.h | 6 ++++++
fs/smb/server/smb2pdu.c | 4 ++--
fs/smb/server/smb_common.h | 5 -----
4 files changed, 8 insertions(+), 12 deletions(-)
diff --git a/fs/smb/client/cifspdu.h b/fs/smb/client/cifspdu.h
index a6f7e168961e..17255d7a4615 100644
--- a/fs/smb/client/cifspdu.h
+++ b/fs/smb/client/cifspdu.h
@@ -1929,11 +1929,6 @@ typedef struct {
#define FILE_PORTABLE_DEVICE 0x00004000
#define FILE_DEVICE_ALLOW_APPCONTAINER_TRAVERSAL 0x00020000
-typedef struct {
- __le32 DeviceType;
- __le32 DeviceCharacteristics;
-} __attribute__((packed)) FILE_SYSTEM_DEVICE_INFO; /* device info level 0x104 */
-
/* minimum includes first three fields, and empty FS Name */
#define MIN_FS_ATTR_INFO_SIZE 12
diff --git a/fs/smb/common/cifspdu.h b/fs/smb/common/cifspdu.h
index 560900617be7..055c6577b4e9 100644
--- a/fs/smb/common/cifspdu.h
+++ b/fs/smb/common/cifspdu.h
@@ -321,6 +321,12 @@ typedef struct server_negotiate_rsp {
__le16 ByteCount;
} __attribute__((packed)) SERVER_NEGOTIATE_RSP;
+/* See MS-CIFS 2.2.8.2.5 */
+typedef struct {
+ __le32 DeviceType;
+ __le32 DeviceCharacteristics;
+} __attribute__((packed)) FILE_SYSTEM_DEVICE_INFO; /* device info level 0x104 */
+
/* List of FileSystemAttributes - see 2.5.1 of MS-FSCC */
#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 a05b04799c0d..41167e7cca77 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -5469,9 +5469,9 @@ static int smb2_get_info_filesystem(struct ksmbd_work *work,
switch (fsinfoclass) {
case FS_DEVICE_INFORMATION:
{
- struct filesystem_device_info *info;
+ FILE_SYSTEM_DEVICE_INFO *info;
- info = (struct filesystem_device_info *)rsp->Buffer;
+ info = (FILE_SYSTEM_DEVICE_INFO *)rsp->Buffer;
info->DeviceType = cpu_to_le32(FILE_DEVICE_DISK);
info->DeviceCharacteristics =
diff --git a/fs/smb/server/smb_common.h b/fs/smb/server/smb_common.h
index 016ec93e6df4..86d18a8badff 100644
--- a/fs/smb/server/smb_common.h
+++ b/fs/smb/server/smb_common.h
@@ -56,11 +56,6 @@
FILE_EXECUTE | FILE_DELETE_CHILD | \
FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES)
-struct filesystem_device_info {
- __le32 DeviceType;
- __le32 DeviceCharacteristics;
-} __packed; /* device info level 0x104 */
-
struct filesystem_vol_info {
__le64 VolumeCreationTime;
__le32 SerialNumber;
--
2.43.0
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH v3 17/22] smb: move FILE_SYSTEM_INFO to common/cifspdu.h
2025-10-14 7:28 ` [PATCH v3 11/22] smb: move smb2_file_network_open_info " chenxiaosong.chenxiaosong
` (4 preceding siblings ...)
2025-10-14 7:28 ` [PATCH v3 16/22] smb: move FILE_SYSTEM_DEVICE_INFO " chenxiaosong.chenxiaosong
@ 2025-10-14 7:28 ` chenxiaosong.chenxiaosong
2025-10-14 7:28 ` [PATCH v3 18/22] smb: move FILE_DIRECTORY_INFO " chenxiaosong.chenxiaosong
` (4 subsequent siblings)
10 siblings, 0 replies; 37+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-10-14 7:28 UTC (permalink / raw)
To: stfrench, metze, pali, linkinjeon, smfrench, sfrench, senozhatsky,
tom, pc, ronniesahlberg, sprasad, bharathsm, christophe.jaillet
Cc: linux-cifs, linux-kernel
From: ChenXiaoSong <chenxiaosong@kylinos.cn>
Rename "struct filesystem_info" to "FILE_SYSTEM_INFO",
then move duplicate definitions to common header file.
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
fs/smb/client/cifspdu.h | 7 -------
fs/smb/common/cifspdu.h | 8 ++++++++
fs/smb/server/smb2pdu.c | 4 ++--
fs/smb/server/smb_common.h | 7 -------
4 files changed, 10 insertions(+), 16 deletions(-)
diff --git a/fs/smb/client/cifspdu.h b/fs/smb/client/cifspdu.h
index 17255d7a4615..889be409146c 100644
--- a/fs/smb/client/cifspdu.h
+++ b/fs/smb/client/cifspdu.h
@@ -1819,13 +1819,6 @@ struct aliasInfo92 {
int shareNameOffset;
} __attribute__((packed));
-typedef struct {
- __le64 TotalAllocationUnits;
- __le64 FreeAllocationUnits;
- __le32 SectorsPerAllocationUnit;
- __le32 BytesPerSector;
-} __attribute__((packed)) FILE_SYSTEM_INFO; /* size info, level 0x103 */
-
typedef struct {
__le32 fsid;
__le32 SectorsPerAllocationUnit;
diff --git a/fs/smb/common/cifspdu.h b/fs/smb/common/cifspdu.h
index 055c6577b4e9..548d621ec233 100644
--- a/fs/smb/common/cifspdu.h
+++ b/fs/smb/common/cifspdu.h
@@ -321,6 +321,14 @@ typedef struct server_negotiate_rsp {
__le16 ByteCount;
} __attribute__((packed)) SERVER_NEGOTIATE_RSP;
+/* See MS-CIFS 2.2.8.2.4 */
+typedef struct {
+ __le64 TotalAllocationUnits;
+ __le64 FreeAllocationUnits;
+ __le32 SectorsPerAllocationUnit;
+ __le32 BytesPerSector;
+} __attribute__((packed)) FILE_SYSTEM_INFO; /* size info, level 0x103 */
+
/* See MS-CIFS 2.2.8.2.5 */
typedef struct {
__le32 DeviceType;
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index 41167e7cca77..2ad46a11e7ef 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -5539,9 +5539,9 @@ static int smb2_get_info_filesystem(struct ksmbd_work *work,
}
case FS_SIZE_INFORMATION:
{
- struct filesystem_info *info;
+ FILE_SYSTEM_INFO *info;
- info = (struct filesystem_info *)(rsp->Buffer);
+ info = (FILE_SYSTEM_INFO *)(rsp->Buffer);
info->TotalAllocationUnits = cpu_to_le64(stfs.f_blocks);
info->FreeAllocationUnits = cpu_to_le64(stfs.f_bfree);
info->SectorsPerAllocationUnit = cpu_to_le32(1);
diff --git a/fs/smb/server/smb_common.h b/fs/smb/server/smb_common.h
index 86d18a8badff..d6351b0ee62a 100644
--- a/fs/smb/server/smb_common.h
+++ b/fs/smb/server/smb_common.h
@@ -64,13 +64,6 @@ struct filesystem_vol_info {
__le16 VolumeLabel[];
} __packed;
-struct filesystem_info {
- __le64 TotalAllocationUnits;
- __le64 FreeAllocationUnits;
- __le32 SectorsPerAllocationUnit;
- __le32 BytesPerSector;
-} __packed; /* size info, level 0x103 */
-
#define EXTENDED_INFO_MAGIC 0x43667364 /* Cfsd */
#define STRING_LENGTH 28
--
2.43.0
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH v3 18/22] smb: move FILE_DIRECTORY_INFO to common/cifspdu.h
2025-10-14 7:28 ` [PATCH v3 11/22] smb: move smb2_file_network_open_info " chenxiaosong.chenxiaosong
` (5 preceding siblings ...)
2025-10-14 7:28 ` [PATCH v3 17/22] smb: move FILE_SYSTEM_INFO " chenxiaosong.chenxiaosong
@ 2025-10-14 7:28 ` chenxiaosong.chenxiaosong
2025-10-14 7:28 ` [PATCH v3 19/22] smb: move FILE_FULL_DIRECTORY_INFO " chenxiaosong.chenxiaosong
` (3 subsequent siblings)
10 siblings, 0 replies; 37+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-10-14 7:28 UTC (permalink / raw)
To: stfrench, metze, pali, linkinjeon, smfrench, sfrench, senozhatsky,
tom, pc, ronniesahlberg, sprasad, bharathsm, christophe.jaillet
Cc: linux-cifs, linux-kernel
From: ChenXiaoSong <chenxiaosong@kylinos.cn>
Rename "struct file_directory_info" to "FILE_DIRECTORY_INFO",
then move duplicate definitions to common header file.
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
fs/smb/client/cifspdu.h | 14 --------------
fs/smb/common/cifspdu.h | 15 +++++++++++++++
fs/smb/server/smb2pdu.c | 16 ++++++++--------
fs/smb/server/smb_common.h | 14 --------------
fs/smb/server/vfs.c | 2 +-
5 files changed, 24 insertions(+), 37 deletions(-)
diff --git a/fs/smb/client/cifspdu.h b/fs/smb/client/cifspdu.h
index 889be409146c..8031e24234a9 100644
--- a/fs/smb/client/cifspdu.h
+++ b/fs/smb/client/cifspdu.h
@@ -2150,20 +2150,6 @@ typedef struct {
};
} __attribute__((packed)) FILE_UNIX_INFO; /* level 0x202 */
-typedef struct {
- __le32 NextEntryOffset;
- __u32 FileIndex;
- __le64 CreationTime;
- __le64 LastAccessTime;
- __le64 LastWriteTime;
- __le64 ChangeTime;
- __le64 EndOfFile;
- __le64 AllocationSize;
- __le32 ExtFileAttributes;
- __le32 FileNameLength;
- char FileName[];
-} __attribute__((packed)) FILE_DIRECTORY_INFO; /* level 0x101 FF resp data */
-
typedef struct {
__le32 NextEntryOffset;
__u32 FileIndex;
diff --git a/fs/smb/common/cifspdu.h b/fs/smb/common/cifspdu.h
index 548d621ec233..82d57ba275ee 100644
--- a/fs/smb/common/cifspdu.h
+++ b/fs/smb/common/cifspdu.h
@@ -370,4 +370,19 @@ typedef struct {
__le16 FileSystemName[]; /* do not have to save this - get subset? */
} __attribute__((packed)) FILE_SYSTEM_ATTRIBUTE_INFO;
+/* See MS-CIFS 2.2.8.1.4 */
+typedef struct {
+ __le32 NextEntryOffset;
+ __u32 FileIndex;
+ __le64 CreationTime;
+ __le64 LastAccessTime;
+ __le64 LastWriteTime;
+ __le64 ChangeTime;
+ __le64 EndOfFile;
+ __le64 AllocationSize;
+ __le32 ExtFileAttributes;
+ __le32 FileNameLength;
+ char FileName[];
+} __attribute__((packed)) FILE_DIRECTORY_INFO; /* level 0x101 FF resp data */
+
#endif /* _COMMON_CIFSPDU_H */
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index 2ad46a11e7ef..679318afdce3 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -3800,7 +3800,7 @@ static int readdir_info_level_struct_sz(int info_level)
case FILE_BOTH_DIRECTORY_INFORMATION:
return sizeof(struct file_both_directory_info);
case FILE_DIRECTORY_INFORMATION:
- return sizeof(struct file_directory_info);
+ return sizeof(FILE_DIRECTORY_INFO);
case FILE_NAMES_INFORMATION:
return sizeof(struct file_names_info);
case FILEID_FULL_DIRECTORY_INFORMATION:
@@ -3839,9 +3839,9 @@ static int dentry_name(struct ksmbd_dir_info *d_info, int info_level)
}
case FILE_DIRECTORY_INFORMATION:
{
- struct file_directory_info *fdinfo;
+ FILE_DIRECTORY_INFO *fdinfo;
- fdinfo = (struct file_directory_info *)d_info->rptr;
+ fdinfo = (FILE_DIRECTORY_INFO *)d_info->rptr;
d_info->rptr += le32_to_cpu(fdinfo->NextEntryOffset);
d_info->name = fdinfo->FileName;
d_info->name_len = le32_to_cpu(fdinfo->FileNameLength);
@@ -3978,9 +3978,9 @@ static int smb2_populate_readdir_entry(struct ksmbd_conn *conn, int info_level,
}
case FILE_DIRECTORY_INFORMATION:
{
- struct file_directory_info *fdinfo;
+ FILE_DIRECTORY_INFO *fdinfo;
- fdinfo = (struct file_directory_info *)kstat;
+ fdinfo = (FILE_DIRECTORY_INFO *)kstat;
fdinfo->FileNameLength = cpu_to_le32(conv_len);
if (d_info->hide_dot_file && d_info->name[0] == '.')
fdinfo->ExtFileAttributes |= FILE_ATTRIBUTE_HIDDEN_LE;
@@ -4228,9 +4228,9 @@ static int reserve_populate_dentry(struct ksmbd_dir_info *d_info,
}
case FILE_DIRECTORY_INFORMATION:
{
- struct file_directory_info *fdinfo;
+ FILE_DIRECTORY_INFO *fdinfo;
- fdinfo = (struct file_directory_info *)d_info->wptr;
+ fdinfo = (FILE_DIRECTORY_INFO *)d_info->wptr;
memcpy(fdinfo->FileName, d_info->name, d_info->name_len);
fdinfo->FileName[d_info->name_len] = 0x00;
fdinfo->FileNameLength = cpu_to_le32(d_info->name_len);
@@ -4514,7 +4514,7 @@ int smb2_query_dir(struct ksmbd_work *work)
goto err_out;
} else {
no_buf_len:
- ((struct file_directory_info *)
+ ((FILE_DIRECTORY_INFO *)
((char *)rsp->Buffer + d_info.last_entry_offset))
->NextEntryOffset = 0;
if (d_info.data_count >= d_info.last_entry_off_align)
diff --git a/fs/smb/server/smb_common.h b/fs/smb/server/smb_common.h
index d6351b0ee62a..ea1c64f84ff1 100644
--- a/fs/smb/server/smb_common.h
+++ b/fs/smb/server/smb_common.h
@@ -80,20 +80,6 @@ struct object_id_info {
struct fs_extended_info extended_info;
} __packed;
-struct file_directory_info {
- __le32 NextEntryOffset;
- __u32 FileIndex;
- __le64 CreationTime;
- __le64 LastAccessTime;
- __le64 LastWriteTime;
- __le64 ChangeTime;
- __le64 EndOfFile;
- __le64 AllocationSize;
- __le32 ExtFileAttributes;
- __le32 FileNameLength;
- char FileName[];
-} __packed; /* level 0x101 FF resp data */
-
struct file_names_info {
__le32 NextEntryOffset;
__u32 FileIndex;
diff --git a/fs/smb/server/vfs.c b/fs/smb/server/vfs.c
index 891ed2dc2b73..a8660487e4ae 100644
--- a/fs/smb/server/vfs.c
+++ b/fs/smb/server/vfs.c
@@ -1654,7 +1654,7 @@ int ksmbd_vfs_get_dos_attrib_xattr(struct mnt_idmap *idmap,
*/
void *ksmbd_vfs_init_kstat(char **p, struct ksmbd_kstat *ksmbd_kstat)
{
- struct file_directory_info *info = (struct file_directory_info *)(*p);
+ FILE_DIRECTORY_INFO *info = (FILE_DIRECTORY_INFO *)(*p);
struct kstat *kstat = ksmbd_kstat->kstat;
u64 time;
--
2.43.0
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH v3 19/22] smb: move FILE_FULL_DIRECTORY_INFO to common/cifspdu.h
2025-10-14 7:28 ` [PATCH v3 11/22] smb: move smb2_file_network_open_info " chenxiaosong.chenxiaosong
` (6 preceding siblings ...)
2025-10-14 7:28 ` [PATCH v3 18/22] smb: move FILE_DIRECTORY_INFO " chenxiaosong.chenxiaosong
@ 2025-10-14 7:28 ` chenxiaosong.chenxiaosong
2025-10-14 7:28 ` [PATCH v3 20/22] smb: move FILE_BOTH_DIRECTORY_INFO " chenxiaosong.chenxiaosong
` (2 subsequent siblings)
10 siblings, 0 replies; 37+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-10-14 7:28 UTC (permalink / raw)
To: stfrench, metze, pali, linkinjeon, smfrench, sfrench, senozhatsky,
tom, pc, ronniesahlberg, sprasad, bharathsm, christophe.jaillet
Cc: linux-cifs, linux-kernel
From: ChenXiaoSong <chenxiaosong@kylinos.cn>
Rename "struct file_full_directory_info" to "FILE_FULL_DIRECTORY_INFO",
then move duplicate definitions to common header file.
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
fs/smb/client/cifspdu.h | 15 ---------------
fs/smb/common/cifspdu.h | 16 ++++++++++++++++
fs/smb/server/smb2pdu.c | 14 +++++++-------
fs/smb/server/smb_common.h | 15 ---------------
4 files changed, 23 insertions(+), 37 deletions(-)
diff --git a/fs/smb/client/cifspdu.h b/fs/smb/client/cifspdu.h
index 8031e24234a9..f89abcb88dee 100644
--- a/fs/smb/client/cifspdu.h
+++ b/fs/smb/client/cifspdu.h
@@ -2150,21 +2150,6 @@ typedef struct {
};
} __attribute__((packed)) FILE_UNIX_INFO; /* level 0x202 */
-typedef struct {
- __le32 NextEntryOffset;
- __u32 FileIndex;
- __le64 CreationTime;
- __le64 LastAccessTime;
- __le64 LastWriteTime;
- __le64 ChangeTime;
- __le64 EndOfFile;
- __le64 AllocationSize;
- __le32 ExtFileAttributes;
- __le32 FileNameLength;
- __le32 EaSize; /* length of the xattrs */
- char FileName[];
-} __attribute__((packed)) FILE_FULL_DIRECTORY_INFO; /* level 0x102 rsp data */
-
typedef struct {
__le32 NextEntryOffset;
__u32 FileIndex;
diff --git a/fs/smb/common/cifspdu.h b/fs/smb/common/cifspdu.h
index 82d57ba275ee..d7c9f17ed220 100644
--- a/fs/smb/common/cifspdu.h
+++ b/fs/smb/common/cifspdu.h
@@ -385,4 +385,20 @@ typedef struct {
char FileName[];
} __attribute__((packed)) FILE_DIRECTORY_INFO; /* level 0x101 FF resp data */
+/* See MS-CIFS 2.2.8.1.5 */
+typedef struct {
+ __le32 NextEntryOffset;
+ __u32 FileIndex;
+ __le64 CreationTime;
+ __le64 LastAccessTime;
+ __le64 LastWriteTime;
+ __le64 ChangeTime;
+ __le64 EndOfFile;
+ __le64 AllocationSize;
+ __le32 ExtFileAttributes;
+ __le32 FileNameLength;
+ __le32 EaSize; /* length of the xattrs */
+ char FileName[];
+} __attribute__((packed)) FILE_FULL_DIRECTORY_INFO; /* level 0x102 rsp data */
+
#endif /* _COMMON_CIFSPDU_H */
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index 679318afdce3..6121060d84ae 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -3796,7 +3796,7 @@ static int readdir_info_level_struct_sz(int info_level)
{
switch (info_level) {
case FILE_FULL_DIRECTORY_INFORMATION:
- return sizeof(struct file_full_directory_info);
+ return sizeof(FILE_FULL_DIRECTORY_INFO);
case FILE_BOTH_DIRECTORY_INFORMATION:
return sizeof(struct file_both_directory_info);
case FILE_DIRECTORY_INFORMATION:
@@ -3819,9 +3819,9 @@ static int dentry_name(struct ksmbd_dir_info *d_info, int info_level)
switch (info_level) {
case FILE_FULL_DIRECTORY_INFORMATION:
{
- struct file_full_directory_info *ffdinfo;
+ FILE_FULL_DIRECTORY_INFO *ffdinfo;
- ffdinfo = (struct file_full_directory_info *)d_info->rptr;
+ ffdinfo = (FILE_FULL_DIRECTORY_INFO *)d_info->rptr;
d_info->rptr += le32_to_cpu(ffdinfo->NextEntryOffset);
d_info->name = ffdinfo->FileName;
d_info->name_len = le32_to_cpu(ffdinfo->FileNameLength);
@@ -3944,9 +3944,9 @@ static int smb2_populate_readdir_entry(struct ksmbd_conn *conn, int info_level,
switch (info_level) {
case FILE_FULL_DIRECTORY_INFORMATION:
{
- struct file_full_directory_info *ffdinfo;
+ FILE_FULL_DIRECTORY_INFO *ffdinfo;
- ffdinfo = (struct file_full_directory_info *)kstat;
+ ffdinfo = (FILE_FULL_DIRECTORY_INFO *)kstat;
ffdinfo->FileNameLength = cpu_to_le32(conv_len);
ffdinfo->EaSize =
smb2_get_reparse_tag_special_file(ksmbd_kstat->kstat->mode);
@@ -4206,9 +4206,9 @@ static int reserve_populate_dentry(struct ksmbd_dir_info *d_info,
switch (info_level) {
case FILE_FULL_DIRECTORY_INFORMATION:
{
- struct file_full_directory_info *ffdinfo;
+ FILE_FULL_DIRECTORY_INFO *ffdinfo;
- ffdinfo = (struct file_full_directory_info *)d_info->wptr;
+ ffdinfo = (FILE_FULL_DIRECTORY_INFO *)d_info->wptr;
memcpy(ffdinfo->FileName, d_info->name, d_info->name_len);
ffdinfo->FileName[d_info->name_len] = 0x00;
ffdinfo->FileNameLength = cpu_to_le32(d_info->name_len);
diff --git a/fs/smb/server/smb_common.h b/fs/smb/server/smb_common.h
index ea1c64f84ff1..e325c2e89aa5 100644
--- a/fs/smb/server/smb_common.h
+++ b/fs/smb/server/smb_common.h
@@ -87,21 +87,6 @@ struct file_names_info {
char FileName[];
} __packed; /* level 0xc FF resp data */
-struct file_full_directory_info {
- __le32 NextEntryOffset;
- __u32 FileIndex;
- __le64 CreationTime;
- __le64 LastAccessTime;
- __le64 LastWriteTime;
- __le64 ChangeTime;
- __le64 EndOfFile;
- __le64 AllocationSize;
- __le32 ExtFileAttributes;
- __le32 FileNameLength;
- __le32 EaSize;
- char FileName[];
-} __packed; /* level 0x102 FF resp */
-
struct file_both_directory_info {
__le32 NextEntryOffset;
__u32 FileIndex;
--
2.43.0
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH v3 20/22] smb: move FILE_BOTH_DIRECTORY_INFO to common/cifspdu.h
2025-10-14 7:28 ` [PATCH v3 11/22] smb: move smb2_file_network_open_info " chenxiaosong.chenxiaosong
` (7 preceding siblings ...)
2025-10-14 7:28 ` [PATCH v3 19/22] smb: move FILE_FULL_DIRECTORY_INFO " chenxiaosong.chenxiaosong
@ 2025-10-14 7:28 ` chenxiaosong.chenxiaosong
2025-10-14 7:28 ` [PATCH v3 21/22] smb: move SEARCH_ID_FULL_DIR_INFO " chenxiaosong.chenxiaosong
2025-10-14 7:28 ` [PATCH v3 22/22] smb: move FILE_SYSTEM_POSIX_INFO " chenxiaosong.chenxiaosong
10 siblings, 0 replies; 37+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-10-14 7:28 UTC (permalink / raw)
To: stfrench, metze, pali, linkinjeon, smfrench, sfrench, senozhatsky,
tom, pc, ronniesahlberg, sprasad, bharathsm, christophe.jaillet
Cc: linux-cifs, linux-kernel
From: ChenXiaoSong <chenxiaosong@kylinos.cn>
Rename "struct file_both_directory_info" to "FILE_BOTH_DIRECTORY_INFO",
then move duplicate definitions to common header file.
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
fs/smb/client/cifspdu.h | 18 ------------------
fs/smb/common/cifspdu.h | 19 +++++++++++++++++++
fs/smb/server/smb2pdu.c | 14 +++++++-------
fs/smb/server/smb_common.h | 18 ------------------
4 files changed, 26 insertions(+), 43 deletions(-)
diff --git a/fs/smb/client/cifspdu.h b/fs/smb/client/cifspdu.h
index f89abcb88dee..3db5e7e6172e 100644
--- a/fs/smb/client/cifspdu.h
+++ b/fs/smb/client/cifspdu.h
@@ -2167,24 +2167,6 @@ typedef struct {
char FileName[];
} __attribute__((packed)) SEARCH_ID_FULL_DIR_INFO; /* level 0x105 FF rsp data */
-typedef struct {
- __le32 NextEntryOffset;
- __u32 FileIndex;
- __le64 CreationTime;
- __le64 LastAccessTime;
- __le64 LastWriteTime;
- __le64 ChangeTime;
- __le64 EndOfFile;
- __le64 AllocationSize;
- __le32 ExtFileAttributes;
- __le32 FileNameLength;
- __le32 EaSize; /* length of the xattrs */
- __u8 ShortNameLength;
- __u8 Reserved;
- __u8 ShortName[24];
- char FileName[];
-} __attribute__((packed)) FILE_BOTH_DIRECTORY_INFO; /* level 0x104 FFrsp data */
-
typedef struct {
__u32 ResumeKey;
__le16 CreationDate; /* SMB Date */
diff --git a/fs/smb/common/cifspdu.h b/fs/smb/common/cifspdu.h
index d7c9f17ed220..cf5e3ee577d0 100644
--- a/fs/smb/common/cifspdu.h
+++ b/fs/smb/common/cifspdu.h
@@ -401,4 +401,23 @@ typedef struct {
char FileName[];
} __attribute__((packed)) FILE_FULL_DIRECTORY_INFO; /* level 0x102 rsp data */
+/* See MS-CIFS 2.2.8.1.7 */
+typedef struct {
+ __le32 NextEntryOffset;
+ __u32 FileIndex;
+ __le64 CreationTime;
+ __le64 LastAccessTime;
+ __le64 LastWriteTime;
+ __le64 ChangeTime;
+ __le64 EndOfFile;
+ __le64 AllocationSize;
+ __le32 ExtFileAttributes;
+ __le32 FileNameLength;
+ __le32 EaSize; /* length of the xattrs */
+ __u8 ShortNameLength;
+ __u8 Reserved;
+ __u8 ShortName[24];
+ char FileName[];
+} __attribute__((packed)) FILE_BOTH_DIRECTORY_INFO; /* level 0x104 FFrsp data */
+
#endif /* _COMMON_CIFSPDU_H */
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index 6121060d84ae..8c5700102cc6 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -3798,7 +3798,7 @@ static int readdir_info_level_struct_sz(int info_level)
case FILE_FULL_DIRECTORY_INFORMATION:
return sizeof(FILE_FULL_DIRECTORY_INFO);
case FILE_BOTH_DIRECTORY_INFORMATION:
- return sizeof(struct file_both_directory_info);
+ return sizeof(FILE_BOTH_DIRECTORY_INFO);
case FILE_DIRECTORY_INFORMATION:
return sizeof(FILE_DIRECTORY_INFO);
case FILE_NAMES_INFORMATION:
@@ -3829,9 +3829,9 @@ static int dentry_name(struct ksmbd_dir_info *d_info, int info_level)
}
case FILE_BOTH_DIRECTORY_INFORMATION:
{
- struct file_both_directory_info *fbdinfo;
+ FILE_BOTH_DIRECTORY_INFO *fbdinfo;
- fbdinfo = (struct file_both_directory_info *)d_info->rptr;
+ fbdinfo = (FILE_BOTH_DIRECTORY_INFO *)d_info->rptr;
d_info->rptr += le32_to_cpu(fbdinfo->NextEntryOffset);
d_info->name = fbdinfo->FileName;
d_info->name_len = le32_to_cpu(fbdinfo->FileNameLength);
@@ -3960,9 +3960,9 @@ static int smb2_populate_readdir_entry(struct ksmbd_conn *conn, int info_level,
}
case FILE_BOTH_DIRECTORY_INFORMATION:
{
- struct file_both_directory_info *fbdinfo;
+ FILE_BOTH_DIRECTORY_INFO *fbdinfo;
- fbdinfo = (struct file_both_directory_info *)kstat;
+ fbdinfo = (FILE_BOTH_DIRECTORY_INFO *)kstat;
fbdinfo->FileNameLength = cpu_to_le32(conv_len);
fbdinfo->EaSize =
smb2_get_reparse_tag_special_file(ksmbd_kstat->kstat->mode);
@@ -4217,9 +4217,9 @@ static int reserve_populate_dentry(struct ksmbd_dir_info *d_info,
}
case FILE_BOTH_DIRECTORY_INFORMATION:
{
- struct file_both_directory_info *fbdinfo;
+ FILE_BOTH_DIRECTORY_INFO *fbdinfo;
- fbdinfo = (struct file_both_directory_info *)d_info->wptr;
+ fbdinfo = (FILE_BOTH_DIRECTORY_INFO *)d_info->wptr;
memcpy(fbdinfo->FileName, d_info->name, d_info->name_len);
fbdinfo->FileName[d_info->name_len] = 0x00;
fbdinfo->FileNameLength = cpu_to_le32(d_info->name_len);
diff --git a/fs/smb/server/smb_common.h b/fs/smb/server/smb_common.h
index e325c2e89aa5..9e72c45c100b 100644
--- a/fs/smb/server/smb_common.h
+++ b/fs/smb/server/smb_common.h
@@ -87,24 +87,6 @@ struct file_names_info {
char FileName[];
} __packed; /* level 0xc FF resp data */
-struct file_both_directory_info {
- __le32 NextEntryOffset;
- __u32 FileIndex;
- __le64 CreationTime;
- __le64 LastAccessTime;
- __le64 LastWriteTime;
- __le64 ChangeTime;
- __le64 EndOfFile;
- __le64 AllocationSize;
- __le32 ExtFileAttributes;
- __le32 FileNameLength;
- __le32 EaSize; /* length of the xattrs */
- __u8 ShortNameLength;
- __u8 Reserved;
- __u8 ShortName[24];
- char FileName[];
-} __packed; /* level 0x104 FFrsp data */
-
struct file_id_both_directory_info {
__le32 NextEntryOffset;
__u32 FileIndex;
--
2.43.0
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH v3 21/22] smb: move SEARCH_ID_FULL_DIR_INFO to common/cifspdu.h
2025-10-14 7:28 ` [PATCH v3 11/22] smb: move smb2_file_network_open_info " chenxiaosong.chenxiaosong
` (8 preceding siblings ...)
2025-10-14 7:28 ` [PATCH v3 20/22] smb: move FILE_BOTH_DIRECTORY_INFO " chenxiaosong.chenxiaosong
@ 2025-10-14 7:28 ` chenxiaosong.chenxiaosong
2025-10-14 7:28 ` [PATCH v3 22/22] smb: move FILE_SYSTEM_POSIX_INFO " chenxiaosong.chenxiaosong
10 siblings, 0 replies; 37+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-10-14 7:28 UTC (permalink / raw)
To: stfrench, metze, pali, linkinjeon, smfrench, sfrench, senozhatsky,
tom, pc, ronniesahlberg, sprasad, bharathsm, christophe.jaillet
Cc: linux-cifs, linux-kernel
From: ChenXiaoSong <chenxiaosong@kylinos.cn>
Rename "struct file_id_full_dir_info" to "SEARCH_ID_FULL_DIR_INFO",
then move duplicate definitions to common header file.
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
fs/smb/client/cifspdu.h | 17 -----------------
fs/smb/common/cifspdu.h | 18 ++++++++++++++++++
fs/smb/server/smb2pdu.c | 14 +++++++-------
fs/smb/server/smb_common.h | 17 -----------------
4 files changed, 25 insertions(+), 41 deletions(-)
diff --git a/fs/smb/client/cifspdu.h b/fs/smb/client/cifspdu.h
index 3db5e7e6172e..68e3af176add 100644
--- a/fs/smb/client/cifspdu.h
+++ b/fs/smb/client/cifspdu.h
@@ -2150,23 +2150,6 @@ typedef struct {
};
} __attribute__((packed)) FILE_UNIX_INFO; /* level 0x202 */
-typedef struct {
- __le32 NextEntryOffset;
- __u32 FileIndex;
- __le64 CreationTime;
- __le64 LastAccessTime;
- __le64 LastWriteTime;
- __le64 ChangeTime;
- __le64 EndOfFile;
- __le64 AllocationSize;
- __le32 ExtFileAttributes;
- __le32 FileNameLength;
- __le32 EaSize; /* EA size */
- __le32 Reserved;
- __le64 UniqueId; /* inode num - le since Samba puts ino in low 32 bit*/
- char FileName[];
-} __attribute__((packed)) SEARCH_ID_FULL_DIR_INFO; /* level 0x105 FF rsp data */
-
typedef struct {
__u32 ResumeKey;
__le16 CreationDate; /* SMB Date */
diff --git a/fs/smb/common/cifspdu.h b/fs/smb/common/cifspdu.h
index cf5e3ee577d0..b4ca0c36cf84 100644
--- a/fs/smb/common/cifspdu.h
+++ b/fs/smb/common/cifspdu.h
@@ -401,6 +401,24 @@ typedef struct {
char FileName[];
} __attribute__((packed)) FILE_FULL_DIRECTORY_INFO; /* level 0x102 rsp data */
+/* See MS-SMB 2.2.8.1.2 */
+typedef struct {
+ __le32 NextEntryOffset;
+ __u32 FileIndex;
+ __le64 CreationTime;
+ __le64 LastAccessTime;
+ __le64 LastWriteTime;
+ __le64 ChangeTime;
+ __le64 EndOfFile;
+ __le64 AllocationSize;
+ __le32 ExtFileAttributes;
+ __le32 FileNameLength;
+ __le32 EaSize; /* EA size */
+ __le32 Reserved;
+ __le64 UniqueId; /* inode num - le since Samba puts ino in low 32 bit*/
+ char FileName[];
+} __attribute__((packed)) SEARCH_ID_FULL_DIR_INFO; /* level 0x105 FF rsp data */
+
/* See MS-CIFS 2.2.8.1.7 */
typedef struct {
__le32 NextEntryOffset;
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index 8c5700102cc6..065e0daaa91b 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -3804,7 +3804,7 @@ static int readdir_info_level_struct_sz(int info_level)
case FILE_NAMES_INFORMATION:
return sizeof(struct file_names_info);
case FILEID_FULL_DIRECTORY_INFORMATION:
- return sizeof(struct file_id_full_dir_info);
+ return sizeof(SEARCH_ID_FULL_DIR_INFO);
case FILEID_BOTH_DIRECTORY_INFORMATION:
return sizeof(struct file_id_both_directory_info);
case SMB_FIND_FILE_POSIX_INFO:
@@ -3859,9 +3859,9 @@ static int dentry_name(struct ksmbd_dir_info *d_info, int info_level)
}
case FILEID_FULL_DIRECTORY_INFORMATION:
{
- struct file_id_full_dir_info *dinfo;
+ SEARCH_ID_FULL_DIR_INFO *dinfo;
- dinfo = (struct file_id_full_dir_info *)d_info->rptr;
+ dinfo = (SEARCH_ID_FULL_DIR_INFO *)d_info->rptr;
d_info->rptr += le32_to_cpu(dinfo->NextEntryOffset);
d_info->name = dinfo->FileName;
d_info->name_len = le32_to_cpu(dinfo->FileNameLength);
@@ -4000,9 +4000,9 @@ static int smb2_populate_readdir_entry(struct ksmbd_conn *conn, int info_level,
}
case FILEID_FULL_DIRECTORY_INFORMATION:
{
- struct file_id_full_dir_info *dinfo;
+ SEARCH_ID_FULL_DIR_INFO *dinfo;
- dinfo = (struct file_id_full_dir_info *)kstat;
+ dinfo = (SEARCH_ID_FULL_DIR_INFO *)kstat;
dinfo->FileNameLength = cpu_to_le32(conv_len);
dinfo->EaSize =
smb2_get_reparse_tag_special_file(ksmbd_kstat->kstat->mode);
@@ -4250,9 +4250,9 @@ static int reserve_populate_dentry(struct ksmbd_dir_info *d_info,
}
case FILEID_FULL_DIRECTORY_INFORMATION:
{
- struct file_id_full_dir_info *dinfo;
+ SEARCH_ID_FULL_DIR_INFO *dinfo;
- dinfo = (struct file_id_full_dir_info *)d_info->wptr;
+ dinfo = (SEARCH_ID_FULL_DIR_INFO *)d_info->wptr;
memcpy(dinfo->FileName, d_info->name, d_info->name_len);
dinfo->FileName[d_info->name_len] = 0x00;
dinfo->FileNameLength = cpu_to_le32(d_info->name_len);
diff --git a/fs/smb/server/smb_common.h b/fs/smb/server/smb_common.h
index 9e72c45c100b..4f48dbf9c13b 100644
--- a/fs/smb/server/smb_common.h
+++ b/fs/smb/server/smb_common.h
@@ -107,23 +107,6 @@ struct file_id_both_directory_info {
char FileName[];
} __packed;
-struct file_id_full_dir_info {
- __le32 NextEntryOffset;
- __u32 FileIndex;
- __le64 CreationTime;
- __le64 LastAccessTime;
- __le64 LastWriteTime;
- __le64 ChangeTime;
- __le64 EndOfFile;
- __le64 AllocationSize;
- __le32 ExtFileAttributes;
- __le32 FileNameLength;
- __le32 EaSize; /* EA size */
- __le32 Reserved;
- __le64 UniqueId; /* inode num - le since Samba puts ino in low 32 bit*/
- char FileName[];
-} __packed; /* level 0x105 FF rsp data */
-
struct filesystem_posix_info {
/* For undefined recommended transfer size return -1 in that field */
__le32 OptimalTransferSize; /* bsize on some os, iosize on other os */
--
2.43.0
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH v3 22/22] smb: move FILE_SYSTEM_POSIX_INFO to common/cifspdu.h
2025-10-14 7:28 ` [PATCH v3 11/22] smb: move smb2_file_network_open_info " chenxiaosong.chenxiaosong
` (9 preceding siblings ...)
2025-10-14 7:28 ` [PATCH v3 21/22] smb: move SEARCH_ID_FULL_DIR_INFO " chenxiaosong.chenxiaosong
@ 2025-10-14 7:28 ` chenxiaosong.chenxiaosong
10 siblings, 0 replies; 37+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-10-14 7:28 UTC (permalink / raw)
To: stfrench, metze, pali, linkinjeon, smfrench, sfrench, senozhatsky,
tom, pc, ronniesahlberg, sprasad, bharathsm, christophe.jaillet
Cc: linux-cifs, linux-kernel
From: ChenXiaoSong <chenxiaosong@kylinos.cn>
Rename "struct filesystem_posix_info" to "FILE_SYSTEM_POSIX_INFO",
then move duplicate definitions to common header file.
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
fs/smb/client/cifspdu.h | 22 ----------------------
fs/smb/common/cifspdu.h | 23 +++++++++++++++++++++++
fs/smb/server/smb2pdu.c | 4 ++--
fs/smb/server/smb_common.h | 23 -----------------------
4 files changed, 25 insertions(+), 47 deletions(-)
diff --git a/fs/smb/client/cifspdu.h b/fs/smb/client/cifspdu.h
index 68e3af176add..ab23a233153a 100644
--- a/fs/smb/client/cifspdu.h
+++ b/fs/smb/client/cifspdu.h
@@ -1866,28 +1866,6 @@ typedef struct {
#define CIFS_POSIX_EXTENSIONS 0x00000010 /* support for new QFSInfo */
-typedef struct {
- /* For undefined recommended transfer size return -1 in that field */
- __le32 OptimalTransferSize; /* bsize on some os, iosize on other os */
- __le32 BlockSize;
- /* The next three fields are in terms of the block size.
- (above). If block size is unknown, 4096 would be a
- reasonable block size for a server to report.
- Note that returning the blocks/blocksavail removes need
- to make a second call (to QFSInfo level 0x103 to get this info.
- UserBlockAvail is typically less than or equal to BlocksAvail,
- if no distinction is made return the same value in each */
- __le64 TotalBlocks;
- __le64 BlocksAvail; /* bfree */
- __le64 UserBlocksAvail; /* bavail */
- /* For undefined Node fields or FSID return -1 */
- __le64 TotalFileNodes;
- __le64 FreeFileNodes;
- __le64 FileSysIdentifier; /* fsid */
- /* NB Namelen comes from FILE_SYSTEM_ATTRIBUTE_INFO call */
- /* NB flags can come from FILE_SYSTEM_DEVICE_INFO call */
-} __attribute__((packed)) FILE_SYSTEM_POSIX_INFO;
-
/* DeviceType Flags */
#define FILE_DEVICE_CD_ROM 0x00000002
#define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003
diff --git a/fs/smb/common/cifspdu.h b/fs/smb/common/cifspdu.h
index b4ca0c36cf84..853e03f395be 100644
--- a/fs/smb/common/cifspdu.h
+++ b/fs/smb/common/cifspdu.h
@@ -329,6 +329,29 @@ typedef struct {
__le32 BytesPerSector;
} __attribute__((packed)) FILE_SYSTEM_INFO; /* size info, level 0x103 */
+typedef struct {
+ /* For undefined recommended transfer size return -1 in that field */
+ __le32 OptimalTransferSize; /* bsize on some os, iosize on other os */
+ __le32 BlockSize;
+ /* The next three fields are in terms of the block size.
+ * (above). If block size is unknown, 4096 would be a
+ * reasonable block size for a server to report.
+ * Note that returning the blocks/blocksavail removes need
+ * to make a second call (to QFSInfo level 0x103 to get this info.
+ * UserBlockAvail is typically less than or equal to BlocksAvail,
+ * if no distinction is made return the same value in each
+ */
+ __le64 TotalBlocks;
+ __le64 BlocksAvail; /* bfree */
+ __le64 UserBlocksAvail; /* bavail */
+ /* For undefined Node fields or FSID return -1 */
+ __le64 TotalFileNodes;
+ __le64 FreeFileNodes;
+ __le64 FileSysIdentifier; /* fsid */
+ /* NB Namelen comes from FILE_SYSTEM_ATTRIBUTE_INFO call */
+ /* NB flags can come from FILE_SYSTEM_DEVICE_INFO call */
+} __attribute__((packed)) FILE_SYSTEM_POSIX_INFO;
+
/* See MS-CIFS 2.2.8.2.5 */
typedef struct {
__le32 DeviceType;
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index 065e0daaa91b..d49cd1ad1d70 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -5626,14 +5626,14 @@ static int smb2_get_info_filesystem(struct ksmbd_work *work,
}
case FS_POSIX_INFORMATION:
{
- struct filesystem_posix_info *info;
+ FILE_SYSTEM_POSIX_INFO *info;
if (!work->tcon->posix_extensions) {
pr_err("client doesn't negotiate with SMB3.1.1 POSIX Extensions\n");
path_put(&path);
return -EOPNOTSUPP;
} else {
- info = (struct filesystem_posix_info *)(rsp->Buffer);
+ info = (FILE_SYSTEM_POSIX_INFO *)(rsp->Buffer);
info->OptimalTransferSize = cpu_to_le32(stfs.f_bsize);
info->BlockSize = cpu_to_le32(stfs.f_bsize);
info->TotalBlocks = cpu_to_le64(stfs.f_blocks);
diff --git a/fs/smb/server/smb_common.h b/fs/smb/server/smb_common.h
index 4f48dbf9c13b..d349b3443219 100644
--- a/fs/smb/server/smb_common.h
+++ b/fs/smb/server/smb_common.h
@@ -107,29 +107,6 @@ struct file_id_both_directory_info {
char FileName[];
} __packed;
-struct filesystem_posix_info {
- /* For undefined recommended transfer size return -1 in that field */
- __le32 OptimalTransferSize; /* bsize on some os, iosize on other os */
- __le32 BlockSize;
- /* The next three fields are in terms of the block size.
- * (above). If block size is unknown, 4096 would be a
- * reasonable block size for a server to report.
- * Note that returning the blocks/blocksavail removes need
- * to make a second call (to QFSInfo level 0x103 to get this info.
- * UserBlockAvail is typically less than or equal to BlocksAvail,
- * if no distinction is made return the same value in each
- */
- __le64 TotalBlocks;
- __le64 BlocksAvail; /* bfree */
- __le64 UserBlocksAvail; /* bavail */
- /* For undefined Node fields or FSID return -1 */
- __le64 TotalFileNodes;
- __le64 FreeFileNodes;
- __le64 FileSysIdentifier; /* fsid */
- /* NB Namelen comes from FILE_SYSTEM_ATTRIBUTE_INFO call */
- /* NB flags can come from FILE_SYSTEM_DEVICE_INFO call */
-} __packed;
-
struct smb_version_ops {
u16 (*get_cmd_val)(struct ksmbd_work *swork);
int (*init_rsp_hdr)(struct ksmbd_work *swork);
--
2.43.0
^ permalink raw reply related [flat|nested] 37+ messages in thread
* Re: [PATCH v3 00/22] smb: fix some bugs, move duplicate definitions to common header file
2025-10-14 7:18 [PATCH v3 00/22] smb: fix some bugs, move duplicate definitions to common header file chenxiaosong.chenxiaosong
` (10 preceding siblings ...)
2025-10-14 7:28 ` [PATCH v3 11/22] smb: move smb2_file_network_open_info " chenxiaosong.chenxiaosong
@ 2025-10-15 5:43 ` Namjae Jeon
11 siblings, 0 replies; 37+ messages in thread
From: Namjae Jeon @ 2025-10-15 5:43 UTC (permalink / raw)
To: chenxiaosong.chenxiaosong
Cc: stfrench, metze, pali, smfrench, sfrench, senozhatsky, tom, pc,
ronniesahlberg, sprasad, bharathsm, christophe.jaillet,
zhangguodong, linux-cifs, linux-kernel, ChenXiaoSong
On Tue, Oct 14, 2025 at 4:20 PM <chenxiaosong.chenxiaosong@linux.dev> wrote:
>
> From: ChenXiaoSong <chenxiaosong@kylinos.cn>
>
> Emails from previous address were often not received (went to the spam
> folder or other reasons), and the cover letter wasn't linked to the
> patches. So yesterday I requested chenxiaosong.chenxiaosong@linux.dev
> account and have now sent v3.
>
> Fix some bugs of smb server.
>
> In order to maintain the code more easily, move some duplicate definitions
> to common header file.
>
> Add some MS documentation references for macro and struct definitions.
I have applied 0001, 0002 patches to #ksmbd-for-next-next as they are
obvious bug fixes.
I will give you feedback on the remaining patches soon.
Thanks.
>
> v2->v3:
> - Update patch #06: use "Suggested-by:" instead of "Reviewed-by:"
>
> v1->v2:
> - Update patch #06 according to Christophe JAILLET's suggestions: https://lore.kernel.org/all/d03c64d2-46c0-42d8-8f88-28669e921c95@wanadoo.fr/
>
> v2:
> - cover-letter: https://lore.kernel.org/all/40F04A8E2145E761+20251012161749.2994033-1-chenxiaosong@chenxiaosong.com/
> - patches: https://lore.kernel.org/all/47508024F79AE36C+20251012161749.2994033-2-chenxiaosong@chenxiaosong.com/
>
> v1:
> - cover-letter: https://lore.kernel.org/all/76A15C078023E21F+20251012150915.2992220-1-chenxiaosong@chenxiaosong.com/
> - patches: https://lore.kernel.org/all/029014EF18C9D322+20251012150915.2992220-2-chenxiaosong@chenxiaosong.com/
> - RESEND cover-letter: https://lore.kernel.org/all/37DF3D711BAD3621+20251012152247.2992573-1-chenxiaosong@chenxiaosong.com/
> - RESEND patches: https://lore.kernel.org/all/9836A3F274B62345+20251012152247.2992573-2-chenxiaosong@chenxiaosong.com/
>
> ZhangGuoDong (10):
> smb/server: fix possible memory leak in smb2_read()
> smb/server: fix possible refcount leak in smb2_sess_setup()
> smb: move some duplicate definitions to common/cifsglob.h
> smb: move smb_version_values to common/cifsglob.h
> smb: move get_rfc1002_len() to common/cifsglob.h
> smb: move SMB1_PROTO_NUMBER to common/cifsglob.h
> smb: move some duplicate definitions to common/smb2pdu.h
> smb: move smb_sockaddr_in and smb_sockaddr_in6 to common/smb2pdu.h
> smb: move copychunk definitions to common/smb2pdu.h
> smb: move resume_key_ioctl_rsp to common/smb2pdu.h
>
> ChenXiaoSong (12):
> smb: move smb2_file_network_open_info to common/smb2pdu.h
> smb: move some duplicate definitions to common/cifspdu.h
> smb: move file access permission bits definitions to common/cifspdu.h
> smb: move SMB frame definitions to common/cifspdu.h
> smb: move FILE_SYSTEM_ATTRIBUTE_INFO to common/cifspdu.h
> smb: move FILE_SYSTEM_DEVICE_INFO to common/cifspdu.h
> smb: move FILE_SYSTEM_INFO to common/cifspdu.h
> smb: move FILE_DIRECTORY_INFO to common/cifspdu.h
> smb: move FILE_FULL_DIRECTORY_INFO to common/cifspdu.h
> smb: move FILE_BOTH_DIRECTORY_INFO to common/cifspdu.h
> smb: move SEARCH_ID_FULL_DIR_INFO to common/cifspdu.h
> smb: move FILE_SYSTEM_POSIX_INFO to common/cifspdu.h
>
> fs/smb/client/cifsacl.c | 4 +-
> fs/smb/client/cifsglob.h | 47 +---
> fs/smb/client/cifspdu.h | 436 +-------------------------------
> fs/smb/client/cifssmb.c | 10 +-
> fs/smb/client/cifstransport.c | 8 +-
> fs/smb/client/connect.c | 2 +-
> fs/smb/client/misc.c | 2 +-
> fs/smb/client/smb2ops.c | 18 +-
> fs/smb/client/smb2pdu.h | 80 +-----
> fs/smb/common/cifsglob.h | 68 +++++
> fs/smb/common/cifspdu.h | 464 ++++++++++++++++++++++++++++++++++
> fs/smb/common/smb2pdu.h | 98 ++++++-
> fs/smb/server/smb2misc.c | 2 +-
> fs/smb/server/smb2ops.c | 32 +--
> fs/smb/server/smb2pdu.c | 114 +++++----
> fs/smb/server/smb2pdu.h | 67 -----
> fs/smb/server/smb_common.c | 10 +-
> fs/smb/server/smb_common.h | 304 +---------------------
> fs/smb/server/smbacl.c | 2 +-
> fs/smb/server/vfs.c | 2 +-
> 20 files changed, 735 insertions(+), 1035 deletions(-)
> create mode 100644 fs/smb/common/cifsglob.h
> create mode 100644 fs/smb/common/cifspdu.h
>
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v3 03/22] smb: move some duplicate definitions to common/cifsglob.h
2025-10-14 7:18 ` [PATCH v3 03/22] smb: move some duplicate definitions to common/cifsglob.h chenxiaosong.chenxiaosong
@ 2025-10-20 4:39 ` Namjae Jeon
0 siblings, 0 replies; 37+ messages in thread
From: Namjae Jeon @ 2025-10-20 4:39 UTC (permalink / raw)
To: chenxiaosong.chenxiaosong
Cc: stfrench, metze, pali, smfrench, sfrench, senozhatsky, tom, pc,
ronniesahlberg, sprasad, bharathsm, christophe.jaillet,
zhangguodong, linux-cifs, linux-kernel, ChenXiaoSong
On Tue, Oct 14, 2025 at 4:21 PM <chenxiaosong.chenxiaosong@linux.dev> wrote:
>
> From: ZhangGuoDong <zhangguodong@kylinos.cn>
>
> In order to maintain the code more easily, move duplicate definitions to
> new common header file.
>
> Co-developed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
> Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
> Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn>
> ---
> fs/smb/client/cifsglob.h | 19 +------------------
> fs/smb/common/cifsglob.h | 30 ++++++++++++++++++++++++++++++
> fs/smb/server/smb_common.h | 14 +-------------
> 3 files changed, 32 insertions(+), 31 deletions(-)
> create mode 100644 fs/smb/common/cifsglob.h
>
> diff --git a/fs/smb/client/cifsglob.h b/fs/smb/client/cifsglob.h
> index 8f6f567d7474..c5034cf9ac9e 100644
> --- a/fs/smb/client/cifsglob.h
> +++ b/fs/smb/client/cifsglob.h
> @@ -24,6 +24,7 @@
> #include "cifsacl.h"
> #include <crypto/internal/hash.h>
> #include <uapi/linux/cifs/cifs_mount.h>
> +#include "../common/cifsglob.h"
cifs is a legacy name. How about renaming it smbglob.h?
> #include "../common/smb2pdu.h"
> #include "smb2pdu.h"
> #include <linux/filelock.h>
> @@ -702,12 +703,6 @@ get_rfc1002_length(void *buf)
> return be32_to_cpu(*((__be32 *)buf)) & 0xffffff;
> }
>
> -static inline void
> -inc_rfc1001_len(void *buf, int count)
> -{
> - be32_add_cpu((__be32 *)buf, count);
> -}
> -
> struct TCP_Server_Info {
> struct list_head tcp_ses_list;
> struct list_head smb_ses_list;
> @@ -1021,8 +1016,6 @@ compare_mid(__u16 mid, const struct smb_hdr *smb)
> #define CIFS_MAX_RFC1002_WSIZE ((1<<17) - 1 - sizeof(WRITE_REQ) + 4)
> #define CIFS_MAX_RFC1002_RSIZE ((1<<17) - 1 - sizeof(READ_RSP) + 4)
>
> -#define CIFS_DEFAULT_IOSIZE (1024 * 1024)
> -
> /*
> * Windows only supports a max of 60kb reads and 65535 byte writes. Default to
> * those values when posix extensions aren't in force. In actuality here, we
> @@ -2148,30 +2141,20 @@ extern mempool_t cifs_io_request_pool;
> extern mempool_t cifs_io_subrequest_pool;
>
> /* Operations for different SMB versions */
> -#define SMB1_VERSION_STRING "1.0"
> -#define SMB20_VERSION_STRING "2.0"
> #ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
> extern struct smb_version_operations smb1_operations;
> extern struct smb_version_values smb1_values;
> extern struct smb_version_operations smb20_operations;
> extern struct smb_version_values smb20_values;
> #endif /* CIFS_ALLOW_INSECURE_LEGACY */
> -#define SMB21_VERSION_STRING "2.1"
> extern struct smb_version_operations smb21_operations;
> extern struct smb_version_values smb21_values;
> -#define SMBDEFAULT_VERSION_STRING "default"
> extern struct smb_version_values smbdefault_values;
> -#define SMB3ANY_VERSION_STRING "3"
> extern struct smb_version_values smb3any_values;
> -#define SMB30_VERSION_STRING "3.0"
> extern struct smb_version_operations smb30_operations;
> extern struct smb_version_values smb30_values;
> -#define SMB302_VERSION_STRING "3.02"
> -#define ALT_SMB302_VERSION_STRING "3.0.2"
> /*extern struct smb_version_operations smb302_operations;*/ /* not needed yet */
> extern struct smb_version_values smb302_values;
> -#define SMB311_VERSION_STRING "3.1.1"
> -#define ALT_SMB311_VERSION_STRING "3.11"
> extern struct smb_version_operations smb311_operations;
> extern struct smb_version_values smb311_values;
>
> diff --git a/fs/smb/common/cifsglob.h b/fs/smb/common/cifsglob.h
> new file mode 100644
> index 000000000000..00fd215e3eb5
> --- /dev/null
> +++ b/fs/smb/common/cifsglob.h
> @@ -0,0 +1,30 @@
> +/* SPDX-License-Identifier: LGPL-2.1 */
> +/*
> + *
> + * Copyright (C) International Business Machines Corp., 2002,2008
> + * Author(s): Steve French (sfrench@us.ibm.com)
> + * Jeremy Allison (jra@samba.org)
> + *
> + */
> +#ifndef _COMMON_CIFS_GLOB_H
> +#define _COMMON_CIFS_GLOB_H
> +
> +static inline void inc_rfc1001_len(void *buf, int count)
> +{
> + be32_add_cpu((__be32 *)buf, count);
> +}
> +
> +#define SMB1_VERSION_STRING "1.0"
> +#define SMB20_VERSION_STRING "2.0"
> +#define SMB21_VERSION_STRING "2.1"
> +#define SMBDEFAULT_VERSION_STRING "default"
> +#define SMB3ANY_VERSION_STRING "3"
> +#define SMB30_VERSION_STRING "3.0"
> +#define SMB302_VERSION_STRING "3.02"
> +#define ALT_SMB302_VERSION_STRING "3.0.2"
> +#define SMB311_VERSION_STRING "3.1.1"
> +#define ALT_SMB311_VERSION_STRING "3.11"
> +
> +#define CIFS_DEFAULT_IOSIZE (1024 * 1024)
> +
> +#endif /* _COMMON_CIFS_GLOB_H */
> diff --git a/fs/smb/server/smb_common.h b/fs/smb/server/smb_common.h
> index d742ba754348..863716207a0d 100644
> --- a/fs/smb/server/smb_common.h
> +++ b/fs/smb/server/smb_common.h
> @@ -10,6 +10,7 @@
>
> #include "glob.h"
> #include "nterr.h"
> +#include "../common/cifsglob.h"
> #include "../common/smb2pdu.h"
> #include "smb2pdu.h"
>
> @@ -26,16 +27,8 @@
> #define SMB311_PROT 6
> #define BAD_PROT 0xFFFF
>
> -#define SMB1_VERSION_STRING "1.0"
> -#define SMB20_VERSION_STRING "2.0"
> -#define SMB21_VERSION_STRING "2.1"
> -#define SMB30_VERSION_STRING "3.0"
> -#define SMB302_VERSION_STRING "3.02"
> -#define SMB311_VERSION_STRING "3.1.1"
> -
> #define SMB_ECHO_INTERVAL (60 * HZ)
>
> -#define CIFS_DEFAULT_IOSIZE (64 * 1024)
> #define MAX_CIFS_SMALL_BUFFER_SIZE 448 /* big enough for most */
>
> #define MAX_STREAM_PROT_LEN 0x00FFFFFF
> @@ -464,9 +457,4 @@ static inline unsigned int get_rfc1002_len(void *buf)
> {
> return be32_to_cpu(*((__be32 *)buf)) & 0xffffff;
> }
> -
> -static inline void inc_rfc1001_len(void *buf, int count)
> -{
> - be32_add_cpu((__be32 *)buf, count);
> -}
> #endif /* __SMB_COMMON_H__ */
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v3 07/22] smb: move some duplicate definitions to common/smb2pdu.h
2025-10-14 7:19 ` [PATCH v3 07/22] smb: move some duplicate definitions to common/smb2pdu.h chenxiaosong.chenxiaosong
@ 2025-10-20 4:52 ` Namjae Jeon
2025-10-26 9:20 ` ChenXiaoSong
0 siblings, 1 reply; 37+ messages in thread
From: Namjae Jeon @ 2025-10-20 4:52 UTC (permalink / raw)
To: chenxiaosong.chenxiaosong
Cc: stfrench, metze, pali, smfrench, sfrench, senozhatsky, tom, pc,
ronniesahlberg, sprasad, bharathsm, christophe.jaillet,
zhangguodong, linux-cifs, linux-kernel, ChenXiaoSong
On Tue, Oct 14, 2025 at 4:21 PM <chenxiaosong.chenxiaosong@linux.dev> wrote:
>
> From: ZhangGuoDong <zhangguodong@kylinos.cn>
>
> In order to maintain the code more easily, move duplicate definitions to
> new common header file.
>
> Co-developed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
> Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
> Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn>
> ---
> fs/smb/client/smb2pdu.h | 24 +++---------------------
> fs/smb/common/smb2pdu.h | 24 ++++++++++++++++++++++++
> fs/smb/server/smb2pdu.c | 8 ++++----
> fs/smb/server/smb2pdu.h | 17 -----------------
> 4 files changed, 31 insertions(+), 42 deletions(-)
>
> diff --git a/fs/smb/client/smb2pdu.h b/fs/smb/client/smb2pdu.h
> index 101024f8f725..c013560bcfa1 100644
> --- a/fs/smb/client/smb2pdu.h
> +++ b/fs/smb/client/smb2pdu.h
> @@ -135,11 +135,9 @@ struct share_redirect_error_context_rsp {
>
>
> /* See MS-SMB2 2.2.13.2.11 */
> -/* Flags */
> -#define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002
> struct durable_context_v2 {
> __le32 Timeout;
> - __le32 Flags;
> + __le32 Flags; /* see SMB2_DHANDLE_FLAG_PERSISTENT */
> __u64 Reserved;
> __u8 CreateGuid[16];
> } __packed;
> @@ -157,13 +155,13 @@ struct durable_reconnect_context_v2 {
> __u64 VolatileFileId;
> } Fid;
> __u8 CreateGuid[16];
> - __le32 Flags; /* see above DHANDLE_FLAG_PERSISTENT */
> + __le32 Flags; /* see SMB2_DHANDLE_FLAG_PERSISTENT */
> } __packed;
>
> /* See MS-SMB2 2.2.14.2.12 */
> struct durable_reconnect_context_v2_rsp {
> __le32 Timeout;
> - __le32 Flags; /* see above DHANDLE_FLAG_PERSISTENT */
> + __le32 Flags; /* see SMB2_DHANDLE_FLAG_PERSISTENT */
> } __packed;
>
> struct create_durable_handle_reconnect_v2 {
> @@ -263,22 +261,6 @@ struct network_resiliency_req {
> } __packed;
> /* There is no buffer for the response ie no struct network_resiliency_rsp */
>
> -#define RSS_CAPABLE cpu_to_le32(0x00000001)
> -#define RDMA_CAPABLE cpu_to_le32(0x00000002)
> -
> -#define INTERNETWORK cpu_to_le16(0x0002)
> -#define INTERNETWORKV6 cpu_to_le16(0x0017)
> -
> -struct network_interface_info_ioctl_rsp {
> - __le32 Next; /* next interface. zero if this is last one */
> - __le32 IfIndex;
> - __le32 Capability; /* RSS or RDMA Capable */
> - __le32 Reserved;
> - __le64 LinkSpeed;
> - __le16 Family;
> - __u8 Buffer[126];
> -} __packed;
> -
> struct iface_info_ipv4 {
> __be16 Port;
> __be32 IPv4Address;
> diff --git a/fs/smb/common/smb2pdu.h b/fs/smb/common/smb2pdu.h
> index f79a5165a7cc..25e8ece283c4 100644
> --- a/fs/smb/common/smb2pdu.h
> +++ b/fs/smb/common/smb2pdu.h
> @@ -1290,6 +1290,10 @@ struct create_mxac_req {
> __le64 Timestamp;
> } __packed;
>
> +/* See MS-SMB2 2.2.13.2.11 and MS-SMB2 2.2.13.2.12 and MS-SMB2 2.2.14.2.12 */
> +/* Flags */
> +#define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002
I prefer moving it when the durable handle structures are moved to
/common later.
Thanks.
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v3 09/22] smb: move copychunk definitions to common/smb2pdu.h
2025-10-14 7:19 ` [PATCH v3 09/22] smb: move copychunk definitions " chenxiaosong.chenxiaosong
@ 2025-10-20 5:03 ` Namjae Jeon
2025-10-22 5:47 ` ChenXiaoSong
0 siblings, 1 reply; 37+ messages in thread
From: Namjae Jeon @ 2025-10-20 5:03 UTC (permalink / raw)
To: chenxiaosong.chenxiaosong
Cc: stfrench, metze, pali, smfrench, sfrench, senozhatsky, tom, pc,
ronniesahlberg, sprasad, bharathsm, christophe.jaillet,
zhangguodong, linux-cifs, linux-kernel, ChenXiaoSong
> diff --git a/fs/smb/client/smb2pdu.h b/fs/smb/client/smb2pdu.h
> index 0be63c00f848..9b5880e60a4e 100644
> --- a/fs/smb/client/smb2pdu.h
> +++ b/fs/smb/client/smb2pdu.h
> @@ -191,36 +191,12 @@ struct crt_sd_ctxt {
> struct smb3_sd sd;
> } __packed;
>
> -
> -#define COPY_CHUNK_RES_KEY_SIZE 24
> struct resume_key_req {
> char ResumeKey[COPY_CHUNK_RES_KEY_SIZE];
> __le32 ContextLength; /* MBZ */
> char Context[]; /* ignored, Windows sets to 4 bytes of zero */
> } __packed;
This can also be moved along with copychunk structures.
Thanks.
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v3 12/22] smb: move some duplicate definitions to common/cifspdu.h
2025-10-14 7:28 ` [PATCH v3 12/22] smb: move some duplicate definitions to common/cifspdu.h chenxiaosong.chenxiaosong
@ 2025-10-20 5:22 ` Namjae Jeon
2025-10-22 6:01 ` ChenXiaoSong
0 siblings, 1 reply; 37+ messages in thread
From: Namjae Jeon @ 2025-10-20 5:22 UTC (permalink / raw)
To: chenxiaosong.chenxiaosong
Cc: stfrench, metze, pali, smfrench, sfrench, senozhatsky, tom, pc,
ronniesahlberg, sprasad, bharathsm, christophe.jaillet,
linux-cifs, linux-kernel
On Tue, Oct 14, 2025 at 4:30 PM <chenxiaosong.chenxiaosong@linux.dev> wrote:
>
> From: ChenXiaoSong <chenxiaosong@kylinos.cn>
>
> In order to maintain the code more easily, move duplicate definitions to
> new common header file.
>
> Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
> ---
> fs/smb/client/cifspdu.h | 153 +---------------------------------
> fs/smb/common/cifspdu.h | 165 +++++++++++++++++++++++++++++++++++++
> fs/smb/server/smb_common.h | 80 +-----------------
> 3 files changed, 167 insertions(+), 231 deletions(-)
> create mode 100644 fs/smb/common/cifspdu.h
>
> diff --git a/fs/smb/client/cifspdu.h b/fs/smb/client/cifspdu.h
> index c86a329e5822..9f42b0469d1a 100644
> --- a/fs/smb/client/cifspdu.h
> +++ b/fs/smb/client/cifspdu.h
> @@ -12,43 +12,10 @@
> #include <net/sock.h>
> #include <linux/unaligned.h>
> #include "../common/smbfsctl.h"
> +#include "../common/cifspdu.h"
I prefer naming it smb1pdu.h.
>
> #define CIFS_PROT 0
> #define POSIX_PROT (CIFS_PROT+1)
> -#define BAD_PROT 0xFFFF
Moving just this one doesn't look good.
Thanks.
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v3 13/22] smb: move file access permission bits definitions to common/cifspdu.h
2025-10-14 7:28 ` [PATCH v3 13/22] smb: move file access permission bits " chenxiaosong.chenxiaosong
@ 2025-10-20 5:27 ` Namjae Jeon
2025-10-22 5:55 ` ChenXiaoSong
0 siblings, 1 reply; 37+ messages in thread
From: Namjae Jeon @ 2025-10-20 5:27 UTC (permalink / raw)
To: chenxiaosong.chenxiaosong
Cc: stfrench, metze, pali, smfrench, sfrench, senozhatsky, tom, pc,
ronniesahlberg, sprasad, bharathsm, christophe.jaillet,
linux-cifs, linux-kernel
> +
> +#define CLIENT_SET_FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA | FILE_WRITE_EA \
> + | FILE_READ_ATTRIBUTES \
> + | FILE_WRITE_ATTRIBUTES \
> + | DELETE | READ_CONTROL | WRITE_DAC \
> + | WRITE_OWNER | SYNCHRONIZE)
> +#define SERVER_SET_FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA \
> + | FILE_READ_ATTRIBUTES \
> + | DELETE | READ_CONTROL | WRITE_DAC \
> + | WRITE_OWNER | SYNCHRONIZE)
> +#define CLIENT_SET_FILE_WRITE_RIGHTS (FILE_WRITE_DATA | FILE_APPEND_DATA \
> + | FILE_READ_EA | FILE_WRITE_EA \
> + | FILE_READ_ATTRIBUTES \
> + | FILE_WRITE_ATTRIBUTES \
> + | DELETE | READ_CONTROL | WRITE_DAC \
> + | WRITE_OWNER | SYNCHRONIZE)
> +#define SERVER_SET_FILE_WRITE_RIGHTS (FILE_WRITE_DATA | FILE_APPEND_DATA \
> + | FILE_WRITE_EA \
> + | FILE_DELETE_CHILD \
> + | FILE_WRITE_ATTRIBUTES \
> + | DELETE | READ_CONTROL | WRITE_DAC \
> + | WRITE_OWNER | SYNCHRONIZE)
What's the reason for moving it if the smb client and server don't share it?
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v3 15/22] smb: move FILE_SYSTEM_ATTRIBUTE_INFO to common/cifspdu.h
2025-10-14 7:28 ` [PATCH v3 15/22] smb: move FILE_SYSTEM_ATTRIBUTE_INFO " chenxiaosong.chenxiaosong
@ 2025-10-20 5:35 ` Namjae Jeon
2025-10-21 6:35 ` ChenXiaoSong
2025-10-21 6:36 ` ChenXiaoSong
0 siblings, 2 replies; 37+ messages in thread
From: Namjae Jeon @ 2025-10-20 5:35 UTC (permalink / raw)
To: chenxiaosong.chenxiaosong
Cc: stfrench, metze, pali, smfrench, sfrench, senozhatsky, tom, pc,
ronniesahlberg, sprasad, bharathsm, christophe.jaillet,
linux-cifs, linux-kernel
On Tue, Oct 14, 2025 at 4:30 PM <chenxiaosong.chenxiaosong@linux.dev> wrote:
>
> From: ChenXiaoSong <chenxiaosong@kylinos.cn>
>
> Rename "struct filesystem_attribute_info" to "FILE_SYSTEM_ATTRIBUTE_INFO",
> then move duplicate definitions to common header file.
>
> Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Please check the warnings from checkpatch.pl.
WARNING: do not add new typedefs
#109: FILE: fs/smb/common/cifspdu.h:352:
+typedef struct {
WARNING: Prefer __packed over __attribute__((packed))
#114: FILE: fs/smb/common/cifspdu.h:357:
+} __attribute__((packed)) FILE_SYSTEM_ATTRIBUTE_INFO;
> ---
> fs/smb/client/cifspdu.h | 7 -------
> fs/smb/common/cifspdu.h | 8 ++++++++
> fs/smb/server/smb2pdu.c | 6 +++---
> fs/smb/server/smb_common.h | 7 -------
> 4 files changed, 11 insertions(+), 17 deletions(-)
>
> diff --git a/fs/smb/client/cifspdu.h b/fs/smb/client/cifspdu.h
> index 07eb821654e1..a6f7e168961e 100644
> --- a/fs/smb/client/cifspdu.h
> +++ b/fs/smb/client/cifspdu.h
> @@ -1937,13 +1937,6 @@ typedef struct {
> /* 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/common/cifspdu.h b/fs/smb/common/cifspdu.h
> index 1109c20f7bf8..560900617be7 100644
> --- a/fs/smb/common/cifspdu.h
> +++ b/fs/smb/common/cifspdu.h
> @@ -348,4 +348,12 @@ typedef struct server_negotiate_rsp {
> #define FILE_CASE_PRESERVED_NAMES 0x00000002
> #define FILE_CASE_SENSITIVE_SEARCH 0x00000001
>
> +/* See FS-FSCC 2.5.1 */
> +typedef struct {
> + __le32 Attributes;
> + __le32 MaxPathNameComponentLength;
> + __le32 FileSystemNameLen;
> + __le16 FileSystemName[]; /* do not have to save this - get subset? */
> +} __attribute__((packed)) FILE_SYSTEM_ATTRIBUTE_INFO;
> +
> #endif /* _COMMON_CIFSPDU_H */
> diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
> index a46d4ddade9e..a05b04799c0d 100644
> --- a/fs/smb/server/smb2pdu.c
> +++ b/fs/smb/server/smb2pdu.c
> @@ -5485,10 +5485,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 |
> @@ -5507,7 +5507,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 a5dd656c36f1..016ec93e6df4 100644
> --- a/fs/smb/server/smb_common.h
> +++ b/fs/smb/server/smb_common.h
> @@ -56,13 +56,6 @@
> FILE_EXECUTE | FILE_DELETE_CHILD | \
> FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES)
>
> -struct filesystem_attribute_info {
> - __le32 Attributes;
> - __le32 MaxPathNameComponentLength;
> - __le32 FileSystemNameLen;
> - __le16 FileSystemName[]; /* do not have to save this - get subset? */
> -} __packed;
> -
> struct filesystem_device_info {
> __le32 DeviceType;
> __le32 DeviceCharacteristics;
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v3 15/22] smb: move FILE_SYSTEM_ATTRIBUTE_INFO to common/cifspdu.h
2025-10-20 5:35 ` Namjae Jeon
@ 2025-10-21 6:35 ` ChenXiaoSong
2025-10-21 6:36 ` ChenXiaoSong
1 sibling, 0 replies; 37+ messages in thread
From: ChenXiaoSong @ 2025-10-21 6:35 UTC (permalink / raw)
To: Namjae Jeon
Cc: stfrench, metze, pali, smfrench, sfrench, senozhatsky, tom, pc,
ronniesahlberg, sprasad, bharathsm, christophe.jaillet,
linux-cifs, linux-kernel
Thanks for your suggestions. I’ll send v3 soon.
--
Thanks,
ChenXiaoSong.
On 10/20/25 1:35 PM, Namjae Jeon wrote:
> On Tue, Oct 14, 2025 at 4:30 PM <chenxiaosong.chenxiaosong@linux.dev> wrote:
>>
>> From: ChenXiaoSong <chenxiaosong@kylinos.cn>
>>
>> Rename "struct filesystem_attribute_info" to "FILE_SYSTEM_ATTRIBUTE_INFO",
>> then move duplicate definitions to common header file.
>>
>> Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
> Please check the warnings from checkpatch.pl.
>
> WARNING: do not add new typedefs
> #109: FILE: fs/smb/common/cifspdu.h:352:
> +typedef struct {
>
> WARNING: Prefer __packed over __attribute__((packed))
> #114: FILE: fs/smb/common/cifspdu.h:357:
> +} __attribute__((packed)) FILE_SYSTEM_ATTRIBUTE_INFO;
>
>> ---
>> fs/smb/client/cifspdu.h | 7 -------
>> fs/smb/common/cifspdu.h | 8 ++++++++
>> fs/smb/server/smb2pdu.c | 6 +++---
>> fs/smb/server/smb_common.h | 7 -------
>> 4 files changed, 11 insertions(+), 17 deletions(-)
>>
>> diff --git a/fs/smb/client/cifspdu.h b/fs/smb/client/cifspdu.h
>> index 07eb821654e1..a6f7e168961e 100644
>> --- a/fs/smb/client/cifspdu.h
>> +++ b/fs/smb/client/cifspdu.h
>> @@ -1937,13 +1937,6 @@ typedef struct {
>> /* 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/common/cifspdu.h b/fs/smb/common/cifspdu.h
>> index 1109c20f7bf8..560900617be7 100644
>> --- a/fs/smb/common/cifspdu.h
>> +++ b/fs/smb/common/cifspdu.h
>> @@ -348,4 +348,12 @@ typedef struct server_negotiate_rsp {
>> #define FILE_CASE_PRESERVED_NAMES 0x00000002
>> #define FILE_CASE_SENSITIVE_SEARCH 0x00000001
>>
>> +/* See FS-FSCC 2.5.1 */
>> +typedef struct {
>> + __le32 Attributes;
>> + __le32 MaxPathNameComponentLength;
>> + __le32 FileSystemNameLen;
>> + __le16 FileSystemName[]; /* do not have to save this - get subset? */
>> +} __attribute__((packed)) FILE_SYSTEM_ATTRIBUTE_INFO;
>> +
>> #endif /* _COMMON_CIFSPDU_H */
>> diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
>> index a46d4ddade9e..a05b04799c0d 100644
>> --- a/fs/smb/server/smb2pdu.c
>> +++ b/fs/smb/server/smb2pdu.c
>> @@ -5485,10 +5485,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 |
>> @@ -5507,7 +5507,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 a5dd656c36f1..016ec93e6df4 100644
>> --- a/fs/smb/server/smb_common.h
>> +++ b/fs/smb/server/smb_common.h
>> @@ -56,13 +56,6 @@
>> FILE_EXECUTE | FILE_DELETE_CHILD | \
>> FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES)
>>
>> -struct filesystem_attribute_info {
>> - __le32 Attributes;
>> - __le32 MaxPathNameComponentLength;
>> - __le32 FileSystemNameLen;
>> - __le16 FileSystemName[]; /* do not have to save this - get subset? */
>> -} __packed;
>> -
>> struct filesystem_device_info {
>> __le32 DeviceType;
>> __le32 DeviceCharacteristics;
>> --
>> 2.43.0
>>
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v3 15/22] smb: move FILE_SYSTEM_ATTRIBUTE_INFO to common/cifspdu.h
2025-10-20 5:35 ` Namjae Jeon
2025-10-21 6:35 ` ChenXiaoSong
@ 2025-10-21 6:36 ` ChenXiaoSong
1 sibling, 0 replies; 37+ messages in thread
From: ChenXiaoSong @ 2025-10-21 6:36 UTC (permalink / raw)
To: Namjae Jeon
Cc: stfrench, metze, pali, smfrench, sfrench, senozhatsky, tom, pc,
ronniesahlberg, sprasad, bharathsm, christophe.jaillet,
linux-cifs, linux-kernel
Thanks for your suggestions. I’ll send v4 soon.
--
Thanks,
ChenXiaoSong.
On 10/20/25 1:35 PM, Namjae Jeon wrote:
> On Tue, Oct 14, 2025 at 4:30 PM <chenxiaosong.chenxiaosong@linux.dev> wrote:
>>
>> From: ChenXiaoSong <chenxiaosong@kylinos.cn>
>>
>> Rename "struct filesystem_attribute_info" to "FILE_SYSTEM_ATTRIBUTE_INFO",
>> then move duplicate definitions to common header file.
>>
>> Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
> Please check the warnings from checkpatch.pl.
>
> WARNING: do not add new typedefs
> #109: FILE: fs/smb/common/cifspdu.h:352:
> +typedef struct {
>
> WARNING: Prefer __packed over __attribute__((packed))
> #114: FILE: fs/smb/common/cifspdu.h:357:
> +} __attribute__((packed)) FILE_SYSTEM_ATTRIBUTE_INFO;
>
>> ---
>> fs/smb/client/cifspdu.h | 7 -------
>> fs/smb/common/cifspdu.h | 8 ++++++++
>> fs/smb/server/smb2pdu.c | 6 +++---
>> fs/smb/server/smb_common.h | 7 -------
>> 4 files changed, 11 insertions(+), 17 deletions(-)
>>
>> diff --git a/fs/smb/client/cifspdu.h b/fs/smb/client/cifspdu.h
>> index 07eb821654e1..a6f7e168961e 100644
>> --- a/fs/smb/client/cifspdu.h
>> +++ b/fs/smb/client/cifspdu.h
>> @@ -1937,13 +1937,6 @@ typedef struct {
>> /* 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/common/cifspdu.h b/fs/smb/common/cifspdu.h
>> index 1109c20f7bf8..560900617be7 100644
>> --- a/fs/smb/common/cifspdu.h
>> +++ b/fs/smb/common/cifspdu.h
>> @@ -348,4 +348,12 @@ typedef struct server_negotiate_rsp {
>> #define FILE_CASE_PRESERVED_NAMES 0x00000002
>> #define FILE_CASE_SENSITIVE_SEARCH 0x00000001
>>
>> +/* See FS-FSCC 2.5.1 */
>> +typedef struct {
>> + __le32 Attributes;
>> + __le32 MaxPathNameComponentLength;
>> + __le32 FileSystemNameLen;
>> + __le16 FileSystemName[]; /* do not have to save this - get subset? */
>> +} __attribute__((packed)) FILE_SYSTEM_ATTRIBUTE_INFO;
>> +
>> #endif /* _COMMON_CIFSPDU_H */
>> diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
>> index a46d4ddade9e..a05b04799c0d 100644
>> --- a/fs/smb/server/smb2pdu.c
>> +++ b/fs/smb/server/smb2pdu.c
>> @@ -5485,10 +5485,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 |
>> @@ -5507,7 +5507,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 a5dd656c36f1..016ec93e6df4 100644
>> --- a/fs/smb/server/smb_common.h
>> +++ b/fs/smb/server/smb_common.h
>> @@ -56,13 +56,6 @@
>> FILE_EXECUTE | FILE_DELETE_CHILD | \
>> FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES)
>>
>> -struct filesystem_attribute_info {
>> - __le32 Attributes;
>> - __le32 MaxPathNameComponentLength;
>> - __le32 FileSystemNameLen;
>> - __le16 FileSystemName[]; /* do not have to save this - get subset? */
>> -} __packed;
>> -
>> struct filesystem_device_info {
>> __le32 DeviceType;
>> __le32 DeviceCharacteristics;
>> --
>> 2.43.0
>>
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v3 09/22] smb: move copychunk definitions to common/smb2pdu.h
2025-10-20 5:03 ` Namjae Jeon
@ 2025-10-22 5:47 ` ChenXiaoSong
0 siblings, 0 replies; 37+ messages in thread
From: ChenXiaoSong @ 2025-10-22 5:47 UTC (permalink / raw)
To: Namjae Jeon
Cc: stfrench, metze, pali, smfrench, sfrench, senozhatsky, tom, pc,
ronniesahlberg, sprasad, bharathsm, christophe.jaillet,
zhangguodong, linux-cifs, linux-kernel, ChenXiaoSong
Hi Namjae,
In this patch, COPY_CHUNK_RES_KEY_SIZE has already been moved to
common/smb2pdu.h
--
Thanks,
ChenXiaoSong.
On 10/20/25 1:03 PM, Namjae Jeon wrote:
>> diff --git a/fs/smb/client/smb2pdu.h b/fs/smb/client/smb2pdu.h
>> index 0be63c00f848..9b5880e60a4e 100644
>> --- a/fs/smb/client/smb2pdu.h
>> +++ b/fs/smb/client/smb2pdu.h
>> @@ -191,36 +191,12 @@ struct crt_sd_ctxt {
>> struct smb3_sd sd;
>> } __packed;
>>
>> -
>> -#define COPY_CHUNK_RES_KEY_SIZE 24
>> struct resume_key_req {
>> char ResumeKey[COPY_CHUNK_RES_KEY_SIZE];
>> __le32 ContextLength; /* MBZ */
>> char Context[]; /* ignored, Windows sets to 4 bytes of zero */
>> } __packed;
> This can also be moved along with copychunk structures.
> Thanks.
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v3 13/22] smb: move file access permission bits definitions to common/cifspdu.h
2025-10-20 5:27 ` Namjae Jeon
@ 2025-10-22 5:55 ` ChenXiaoSong
0 siblings, 0 replies; 37+ messages in thread
From: ChenXiaoSong @ 2025-10-22 5:55 UTC (permalink / raw)
To: Namjae Jeon
Cc: stfrench, metze, pali, smfrench, sfrench, senozhatsky, tom, pc,
ronniesahlberg, sprasad, bharathsm, christophe.jaillet,
linux-cifs, linux-kernel
Should we move all file access permission bit definitions to
common/cifspdu.h?
Perhaps in the future we can change them to be the same.
On 10/20/25 1:27 PM, Namjae Jeon wrote:
>> +
>> +#define CLIENT_SET_FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA | FILE_WRITE_EA \
>> + | FILE_READ_ATTRIBUTES \
>> + | FILE_WRITE_ATTRIBUTES \
>> + | DELETE | READ_CONTROL | WRITE_DAC \
>> + | WRITE_OWNER | SYNCHRONIZE)
>> +#define SERVER_SET_FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA \
>> + | FILE_READ_ATTRIBUTES \
>> + | DELETE | READ_CONTROL | WRITE_DAC \
>> + | WRITE_OWNER | SYNCHRONIZE)
>> +#define CLIENT_SET_FILE_WRITE_RIGHTS (FILE_WRITE_DATA | FILE_APPEND_DATA \
>> + | FILE_READ_EA | FILE_WRITE_EA \
>> + | FILE_READ_ATTRIBUTES \
>> + | FILE_WRITE_ATTRIBUTES \
>> + | DELETE | READ_CONTROL | WRITE_DAC \
>> + | WRITE_OWNER | SYNCHRONIZE)
>> +#define SERVER_SET_FILE_WRITE_RIGHTS (FILE_WRITE_DATA | FILE_APPEND_DATA \
>> + | FILE_WRITE_EA \
>> + | FILE_DELETE_CHILD \
>> + | FILE_WRITE_ATTRIBUTES \
>> + | DELETE | READ_CONTROL | WRITE_DAC \
>> + | WRITE_OWNER | SYNCHRONIZE)
> What's the reason for moving it if the smb client and server don't share it?
--
Thanks,
ChenXiaoSong.
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v3 12/22] smb: move some duplicate definitions to common/cifspdu.h
2025-10-20 5:22 ` Namjae Jeon
@ 2025-10-22 6:01 ` ChenXiaoSong
0 siblings, 0 replies; 37+ messages in thread
From: ChenXiaoSong @ 2025-10-22 6:01 UTC (permalink / raw)
To: Namjae Jeon
Cc: stfrench, metze, pali, smfrench, sfrench, senozhatsky, tom, pc,
ronniesahlberg, sprasad, bharathsm, christophe.jaillet,
linux-cifs, linux-kernel
Hi Namjae and Steve,
Would it be more appropriate to move these to common/cifsglob.h?
On 10/20/25 1:22 PM, Namjae Jeon wrote:
>> #define CIFS_PROT 0
>> #define POSIX_PROT (CIFS_PROT+1)
>> -#define BAD_PROT 0xFFFF
> Moving just this one doesn't look good.
> Thanks.
--
Thanks,
ChenXiaoSong.
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v3 07/22] smb: move some duplicate definitions to common/smb2pdu.h
2025-10-20 4:52 ` Namjae Jeon
@ 2025-10-26 9:20 ` ChenXiaoSong
2025-10-26 23:17 ` Namjae Jeon
0 siblings, 1 reply; 37+ messages in thread
From: ChenXiaoSong @ 2025-10-26 9:20 UTC (permalink / raw)
To: Namjae Jeon
Cc: stfrench, metze, pali, smfrench, sfrench, senozhatsky, tom, pc,
ronniesahlberg, sprasad, bharathsm, christophe.jaillet,
zhangguodong, linux-cifs, linux-kernel, ChenXiaoSong
Hi Namjae,
I'm confused by what this sentence means: "I prefer moving it when the
durable handle structures are moved to /common later.".
What does "it" refer to? Does "it" refer to the whole patch, or only to
"SMB2_DHANDLE_FLAG_PERSISTENT"?
On 10/20/25 12:52 PM, Namjae Jeon wrote:
> On Tue, Oct 14, 2025 at 4:21 PM <chenxiaosong.chenxiaosong@linux.dev> wrote:
>>
>> From: ZhangGuoDong <zhangguodong@kylinos.cn>
>>
>> In order to maintain the code more easily, move duplicate definitions to
>> new common header file.
>>
>> Co-developed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
>> Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
>> Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn>
>> ---
>> fs/smb/client/smb2pdu.h | 24 +++---------------------
>> fs/smb/common/smb2pdu.h | 24 ++++++++++++++++++++++++
>> fs/smb/server/smb2pdu.c | 8 ++++----
>> fs/smb/server/smb2pdu.h | 17 -----------------
>> 4 files changed, 31 insertions(+), 42 deletions(-)
>>
>> diff --git a/fs/smb/client/smb2pdu.h b/fs/smb/client/smb2pdu.h
>> index 101024f8f725..c013560bcfa1 100644
>> --- a/fs/smb/client/smb2pdu.h
>> +++ b/fs/smb/client/smb2pdu.h
>> @@ -135,11 +135,9 @@ struct share_redirect_error_context_rsp {
>>
>>
>> /* See MS-SMB2 2.2.13.2.11 */
>> -/* Flags */
>> -#define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002
>> struct durable_context_v2 {
>> __le32 Timeout;
>> - __le32 Flags;
>> + __le32 Flags; /* see SMB2_DHANDLE_FLAG_PERSISTENT */
>> __u64 Reserved;
>> __u8 CreateGuid[16];
>> } __packed;
>> @@ -157,13 +155,13 @@ struct durable_reconnect_context_v2 {
>> __u64 VolatileFileId;
>> } Fid;
>> __u8 CreateGuid[16];
>> - __le32 Flags; /* see above DHANDLE_FLAG_PERSISTENT */
>> + __le32 Flags; /* see SMB2_DHANDLE_FLAG_PERSISTENT */
>> } __packed;
>>
>> /* See MS-SMB2 2.2.14.2.12 */
>> struct durable_reconnect_context_v2_rsp {
>> __le32 Timeout;
>> - __le32 Flags; /* see above DHANDLE_FLAG_PERSISTENT */
>> + __le32 Flags; /* see SMB2_DHANDLE_FLAG_PERSISTENT */
>> } __packed;
>>
>> struct create_durable_handle_reconnect_v2 {
>> @@ -263,22 +261,6 @@ struct network_resiliency_req {
>> } __packed;
>> /* There is no buffer for the response ie no struct network_resiliency_rsp */
>>
>> -#define RSS_CAPABLE cpu_to_le32(0x00000001)
>> -#define RDMA_CAPABLE cpu_to_le32(0x00000002)
>> -
>> -#define INTERNETWORK cpu_to_le16(0x0002)
>> -#define INTERNETWORKV6 cpu_to_le16(0x0017)
>> -
>> -struct network_interface_info_ioctl_rsp {
>> - __le32 Next; /* next interface. zero if this is last one */
>> - __le32 IfIndex;
>> - __le32 Capability; /* RSS or RDMA Capable */
>> - __le32 Reserved;
>> - __le64 LinkSpeed;
>> - __le16 Family;
>> - __u8 Buffer[126];
>> -} __packed;
>> -
>> struct iface_info_ipv4 {
>> __be16 Port;
>> __be32 IPv4Address;
>> diff --git a/fs/smb/common/smb2pdu.h b/fs/smb/common/smb2pdu.h
>> index f79a5165a7cc..25e8ece283c4 100644
>> --- a/fs/smb/common/smb2pdu.h
>> +++ b/fs/smb/common/smb2pdu.h
>> @@ -1290,6 +1290,10 @@ struct create_mxac_req {
>> __le64 Timestamp;
>> } __packed;
>>
>> +/* See MS-SMB2 2.2.13.2.11 and MS-SMB2 2.2.13.2.12 and MS-SMB2 2.2.14.2.12 */
>> +/* Flags */
>> +#define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002
> I prefer moving it when the durable handle structures are moved to
> /common later.
> Thanks.
--
Thanks,
ChenXiaoSong.
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v3 07/22] smb: move some duplicate definitions to common/smb2pdu.h
2025-10-26 9:20 ` ChenXiaoSong
@ 2025-10-26 23:17 ` Namjae Jeon
0 siblings, 0 replies; 37+ messages in thread
From: Namjae Jeon @ 2025-10-26 23:17 UTC (permalink / raw)
To: ChenXiaoSong
Cc: stfrench, metze, pali, smfrench, sfrench, senozhatsky, tom, pc,
ronniesahlberg, sprasad, bharathsm, christophe.jaillet,
zhangguodong, linux-cifs, linux-kernel, ChenXiaoSong
On Sun, Oct 26, 2025 at 6:21 PM ChenXiaoSong
<chenxiaosong.chenxiaosong@linux.dev> wrote:
>
> Hi Namjae,
Hi Chen,
>
> I'm confused by what this sentence means: "I prefer moving it when the
> durable handle structures are moved to /common later.".
>
> What does "it" refer to? Does "it" refer to the whole patch, or only to
> "SMB2_DHANDLE_FLAG_PERSISTENT"?
Only SMB2_DHANDLE_FLAG_PERSISTENT.
Thanks!
>
> On 10/20/25 12:52 PM, Namjae Jeon wrote:
> > On Tue, Oct 14, 2025 at 4:21 PM <chenxiaosong.chenxiaosong@linux.dev> wrote:
> >>
> >> From: ZhangGuoDong <zhangguodong@kylinos.cn>
> >>
> >> In order to maintain the code more easily, move duplicate definitions to
> >> new common header file.
> >>
> >> Co-developed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
> >> Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
> >> Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn>
> >> ---
> >> fs/smb/client/smb2pdu.h | 24 +++---------------------
> >> fs/smb/common/smb2pdu.h | 24 ++++++++++++++++++++++++
> >> fs/smb/server/smb2pdu.c | 8 ++++----
> >> fs/smb/server/smb2pdu.h | 17 -----------------
> >> 4 files changed, 31 insertions(+), 42 deletions(-)
> >>
> >> diff --git a/fs/smb/client/smb2pdu.h b/fs/smb/client/smb2pdu.h
> >> index 101024f8f725..c013560bcfa1 100644
> >> --- a/fs/smb/client/smb2pdu.h
> >> +++ b/fs/smb/client/smb2pdu.h
> >> @@ -135,11 +135,9 @@ struct share_redirect_error_context_rsp {
> >>
> >>
> >> /* See MS-SMB2 2.2.13.2.11 */
> >> -/* Flags */
> >> -#define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002
> >> struct durable_context_v2 {
> >> __le32 Timeout;
> >> - __le32 Flags;
> >> + __le32 Flags; /* see SMB2_DHANDLE_FLAG_PERSISTENT */
> >> __u64 Reserved;
> >> __u8 CreateGuid[16];
> >> } __packed;
> >> @@ -157,13 +155,13 @@ struct durable_reconnect_context_v2 {
> >> __u64 VolatileFileId;
> >> } Fid;
> >> __u8 CreateGuid[16];
> >> - __le32 Flags; /* see above DHANDLE_FLAG_PERSISTENT */
> >> + __le32 Flags; /* see SMB2_DHANDLE_FLAG_PERSISTENT */
> >> } __packed;
> >>
> >> /* See MS-SMB2 2.2.14.2.12 */
> >> struct durable_reconnect_context_v2_rsp {
> >> __le32 Timeout;
> >> - __le32 Flags; /* see above DHANDLE_FLAG_PERSISTENT */
> >> + __le32 Flags; /* see SMB2_DHANDLE_FLAG_PERSISTENT */
> >> } __packed;
> >>
> >> struct create_durable_handle_reconnect_v2 {
> >> @@ -263,22 +261,6 @@ struct network_resiliency_req {
> >> } __packed;
> >> /* There is no buffer for the response ie no struct network_resiliency_rsp */
> >>
> >> -#define RSS_CAPABLE cpu_to_le32(0x00000001)
> >> -#define RDMA_CAPABLE cpu_to_le32(0x00000002)
> >> -
> >> -#define INTERNETWORK cpu_to_le16(0x0002)
> >> -#define INTERNETWORKV6 cpu_to_le16(0x0017)
> >> -
> >> -struct network_interface_info_ioctl_rsp {
> >> - __le32 Next; /* next interface. zero if this is last one */
> >> - __le32 IfIndex;
> >> - __le32 Capability; /* RSS or RDMA Capable */
> >> - __le32 Reserved;
> >> - __le64 LinkSpeed;
> >> - __le16 Family;
> >> - __u8 Buffer[126];
> >> -} __packed;
> >> -
> >> struct iface_info_ipv4 {
> >> __be16 Port;
> >> __be32 IPv4Address;
> >> diff --git a/fs/smb/common/smb2pdu.h b/fs/smb/common/smb2pdu.h
> >> index f79a5165a7cc..25e8ece283c4 100644
> >> --- a/fs/smb/common/smb2pdu.h
> >> +++ b/fs/smb/common/smb2pdu.h
> >> @@ -1290,6 +1290,10 @@ struct create_mxac_req {
> >> __le64 Timestamp;
> >> } __packed;
> >>
> >> +/* See MS-SMB2 2.2.13.2.11 and MS-SMB2 2.2.13.2.12 and MS-SMB2 2.2.14.2.12 */
> >> +/* Flags */
> >> +#define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002
> > I prefer moving it when the durable handle structures are moved to
> > /common later.
> > Thanks.
>
> --
> Thanks,
> ChenXiaoSong.
>
>
^ permalink raw reply [flat|nested] 37+ messages in thread
end of thread, other threads:[~2025-10-26 23:17 UTC | newest]
Thread overview: 37+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-14 7:18 [PATCH v3 00/22] smb: fix some bugs, move duplicate definitions to common header file chenxiaosong.chenxiaosong
2025-10-14 7:18 ` [PATCH v3 01/22] smb/server: fix possible memory leak in smb2_read() chenxiaosong.chenxiaosong
2025-10-14 7:18 ` [PATCH v3 02/22] smb/server: fix possible refcount leak in smb2_sess_setup() chenxiaosong.chenxiaosong
2025-10-14 7:18 ` [PATCH v3 03/22] smb: move some duplicate definitions to common/cifsglob.h chenxiaosong.chenxiaosong
2025-10-20 4:39 ` Namjae Jeon
2025-10-14 7:18 ` [PATCH v3 04/22] smb: move smb_version_values " chenxiaosong.chenxiaosong
2025-10-14 7:19 ` [PATCH v3 05/22] smb: move get_rfc1002_len() " chenxiaosong.chenxiaosong
2025-10-14 7:19 ` [PATCH v3 06/22] smb: move SMB1_PROTO_NUMBER " chenxiaosong.chenxiaosong
2025-10-14 7:19 ` [PATCH v3 07/22] smb: move some duplicate definitions to common/smb2pdu.h chenxiaosong.chenxiaosong
2025-10-20 4:52 ` Namjae Jeon
2025-10-26 9:20 ` ChenXiaoSong
2025-10-26 23:17 ` Namjae Jeon
2025-10-14 7:19 ` [PATCH v3 08/22] smb: move smb_sockaddr_in and smb_sockaddr_in6 " chenxiaosong.chenxiaosong
2025-10-14 7:19 ` [PATCH v3 09/22] smb: move copychunk definitions " chenxiaosong.chenxiaosong
2025-10-20 5:03 ` Namjae Jeon
2025-10-22 5:47 ` ChenXiaoSong
2025-10-14 7:19 ` [PATCH v3 10/22] smb: move resume_key_ioctl_rsp " chenxiaosong.chenxiaosong
2025-10-14 7:28 ` [PATCH v3 11/22] smb: move smb2_file_network_open_info " chenxiaosong.chenxiaosong
2025-10-14 7:28 ` [PATCH v3 12/22] smb: move some duplicate definitions to common/cifspdu.h chenxiaosong.chenxiaosong
2025-10-20 5:22 ` Namjae Jeon
2025-10-22 6:01 ` ChenXiaoSong
2025-10-14 7:28 ` [PATCH v3 13/22] smb: move file access permission bits " chenxiaosong.chenxiaosong
2025-10-20 5:27 ` Namjae Jeon
2025-10-22 5:55 ` ChenXiaoSong
2025-10-14 7:28 ` [PATCH v3 14/22] smb: move SMB frame " chenxiaosong.chenxiaosong
2025-10-14 7:28 ` [PATCH v3 15/22] smb: move FILE_SYSTEM_ATTRIBUTE_INFO " chenxiaosong.chenxiaosong
2025-10-20 5:35 ` Namjae Jeon
2025-10-21 6:35 ` ChenXiaoSong
2025-10-21 6:36 ` ChenXiaoSong
2025-10-14 7:28 ` [PATCH v3 16/22] smb: move FILE_SYSTEM_DEVICE_INFO " chenxiaosong.chenxiaosong
2025-10-14 7:28 ` [PATCH v3 17/22] smb: move FILE_SYSTEM_INFO " chenxiaosong.chenxiaosong
2025-10-14 7:28 ` [PATCH v3 18/22] smb: move FILE_DIRECTORY_INFO " chenxiaosong.chenxiaosong
2025-10-14 7:28 ` [PATCH v3 19/22] smb: move FILE_FULL_DIRECTORY_INFO " chenxiaosong.chenxiaosong
2025-10-14 7:28 ` [PATCH v3 20/22] smb: move FILE_BOTH_DIRECTORY_INFO " chenxiaosong.chenxiaosong
2025-10-14 7:28 ` [PATCH v3 21/22] smb: move SEARCH_ID_FULL_DIR_INFO " chenxiaosong.chenxiaosong
2025-10-14 7:28 ` [PATCH v3 22/22] smb: move FILE_SYSTEM_POSIX_INFO " chenxiaosong.chenxiaosong
2025-10-15 5:43 ` [PATCH v3 00/22] smb: fix some bugs, move duplicate definitions to common header file Namjae Jeon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox