* [PATCH 0/6] smb/server: fix return values of smb2_0_server_cmds proc
@ 2025-10-17 8:46 chenxiaosong.chenxiaosong
2025-10-17 8:46 ` [PATCH 1/6] smb/server: fix return value of smb2_read() chenxiaosong.chenxiaosong
` (6 more replies)
0 siblings, 7 replies; 9+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-10-17 8:46 UTC (permalink / raw)
To: sfrench, smfrench, linkinjeon, linkinjeon
Cc: linux-cifs, linux-kernel, ChenXiaoSong
From: ChenXiaoSong <chenxiaosong@kylinos.cn>
These functions should return error code when an error occurs,
then __process_request() will print the error messages.
ChenXiaoSong (6):
smb/server: fix return value of smb2_read()
smb/server: fix return value of smb2_notify()
smb/server: fix return value of smb2_query_dir()
smb/server: fix return value of smb2_ioctl()
smb/server: fix return value of smb2_oplock_break()
smb/server: update some misguided comment of smb2_0_server_cmds proc
fs/smb/server/smb2pdu.c | 30 +++++++++++++++++-------------
1 file changed, 17 insertions(+), 13 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/6] smb/server: fix return value of smb2_read()
2025-10-17 8:46 [PATCH 0/6] smb/server: fix return values of smb2_0_server_cmds proc chenxiaosong.chenxiaosong
@ 2025-10-17 8:46 ` chenxiaosong.chenxiaosong
2025-10-17 8:46 ` [PATCH 2/6] smb/server: fix return value of smb2_notify() chenxiaosong.chenxiaosong
` (5 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-10-17 8:46 UTC (permalink / raw)
To: sfrench, smfrench, linkinjeon, linkinjeon
Cc: linux-cifs, linux-kernel, ChenXiaoSong
From: ChenXiaoSong <chenxiaosong@kylinos.cn>
STATUS_END_OF_FILE maps to the linux error -ENODATA. Perhaps in the future
we can move client/smb2maperror.c into common/ and then call
map_smb2_to_linux_error() to get the linux error.
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
fs/smb/server/smb2pdu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index f901ae18e68a..83d8a325b9ea 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -6842,7 +6842,7 @@ int smb2_read(struct ksmbd_work *work)
rsp->hdr.Status = STATUS_END_OF_FILE;
smb2_set_err_rsp(work);
ksmbd_fd_put(work, fp);
- return 0;
+ return -ENODATA,;
}
ksmbd_debug(SMB, "nbytes %zu, offset %lld mincount %zu\n",
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/6] smb/server: fix return value of smb2_notify()
2025-10-17 8:46 [PATCH 0/6] smb/server: fix return values of smb2_0_server_cmds proc chenxiaosong.chenxiaosong
2025-10-17 8:46 ` [PATCH 1/6] smb/server: fix return value of smb2_read() chenxiaosong.chenxiaosong
@ 2025-10-17 8:46 ` chenxiaosong.chenxiaosong
2025-10-17 8:46 ` [PATCH 3/6] smb/server: fix return value of smb2_query_dir() chenxiaosong.chenxiaosong
` (4 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-10-17 8:46 UTC (permalink / raw)
To: sfrench, smfrench, linkinjeon, linkinjeon
Cc: linux-cifs, linux-kernel, ChenXiaoSong
From: ChenXiaoSong <chenxiaosong@kylinos.cn>
smb2_notify() should return error code when an error occurs,
__process_request() will print the error messages.
I may implement the SMB2 CHANGE_NOTIFY response (see MS-SMB2 2.2.36)
in the future.
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
fs/smb/server/smb2pdu.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index 83d8a325b9ea..c040df0a2073 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -8787,7 +8787,7 @@ int smb2_oplock_break(struct ksmbd_work *work)
* smb2_notify() - handler for smb2 notify request
* @work: smb work containing notify command buffer
*
- * Return: 0
+ * Return: 0 on success, otherwise error
*/
int smb2_notify(struct ksmbd_work *work)
{
@@ -8801,12 +8801,12 @@ int smb2_notify(struct ksmbd_work *work)
if (work->next_smb2_rcv_hdr_off && req->hdr.NextCommand) {
rsp->hdr.Status = STATUS_INTERNAL_ERROR;
smb2_set_err_rsp(work);
- return 0;
+ return -EIO;
}
smb2_set_err_rsp(work);
rsp->hdr.Status = STATUS_NOT_IMPLEMENTED;
- return 0;
+ return -EOPNOTSUPP,;
}
/**
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 3/6] smb/server: fix return value of smb2_query_dir()
2025-10-17 8:46 [PATCH 0/6] smb/server: fix return values of smb2_0_server_cmds proc chenxiaosong.chenxiaosong
2025-10-17 8:46 ` [PATCH 1/6] smb/server: fix return value of smb2_read() chenxiaosong.chenxiaosong
2025-10-17 8:46 ` [PATCH 2/6] smb/server: fix return value of smb2_notify() chenxiaosong.chenxiaosong
@ 2025-10-17 8:46 ` chenxiaosong.chenxiaosong
2025-10-17 8:46 ` [PATCH 4/6] smb/server: fix return value of smb2_ioctl() chenxiaosong.chenxiaosong
` (3 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-10-17 8:46 UTC (permalink / raw)
To: sfrench, smfrench, linkinjeon, linkinjeon
Cc: linux-cifs, linux-kernel, ChenXiaoSong
From: ChenXiaoSong <chenxiaosong@kylinos.cn>
__process_request() will not print error messages if smb2_query_dir()
always returns 0.
Fix this by returning the correct value at the end of function.
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
fs/smb/server/smb2pdu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index c040df0a2073..dabc3a49bd15 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -4560,7 +4560,7 @@ int smb2_query_dir(struct ksmbd_work *work)
smb2_set_err_rsp(work);
ksmbd_fd_put(work, dir_fp);
ksmbd_revert_fsids(work);
- return 0;
+ return rc;
}
/**
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 4/6] smb/server: fix return value of smb2_ioctl()
2025-10-17 8:46 [PATCH 0/6] smb/server: fix return values of smb2_0_server_cmds proc chenxiaosong.chenxiaosong
` (2 preceding siblings ...)
2025-10-17 8:46 ` [PATCH 3/6] smb/server: fix return value of smb2_query_dir() chenxiaosong.chenxiaosong
@ 2025-10-17 8:46 ` chenxiaosong.chenxiaosong
2025-10-17 8:46 ` [PATCH 5/6] smb/server: fix return value of smb2_oplock_break() chenxiaosong.chenxiaosong
` (2 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-10-17 8:46 UTC (permalink / raw)
To: sfrench, smfrench, linkinjeon, linkinjeon
Cc: linux-cifs, linux-kernel, ChenXiaoSong
From: ChenXiaoSong <chenxiaosong@kylinos.cn>
__process_request() will not print error messages if smb2_ioctl()
always returns 0.
Fix this by returning the correct value at the end of function.
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
fs/smb/server/smb2pdu.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index dabc3a49bd15..488915a8639b 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -8164,7 +8164,7 @@ int smb2_ioctl(struct ksmbd_work *work)
id = req->VolatileFileId;
if (req->Flags != cpu_to_le32(SMB2_0_IOCTL_IS_FSCTL)) {
- rsp->hdr.Status = STATUS_NOT_SUPPORTED;
+ ret = -EOPNOTSUPP;
goto out;
}
@@ -8184,8 +8184,9 @@ int smb2_ioctl(struct ksmbd_work *work)
case FSCTL_DFS_GET_REFERRALS:
case FSCTL_DFS_GET_REFERRALS_EX:
/* Not support DFS yet */
+ ret = -EOPNOTSUPP;
rsp->hdr.Status = STATUS_FS_DRIVER_REQUIRED;
- goto out;
+ goto out2;
case FSCTL_CREATE_OR_GET_OBJECT_ID:
{
struct file_object_buf_type1_ioctl_rsp *obj_buf;
@@ -8475,8 +8476,10 @@ int smb2_ioctl(struct ksmbd_work *work)
rsp->hdr.Status = STATUS_BUFFER_TOO_SMALL;
else if (ret < 0 || rsp->hdr.Status == 0)
rsp->hdr.Status = STATUS_INVALID_PARAMETER;
+
+out2:
smb2_set_err_rsp(work);
- return 0;
+ return ret;
}
/**
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 5/6] smb/server: fix return value of smb2_oplock_break()
2025-10-17 8:46 [PATCH 0/6] smb/server: fix return values of smb2_0_server_cmds proc chenxiaosong.chenxiaosong
` (3 preceding siblings ...)
2025-10-17 8:46 ` [PATCH 4/6] smb/server: fix return value of smb2_ioctl() chenxiaosong.chenxiaosong
@ 2025-10-17 8:46 ` chenxiaosong.chenxiaosong
2025-10-17 8:46 ` [PATCH 6/6] smb/server: update some misguided comment of smb2_0_server_cmds proc chenxiaosong.chenxiaosong
2025-10-17 14:02 ` [PATCH 0/6] smb/server: fix return values " Namjae Jeon
6 siblings, 0 replies; 9+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-10-17 8:46 UTC (permalink / raw)
To: sfrench, smfrench, linkinjeon, linkinjeon
Cc: linux-cifs, linux-kernel, ChenXiaoSong
From: ChenXiaoSong <chenxiaosong@kylinos.cn>
smb2_oplock_break() should return error code when an error occurs,
__process_request() will print the error messages.
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
fs/smb/server/smb2pdu.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index 488915a8639b..0fb517838325 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -8758,7 +8758,7 @@ static void smb21_lease_break_ack(struct ksmbd_work *work)
* smb2_oplock_break() - dispatcher for smb2.0 and 2.1 oplock/lease break
* @work: smb work containing oplock/lease break command buffer
*
- * Return: 0
+ * Return: 0 on success, otherwise error
*/
int smb2_oplock_break(struct ksmbd_work *work)
{
@@ -8781,6 +8781,7 @@ int smb2_oplock_break(struct ksmbd_work *work)
le16_to_cpu(req->StructureSize));
rsp->hdr.Status = STATUS_INVALID_PARAMETER;
smb2_set_err_rsp(work);
+ return -EINVAL;
}
return 0;
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 6/6] smb/server: update some misguided comment of smb2_0_server_cmds proc
2025-10-17 8:46 [PATCH 0/6] smb/server: fix return values of smb2_0_server_cmds proc chenxiaosong.chenxiaosong
` (4 preceding siblings ...)
2025-10-17 8:46 ` [PATCH 5/6] smb/server: fix return value of smb2_oplock_break() chenxiaosong.chenxiaosong
@ 2025-10-17 8:46 ` chenxiaosong.chenxiaosong
2025-10-17 14:02 ` [PATCH 0/6] smb/server: fix return values " Namjae Jeon
6 siblings, 0 replies; 9+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-10-17 8:46 UTC (permalink / raw)
To: sfrench, smfrench, linkinjeon, linkinjeon
Cc: linux-cifs, linux-kernel, ChenXiaoSong
From: ChenXiaoSong <chenxiaosong@kylinos.cn>
These functions return error code rather than always returning 0.
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
fs/smb/server/smb2pdu.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index 0fb517838325..9ddfc2dbe07c 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -2168,7 +2168,7 @@ static int smb2_create_open_flags(bool file_present, __le32 access,
* smb2_tree_disconnect() - handler for smb tree connect request
* @work: smb work containing request buffer
*
- * Return: 0
+ * Return: 0 on success, otherwise error
*/
int smb2_tree_disconnect(struct ksmbd_work *work)
{
@@ -2232,7 +2232,7 @@ int smb2_tree_disconnect(struct ksmbd_work *work)
* smb2_session_logoff() - handler for session log off request
* @work: smb work containing request buffer
*
- * Return: 0
+ * Return: 0 on success, otherwise error
*/
int smb2_session_logoff(struct ksmbd_work *work)
{
@@ -5844,7 +5844,7 @@ static noinline int smb2_close_pipe(struct ksmbd_work *work)
* smb2_close() - handler for smb2 close file command
* @work: smb work containing close request buffer
*
- * Return: 0
+ * Return: 0 on success, otherwise error
*/
int smb2_close(struct ksmbd_work *work)
{
@@ -5969,7 +5969,7 @@ int smb2_close(struct ksmbd_work *work)
* smb2_echo() - handler for smb2 echo(ping) command
* @work: smb work containing echo request buffer
*
- * Return: 0
+ * Return: 0 on success, otherwise error
*/
int smb2_echo(struct ksmbd_work *work)
{
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 0/6] smb/server: fix return values of smb2_0_server_cmds proc
2025-10-17 8:46 [PATCH 0/6] smb/server: fix return values of smb2_0_server_cmds proc chenxiaosong.chenxiaosong
` (5 preceding siblings ...)
2025-10-17 8:46 ` [PATCH 6/6] smb/server: update some misguided comment of smb2_0_server_cmds proc chenxiaosong.chenxiaosong
@ 2025-10-17 14:02 ` Namjae Jeon
2025-10-17 14:47 ` ChenXiaoSong
6 siblings, 1 reply; 9+ messages in thread
From: Namjae Jeon @ 2025-10-17 14:02 UTC (permalink / raw)
To: chenxiaosong.chenxiaosong
Cc: sfrench, smfrench, linkinjeon, linux-cifs, linux-kernel,
ChenXiaoSong
On Fri, Oct 17, 2025 at 5:47 PM <chenxiaosong.chenxiaosong@linux.dev> wrote:
>
> From: ChenXiaoSong <chenxiaosong@kylinos.cn>
>
> These functions should return error code when an error occurs,
> then __process_request() will print the error messages.
>
> ChenXiaoSong (6):
> smb/server: fix return value of smb2_read()
> smb/server: fix return value of smb2_notify()
> smb/server: fix return value of smb2_query_dir()
> smb/server: fix return value of smb2_ioctl()
> smb/server: fix return value of smb2_oplock_break()
> smb/server: update some misguided comment of smb2_0_server_cmds proc
Applied them to #ksmbd-for-next-next.
Thanks!
>
> fs/smb/server/smb2pdu.c | 30 +++++++++++++++++-------------
> 1 file changed, 17 insertions(+), 13 deletions(-)
>
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 0/6] smb/server: fix return values of smb2_0_server_cmds proc
2025-10-17 14:02 ` [PATCH 0/6] smb/server: fix return values " Namjae Jeon
@ 2025-10-17 14:47 ` ChenXiaoSong
0 siblings, 0 replies; 9+ messages in thread
From: ChenXiaoSong @ 2025-10-17 14:47 UTC (permalink / raw)
To: Namjae Jeon
Cc: sfrench, smfrench, linkinjeon, linux-cifs, linux-kernel,
ChenXiaoSong
Hi Namjae,
v1 has typos, and I've already sent v2:
https://lore.kernel.org/all/20251017104613.3094031-1-chenxiaosong.chenxiaosong@linux.dev/
Thanks.
On 10/17/25 10:02 PM, Namjae Jeon wrote:
> On Fri, Oct 17, 2025 at 5:47 PM <chenxiaosong.chenxiaosong@linux.dev> wrote:
>>
>> From: ChenXiaoSong <chenxiaosong@kylinos.cn>
>>
>> These functions should return error code when an error occurs,
>> then __process_request() will print the error messages.
>>
>> ChenXiaoSong (6):
>> smb/server: fix return value of smb2_read()
>> smb/server: fix return value of smb2_notify()
>> smb/server: fix return value of smb2_query_dir()
>> smb/server: fix return value of smb2_ioctl()
>> smb/server: fix return value of smb2_oplock_break()
>> smb/server: update some misguided comment of smb2_0_server_cmds proc
> Applied them to #ksmbd-for-next-next.
> Thanks!
>>
>> fs/smb/server/smb2pdu.c | 30 +++++++++++++++++-------------
>> 1 file changed, 17 insertions(+), 13 deletions(-)
>>
>> --
>> 2.43.0
>>
>
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2025-10-17 14:47 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-17 8:46 [PATCH 0/6] smb/server: fix return values of smb2_0_server_cmds proc chenxiaosong.chenxiaosong
2025-10-17 8:46 ` [PATCH 1/6] smb/server: fix return value of smb2_read() chenxiaosong.chenxiaosong
2025-10-17 8:46 ` [PATCH 2/6] smb/server: fix return value of smb2_notify() chenxiaosong.chenxiaosong
2025-10-17 8:46 ` [PATCH 3/6] smb/server: fix return value of smb2_query_dir() chenxiaosong.chenxiaosong
2025-10-17 8:46 ` [PATCH 4/6] smb/server: fix return value of smb2_ioctl() chenxiaosong.chenxiaosong
2025-10-17 8:46 ` [PATCH 5/6] smb/server: fix return value of smb2_oplock_break() chenxiaosong.chenxiaosong
2025-10-17 8:46 ` [PATCH 6/6] smb/server: update some misguided comment of smb2_0_server_cmds proc chenxiaosong.chenxiaosong
2025-10-17 14:02 ` [PATCH 0/6] smb/server: fix return values " Namjae Jeon
2025-10-17 14:47 ` ChenXiaoSong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).