* [PATCH][SMB3 client] missing lock when picking channel
@ 2024-04-25 16:44 Steve French
2024-04-25 16:55 ` Shyam Prasad N
2024-04-26 6:46 ` Meetakshi Setiya
0 siblings, 2 replies; 3+ messages in thread
From: Steve French @ 2024-04-25 16:44 UTC (permalink / raw)
To: CIFS; +Cc: Shyam Prasad N, Meetakshi Setiya
[-- Attachment #1: Type: text/plain, Size: 839 bytes --]
Coverity spotted a place where we should have been holding the
channel lock when accessing the ses channel index.
Addresses-Coverity: 1582039 ("Data race condition (MISSING_LOCK)")
Cc: stable@vger.kernel.org
Signed-off-by: Steve French <stfrench@microsoft.com>
---
fs/smb/client/transport.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/fs/smb/client/transport.c b/fs/smb/client/transport.c
index 443b4b89431d..fc0ddc75abc9 100644
--- a/fs/smb/client/transport.c
+++ b/fs/smb/client/transport.c
@@ -1059,9 +1059,11 @@ struct TCP_Server_Info
*cifs_pick_channel(struct cifs_ses *ses)
index = (uint)atomic_inc_return(&ses->chan_seq);
index %= ses->chan_count;
}
+
+ server = ses->chans[index].server;
spin_unlock(&ses->chan_lock);
- return ses->chans[index].server;
+ return server;
}
--
Thanks,
Steve
[-- Attachment #2: 0002-smb3-missing-lock-when-picking-channel.patch --]
[-- Type: text/x-patch, Size: 1056 bytes --]
From 5ec995c33cc30f1cfb26ab0126c077ca82f64a06 Mon Sep 17 00:00:00 2001
From: Steve French <stfrench@microsoft.com>
Date: Thu, 25 Apr 2024 11:30:16 -0500
Subject: [PATCH 2/2] smb3: missing lock when picking channel
Coverity spotted a place where we should have been holding the
channel lock when accessing the ses channel index.
Addresses-Coverity: 1582039 ("Data race condition (MISSING_LOCK)")
Cc: stable@vger.kernel.org
Signed-off-by: Steve French <stfrench@microsoft.com>
---
fs/smb/client/transport.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/fs/smb/client/transport.c b/fs/smb/client/transport.c
index 443b4b89431d..fc0ddc75abc9 100644
--- a/fs/smb/client/transport.c
+++ b/fs/smb/client/transport.c
@@ -1059,9 +1059,11 @@ struct TCP_Server_Info *cifs_pick_channel(struct cifs_ses *ses)
index = (uint)atomic_inc_return(&ses->chan_seq);
index %= ses->chan_count;
}
+
+ server = ses->chans[index].server;
spin_unlock(&ses->chan_lock);
- return ses->chans[index].server;
+ return server;
}
int
--
2.40.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH][SMB3 client] missing lock when picking channel
2024-04-25 16:44 [PATCH][SMB3 client] missing lock when picking channel Steve French
@ 2024-04-25 16:55 ` Shyam Prasad N
2024-04-26 6:46 ` Meetakshi Setiya
1 sibling, 0 replies; 3+ messages in thread
From: Shyam Prasad N @ 2024-04-25 16:55 UTC (permalink / raw)
To: Steve French; +Cc: CIFS, Meetakshi Setiya
On Thu, Apr 25, 2024 at 10:14 PM Steve French <smfrench@gmail.com> wrote:
>
> Coverity spotted a place where we should have been holding the
> channel lock when accessing the ses channel index.
>
> Addresses-Coverity: 1582039 ("Data race condition (MISSING_LOCK)")
> Cc: stable@vger.kernel.org
> Signed-off-by: Steve French <stfrench@microsoft.com>
> ---
> fs/smb/client/transport.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/fs/smb/client/transport.c b/fs/smb/client/transport.c
> index 443b4b89431d..fc0ddc75abc9 100644
> --- a/fs/smb/client/transport.c
> +++ b/fs/smb/client/transport.c
> @@ -1059,9 +1059,11 @@ struct TCP_Server_Info
> *cifs_pick_channel(struct cifs_ses *ses)
> index = (uint)atomic_inc_return(&ses->chan_seq);
> index %= ses->chan_count;
> }
> +
> + server = ses->chans[index].server;
> spin_unlock(&ses->chan_lock);
>
> - return ses->chans[index].server;
> + return server;
> }
>
> --
> Thanks,
>
> Steve
Looks good to me.
--
Regards,
Shyam
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH][SMB3 client] missing lock when picking channel
2024-04-25 16:44 [PATCH][SMB3 client] missing lock when picking channel Steve French
2024-04-25 16:55 ` Shyam Prasad N
@ 2024-04-26 6:46 ` Meetakshi Setiya
1 sibling, 0 replies; 3+ messages in thread
From: Meetakshi Setiya @ 2024-04-26 6:46 UTC (permalink / raw)
To: Steve French; +Cc: CIFS, Shyam Prasad N
Looks good
Thanks
Meetakshi
On Thu, Apr 25, 2024 at 10:14 PM Steve French <smfrench@gmail.com> wrote:
>
> Coverity spotted a place where we should have been holding the
> channel lock when accessing the ses channel index.
>
> Addresses-Coverity: 1582039 ("Data race condition (MISSING_LOCK)")
> Cc: stable@vger.kernel.org
> Signed-off-by: Steve French <stfrench@microsoft.com>
> ---
> fs/smb/client/transport.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/fs/smb/client/transport.c b/fs/smb/client/transport.c
> index 443b4b89431d..fc0ddc75abc9 100644
> --- a/fs/smb/client/transport.c
> +++ b/fs/smb/client/transport.c
> @@ -1059,9 +1059,11 @@ struct TCP_Server_Info
> *cifs_pick_channel(struct cifs_ses *ses)
> index = (uint)atomic_inc_return(&ses->chan_seq);
> index %= ses->chan_count;
> }
> +
> + server = ses->chans[index].server;
> spin_unlock(&ses->chan_lock);
>
> - return ses->chans[index].server;
> + return server;
> }
>
> --
> Thanks,
>
> Steve
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-04-26 6:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-25 16:44 [PATCH][SMB3 client] missing lock when picking channel Steve French
2024-04-25 16:55 ` Shyam Prasad N
2024-04-26 6:46 ` Meetakshi Setiya
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).