cifs: protect updating server->dstaddr with a spinlock
authorRonnie Sahlberg <lsahlber@redhat.com>
Tue, 21 Apr 2020 02:37:39 +0000 (12:37 +1000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 10 May 2020 08:28:01 +0000 (10:28 +0200)
[ Upstream commit fada37f6f62995cc449b36ebba1220594bfe55fe ]

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 address from
reconn_set_ipaddr().

Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/cifs/connect.c

index f2707ff..c018d16 100644 (file)
@@ -341,8 +341,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;