diff mbox series

smb: client: Fix a double lock bug in smb2_reconnect()

Message ID bf90de00-4d6a-4440-b6a1-42ac9e358158@moroto.mountain (mailing list archive)
State New, archived
Headers show
Series smb: client: Fix a double lock bug in smb2_reconnect() | expand

Commit Message

Dan Carpenter Feb. 1, 2024, 12:18 p.m. UTC
This goto will try to lock spin_lock(&ses->ses_lock) twice which will
lead to a deadlock.

Fixes: 17525952fa83 ("cifs: make sure that channel scaling is done only once")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 fs/smb/client/smb2pdu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Steve French Feb. 1, 2024, 6:03 p.m. UTC | #1
This (and a loosely related problem   were already fixed in an updated
version of that patch (updated in cifs-2.6.git for-next yesterday);
https://git.samba.org/?p=sfrench/cifs-2.6.git;a=commit;h=ee36a3b345c433a846effcdcfba437c2298eeda5


On Thu, Feb 1, 2024 at 6:19 AM Dan Carpenter <dan.carpenter@linaro.org> wrote:
>
> This goto will try to lock spin_lock(&ses->ses_lock) twice which will
> lead to a deadlock.
>
> Fixes: 17525952fa83 ("cifs: make sure that channel scaling is done only once")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
>  fs/smb/client/smb2pdu.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c
> index 2837fc4465a7..dcd3f6f08c7f 100644
> --- a/fs/smb/client/smb2pdu.c
> +++ b/fs/smb/client/smb2pdu.c
> @@ -401,7 +401,7 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon,
>
>         spin_lock(&ses->ses_lock);
>         if (ses->flags & CIFS_SES_FLAG_SCALE_CHANNELS)
> -               goto skip_add_channels;
> +               goto skip_add_channels_locked;
>         ses->flags |= CIFS_SES_FLAG_SCALE_CHANNELS;
>         spin_unlock(&ses->ses_lock);
>
> @@ -448,6 +448,7 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon,
>
>  skip_add_channels:
>         spin_lock(&ses->ses_lock);
> +skip_add_channels_locked:
>         ses->flags &= ~CIFS_SES_FLAG_SCALE_CHANNELS;
>         spin_unlock(&ses->ses_lock);
>
> --
> 2.43.0
>
>
diff mbox series

Patch

diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c
index 2837fc4465a7..dcd3f6f08c7f 100644
--- a/fs/smb/client/smb2pdu.c
+++ b/fs/smb/client/smb2pdu.c
@@ -401,7 +401,7 @@  smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon,
 
 	spin_lock(&ses->ses_lock);
 	if (ses->flags & CIFS_SES_FLAG_SCALE_CHANNELS)
-		goto skip_add_channels;
+		goto skip_add_channels_locked;
 	ses->flags |= CIFS_SES_FLAG_SCALE_CHANNELS;
 	spin_unlock(&ses->ses_lock);
 
@@ -448,6 +448,7 @@  smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon,
 
 skip_add_channels:
 	spin_lock(&ses->ses_lock);
+skip_add_channels_locked:
 	ses->flags &= ~CIFS_SES_FLAG_SCALE_CHANNELS;
 	spin_unlock(&ses->ses_lock);