Linux CIFS filesystem development
 help / color / mirror / Atom feed
* [PATCH] fix error code overwriting in smb2_get_info_filesystem()
@ 2025-09-25 12:12 Matvey Kovalev
  2025-09-25 14:18 ` Namjae Jeon
  2025-09-26 12:28 ` Markus Elfring
  0 siblings, 2 replies; 3+ messages in thread
From: Matvey Kovalev @ 2025-09-25 12:12 UTC (permalink / raw)
  To: Namjae Jeon
  Cc: Matvey Kovalev, Steve French, Sergey Senozhatsky, Tom Talpey,
	linux-cifs, linux-kernel, lvc-project, stable

If client doesn't negotiate with SMB3.1.1 POSIX Extensions, 
then proper error code won't be returned due to overwriting.

Return error immediately.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: e2f34481b24db ("cifsd: add server-side procedures for SMB3")
Cc: stable@vger.kernel.org
Signed-off-by: Matvey Kovalev <matvey.kovalev@ispras.ru>
---
 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 a565fc36cee6d..a1db006ab6e92 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -5628,7 +5628,8 @@ static int smb2_get_info_filesystem(struct ksmbd_work *work,
 
 		if (!work->tcon->posix_extensions) {
 			pr_err("client doesn't negotiate with SMB3.1.1 POSIX Extensions\n");
-			rc = -EOPNOTSUPP;
+			path_put(&path);
+			return -EOPNOTSUPP;
 		} else {
 			info = (struct filesystem_posix_info *)(rsp->Buffer);
 			info->OptimalTransferSize = cpu_to_le32(stfs.f_bsize);
-- 
2.43.0.windows.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] fix error code overwriting in smb2_get_info_filesystem()
  2025-09-25 12:12 [PATCH] fix error code overwriting in smb2_get_info_filesystem() Matvey Kovalev
@ 2025-09-25 14:18 ` Namjae Jeon
  2025-09-26 12:28 ` Markus Elfring
  1 sibling, 0 replies; 3+ messages in thread
From: Namjae Jeon @ 2025-09-25 14:18 UTC (permalink / raw)
  To: Matvey Kovalev
  Cc: Steve French, Sergey Senozhatsky, Tom Talpey, linux-cifs,
	linux-kernel, lvc-project, stable

On Thu, Sep 25, 2025 at 9:14 PM Matvey Kovalev <matvey.kovalev@ispras.ru> wrote:
>
> If client doesn't negotiate with SMB3.1.1 POSIX Extensions,
> then proper error code won't be returned due to overwriting.
>
> Return error immediately.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Fixes: e2f34481b24db ("cifsd: add server-side procedures for SMB3")
> Cc: stable@vger.kernel.org
> Signed-off-by: Matvey Kovalev <matvey.kovalev@ispras.ru>
Applied it to #ksmbd-for-next-next.
Thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] fix error code overwriting in smb2_get_info_filesystem()
  2025-09-25 12:12 [PATCH] fix error code overwriting in smb2_get_info_filesystem() Matvey Kovalev
  2025-09-25 14:18 ` Namjae Jeon
@ 2025-09-26 12:28 ` Markus Elfring
  1 sibling, 0 replies; 3+ messages in thread
From: Markus Elfring @ 2025-09-26 12:28 UTC (permalink / raw)
  To: Matvey Kovalev, linux-cifs, lvc-project, Namjae Jeon
  Cc: stable, LKML, Sergey Senozhatsky, Steve French, Tom Talpey

…
> ++ b/fs/smb/server/smb2pdu.c
> @@ -5628,7 +5628,8 @@ static int smb2_get_info_filesystem(struct ksmbd_work *work,
>  
>  		if (!work->tcon->posix_extensions) {
>  			pr_err("client doesn't negotiate with SMB3.1.1 POSIX Extensions\n");
> -			rc = -EOPNOTSUPP;
> +			path_put(&path);
> +			return -EOPNOTSUPP;
>  		} else {
>  			info = (struct filesystem_posix_info *)(rsp->Buffer);
>  			info->OptimalTransferSize = cpu_to_le32(stfs.f_bsize);
…

How do you think about to avoid duplicate source code another bit?
https://elixir.bootlin.com/linux/v6.17-rc7/source/fs/smb/server/smb2pdu.c#L5437-L5653
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?h=v6.17-rc7#n532

Would you like to choose a more appropriate subsystem specification?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.17-rc7#n646

Regards,
Markus

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-09-26 12:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-25 12:12 [PATCH] fix error code overwriting in smb2_get_info_filesystem() Matvey Kovalev
2025-09-25 14:18 ` Namjae Jeon
2025-09-26 12:28 ` Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox