From: Eric Blake <eblake@redhat.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
qemu-block@nongnu.org, qemu-devel@nongnu.org
Cc: kwolf@redhat.com, pbonzini@redhat.com, den@openvz.org,
P J P <ppandit@redhat.com>,
mreitz@redhat.com
Subject: Re: [Qemu-devel] [Qemu-block] [PATCH 06/17] block/nbd-client: fix nbd_read_reply_entry
Date: Mon, 7 Aug 2017 10:33:08 -0500 [thread overview]
Message-ID: <ec30e36d-e6b2-78f6-3cf9-eb8ef12a0532@redhat.com> (raw)
In-Reply-To: <b204c5ab-2d4c-315d-7fe7-2111559052a8@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 3197 bytes --]
On 08/07/2017 10:13 AM, Eric Blake wrote:
> On 08/07/2017 07:56 AM, Vladimir Sementsov-Ogievskiy wrote:
>> 07.08.2017 14:52, Eric Blake wrote:
>>> On 08/04/2017 10:14 AM, Vladimir Sementsov-Ogievskiy wrote:
>>>> Set reply.handle to 0 on error path to prevent normal path of
>>>> nbd_co_receive_reply.
>
> ...and the client is recognizing that the server sent garbage, but then
> proceeds to handle the packet anyway. The ideal reaction is that the
> client should disconnect from the server, rather than handle the packet.
> But because it didn't do that, the client is now unable to receive any
> future messages from the server. Compare the traces of:
>
> followed by a clean disconnect; vs. the buggy server:
>
> 29148@1502118384.385133:nbd_opt_go_success Export is good to go
> 29148@1502118384.385321:nbd_send_request Sending request to server: {
> .from = 0, .len = 1, .handle = 94152262559840, .flags = 0x0, .type = 0
> (read) }
> 29148@1502118396.494643:nbd_receive_reply Got reply: { magic =
> 0x1446698, .error = 0, handle = 94152262559840 }
> invalid magic (got 0x1446698)
> read 1/1 bytes at offset 0
> 1 bytes, 1 ops; 0:00:12.10 (0.082581 bytes/sec and 0.0826 ops/sec)
> 29148@1502118396.494746:nbd_send_request Sending request to server: {
> .from = 0, .len = 0, .handle = 94152262559840, .flags = 0x0, .type = 3
> (flush) }
>
> where the client is now hung. Thankfully, the client is blocked in an
> idle loop (not eating CPU), so I don't know if this counts as the
> ability for a malicious server to cause a denial of service against qemu
> as an NBD client (in general, being unable to read further data from the
> server because client internal state is now botched is not that much
> different from being unable to read further data from the server because
> the client hung up on the invalid server), unless there is some way to
> cause qemu to die from an assertion failure rather than just get stuck.
With just patch 6/17 applied, the client still hangs, but this time with
a different trace:
30053@1502119637.604092:nbd_opt_go_success Export is good to go
30053@1502119637.604256:nbd_send_request Sending request to server: {
.from = 0, .len = 1, .handle = 94716063746144, .flags = 0x0, .type = 0
(read) }
30053@1502119649.070156:nbd_receive_reply Got reply: { magic =
0x1446698, .error = 0, handle = 94716063746144 }
invalid magic (got 0x1446698)
read failed: Input/output error
30053@1502119649.070243:nbd_send_request Sending request to server: {
.from = 0, .len = 0, .handle = 94716063746144, .flags = 0x0, .type = 3
(flush) }
The client still tried to send a flush request to the server, when it
should REALLY quit talking to the server at all and just disconnect,
because the moment the client recognizes that the server has sent
garbage is the moment that the client can no longer assume that the
server will react correctly to any further commands.
So I don't think your patch is quite correct, even if you have
identified a shortfall in our client code.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]
next prev parent reply other threads:[~2017-08-07 15:33 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-04 15:14 [Qemu-devel] [PATCH 00/17] nbd client refactoring and fixing Vladimir Sementsov-Ogievskiy
2017-08-04 15:14 ` [Qemu-devel] [PATCH 01/17] nbd/client: fix nbd_opt_go Vladimir Sementsov-Ogievskiy
2017-08-07 11:31 ` Eric Blake
2017-08-04 15:14 ` [Qemu-devel] [PATCH 02/17] nbd/client: refactor nbd_read_eof Vladimir Sementsov-Ogievskiy
2017-08-07 11:42 ` Eric Blake
2017-08-07 12:05 ` Vladimir Sementsov-Ogievskiy
2017-08-25 19:22 ` Eric Blake
2017-08-04 15:14 ` [Qemu-devel] [PATCH 03/17] nbd/client: refactor nbd_receive_reply Vladimir Sementsov-Ogievskiy
2017-08-25 21:16 ` Eric Blake
2017-08-04 15:14 ` [Qemu-devel] [PATCH 04/17] nbd/client: fix nbd_send_request to return int Vladimir Sementsov-Ogievskiy
2017-08-07 8:23 ` Daniel P. Berrange
2017-08-07 8:57 ` Vladimir Sementsov-Ogievskiy
2017-08-07 11:49 ` Eric Blake
2017-08-07 12:03 ` Daniel P. Berrange
2017-08-25 21:20 ` Eric Blake
2017-08-04 15:14 ` [Qemu-devel] [PATCH 05/17] block/nbd-client: get rid of ssize_t Vladimir Sementsov-Ogievskiy
2017-08-04 16:11 ` Daniel P. Berrange
2017-08-07 6:57 ` Vladimir Sementsov-Ogievskiy
2017-08-07 8:24 ` Daniel P. Berrange
2017-08-25 21:25 ` Eric Blake
2017-08-04 15:14 ` [Qemu-devel] [PATCH 06/17] block/nbd-client: fix nbd_read_reply_entry Vladimir Sementsov-Ogievskiy
2017-08-07 11:52 ` Eric Blake
2017-08-07 12:56 ` Vladimir Sementsov-Ogievskiy
2017-08-07 15:13 ` Eric Blake
2017-08-07 15:33 ` Eric Blake [this message]
2017-08-07 16:09 ` [Qemu-devel] [Qemu-block] " Vladimir Sementsov-Ogievskiy
2017-08-07 16:18 ` Eric Blake
2017-08-04 15:14 ` [Qemu-devel] [PATCH 07/17] block/nbd-client: refactor request send/receive Vladimir Sementsov-Ogievskiy
2017-08-25 18:49 ` Eric Blake
2017-08-25 19:08 ` Eric Blake
2017-08-04 15:14 ` [Qemu-devel] [PATCH 08/17] block/nbd-client: rename nbd_recv_coroutines_enter_all Vladimir Sementsov-Ogievskiy
2017-08-25 18:43 ` Eric Blake
2017-08-25 21:48 ` Eric Blake
2017-08-04 15:14 ` [Qemu-devel] [PATCH 09/17] block/nbd-client: move nbd_co_receive_reply content into nbd_co_request Vladimir Sementsov-Ogievskiy
2017-08-25 18:52 ` Eric Blake
2017-08-04 15:14 ` [Qemu-devel] [PATCH 10/17] block/nbd-client: move nbd_coroutine_end " Vladimir Sementsov-Ogievskiy
2017-08-25 21:57 ` Eric Blake
2017-08-04 15:14 ` [Qemu-devel] [PATCH 11/17] block/nbd-client: fix nbd_co_request: set s->reply.handle to 0 on error Vladimir Sementsov-Ogievskiy
2017-08-07 11:55 ` Eric Blake
2017-08-07 13:17 ` Vladimir Sementsov-Ogievskiy
2017-08-04 15:14 ` [Qemu-devel] [PATCH 12/17] block/nbd-client: refactor nbd_co_request Vladimir Sementsov-Ogievskiy
2017-08-04 15:14 ` [Qemu-devel] [PATCH 13/17] block/nbd-client: refactor NBDClientSession.recv_coroutine Vladimir Sementsov-Ogievskiy
2017-08-04 15:14 ` [Qemu-devel] [PATCH 14/17] block/nbd-client: exit reply-reading coroutine on incorrect handle Vladimir Sementsov-Ogievskiy
2017-08-04 15:14 ` [Qemu-devel] [PATCH 15/17] block/nbd-client: refactor reading reply Vladimir Sementsov-Ogievskiy
2017-08-04 15:14 ` [Qemu-devel] [PATCH 16/17] block/nbd-client: drop reply field from NBDClientSession Vladimir Sementsov-Ogievskiy
2017-08-04 15:14 ` [Qemu-devel] [PATCH 17/17] block/nbd-client: always return EIO on and after the first io channel error Vladimir Sementsov-Ogievskiy
2017-08-16 21:21 ` [Qemu-devel] [PATCH 00/17] nbd client refactoring and fixing Eric Blake
2017-08-17 7:37 ` Vladimir Sementsov-Ogievskiy
2017-08-25 22:10 ` Eric Blake
2017-08-29 22:12 ` Eric Blake
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=ec30e36d-e6b2-78f6-3cf9-eb8ef12a0532@redhat.com \
--to=eblake@redhat.com \
--cc=den@openvz.org \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=ppandit@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=vsementsov@virtuozzo.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 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).