Re: [PATCH][CIFS] make locking consistent around the server session status

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Steve French <smfrench@xxxxxxxxx> writes:
> There were three places where we were not taking the spinlock
> around updates to server->tcpStatus when it was being modified.
> To be consistent (also removes Coverity warning) and to remove
> possibility of race best to lock all places where it is updated.

If we lock for writing we also need to lock for reading otherwise the
locking isn't protecting anything.
> --- a/fs/cifs/connect.c
> +++ b/fs/cifs/connect.c
> @@ -1358,7 +1358,9 @@ cifs_get_tcp_session(struct smb3_fs_context *ctx)
>   * to the struct since the kernel thread not created yet
>   * no need to spinlock this init of tcpStatus or srv_count

    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

There is comment just on top saying no need to spinlock.

>   */
> + spin_lock(&GlobalMid_Lock);
>   tcp_ses->tcpStatus = CifsNew;
> + spin_unlock(&GlobalMid_Lock);
>   ++tcp_ses->srv_count;

Cheers,
-- 
Aurélien Aptel / SUSE Labs Samba Team
GPG: 1839 CB5F 9F5B FB9B AA97  8C99 03C8 A49B 521B D5D3
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg, DE
GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 247165 (AG München)





[Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux