Re: [PATCH 2/3] cifs: fix session state check in reconnect to avoid use-after-free issue

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

 



On Mon, Jun 26, 2023 at 9:24 AM Winston Wen <wentao@xxxxxxxxxxxxx> wrote:
>
> Don't collect exiting session in smb2_reconnect_server(), because it
> will be released soon.
>
> Note that the exiting session will stay in server->smb_ses_list until
> it complete the cifs_free_ipc() and logoff() and then delete itself
> from the list.
>
> Signed-off-by: Winston Wen <wentao@xxxxxxxxxxxxx>
> ---
>  fs/smb/client/smb2pdu.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c
> index 17fe212ab895..e04766fe6f80 100644
> --- a/fs/smb/client/smb2pdu.c
> +++ b/fs/smb/client/smb2pdu.c
> @@ -3797,6 +3797,12 @@ void smb2_reconnect_server(struct work_struct *work)
>
>         spin_lock(&cifs_tcp_ses_lock);
>         list_for_each_entry(ses, &pserver->smb_ses_list, smb_ses_list) {
> +               spin_lock(&ses->ses_lock);
> +               if (ses->ses_status == SES_EXITING) {
> +                       spin_unlock(&ses->ses_lock);
> +                       continue;
> +               }
> +               spin_unlock(&ses->ses_lock);
>
>                 tcon_selected = false;
>
> --
> 2.40.1
>

Hi Winston,

We already have this check in smb2_reconnect, which gets called from
smb2_reconnect_server.
But one additional check here will not hurt.

Reviewed-by: Shyam Prasad N <sprasad@xxxxxxxxxxxxx>

-- 
Regards,
Shyam




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

  Powered by Linux