lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAKywueTOHQq8iEiQRHer7yGstvKEF7SrSgNqmETYV73uEgqA+A@mail.gmail.com>
Date:   Sat, 16 Mar 2019 11:03:33 -0700
From:   Pavel Shilovsky <piastryyy@...il.com>
To:     Long Li <longli@...rosoft.com>
Cc:     Steve French <sfrench@...ba.org>,
        linux-cifs <linux-cifs@...r.kernel.org>,
        samba-technical <samba-technical@...ts.samba.org>,
        Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [Patch v2 2/2] CIFS: Fix an issue with re-sending rdata when
 transport returning -EAGAIN

пт, 15 мар. 2019 г. в 00:56, Long Li <longli@...uxonhyperv.com>:
>
> From: Long Li <longli@...rosoft.com>
>
> When sending a rdata, transport may return -EAGAIN. In this case
> we should re-obtain credits because the session may have been
> reconnected.
>
> Change in v2: adjust_credits before re-sending
>
> Signed-off-by: Long Li <longli@...rosoft.com>
> ---
>  fs/cifs/file.c | 71 +++++++++++++++++++++++++++++++++-------------------------
>  1 file changed, 41 insertions(+), 30 deletions(-)
>
> diff --git a/fs/cifs/file.c b/fs/cifs/file.c
> index 321df1d27422..9d90cc07e38b 100644
> --- a/fs/cifs/file.c
> +++ b/fs/cifs/file.c
> @@ -3347,44 +3347,55 @@ static int cifs_resend_rdata(struct cifs_readdata *rdata,
>         struct TCP_Server_Info *server =
>                 tlink_tcon(rdata->cfile->tlink)->ses->server;
>
> -       /*
> -        * Wait for credits to resend this rdata.
> -        * Note: we are attempting to resend the whole rdata not in segments
> -        */
>         do {
> -               rc = server->ops->wait_mtu_credits(server, rdata->bytes,
> +               if (rdata->cfile->invalidHandle) {
> +                       rc = cifs_reopen_file(rdata->cfile, true);
> +                       if (rc == -EAGAIN)
> +                               continue;
> +                       else if (rc)
> +                               break;
> +               }
> +
> +               /*
> +                * Wait for credits to resend this rdata.
> +                * Note: we are attempting to resend the whole rdata not in
> +                * segments
> +                */
> +               do {
> +                       rc = server->ops->wait_mtu_credits(server, rdata->bytes,
>                                                 &rsize, &credits);
>
> -               if (rc)
> -                       goto out;
> +                       if (rc)
> +                               goto fail;
>
> -               if (rsize < rdata->bytes) {
> -                       add_credits_and_wake_if(server, &credits, 0);
> -                       msleep(1000);
> -               }
> -       } while (rsize < rdata->bytes);
> +                       if (rsize < rdata->bytes) {
> +                               add_credits_and_wake_if(server, &credits, 0);
> +                               msleep(1000);
> +                       }
> +               } while (rsize < rdata->bytes);
> +               rdata->credits = credits;
>
> -       rdata->credits = credits;
> -       rc = -EAGAIN;
> -       while (rc == -EAGAIN) {
> -               rc = 0;
> -               if (rdata->cfile->invalidHandle)
> -                       rc = cifs_reopen_file(rdata->cfile, true);
> -               if (!rc)
> -                       rc = server->ops->async_readv(rdata);
> -       }
> +               rc = adjust_credits(server, &rdata->credits, rdata->bytes);
> +               if (!rc) {
> +                       if (rdata->cfile->invalidHandle)
> +                               rc = -EAGAIN;
> +                       else
> +                               rc = server->ops->async_readv(rdata);
> +               }
>
> -       if (!rc) {
> -               /* Add to aio pending list */
> -               list_add_tail(&rdata->list, rdata_list);
> -               return 0;
> -       }
> +               /* If the read was successfully sent, we are done */
> +               if (!rc) {
> +                       /* Add to aio pending list */
> +                       list_add_tail(&rdata->list, rdata_list);
> +                       return 0;
> +               }
>
> -       add_credits_and_wake_if(server, &rdata->credits, 0);
> -out:
> -       kref_put(&rdata->refcount,
> -               cifs_uncached_readdata_release);
> +               /* Roll back credits and retry if needed */
> +               add_credits_and_wake_if(server, &rdata->credits, 0);
> +       } while (rc == -EAGAIN);
>
> +fail:
> +       kref_put(&rdata->refcount, cifs_uncached_readdata_release);
>         return rc;
>  }
>
> --
> 2.14.1
>

Reviewed-by: Pavel Shilovsky <pshilov@...rosoft.com>

--
Best regards,
Pavel Shilovsky

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ