Skip to contentSkip to conversation

cifs: fix channel signing

PATCH In review Aurelien Aptel 2 participants 2 messages Feb 6, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cifs: fix channel signing

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.

---
 fs/cifs/smb2transport.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
fs/cifs/smb2transport.c +3 -2
index fe6acfce3390..08b703b7a15e 100644
@@ -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;
 		}
Signature · 1 line
2.16.4
Reviewed-by on v1 1/1
#1 lore raw

чт, 6 февр. 2020 г. в 05:00, Aurelien Aptel <[email protected]>:

Quoted 23 lines

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.

---
 fs/cifs/smb2transport.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
fs/cifs/smb2transport.c +1 -0
index fe6acfce3390..08b703b7a15e 100644
@@ -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;

fs/cifs/smb2transport.c int smb2_get_sign_key(__u64 ses_id, struct TCP_Server_Info *server, u8 *key) · line 117

Quoted 10 lines
fs/cifs/smb2transport.c +2 -2
 
        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!

Stable candidate?

--
Best regards,
Pavel Shilovsky