All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steve French <smfrench@gmail.com>
To: Adam McCoy <adam@forsedomani.com>, Jeff Layton <jlayton@kernel.org>
Cc: CIFS <linux-cifs@vger.kernel.org>,
	Shyam Prasad N <nspmangalore@gmail.com>,
	Pavel Shilovsky <piastryyy@gmail.com>
Subject: Re: [PATCH] cifs: fix leaked reference on requeued write
Date: Wed, 13 May 2020 14:14:41 -0500	[thread overview]
Message-ID: <CAH2r5ms14KKspfjv7rc_vkWGMantAxoTE7p0bi66NmMzcex+tg@mail.gmail.com> (raw)
In-Reply-To: <20200513115330.5187-1-adam@forsedomani.com>

Shyam and Pavel noticed things which didn't make sense

e.g. in cifs_writepages weare putting the reference unconditionally
but in cifs_write_from_iter we are doing the same thing.   So how was
this working before - should have resulted in a reference leak and
direct i/o shouldn't have had a chance to complete??

and wouldn't there be an underrun if a retryable error with your patch
with it getting called twice?

Jeff,
Any thoughts on this?



On Wed, May 13, 2020 at 6:55 AM Adam McCoy <adam@forsedomani.com> wrote:
>
> Failed async writes that are requeued may not clean up a refcount
> on the file, which can result in a leaked open. This scenario arises
> very reliably when using persistent handles and a reconnect occurs
> while writing.
>
> cifs_writev_requeue only releases the reference if the write fails
> (rc != 0). The server->ops->async_writev operation will take its own
> reference, so the initial reference can always be released.
>
> Signed-off-by: Adam McCoy <adam@forsedomani.com>
> ---
>  fs/cifs/cifssmb.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
> index 182b864b3075..5014a82391ff 100644
> --- a/fs/cifs/cifssmb.c
> +++ b/fs/cifs/cifssmb.c
> @@ -2152,8 +2152,8 @@ cifs_writev_requeue(struct cifs_writedata *wdata)
>                         }
>                 }
>
> +               kref_put(&wdata2->refcount, cifs_writedata_release);
>                 if (rc) {
> -                       kref_put(&wdata2->refcount, cifs_writedata_release);
>                         if (is_retryable_error(rc))
>                                 continue;
>                         i += nr_pages;
> --
> 2.17.1
>


--
Thanks,

Steve

  reply	other threads:[~2020-05-13 19:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-13 11:53 [PATCH] cifs: fix leaked reference on requeued write Adam McCoy
2020-05-13 19:14 ` Steve French [this message]
2020-05-13 21:04   ` Steve French
2020-05-14  1:17     ` Adam McCoy
2020-05-14 22:13       ` Pavel Shilovsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAH2r5ms14KKspfjv7rc_vkWGMantAxoTE7p0bi66NmMzcex+tg@mail.gmail.com \
    --to=smfrench@gmail.com \
    --cc=adam@forsedomani.com \
    --cc=jlayton@kernel.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=nspmangalore@gmail.com \
    --cc=piastryyy@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.