[{"id":2137749,"web_url":"http://patchwork.ozlabs.org/comment/2137749/","msgid":"<a7d73404-3b61-22f5-626d-6c4791c609b0@redhat.com>","list_archive_url":null,"date":"2019-04-02T22:40:47","subject":"Re: [Qemu-devel] [PULL 10/14] nbd/client: Reject inaccessible tail\n\tof inconsistent server","submitter":{"id":6591,"url":"http://patchwork.ozlabs.org/api/people/6591/","name":"Eric Blake","email":"eblake@redhat.com"},"content":"On 4/1/19 9:08 AM, Eric Blake wrote:\n> The NBD spec suggests that a server should never advertise a size\n> inconsistent with its minimum block alignment, as that tail is\n> effectively inaccessible to a compliant client obeying those block\n> constraints. Since we have a habit of rounding up rather than\n> truncating, to avoid losing the last few bytes of user input, and we\n> cannot access the tail when the server advertises bogus block sizing,\n> abort the connection to alert the server to fix their bug.  And\n> rejecting such servers matches what we already did for a min_block\n> that was not a power of 2 or which was larger than max_block.\n> \n> Does not impact either qemu (which always sends properly aligned\n> sizes) or nbdkit (which does not send minimum block requirements yet);\n> so this is mostly aimed at new NBD server implementations, and ensures\n> that the rest of our code can assume the size is aligned.\n> \n> Signed-off-by: Eric Blake <eblake@redhat.com>\n> Message-Id: <20190330155704.24191-1-eblake@redhat.com>\n> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>\n> ---\n>  nbd/client.c | 8 ++++++++\n>  1 file changed, 8 insertions(+)\n> \n> diff --git a/nbd/client.c b/nbd/client.c\n> index de7da48246b..427980bdd22 100644\n> --- a/nbd/client.c\n> +++ b/nbd/client.c\n> @@ -426,6 +426,14 @@ static int nbd_opt_info_or_go(QIOChannel *ioc, uint32_t opt,\n>                  nbd_send_opt_abort(ioc);\n>                  return -1;\n>              }\n> +            if (info->min_block &&\n> +                !QEMU_IS_ALIGNED(info->size, info->min_block)) {\n> +                error_setg(errp, \"export size %\" PRIu64 \"is not multiple of \"\n\nMissing a space in the error message. If I have any other patches worthy\nof an -rc3 pull request, I'll do the obvious fix then.","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=209.51.188.17; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdmarc=fail (p=none dis=none) header.from=redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [209.51.188.17])\n\t(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 44Ykhr4Twlz9sP7\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed,  3 Apr 2019 09:41:28 +1100 (AEDT)","from localhost ([127.0.0.1]:46240 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1hBS5t-0004gZ-Or\n\tfor incoming@patchwork.ozlabs.org; Tue, 02 Apr 2019 18:41:25 -0400","from eggs.gnu.org ([209.51.188.92]:58447)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <eblake@redhat.com>) id 1hBS5O-0004eJ-Km\n\tfor qemu-devel@nongnu.org; Tue, 02 Apr 2019 18:40:55 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <eblake@redhat.com>) id 1hBS5N-0006WN-LS\n\tfor qemu-devel@nongnu.org; Tue, 02 Apr 2019 18:40:54 -0400","from mx1.redhat.com ([209.132.183.28]:48108)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <eblake@redhat.com>)\n\tid 1hBS5L-0006Mi-36; Tue, 02 Apr 2019 18:40:51 -0400","from smtp.corp.redhat.com\n\t(int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 8EB1383F40;\n\tTue,  2 Apr 2019 22:40:49 +0000 (UTC)","from [10.3.116.168] (ovpn-116-168.phx2.redhat.com [10.3.116.168])\n\tby smtp.corp.redhat.com (Postfix) with ESMTPS id AE9181001DD8;\n\tTue,  2 Apr 2019 22:40:48 +0000 (UTC)"],"To":"qemu-devel@nongnu.org","References":"<20190401140903.19186-1-eblake@redhat.com>\n\t<20190401140903.19186-11-eblake@redhat.com>","From":"Eric Blake <eblake@redhat.com>","Openpgp":"preference=signencrypt","Autocrypt":"addr=eblake@redhat.com; keydata=\n\txsBNBEvHyWwBCACw7DwsQIh0kAbUXyqhfiKAKOTVu6OiMGffw2w90Ggrp4bdVKmCaEXlrVLU\n\txphBM8mb+wsFkU+pq9YR621WXo9REYVIl0FxKeQo9dyQBZ/XvmUMka4NOmHtFg74nvkpJFCD\n\tTUNzmqfcjdKhfFV0d7P/ixKQeZr2WP1xMcjmAQY5YvQ2lUoHP43m8TtpB1LkjyYBCodd+LkV\n\tGmCx2Bop1LSblbvbrOm2bKpZdBPjncRNob73eTpIXEutvEaHH72LzpzksfcKM+M18cyRH+nP\n\tsAd98xIbVjm3Jm4k4d5oQyE2HwOur+trk2EcxTgdp17QapuWPwMfhaNq3runaX7x34zhABEB\n\tAAHNHkVyaWMgQmxha2UgPGVibGFrZUByZWRoYXQuY29tPsLAegQTAQgAJAIbAwULCQgHAwUV\n\tCgkICwUWAgMBAAIeAQIXgAUCS8fL9QIZAQAKCRCnoWtKJSdDahBHCACbl/5FGkUqJ89GAjeX\n\tRjpAeJtdKhujir0iS4CMSIng7fCiGZ0fNJCpL5RpViSo03Q7l37ss+No+dJI8KtAp6ID+PMz\n\twTJe5Egtv/KGUKSDvOLYJ9WIIbftEObekP+GBpWP2+Kbp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.com>","Date":"Tue, 2 Apr 2019 17:40:47 -0500","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101\n\tThunderbird/60.6.0","MIME-Version":"1.0","In-Reply-To":"<20190401140903.19186-11-eblake@redhat.com>","Content-Type":"multipart/signed; micalg=pgp-sha256;\n\tprotocol=\"application/pgp-signature\";\n\tboundary=\"CNGuY8g3aKdo97p01V0F5h8MDQuM2f60R\"","X-Scanned-By":"MIMEDefang 2.84 on 10.5.11.22","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.27]);\n\tTue, 02 Apr 2019 22:40:49 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]","X-Received-From":"209.132.183.28","X-Content-Filtered-By":"Mailman/MimeDel 2.1.21","Subject":"Re: [Qemu-devel] [PULL 10/14] nbd/client: Reject inaccessible tail\n\tof inconsistent server","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,\n\t\"open list:Network Block Dev...\" <qemu-block@nongnu.org>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}}]