From: Miklos Szeredi <miklos@szeredi.hu>
To: Pradeep P V K <pragalla@codeaurora.org>
Cc: stummala@codeaurora.org, linux-kernel@vger.kernel.org,
linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH V1] fuse: Set fuse request error upon fuse abort connection
Date: Mon, 21 Jun 2021 09:48:45 +0200 [thread overview]
Message-ID: <YNBEXVUPgqYbraq6@miu.piliscsaba.redhat.com> (raw)
In-Reply-To: <1618582752-26178-1-git-send-email-pragalla@codeaurora.org>
On Fri, Apr 16, 2021 at 07:49:12PM +0530, Pradeep P V K wrote:
> There is a minor race in setting the fuse out request error
> between fuse_abort_conn() and fuse_dev_do_read() as explained
> below.
>
> Thread-1 Thread-2
> ======== ========
> ->fuse_simple_request() ->shutdown
> ->__fuse_request_send()
> ->queue_request() ->fuse_abort_conn()
> ->fuse_dev_do_read() ->acquire(fpq->lock)
> ->wait_for(fpq->lock) ->set err to all req's in fpq->io
> ->release(fpq->lock)
> ->acquire(fpq->lock)
> ->add req to fpq->io
>
> The above scenario may cause Thread-1 request to add into
> fpq->io list after Thread-2 sets -ECONNABORTED err to all
> its requests in fpq->io list. This leaves Thread-1 request
> with unset err and this further misleads as a completed
> request without an err set upon request_end().
>
> Handle this by setting the err appropriately.
The fix looks good, but still allows the request to block during the copy phase
after being aborted, which the FR_LOCKED/FR_ABORT bits are meant to prevent.
Here's an updated fix. It does not allow the request to be queued on the
fpq->io list after fuse_abort_conn() has aborted requests on that list.
Can you verify that it fixes the race you reported?
Thanks,
Miklos
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -1272,6 +1272,15 @@ static ssize_t fuse_dev_do_read(struct f
goto restart;
}
spin_lock(&fpq->lock);
+ /*
+ * Must not put request on fpq->io queue after having been shut down by
+ * fuse_abort_conn()
+ */
+ if (!fpq->connected) {
+ req->out.h.error = err = -ECONNABORTED;
+ goto out_end;
+
+ }
list_add(&req->list, &fpq->io);
spin_unlock(&fpq->lock);
cs->req = req;
prev parent reply other threads:[~2021-06-21 7:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-16 14:19 [PATCH V1] fuse: Set fuse request error upon fuse abort connection Pradeep P V K
2021-05-10 7:52 ` pragalla
2021-05-10 14:05 ` Miklos Szeredi
2021-06-21 7:48 ` Miklos Szeredi [this message]
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=YNBEXVUPgqYbraq6@miu.piliscsaba.redhat.com \
--to=miklos@szeredi.hu \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pragalla@codeaurora.org \
--cc=stummala@codeaurora.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).