Skip to contentSkip to conversation

cifs: protect updating server->dstaddr with a spinlock

PATCH Applied Ronnie Sahlberg 3 participants 3 messages Apr 21, 2020

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

PATCH 1/1 cifs: protect updating server->dstaddr with a spinlock

We use a spinlock while we are reading and accessing the destination address for a server. We need to also use this spinlock to protect when we are modifying this adress from reconn_set_ipaddr().

---
 fs/cifs/connect.c | 2 ++
 1 file changed, 2 insertions(+)
fs/cifs/connect.c +2 -0
index 95b3ab0ca8c0..63830f228b4a 100644
@@ -375,8 +375,10 @@ static int reconn_set_ipaddr(struct TCP_Server_Info *server)
 		return rc;
 	}
 
+	spin_lock(&cifs_tcp_ses_lock);
 	rc = cifs_convert_address((struct sockaddr *)&server->dstaddr, ipaddr,
 				  strlen(ipaddr));
+	spin_unlock(&cifs_tcp_ses_lock);
 	kfree(ipaddr);
 
 	return !rc ? -1 : 0;
Signature · 1 line
2.13.6
Reviewed-by on v1 1/1
#1 lore raw
Quoted 14 lines · Ronnie Sahlberg

We use a spinlock while we are reading and accessing the destination address for a server. We need to also use this spinlock to protect when we are modifying this adress from reconn_set_ipaddr().

---
 fs/cifs/connect.c | 2 ++
 1 file changed, 2 insertions(+)
fs/cifs/connect.c +0 -0
index 95b3ab0ca8c0..63830f228b4a 100644

fs/cifs/connect.c static int reconn_set_ipaddr(struct TCP_Server_Info *server) · line 384

Quoted 10 lines
fs/cifs/connect.c +2 -0
@@ -375,8 +375,10 @@ static int reconn_set_ipaddr(struct TCP_Server_Info *server)
 		return rc;
 	}
 
+	spin_lock(&cifs_tcp_ses_lock);
 	rc = cifs_convert_address((struct sockaddr *)&server->dstaddr, ipaddr,
 				  strlen(ipaddr));
+	spin_unlock(&cifs_tcp_ses_lock);
 	kfree(ipaddr);
 
 	return !rc ? -1 : 0;
Applied
#2 lore raw
In reply to Ronnie Sahlberg

merged into cifs-2.6.git for-next

Quoted 28 lines · Ronnie Sahlberg

We use a spinlock while we are reading and accessing the destination address for a server. We need to also use this spinlock to protect when we are modifying this adress from reconn_set_ipaddr().

---
 fs/cifs/connect.c | 2 ++
 1 file changed, 2 insertions(+)
fs/cifs/connect.c +2 -1
index 95b3ab0ca8c0..63830f228b4a 100644
@@ -375,8 +375,10 @@ static int reconn_set_ipaddr(struct TCP_Server_Info *server)
                return rc;
        }
 
+       spin_lock(&cifs_tcp_ses_lock);
        rc = cifs_convert_address((struct sockaddr *)&server->dstaddr, ipaddr,
                                  strlen(ipaddr));
+       spin_unlock(&cifs_tcp_ses_lock);
        kfree(ipaddr);
 
        return !rc ? -1 : 0;
--

2.13.6

Signature · 3 lines
Thanks,

Steve