Message ID | CAH2r5ms2xmxgZ08pecifj+Za=_oWnrhVOUgifjYLnCw+Rz9_kA@mail.gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [SMB3,client] missing lock when picking channel | expand |
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.
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
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
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(-)