From: Markus Pargmann <mpa@pengutronix.de>
To: Ben Hutchings <ben@decadent.org.uk>
Cc: Jens Axboe <axboe@kernel.dk>,
linux-kernel@vger.kernel.org, nbd-general@lists.sourceforge.net,
kernel@pengutronix.de, Michal Belczyk <belczyk@bsd.krakow.pl>,
Hermann Lauer <Hermann.Lauer@iwr.uni-heidelberg.de>
Subject: Re: [PATCH 01/10] nbd: Fix timeout detection
Date: Thu, 1 Oct 2015 08:04:36 +0200 [thread overview]
Message-ID: <20151001060436.GN19121@pengutronix.de> (raw)
In-Reply-To: <1443400064.2517.16.camel@decadent.org.uk>
[-- Attachment #1: Type: text/plain, Size: 2393 bytes --]
Hi,
On Mon, Sep 28, 2015 at 01:27:44AM +0100, Ben Hutchings wrote:
> On Mon, 2015-08-17 at 08:20 +0200, Markus Pargmann wrote:
> > At the moment the nbd timeout just detects hanging tcp operations. This
> > is not enough to detect a hanging or bad connection as expected of a
> > timeout.
> >
> > This patch redesigns the timeout detection to include some more cases.
> > The timeout is now in relation to replies from the server. If the server
> > does not send replies within the timeout the connection will be shut
> > down.
> >
> > The patch adds a continous timer 'timeout_timer' that is setup in one of
> > two cases:
> > - The request list is empty and we are sending the first request out to
> > the server. We want to have a reply within the given timeout,
> > otherwise we consider the connection to be dead.
> > - A server response was received. This means the server is still
> > communicating with us. The timer is reset to the timeout value.
> >
> > The timer is not stopped if the list becomes empty. It will just trigger
> > a timeout which will directly leave the handling routine again as the
> > request list is empty.
> >
> > The whole patch does not use any additional explicit locking. The
> > list_empty() calls are safe to be used concurrently. The timer is locked
> > internally as we just use mod_timer and del_timer_sync().
>
> This is crazy. The timer is locked internally but the tasks are not.
> So it is possible for the timeout handler to kill a task after it
> exited from nbd_do_it()/nbd_thread_recv(), or after it exited entirely
> (use-after-free).
Indeed, thanks. I am working on a patch to fix this issue.
Best Regards,
Markus
>
> [...]
> > +> > task = READ_ONCE(nbd->task_send);
> > +> > if (task)
> > +> > > force_sig(SIGKILL, nbd->task_send);
> [...]
>
> And this is just... what? What is the point of using READ_ONCE() if
> you're going to look up nbd->task_send again?
>
> Ben.
>
> --
> Ben Hutchings
> All extremists should be taken out and shot.
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2015-10-01 6:04 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-17 6:19 [PULL 00/10] NBD updates for 4.3 Markus Pargmann
2015-08-17 6:20 ` [PATCH 01/10] nbd: Fix timeout detection Markus Pargmann
2015-09-28 0:27 ` Ben Hutchings
2015-10-01 6:04 ` Markus Pargmann [this message]
2015-10-06 18:03 ` [PATCH] nbd: Add locking for tasks Markus Pargmann
2015-10-08 20:14 ` Ben Hutchings
2015-10-08 20:21 ` Jens Axboe
2015-08-17 6:20 ` [PATCH 02/10] nbd: sock_shutdown, remove conditional lock Markus Pargmann
2015-08-17 6:20 ` [PATCH 03/10] nbd: restructure sock_shutdown Markus Pargmann
2015-08-17 6:20 ` [PATCH 04/10] nbd: Remove 'harderror' and propagate error properly Markus Pargmann
2015-08-17 6:20 ` [PATCH 05/10] nbd: Move clear queue debug message Markus Pargmann
2015-08-17 6:20 ` [PATCH 06/10] nbd: Remove variable 'pid' Markus Pargmann
2015-08-17 6:20 ` [PATCH 07/10] nbd: Add debugfs entries Markus Pargmann
2015-08-17 6:20 ` [PATCH 08/10] nbd: Change 'disconnect' to be boolean Markus Pargmann
2015-08-17 6:20 ` [PATCH 09/10] nbd: Rename functions for clearness of recv/send path Markus Pargmann
2015-08-17 6:20 ` [PATCH 10/10] nbd: flags is a u32 variable Markus Pargmann
2015-08-17 14:24 ` [PULL 00/10] NBD updates for 4.3 Jens Axboe
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=20151001060436.GN19121@pengutronix.de \
--to=mpa@pengutronix.de \
--cc=Hermann.Lauer@iwr.uni-heidelberg.de \
--cc=axboe@kernel.dk \
--cc=belczyk@bsd.krakow.pl \
--cc=ben@decadent.org.uk \
--cc=kernel@pengutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=nbd-general@lists.sourceforge.net \
/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