Skip to contentSkip to conversation

smb/server: fix return values of smb2_0_server_cmds proc

PATCH Applied [email protected] 4 participants 15 messages Oct 17, 2025 – Nov 2, 2025

Subsystems (2)

v1 of 2 Applied Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover smb/server: fix return values of smb2_0_server_cmds proc

From: ChenXiaoSong <[email protected]>

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(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/6 smb/server: fix return value of smb2_read()

From: ChenXiaoSong <[email protected]>

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.

---
 fs/smb/server/smb2pdu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/smb/server/smb2pdu.c +1 -1
index f901ae18e68a..83d8a325b9ea 100644
@@ -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",
Signature · 1 line
2.43.0
#2 lore raw

PATCH 2/6 smb/server: fix return value of smb2_notify()

In reply to [email protected]

From: ChenXiaoSong <[email protected]>

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.

---
 fs/smb/server/smb2pdu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
fs/smb/server/smb2pdu.c +3 -3
index 83d8a325b9ea..c040df0a2073 100644
@@ -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,;
 }
 
 /**
Signature · 1 line
2.43.0
maintainer
#3 lore raw

Re: [PATCH 2/6] smb/server: fix return value of smb2_notify()

Quoted 8 lines · On Fri, Oct 17, 2025 at 5:47 PM <[email protected]> wrote:

From: ChenXiaoSong <[email protected]>

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.

Do you have any plans to implement SMB2 CHANGE_NOTIFY? Thanks.

#4 lore raw

Re: [PATCH 2/6] smb/server: fix return value of smb2_notify()

Hi Namjae,

I’m referring to the userspace samba code and trying to implement this feature.

Thanks,
ChenXiaoSong.

Quoted 11 lines · Namjae Jeon
Quoted 8 lines · On Fri, Oct 17, 2025 at 5:47 PM <[email protected]> wrote:

From: ChenXiaoSong <[email protected]>

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.

Do you have any plans to implement SMB2 CHANGE_NOTIFY? Thanks.

maintainer
#5 lore raw

Re: [PATCH 2/6] smb/server: fix return value of smb2_notify()

Quoted 2 lines · ChenXiaoSong

Hi Namjae,

Hi ChenXiaoSong,

Quoted 3 lines

I’m referring to the userspace samba code and trying to implement this feature.

Sounds great!
There are requests from users to implement it :
https://github.com/namjaejeon/ksmbd/issues/495#issuecomment-3473472265
Thanks!

Quoted 17 lines

Thanks,
ChenXiaoSong.

Quoted 11 lines · Namjae Jeon
Quoted 8 lines · On Fri, Oct 17, 2025 at 5:47 PM <[email protected]> wrote:

From: ChenXiaoSong <[email protected]>

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.

Do you have any plans to implement SMB2 CHANGE_NOTIFY? Thanks.

#6 lore raw

Re: [PATCH 2/6] smb/server: fix return value of smb2_notify()

After I finish the other patchset, I'll fully focus on developing this feature.

Thanks,
ChenXiaoSong.

Quoted 29 lines · Namjae Jeon
Quoted 2 lines · ChenXiaoSong

Hi Namjae,

Hi ChenXiaoSong,

Quoted 3 lines

I’m referring to the userspace samba code and trying to implement this feature.

Sounds great!
There are requests from users to implement it :
https://github.com/namjaejeon/ksmbd/issues/495#issuecomment-3473472265
Thanks!

Quoted 17 lines

Thanks,
ChenXiaoSong.

Quoted 11 lines · Namjae Jeon
Quoted 8 lines · On Fri, Oct 17, 2025 at 5:47 PM <[email protected]> wrote:

From: ChenXiaoSong <[email protected]>

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.

Do you have any plans to implement SMB2 CHANGE_NOTIFY? Thanks.

#7 lore raw

Re: [PATCH 2/6] smb/server: fix return value of smb2_notify()

In reply to Namjae Jeon

I am also very interested in the work to improve the VFS to allow filesystems, especially cifs.ko (client) to support change notify (without having to use the ioctl or smb client specific tool, smbinfo etc). It will be very useful

Quoted 30 lines · Namjae Jeon
Quoted 2 lines · ChenXiaoSong

Hi Namjae,

Hi ChenXiaoSong,

Quoted 3 lines

I’m referring to the userspace samba code and trying to implement this feature.

Sounds great!
There are requests from users to implement it :
https://github.com/namjaejeon/ksmbd/issues/495#issuecomment-3473472265
Thanks!

Quoted 17 lines

Thanks,
ChenXiaoSong.

Quoted 11 lines · Namjae Jeon
Quoted 8 lines · On Fri, Oct 17, 2025 at 5:47 PM <[email protected]> wrote:

From: ChenXiaoSong <[email protected]>

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.

Do you have any plans to implement SMB2 CHANGE_NOTIFY? Thanks.

Signature · 3 lines
Thanks,

Steve
reviewer
#8 lore raw

Re: [PATCH 2/6] smb/server: fix return value of smb2_notify()

I will also try to work on improvements for the client. This will be very interesting and very useful.

Good news: next year I will be able to fully focus on SMB development.

Thanks,
ChenXiaoSong.

Quoted 39 lines · Steve French

I am also very interested in the work to improve the VFS to allow filesystems, especially cifs.ko (client) to support change notify (without having to use the ioctl or smb client specific tool, smbinfo etc). It will be very useful

Quoted 30 lines · Namjae Jeon
Quoted 2 lines · ChenXiaoSong

Hi Namjae,

Hi ChenXiaoSong,

Quoted 3 lines

I’m referring to the userspace samba code and trying to implement this feature.

Sounds great!
There are requests from users to implement it :
https://github.com/namjaejeon/ksmbd/issues/495#issuecomment-3473472265
Thanks!

Quoted 17 lines

Thanks,
ChenXiaoSong.

Quoted 11 lines · Namjae Jeon
Quoted 8 lines · On Fri, Oct 17, 2025 at 5:47 PM <[email protected]> wrote:

From: ChenXiaoSong <[email protected]>

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.

Do you have any plans to implement SMB2 CHANGE_NOTIFY? Thanks.

#9 lore raw

PATCH 3/6 smb/server: fix return value of smb2_query_dir()

In reply to [email protected]

From: ChenXiaoSong <[email protected]>

__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.

---
 fs/smb/server/smb2pdu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/smb/server/smb2pdu.c +1 -1
index c040df0a2073..dabc3a49bd15 100644
@@ -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;
 }
 
 /**
Signature · 1 line
2.43.0
#10 lore raw

PATCH 4/6 smb/server: fix return value of smb2_ioctl()

In reply to [email protected]

From: ChenXiaoSong <[email protected]>

__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.

---
 fs/smb/server/smb2pdu.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
fs/smb/server/smb2pdu.c +6 -3
index dabc3a49bd15..488915a8639b 100644
@@ -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;
 }
 
 /**
Signature · 1 line
2.43.0
#11 lore raw

PATCH 5/6 smb/server: fix return value of smb2_oplock_break()

In reply to [email protected]

From: ChenXiaoSong <[email protected]>

smb2_oplock_break() should return error code when an error occurs, __process_request() will print the error messages.

---
 fs/smb/server/smb2pdu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/smb/server/smb2pdu.c +2 -1
index 488915a8639b..0fb517838325 100644
@@ -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;
Signature · 1 line
2.43.0
#12 lore raw

PATCH 6/6 smb/server: update some misguided comment of smb2_0_server_cmds proc

In reply to [email protected]

From: ChenXiaoSong <[email protected]>

These functions return error code rather than always returning 0.

---
 fs/smb/server/smb2pdu.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
fs/smb/server/smb2pdu.c +4 -4
index 0fb517838325..9ddfc2dbe07c 100644
@@ -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)
 {
Signature · 1 line
2.43.0
maintainer Applied
#13 lore raw
In reply to [email protected]
Quoted 6 lines · On Fri, Oct 17, 2025 at 5:47 PM <[email protected]> wrote:

From: ChenXiaoSong <[email protected]>

These functions should return error code when an error occurs, then __process_request() will print the error messages.

Quoted 7 lines

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!

Quoted 7 lines
 fs/smb/server/smb2pdu.c | 30 +++++++++++++++++-------------
 1 file changed, 17 insertions(+), 13 deletions(-)

--
2.43.0

#14 lore raw

Hi Namjae,

v1 has typos, and I've already sent v2:

https://lore.kernel.org/all/[email protected]/

Thanks.

Quoted 24 lines · Namjae Jeon
Quoted 6 lines · On Fri, Oct 17, 2025 at 5:47 PM <[email protected]> wrote:

From: ChenXiaoSong <[email protected]>

These functions should return error code when an error occurs, then __process_request() will print the error messages.

Quoted 7 lines

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!

Quoted 7 lines
  fs/smb/server/smb2pdu.c | 30 +++++++++++++++++-------------
  1 file changed, 17 insertions(+), 13 deletions(-)

--
2.43.0