From: Miklos Szeredi <miklos@szeredi.hu>
To: Kirill Tkhai <ktkhai@virtuozzo.com>
Cc: linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 1/7] fuse: Check for fc->connected in fuse_dev_alloc()
Date: Wed, 23 Jan 2019 11:24:03 +0100 [thread overview]
Message-ID: <CAJfpegtc6+hCm7ye4t0NHzd2H9PoeD-2XiQ_7aUUiNNQDQwuwQ@mail.gmail.com> (raw)
In-Reply-To: <ae6245a6-d982-ee43-8275-bc5aa5453f58@virtuozzo.com>
On Wed, Jan 23, 2019 at 10:55 AM Kirill Tkhai <ktkhai@virtuozzo.com> wrote:
>
> On 23.01.2019 12:45, Miklos Szeredi wrote:
> > On Fri, Jan 18, 2019 at 1:28 PM Kirill Tkhai <ktkhai@virtuozzo.com> wrote:
> >>
> >> On 18.01.2019 15:07, Miklos Szeredi wrote:
> >>> On Tue, Jan 15, 2019 at 11:19 AM Kirill Tkhai <ktkhai@virtuozzo.com> wrote:
> >>>>
> >>>> fuse_dev_alloc() may be called after fc->connected
> >>>> is dropped (from ioctl), so here we add sanity check
> >>>> for that case.
> >>>
> >>> AFAICS this is not fixing a bug; i.e. even if the fuse_dev is added to
> >>> the fuse_conn's list after disconnection there would be no leak.
> >>>
> >>> In other words, it's irrelevant whether the connection reset comes
> >>> just before the ioctl completes or just after. Or am I missing
> >>> something?
> >>
> >> Yeah, there won't be a leak. The only problem I see, userspace daemon
> >> may become waiting in fuse_dev_do_read() after abort is finished.
> >
> > By that time fiq->connected will be reset, so fuse_dev_do_read() will
> > return ENODEV/ECONNABORTED.
> >
> > Am I missing something?
>
> I mean:
>
> [cpu0] [cpu1]
> fuse_device_clone()
> fuse_dev_alloc() fuse_abort_conn()
> spin_lock(&fc->lock)
> list_for_each_entry(fud, &fc->devices, entry)
> fpq->connected = 0
> spin_unlock(&fc->lock)
> spin_lock(&fc->lock);
> list_add_tail(&fud->entry, &fc->devices);
Okay, so there's missing
fpq->connected = fc->connected;
here.
> spin_unlock(&fc->lock);
> ...
> fuse_dev_do_read()
> wait_event_interruptible_exclusive_locked() <-- wait forever
That will exit immediately, because it checks fiq->connected (not
fpq->connected) which is already zero.
Thanks,
Miklos
next prev parent reply other threads:[~2019-01-23 10:24 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-15 10:19 [PATCH 0/7] fuse: Improve disconnect scheme and avoid taking fpq->lock on hot paths Kirill Tkhai
2019-01-15 10:19 ` [PATCH 1/7] fuse: Check for fc->connected in fuse_dev_alloc() Kirill Tkhai
2019-01-18 12:07 ` Miklos Szeredi
2019-01-18 12:28 ` Kirill Tkhai
2019-01-23 9:45 ` Miklos Szeredi
2019-01-23 9:55 ` Kirill Tkhai
2019-01-23 10:24 ` Miklos Szeredi [this message]
2019-01-15 10:19 ` [PATCH 2/7] fuse: Move flush_bg_queue() up in fuse_abort_conn() Kirill Tkhai
2019-01-15 10:19 ` [PATCH 3/7] fuse: Drop and reacquire fc->lock in middle of fuse_abort_conn() Kirill Tkhai
2019-01-15 10:19 ` [PATCH 4/7] fuse: Add fud pointer to struct fuse_copy_state Kirill Tkhai
2019-01-15 10:19 ` [PATCH 5/7] fuse: Introduce generic fuse_copy_aborted() Kirill Tkhai
2019-01-17 9:48 ` Miklos Szeredi
2019-01-15 10:19 ` [PATCH 6/7] fuse: Kill unused FR_ABORTED, FR_LOCKED and FR_PRIVATE flags Kirill Tkhai
2019-01-15 10:19 ` [PATCH 7/7] fuse: Kill fuse_pqueue::io list and avoid taking fpq->lock on hot paths Kirill Tkhai
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=CAJfpegtc6+hCm7ye4t0NHzd2H9PoeD-2XiQ_7aUUiNNQDQwuwQ@mail.gmail.com \
--to=miklos@szeredi.hu \
--cc=ktkhai@virtuozzo.com \
--cc=linux-fsdevel@vger.kernel.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).