Linux-CIFS Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] cifs: fix channel signing
@ 2020-02-06 12:49 Aurelien Aptel
  2020-02-06 18:20 ` Pavel Shilovsky
  0 siblings, 1 reply; 2+ messages in thread
From: Aurelien Aptel @ 2020-02-06 12:49 UTC (permalink / raw)
  To: linux-cifs; +Cc: smfrench, Aurelien Aptel

The server var was accidentally used as an iterator over the global
list of connections, thus overwritten the passed argument. This
resulted in the wrong signing key being returned for extra channels.

Fix this by using a separate var to iterate.

Signed-off-by: Aurelien Aptel <aaptel@suse.com>
---
 fs/cifs/smb2transport.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/cifs/smb2transport.c b/fs/cifs/smb2transport.c
index fe6acfce3390..08b703b7a15e 100644
--- a/fs/cifs/smb2transport.c
+++ b/fs/cifs/smb2transport.c
@@ -104,13 +104,14 @@ int smb2_get_sign_key(__u64 ses_id, struct TCP_Server_Info *server, u8 *key)
 {
 	struct cifs_chan *chan;
 	struct cifs_ses *ses = NULL;
+	struct TCP_Server_Info *it = NULL;
 	int i;
 	int rc = 0;
 
 	spin_lock(&cifs_tcp_ses_lock);
 
-	list_for_each_entry(server, &cifs_tcp_ses_list, tcp_ses_list) {
-		list_for_each_entry(ses, &server->smb_ses_list, smb_ses_list) {
+	list_for_each_entry(it, &cifs_tcp_ses_list, tcp_ses_list) {
+		list_for_each_entry(ses, &it->smb_ses_list, smb_ses_list) {
 			if (ses->Suid == ses_id)
 				goto found;
 		}
-- 
2.16.4


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

* Re: [PATCH] cifs: fix channel signing
  2020-02-06 12:49 [PATCH] cifs: fix channel signing Aurelien Aptel
@ 2020-02-06 18:20 ` Pavel Shilovsky
  0 siblings, 0 replies; 2+ messages in thread
From: Pavel Shilovsky @ 2020-02-06 18:20 UTC (permalink / raw)
  To: Aurelien Aptel; +Cc: linux-cifs, Steve French

чт, 6 февр. 2020 г. в 05:00, Aurelien Aptel <aaptel@suse.com>:
>
> The server var was accidentally used as an iterator over the global
> list of connections, thus overwritten the passed argument. This
> resulted in the wrong signing key being returned for extra channels.
>
> Fix this by using a separate var to iterate.
>
> Signed-off-by: Aurelien Aptel <aaptel@suse.com>
> ---
>  fs/cifs/smb2transport.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/fs/cifs/smb2transport.c b/fs/cifs/smb2transport.c
> index fe6acfce3390..08b703b7a15e 100644
> --- a/fs/cifs/smb2transport.c
> +++ b/fs/cifs/smb2transport.c
> @@ -104,13 +104,14 @@ int smb2_get_sign_key(__u64 ses_id, struct TCP_Server_Info *server, u8 *key)
>  {
>         struct cifs_chan *chan;
>         struct cifs_ses *ses = NULL;
> +       struct TCP_Server_Info *it = NULL;
>         int i;
>         int rc = 0;
>
>         spin_lock(&cifs_tcp_ses_lock);
>
> -       list_for_each_entry(server, &cifs_tcp_ses_list, tcp_ses_list) {
> -               list_for_each_entry(ses, &server->smb_ses_list, smb_ses_list) {
> +       list_for_each_entry(it, &cifs_tcp_ses_list, tcp_ses_list) {
> +               list_for_each_entry(ses, &it->smb_ses_list, smb_ses_list) {
>                         if (ses->Suid == ses_id)
>                                 goto found;
>                 }

Good catch!

Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com>

Stable candidate?

--
Best regards,
Pavel Shilovsky

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

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-06 12:49 [PATCH] cifs: fix channel signing Aurelien Aptel
2020-02-06 18:20 ` Pavel Shilovsky

Linux-CIFS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-cifs/0 linux-cifs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-cifs linux-cifs/ https://lore.kernel.org/linux-cifs \
		linux-cifs@vger.kernel.org
	public-inbox-index linux-cifs

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-cifs


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git