diff mbox series

cifs: protect updating server->dstaddr with a spinlock

Message ID 20200421023739.10708-1-lsahlber@redhat.com (mailing list archive)
State New, archived
Headers show
Series cifs: protect updating server->dstaddr with a spinlock | expand

Commit Message

Ronnie Sahlberg April 21, 2020, 2:37 a.m. UTC
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().

Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
---
 fs/cifs/connect.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Jeff Layton April 21, 2020, 10:04 a.m. UTC | #1
On Tue, 2020-04-21 at 12:37 +1000, Ronnie Sahlberg wrote:
> 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().
> 
> Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
> ---
>  fs/cifs/connect.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
> index 95b3ab0ca8c0..63830f228b4a 100644
> --- a/fs/cifs/connect.c
> +++ b/fs/cifs/connect.c
> @@ -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;

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Steve French April 21, 2020, 3:04 p.m. UTC | #2
merged into cifs-2.6.git for-next

On Mon, Apr 20, 2020 at 9:38 PM Ronnie Sahlberg <lsahlber@redhat.com> wrote:
>
> 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().
>
> Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
> ---
>  fs/cifs/connect.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
> index 95b3ab0ca8c0..63830f228b4a 100644
> --- a/fs/cifs/connect.c
> +++ b/fs/cifs/connect.c
> @@ -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
>
diff mbox series

Patch

diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 95b3ab0ca8c0..63830f228b4a 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -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;