[{"id":1766133,"web_url":"http://patchwork.ozlabs.org/comment/1766133/","msgid":"<20170911085043.GE21444@redhat.com>","list_archive_url":null,"date":"2017-09-11T08:50:43","subject":"Re: [Qemu-devel] [PATCH v2 6/6] io: Reply to ping frames","submitter":{"id":2694,"url":"http://patchwork.ozlabs.org/api/people/2694/","name":"Daniel P. Berrangé","email":"berrange@redhat.com"},"content":"On Fri, Sep 08, 2017 at 10:38:01AM -0700, Brandon Carpenter wrote:\n> Add an immediate ping reply (pong) to the outgoing stream when a ping\n> is received. Unsolicited pongs are ignored.\n> \n> Signed-off-by: Brandon Carpenter <brandon.carpenter@cypherpath.com>\n> ---\n>  io/channel-websock.c | 50 ++++++++++++++++++++++++++++++++------------------\n>  1 file changed, 32 insertions(+), 18 deletions(-)\n> \n> diff --git a/io/channel-websock.c b/io/channel-websock.c\n> index 50387050d5..175f17ce6b 100644\n> --- a/io/channel-websock.c\n> +++ b/io/channel-websock.c\n> @@ -479,7 +479,8 @@ static gboolean qio_channel_websock_handshake_io(QIOChannel *ioc,\n>  }\n>  \n>  \n> -static void qio_channel_websock_encode(QIOChannelWebsock *ioc)\n> +static void qio_channel_websock_encode_buffer(QIOChannelWebsock *ioc,\n> +                                              uint8_t opcode, Buffer *buffer)\n>  {\n>      size_t header_size;\n>      union {\n> @@ -487,33 +488,37 @@ static void qio_channel_websock_encode(QIOChannelWebsock *ioc)\n>          QIOChannelWebsockHeader ws;\n>      } header;\n>  \n> -    if (!ioc->rawoutput.offset) {\n> -        return;\n> -    }\n> -\n>      header.ws.b0 = QIO_CHANNEL_WEBSOCK_HEADER_FIELD_FIN |\n> -        (QIO_CHANNEL_WEBSOCK_OPCODE_BINARY_FRAME &\n> -         QIO_CHANNEL_WEBSOCK_HEADER_FIELD_OPCODE);\n> -    if (ioc->rawoutput.offset <\n> +        (opcode & QIO_CHANNEL_WEBSOCK_HEADER_FIELD_OPCODE);\n> +    if (buffer->offset <\n>          QIO_CHANNEL_WEBSOCK_PAYLOAD_LEN_THRESHOLD_7_BIT) {\n> -        header.ws.b1 = (uint8_t)ioc->rawoutput.offset;\n> +        header.ws.b1 = (uint8_t)buffer->offset;\n>          header_size = QIO_CHANNEL_WEBSOCK_HEADER_LEN_7_BIT;\n> -    } else if (ioc->rawoutput.offset <\n> +    } else if (buffer->offset <\n>                 QIO_CHANNEL_WEBSOCK_PAYLOAD_LEN_THRESHOLD_16_BIT) {\n>          header.ws.b1 = QIO_CHANNEL_WEBSOCK_PAYLOAD_LEN_MAGIC_16_BIT;\n> -        header.ws.u.s16.l16 = cpu_to_be16((uint16_t)ioc->rawoutput.offset);\n> +        header.ws.u.s16.l16 = cpu_to_be16((uint16_t)buffer->offset);\n>          header_size = QIO_CHANNEL_WEBSOCK_HEADER_LEN_16_BIT;\n>      } else {\n>          header.ws.b1 = QIO_CHANNEL_WEBSOCK_PAYLOAD_LEN_MAGIC_64_BIT;\n> -        header.ws.u.s64.l64 = cpu_to_be64(ioc->rawoutput.offset);\n> +        header.ws.u.s64.l64 = cpu_to_be64(buffer->offset);\n>          header_size = QIO_CHANNEL_WEBSOCK_HEADER_LEN_64_BIT;\n>      }\n>      header_size -= QIO_CHANNEL_WEBSOCK_HEADER_LEN_MASK;\n>  \n> -    buffer_reserve(&ioc->encoutput, header_size + ioc->rawoutput.offset);\n> +    buffer_reserve(&ioc->encoutput, header_size + buffer->offset);\n>      buffer_append(&ioc->encoutput, header.buf, header_size);\n> -    buffer_append(&ioc->encoutput, ioc->rawoutput.buffer,\n> -                  ioc->rawoutput.offset);\n> +    buffer_append(&ioc->encoutput, buffer->buffer, buffer->offset);\n> +}\n> +\n> +\n> +static void qio_channel_websock_encode(QIOChannelWebsock *ioc)\n> +{\n> +    if (!ioc->rawoutput.offset) {\n> +        return;\n> +    }\n> +    qio_channel_websock_encode_buffer(ioc,\n> +            QIO_CHANNEL_WEBSOCK_OPCODE_BINARY_FRAME, &ioc->rawoutput);\n>      buffer_reset(&ioc->rawoutput);\n>  }\n>  \n> @@ -558,7 +563,7 @@ static int qio_channel_websock_decode_header(QIOChannelWebsock *ioc,\n>      /* Websocket frame sanity check:\n>       * * Fragmentation is only supported for binary frames.\n>       * * All frames sent by a client MUST be masked.\n> -     * * Only binary encoding is supported.\n> +     * * Only binary and ping/pong encoding is supported.\n>       */\n>      if (!fin) {\n>          if (opcode != QIO_CHANNEL_WEBSOCK_OPCODE_BINARY_FRAME) {\n> @@ -619,6 +624,11 @@ static int qio_channel_websock_decode_payload(QIOChannelWebsock *ioc,\n>           * for purpose of unmasking, except at end of payload\n>           */\n>          if (ioc->encinput.offset < ioc->payload_remain) {\n> +            /* Wait for the entire payload before processing control frames\n> +             * because the payload will most likely be echoed back. */\n> +            if (ioc->opcode & QIO_CHANNEL_WEBSOCK_CONTROL_OPCODE_MASK) {\n> +                return QIO_CHANNEL_ERR_BLOCK;\n> +            }\n>              payload_len = ioc->encinput.offset - (ioc->encinput.offset % 4);\n>          } else {\n>              payload_len = ioc->payload_remain;\n> @@ -641,13 +651,17 @@ static int qio_channel_websock_decode_payload(QIOChannelWebsock *ioc,\n>          }\n>      }\n>  \n> -    /* Drop the payload of ping/pong packets */\n>      if (ioc->opcode == QIO_CHANNEL_WEBSOCK_OPCODE_BINARY_FRAME) {\n>          if (payload_len) {\n> +            /* binary frames are passed on */\n>              buffer_reserve(&ioc->rawinput, payload_len);\n>              buffer_append(&ioc->rawinput, ioc->encinput.buffer, payload_len);\n>          }\n> -    }\n> +    } else if (ioc->opcode == QIO_CHANNEL_WEBSOCK_OPCODE_PING) {\n> +        /* ping frames produce an immediate pong reply */\n> +        qio_channel_websock_encode_buffer(ioc,\n> +                QIO_CHANNEL_WEBSOCK_OPCODE_PONG, &ioc->encinput);\n> +    }   /* pong frames are ignored */\n\nSo qio_channel_websock_opcode_pong() takes the PING payload and adds it\nto ioc->encoutput buffer.  When the socket is later seen as writable\nthe event loop will write this buffer to the wire.\n\nI'm concerned that there is no rate limiting here though, so if a large\nnumber of PINGs are sent, and writing of the reply blocks for some reason,\nencoutput will grow without bounds.\n\nRegards,\nDaniel","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=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ext-mx09.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx09.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=berrange@redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xrM9G3r2gz9s4q\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon, 11 Sep 2017 18:51:29 +1000 (AEST)","from localhost ([::1]:56186 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 1drKRC-00016I-Rq\n\tfor incoming@patchwork.ozlabs.org; Mon, 11 Sep 2017 04:51:26 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:34543)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <berrange@redhat.com>) id 1drKQd-00014R-OB\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 04:50:53 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <berrange@redhat.com>) id 1drKQZ-0001Ob-QB\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 04:50:51 -0400","from mx1.redhat.com ([209.132.183.28]:52076)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <berrange@redhat.com>) id 1drKQZ-0001OB-GA\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 04:50:47 -0400","from smtp.corp.redhat.com\n\t(int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12])\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 4EC0322F304;\n\tMon, 11 Sep 2017 08:50:46 +0000 (UTC)","from redhat.com (unknown [10.33.36.58])\n\tby smtp.corp.redhat.com (Postfix) with ESMTPS id A94F46EC94;\n\tMon, 11 Sep 2017 08:50:45 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 4EC0322F304","Date":"Mon, 11 Sep 2017 09:50:43 +0100","From":"\"Daniel P. Berrange\" <berrange@redhat.com>","To":"Brandon Carpenter <brandon.carpenter@cypherpath.com>","Message-ID":"<20170911085043.GE21444@redhat.com>","References":"<20170724184217.21381-1-brandon.carpenter@cypherpath.com>\n\t<20170908173801.15205-7-brandon.carpenter@cypherpath.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20170908173801.15205-7-brandon.carpenter@cypherpath.com>","User-Agent":"Mutt/1.8.3 (2017-05-23)","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.12","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.38]);\n\tMon, 11 Sep 2017 08:50:46 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","Subject":"Re: [Qemu-devel] [PATCH v2 6/6] io: Reply to ping frames","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>","Reply-To":"\"Daniel P. Berrange\" <berrange@redhat.com>","Cc":"qemu-devel@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>"}},{"id":1766403,"web_url":"http://patchwork.ozlabs.org/comment/1766403/","msgid":"<1505149415.1214.1@smtp.gmail.com>","list_archive_url":null,"date":"2017-09-11T17:03:35","subject":"Re: [Qemu-devel] [PATCH v2 6/6] io: Reply to ping frames","submitter":{"id":72031,"url":"http://patchwork.ozlabs.org/api/people/72031/","name":"Brandon Carpenter","email":"brandon.carpenter@cypherpath.com"},"content":"On Mon, Sep 11, 2017 at 1:50 AM, Daniel P. Berrange \n<berrange@redhat.com> wrote:\n> I'm concerned that there is no rate limiting here though, so if a \n> large number of PINGs are sent, and writing of the reply blocks for \n> some reason, encoutput will grow without bounds.\n\nThat is a good point. How about something like this to fix it?\n\ndiff --git a/include/io/channel-websock.h b/include/io/channel-websock.h\nindex 7c896557c5..c5a8c3e96c 100644\n--- a/include/io/channel-websock.h\n+++ b/include/io/channel-websock.h\n@@ -66,6 +66,7 @@ struct QIOChannelWebsock {\n     Error *io_err;\n     gboolean io_eof;\n     uint8_t opcode;\n+ uint8_t prev_opcode;\n };\n\n /**\ndiff --git a/io/channel-websock.c b/io/channel-websock.c\nindex 175f17ce6b..a9315c01fb 100644\n--- a/io/channel-websock.c\n+++ b/io/channel-websock.c\n@@ -549,6 +549,7 @@ static int \nqio_channel_websock_decode_header(QIOChannelWebsock *ioc,\n     payload_len = header->b1 & \nQIO_CHANNEL_WEBSOCK_HEADER_FIELD_PAYLOAD_LEN;\n\n     /* Save or restore opcode. */\n+ ioc->prev_opcode = ioc->opcode;\n     if (opcode) {\n         ioc->opcode = opcode;\n     } else {\n@@ -658,9 +659,14 @@ static int \nqio_channel_websock_decode_payload(QIOChannelWebsock *ioc,\n             buffer_append(&ioc->rawinput, ioc->encinput.buffer, \npayload_len);\n         }\n     } else if (ioc->opcode == QIO_CHANNEL_WEBSOCK_OPCODE_PING) {\n- /* ping frames produce an immediate pong reply */\n- qio_channel_websock_encode_buffer(ioc,\n- QIO_CHANNEL_WEBSOCK_OPCODE_PONG, &ioc->encinput);\n+ /* Ping frames produce an immediate pong reply, unless one\n+ * is already queued, in which case they are coalesced\n+ * to avoid unbounded buffer growth.\n+ */\n+ if (!ioc->encoutput.offset || ioc->prev_opcode != \nQIO_CHANNEL_WEBSOCK_OPCODE_PING) {\n+ qio_channel_websock_encode_buffer(ioc,\n+ QIO_CHANNEL_WEBSOCK_OPCODE_PONG, &ioc->encinput);\n+ }\n     } /* pong frames are ignored */\n\n     if (payload_len) {\n\n--\nBrandon Carpenter | Software Engineer\nCypherpath, Inc.\n400 Columbia Point Drive Ste 101 | Richland, Washington USA\nOffice: (650) 713-3060","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=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=cypherpath.com header.i=@cypherpath.com\n\theader.b=\"Y5yBUrjn\"; dkim-atps=neutral"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xrZCX0P6fz9s81\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 12 Sep 2017 03:09:12 +1000 (AEST)","from localhost ([::1]:59211 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 1drSCs-0005Hj-48\n\tfor incoming@patchwork.ozlabs.org; Mon, 11 Sep 2017 13:09:10 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:59487)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <brandon.carpenter@cypherpath.com>)\n\tid 1drS7d-000108-KR\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 13:03:51 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <brandon.carpenter@cypherpath.com>)\n\tid 1drS7a-0000JF-Gh\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 13:03:45 -0400","from mail-io0-x22c.google.com ([2607:f8b0:4001:c06::22c]:35419)\n\tby eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)\n\t(Exim 4.71) (envelope-from <brandon.carpenter@cypherpath.com>)\n\tid 1drS7a-0000IU-9g\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 13:03:42 -0400","by mail-io0-x22c.google.com with SMTP id g32so12799098ioj.2\n\tfor <qemu-devel@nongnu.org>; Mon, 11 Sep 2017 10:03:40 -0700 (PDT)","from [10.10.7.25] (68-113-0-218.static.knwc.wa.charter.com.\n\t[68.113.0.218]) by smtp.gmail.com with ESMTPSA id\n\tv204sm5350571oie.17.2017.09.11.10.03.38\n\t(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tMon, 11 Sep 2017 10:03:39 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=cypherpath.com; s=google;\n\th=date:from:subject:to:cc:message-id:in-reply-to:references\n\t:mime-version; bh=2Gxi+hWowZ0eqT4ft/8XUKDhwIXxsC1WMKsN2UuCkHY=;\n\tb=Y5yBUrjncyTqKnJ5iu8o+Vvz7TX0us3qSTL0oAD0dnSHuIOUA/VCWsvYZHZ3PQtQKE\n\tOatwtQ+fD5Koq70X3MkWuGvazPXQYCJgjlpgNRz6sEpg2bNtV+9CO6jb7FMMm47OI0jS\n\tG26FEUeesmQHn2tTl9avXIhgXur8MSTjVfnmU=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:subject:to:cc:message-id:in-reply-to\n\t:references:mime-version;\n\tbh=2Gxi+hWowZ0eqT4ft/8XUKDhwIXxsC1WMKsN2UuCkHY=;\n\tb=DfXHhRrDp5GWfGbXZFEZGQHuc6yGJVFUplZO0iFNITEyCiILErMMAMKWFO3Wdi7DIh\n\tNtxQnmokREeUO+U8/yVkOJudYD+7cTGe2eh7swJnzpvrCPgNQrg9a5X9enRp8We0ApJz\n\tSCqIL5X10h9vIGm9oVGc2Q3K53Kgi6qm7McNFIQPybaQFEl3znbxDXUzZO4cJEuVxLCR\n\txkocIUiDvNvDgXm5jyMPh0iAs7CG33B9FwR5HwtMgl3tYU8GmU0oB/lCvLWKnb7Mbvr4\n\t56NvC8QOQdEd/IMni/mXch7Un7W/BkHW8NoPj/rzyco2HOdnQItleHIzOSuoD7MtEnjE\n\tsi/g==","X-Gm-Message-State":"AHPjjUjiOYct0BLI4epNsaYDsBlaruIXyM1Be2grxehd2UjkDshr1q2L\n\tbMyWduQ87cM3fy+QjJc4La7sm4GrjECdWyFD2hAUHcaqD0AgB0+/cbsFroRLcI5RaYUhKfa/m0g\n\t=","X-Google-Smtp-Source":"AOwi7QBhJb8u1EaXcAPDv+ySppMSRfOICyhA483UofUhlUBXWygVcA/SPwy/HkyFpzK5uHha7+aeag==","X-Received":"by 10.202.173.11 with SMTP id w11mr10671140oie.239.1505149420086;\n\tMon, 11 Sep 2017 10:03:40 -0700 (PDT)","Date":"Mon, 11 Sep 2017 10:03:35 -0700","From":"Brandon Carpenter <brandon.carpenter@cypherpath.com>","To":"\"Daniel P. Berrange\" <berrange@redhat.com>","Message-Id":"<1505149415.1214.1@smtp.gmail.com>","In-Reply-To":"<20170911085043.GE21444@redhat.com>","References":"<20170724184217.21381-1-brandon.carpenter@cypherpath.com>\n\t<20170908173801.15205-7-brandon.carpenter@cypherpath.com>\n\t<20170911085043.GE21444@redhat.com>","X-Mailer":"geary/makepkg~g00718198","MIME-Version":"1.0","X-detected-operating-system":"by eggs.gnu.org: Genre and OS details not\n\trecognized.","X-Received-From":"2607:f8b0:4001:c06::22c","Content-Type":"text/plain; charset=\"US-ASCII\"; format=flowed","X-Content-Filtered-By":"Mailman/MimeDel 2.1.21","Subject":"Re: [Qemu-devel] [PATCH v2 6/6] io: Reply to ping frames","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":"qemu-devel@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>"}},{"id":1766404,"web_url":"http://patchwork.ozlabs.org/comment/1766404/","msgid":"<20170911171015.GU21444@redhat.com>","list_archive_url":null,"date":"2017-09-11T17:10:15","subject":"Re: [Qemu-devel] [PATCH v2 6/6] io: Reply to ping frames","submitter":{"id":2694,"url":"http://patchwork.ozlabs.org/api/people/2694/","name":"Daniel P. Berrangé","email":"berrange@redhat.com"},"content":"On Mon, Sep 11, 2017 at 10:03:35AM -0700, Brandon Carpenter wrote:\n> On Mon, Sep 11, 2017 at 1:50 AM, Daniel P. Berrange <berrange@redhat.com>\n> wrote:\n> > I'm concerned that there is no rate limiting here though, so if a large\n> > number of PINGs are sent, and writing of the reply blocks for some\n> > reason, encoutput will grow without bounds.\n> \n> That is a good point. How about something like this to fix it?\n> \n> diff --git a/include/io/channel-websock.h b/include/io/channel-websock.h\n> index 7c896557c5..c5a8c3e96c 100644\n> --- a/include/io/channel-websock.h\n> +++ b/include/io/channel-websock.h\n> @@ -66,6 +66,7 @@ struct QIOChannelWebsock {\n>     Error *io_err;\n>     gboolean io_eof;\n>     uint8_t opcode;\n> + uint8_t prev_opcode;\n> };\n> \n> /**\n> diff --git a/io/channel-websock.c b/io/channel-websock.c\n> index 175f17ce6b..a9315c01fb 100644\n> --- a/io/channel-websock.c\n> +++ b/io/channel-websock.c\n> @@ -549,6 +549,7 @@ static int\n> qio_channel_websock_decode_header(QIOChannelWebsock *ioc,\n>     payload_len = header->b1 & QIO_CHANNEL_WEBSOCK_HEADER_FIELD_PAYLOAD_LEN;\n> \n>     /* Save or restore opcode. */\n> + ioc->prev_opcode = ioc->opcode;\n>     if (opcode) {\n>         ioc->opcode = opcode;\n>     } else {\n> @@ -658,9 +659,14 @@ static int\n> qio_channel_websock_decode_payload(QIOChannelWebsock *ioc,\n>             buffer_append(&ioc->rawinput, ioc->encinput.buffer,\n> payload_len);\n>         }\n>     } else if (ioc->opcode == QIO_CHANNEL_WEBSOCK_OPCODE_PING) {\n> - /* ping frames produce an immediate pong reply */\n> - qio_channel_websock_encode_buffer(ioc,\n> - QIO_CHANNEL_WEBSOCK_OPCODE_PONG, &ioc->encinput);\n> + /* Ping frames produce an immediate pong reply, unless one\n> + * is already queued, in which case they are coalesced\n> + * to avoid unbounded buffer growth.\n> + */\n> + if (!ioc->encoutput.offset || ioc->prev_opcode !=\n> QIO_CHANNEL_WEBSOCK_OPCODE_PING) {\n> + qio_channel_websock_encode_buffer(ioc,\n> + QIO_CHANNEL_WEBSOCK_OPCODE_PONG, &ioc->encinput);\n> + }\n\nIt feels like this is still dangerous - the client simply has to\ninterleave each \"ping\" with a 1 byte binary frame to get around\nthis limit. We need to make sure we have an absolute cap on the\noutput buffer size. \n\nRegards,\nDaniel","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=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ext-mx06.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx06.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=berrange@redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xrZFh0STPz9s83\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 12 Sep 2017 03:11:01 +1000 (AEST)","from localhost ([::1]:59221 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 1drSEb-0006VH-Dg\n\tfor incoming@patchwork.ozlabs.org; Mon, 11 Sep 2017 13:10:57 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:33398)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <berrange@redhat.com>) id 1drSE3-0006Sv-6W\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 13:10:24 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <berrange@redhat.com>) id 1drSDz-0002gS-5Y\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 13:10:23 -0400","from mx1.redhat.com ([209.132.183.28]:56494)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <berrange@redhat.com>) id 1drSDy-0002fr-Sj\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 13:10:19 -0400","from smtp.corp.redhat.com\n\t(int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15])\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 0DBB418423A;\n\tMon, 11 Sep 2017 17:10:18 +0000 (UTC)","from redhat.com (unknown [10.33.36.58])\n\tby smtp.corp.redhat.com (Postfix) with ESMTPS id 66FB25EE02;\n\tMon, 11 Sep 2017 17:10:17 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 0DBB418423A","Date":"Mon, 11 Sep 2017 18:10:15 +0100","From":"\"Daniel P. Berrange\" <berrange@redhat.com>","To":"Brandon Carpenter <brandon.carpenter@cypherpath.com>","Message-ID":"<20170911171015.GU21444@redhat.com>","References":"<20170724184217.21381-1-brandon.carpenter@cypherpath.com>\n\t<20170908173801.15205-7-brandon.carpenter@cypherpath.com>\n\t<20170911085043.GE21444@redhat.com>\n\t<1505149415.1214.1@smtp.gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<1505149415.1214.1@smtp.gmail.com>","User-Agent":"Mutt/1.8.3 (2017-05-23)","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.15","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.30]);\n\tMon, 11 Sep 2017 17:10:18 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","Subject":"Re: [Qemu-devel] [PATCH v2 6/6] io: Reply to ping frames","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>","Reply-To":"\"Daniel P. Berrange\" <berrange@redhat.com>","Cc":"qemu-devel@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>"}},{"id":1766434,"web_url":"http://patchwork.ozlabs.org/comment/1766434/","msgid":"<20170911173743.GV21444@redhat.com>","list_archive_url":null,"date":"2017-09-11T17:37:43","subject":"Re: [Qemu-devel] [PATCH v2 6/6] io: Reply to ping frames","submitter":{"id":2694,"url":"http://patchwork.ozlabs.org/api/people/2694/","name":"Daniel P. Berrangé","email":"berrange@redhat.com"},"content":"On Fri, Sep 08, 2017 at 10:38:01AM -0700, Brandon Carpenter wrote:\n> Add an immediate ping reply (pong) to the outgoing stream when a ping\n> is received. Unsolicited pongs are ignored.\n> \n> Signed-off-by: Brandon Carpenter <brandon.carpenter@cypherpath.com>\n> ---\n>  io/channel-websock.c | 50 ++++++++++++++++++++++++++++++++------------------\n>  1 file changed, 32 insertions(+), 18 deletions(-)\n> \n> diff --git a/io/channel-websock.c b/io/channel-websock.c\n> index 50387050d5..175f17ce6b 100644\n> --- a/io/channel-websock.c\n> +++ b/io/channel-websock.c\n> @@ -479,7 +479,8 @@ static gboolean qio_channel_websock_handshake_io(QIOChannel *ioc,\n>  }\n>  \n>  \n> -static void qio_channel_websock_encode(QIOChannelWebsock *ioc)\n> +static void qio_channel_websock_encode_buffer(QIOChannelWebsock *ioc,\n> +                                              uint8_t opcode, Buffer *buffer)\n>  {\n>      size_t header_size;\n>      union {\n> @@ -487,33 +488,37 @@ static void qio_channel_websock_encode(QIOChannelWebsock *ioc)\n>          QIOChannelWebsockHeader ws;\n>      } header;\n>  \n> -    if (!ioc->rawoutput.offset) {\n> -        return;\n> -    }\n> -\n>      header.ws.b0 = QIO_CHANNEL_WEBSOCK_HEADER_FIELD_FIN |\n> -        (QIO_CHANNEL_WEBSOCK_OPCODE_BINARY_FRAME &\n> -         QIO_CHANNEL_WEBSOCK_HEADER_FIELD_OPCODE);\n> -    if (ioc->rawoutput.offset <\n> +        (opcode & QIO_CHANNEL_WEBSOCK_HEADER_FIELD_OPCODE);\n> +    if (buffer->offset <\n>          QIO_CHANNEL_WEBSOCK_PAYLOAD_LEN_THRESHOLD_7_BIT) {\n> -        header.ws.b1 = (uint8_t)ioc->rawoutput.offset;\n> +        header.ws.b1 = (uint8_t)buffer->offset;\n>          header_size = QIO_CHANNEL_WEBSOCK_HEADER_LEN_7_BIT;\n> -    } else if (ioc->rawoutput.offset <\n> +    } else if (buffer->offset <\n>                 QIO_CHANNEL_WEBSOCK_PAYLOAD_LEN_THRESHOLD_16_BIT) {\n>          header.ws.b1 = QIO_CHANNEL_WEBSOCK_PAYLOAD_LEN_MAGIC_16_BIT;\n> -        header.ws.u.s16.l16 = cpu_to_be16((uint16_t)ioc->rawoutput.offset);\n> +        header.ws.u.s16.l16 = cpu_to_be16((uint16_t)buffer->offset);\n>          header_size = QIO_CHANNEL_WEBSOCK_HEADER_LEN_16_BIT;\n>      } else {\n>          header.ws.b1 = QIO_CHANNEL_WEBSOCK_PAYLOAD_LEN_MAGIC_64_BIT;\n> -        header.ws.u.s64.l64 = cpu_to_be64(ioc->rawoutput.offset);\n> +        header.ws.u.s64.l64 = cpu_to_be64(buffer->offset);\n>          header_size = QIO_CHANNEL_WEBSOCK_HEADER_LEN_64_BIT;\n>      }\n>      header_size -= QIO_CHANNEL_WEBSOCK_HEADER_LEN_MASK;\n>  \n> -    buffer_reserve(&ioc->encoutput, header_size + ioc->rawoutput.offset);\n> +    buffer_reserve(&ioc->encoutput, header_size + buffer->offset);\n>      buffer_append(&ioc->encoutput, header.buf, header_size);\n> -    buffer_append(&ioc->encoutput, ioc->rawoutput.buffer,\n> -                  ioc->rawoutput.offset);\n> +    buffer_append(&ioc->encoutput, buffer->buffer, buffer->offset);\n> +}\n> +\n> +\n> +static void qio_channel_websock_encode(QIOChannelWebsock *ioc)\n> +{\n> +    if (!ioc->rawoutput.offset) {\n> +        return;\n> +    }\n> +    qio_channel_websock_encode_buffer(ioc,\n> +            QIO_CHANNEL_WEBSOCK_OPCODE_BINARY_FRAME, &ioc->rawoutput);\n>      buffer_reset(&ioc->rawoutput);\n>  }\n>  \n> @@ -558,7 +563,7 @@ static int qio_channel_websock_decode_header(QIOChannelWebsock *ioc,\n>      /* Websocket frame sanity check:\n>       * * Fragmentation is only supported for binary frames.\n>       * * All frames sent by a client MUST be masked.\n> -     * * Only binary encoding is supported.\n> +     * * Only binary and ping/pong encoding is supported.\n>       */\n>      if (!fin) {\n>          if (opcode != QIO_CHANNEL_WEBSOCK_OPCODE_BINARY_FRAME) {\n> @@ -619,6 +624,11 @@ static int qio_channel_websock_decode_payload(QIOChannelWebsock *ioc,\n>           * for purpose of unmasking, except at end of payload\n>           */\n>          if (ioc->encinput.offset < ioc->payload_remain) {\n> +            /* Wait for the entire payload before processing control frames\n> +             * because the payload will most likely be echoed back. */\n> +            if (ioc->opcode & QIO_CHANNEL_WEBSOCK_CONTROL_OPCODE_MASK) {\n> +                return QIO_CHANNEL_ERR_BLOCK;\n> +            }\n>              payload_len = ioc->encinput.offset - (ioc->encinput.offset % 4);\n>          } else {\n>              payload_len = ioc->payload_remain;\n> @@ -641,13 +651,17 @@ static int qio_channel_websock_decode_payload(QIOChannelWebsock *ioc,\n>          }\n>      }\n>  \n> -    /* Drop the payload of ping/pong packets */\n>      if (ioc->opcode == QIO_CHANNEL_WEBSOCK_OPCODE_BINARY_FRAME) {\n>          if (payload_len) {\n> +            /* binary frames are passed on */\n>              buffer_reserve(&ioc->rawinput, payload_len);\n>              buffer_append(&ioc->rawinput, ioc->encinput.buffer, payload_len);\n>          }\n> -    }\n> +    } else if (ioc->opcode == QIO_CHANNEL_WEBSOCK_OPCODE_PING) {\n> +        /* ping frames produce an immediate pong reply */\n> +        qio_channel_websock_encode_buffer(ioc,\n> +                QIO_CHANNEL_WEBSOCK_OPCODE_PONG, &ioc->encinput);\n> +    }   /* pong frames are ignored */\n\nBTW, replying to the PING here is going to scramble the protocol if\nthe PING contains payload data. At the time qio_channel_websock_decode_header\nis run, 'encinput' is only guaranteed to contain enough data to decode the\nheader.  You might be lucky and have some bytes from the payload already\nread off the wire and stored in 'encinput', but equally you might have\nnothing.  So you can not access 'encinput' here for your PONG reply\npayload.\n\nRegards,\nDaniel","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=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ext-mx08.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx08.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=berrange@redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xrbWT4jVVz9s7F\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 12 Sep 2017 04:08:05 +1000 (AEST)","from localhost ([::1]:59619 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 1drT7r-0008UA-MW\n\tfor incoming@patchwork.ozlabs.org; Mon, 11 Sep 2017 14:08:03 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:44819)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <berrange@redhat.com>) id 1drSeb-0006Fx-5v\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 13:37:50 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <berrange@redhat.com>) id 1drSeZ-0002QP-H2\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 13:37:49 -0400","from mx1.redhat.com ([209.132.183.28]:36186)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <berrange@redhat.com>) id 1drSeZ-0002QJ-87\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 13:37:47 -0400","from smtp.corp.redhat.com\n\t(int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13])\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 359B9C0C05AB;\n\tMon, 11 Sep 2017 17:37:46 +0000 (UTC)","from redhat.com (unknown [10.33.36.58])\n\tby smtp.corp.redhat.com (Postfix) with ESMTPS id 6C1DD60842;\n\tMon, 11 Sep 2017 17:37:45 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 359B9C0C05AB","Date":"Mon, 11 Sep 2017 18:37:43 +0100","From":"\"Daniel P. Berrange\" <berrange@redhat.com>","To":"Brandon Carpenter <brandon.carpenter@cypherpath.com>","Message-ID":"<20170911173743.GV21444@redhat.com>","References":"<20170724184217.21381-1-brandon.carpenter@cypherpath.com>\n\t<20170908173801.15205-7-brandon.carpenter@cypherpath.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20170908173801.15205-7-brandon.carpenter@cypherpath.com>","User-Agent":"Mutt/1.8.3 (2017-05-23)","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.13","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.32]);\n\tMon, 11 Sep 2017 17:37:46 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","Subject":"Re: [Qemu-devel] [PATCH v2 6/6] io: Reply to ping frames","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>","Reply-To":"\"Daniel P. Berrange\" <berrange@redhat.com>","Cc":"qemu-devel@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>"}},{"id":1766437,"web_url":"http://patchwork.ozlabs.org/comment/1766437/","msgid":"<1505151801.1214.2@smtp.gmail.com>","list_archive_url":null,"date":"2017-09-11T17:43:21","subject":"Re: [Qemu-devel] [PATCH v2 6/6] io: Reply to ping frames","submitter":{"id":72031,"url":"http://patchwork.ozlabs.org/api/people/72031/","name":"Brandon Carpenter","email":"brandon.carpenter@cypherpath.com"},"content":"On Mon, Sep 11, 2017 at 10:37 AM, Daniel P. Berrange \n<berrange@redhat.com> wrote:\n> At the time qio_channel_websock_decode_header is run, 'encinput' is \n> only guaranteed to contain enough data to decode the header.\n\nBecause the PING opcode is a control frame, this bit of code earlier in \nthe function will ensure the entire frame has been read before the PING \nprocessing occurs:\n\n>       if (ioc->encinput.offset < ioc->payload_remain) {\n>             /* Wait for the entire payload before processing control \n> frames\n>              * because the payload will most likely be echoed back. */\n>             if (ioc->opcode & \n> QIO_CHANNEL_WEBSOCK_CONTROL_OPCODE_MASK) {\n>                 return QIO_CHANNEL_ERR_BLOCK;\n>             }\n>             payload_len = ioc->encinput.offset - \n> (ioc->encinput.offset % 4);\n\n--\nBrandon Carpenter | Software Engineer\nCypherpath, Inc.\n400 Columbia Point Drive Ste 101 | Richland, Washington USA\nOffice: (650) 713-3060","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=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=cypherpath.com header.i=@cypherpath.com\n\theader.b=\"CAGqg62U\"; dkim-atps=neutral"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xrbd24mK7z9s7F\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 12 Sep 2017 04:12:54 +1000 (AEST)","from localhost ([::1]:59652 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 1drTCW-0004le-LH\n\tfor incoming@patchwork.ozlabs.org; Mon, 11 Sep 2017 14:12:52 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:46973)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <brandon.carpenter@cypherpath.com>)\n\tid 1drSk5-0002bZ-Nc\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 13:43:30 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <brandon.carpenter@cypherpath.com>)\n\tid 1drSk0-0005Du-Qz\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 13:43:29 -0400","from mail-io0-x22f.google.com ([2607:f8b0:4001:c06::22f]:37751)\n\tby eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)\n\t(Exim 4.71) (envelope-from <brandon.carpenter@cypherpath.com>)\n\tid 1drSk0-0005D6-LB\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 13:43:24 -0400","by mail-io0-x22f.google.com with SMTP id j141so31071420ioj.4\n\tfor <qemu-devel@nongnu.org>; Mon, 11 Sep 2017 10:43:24 -0700 (PDT)","from [10.10.7.25] (68-113-0-218.static.knwc.wa.charter.com.\n\t[68.113.0.218]) by smtp.gmail.com with ESMTPSA id\n\tm85sm11133484oik.35.2017.09.11.10.43.22\n\t(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tMon, 11 Sep 2017 10:43:23 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=cypherpath.com; s=google;\n\th=date:from:subject:to:cc:message-id:in-reply-to:references\n\t:mime-version; bh=kemaUOyCywMCdHQyJa3sP4jeVzp6NpU2fXAa/o0gi2I=;\n\tb=CAGqg62UZwdYTlO3JFqN3LUBV64VsltNanTxmAQQ+StkPpGFzp6jvEIILANFUJsqjY\n\t/0b9R5cb5IyX5dulWKe/jiYw4Swbhh006HCxTmI0RB/HQX+EWpU8H5Rl8j9W9kT/4xKx\n\tzir0Yerqz8gZ+O2DFZI55lhBL77WmLo06knGo=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:subject:to:cc:message-id:in-reply-to\n\t:references:mime-version;\n\tbh=kemaUOyCywMCdHQyJa3sP4jeVzp6NpU2fXAa/o0gi2I=;\n\tb=ha3yd6p5/CPQmagfZUz67HWP/cdCC9pgL2JTnIuEyfvokLuje85SrVQiL44jk9FVSm\n\t0Z6W3a18GBI2KD0CfGtSx1FRz8X6Uh12JBXEn2tbF5Jq9qfc9DSqHXvbbwFcEjTlmME6\n\twPo8wXY1AboNsyJ1d0MsnW5AtDZ+lHR9tCLDhX5JgaJ68qijVks4+E4a8NInQAgroiDI\n\tfrJi7sBZHn2AGSxXtbsqUndK2NPMHPWIsMs5fs7kXyXu9FruIJvGZE0U/927zi+5R0o1\n\taY/VLo6Pwi5I09lnLWXzlkW9qWws0EqYLrS4j5pBZIX1SgF5WJ8tZqBcA2fQoczTM17j\n\tVIbQ==","X-Gm-Message-State":"AHPjjUje7EkQr6LtLsg56bFCTG1FinBIYar9soir05LSVz2O1LNeISw1\n\tSLUCFsWonEaDjqsB7xMjX/H3xL1/bO7jXaZS+egsVAFUpVmHHsX3K5EIGzUGbykqQ55zGgdt8mM\n\t=","X-Google-Smtp-Source":"AOwi7QBXG60m3ZhYVOUhddfwxlCSu5bthvX61Ajtij4y1TFRKOsv4x9tcHzHB0n/egc23h/pvu1oiw==","X-Received":"by 10.202.206.147 with SMTP id\n\te141mr11295121oig.115.1505151803867; \n\tMon, 11 Sep 2017 10:43:23 -0700 (PDT)","Date":"Mon, 11 Sep 2017 10:43:21 -0700","From":"Brandon Carpenter <brandon.carpenter@cypherpath.com>","To":"\"Daniel P. Berrange\" <berrange@redhat.com>","Message-Id":"<1505151801.1214.2@smtp.gmail.com>","In-Reply-To":"<20170911173743.GV21444@redhat.com>","References":"<20170724184217.21381-1-brandon.carpenter@cypherpath.com>\n\t<20170908173801.15205-7-brandon.carpenter@cypherpath.com>\n\t<20170911173743.GV21444@redhat.com>","X-Mailer":"geary/makepkg~g00718198","MIME-Version":"1.0","X-detected-operating-system":"by eggs.gnu.org: Genre and OS details not\n\trecognized.","X-Received-From":"2607:f8b0:4001:c06::22f","Content-Type":"text/plain; charset=\"US-ASCII\"; format=flowed","X-Content-Filtered-By":"Mailman/MimeDel 2.1.21","Subject":"Re: [Qemu-devel] [PATCH v2 6/6] io: Reply to ping frames","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":"qemu-devel@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>"}},{"id":1766464,"web_url":"http://patchwork.ozlabs.org/comment/1766464/","msgid":"<1505156655.1214.3@smtp.gmail.com>","list_archive_url":null,"date":"2017-09-11T19:04:15","subject":"Re: [Qemu-devel] [PATCH v2 6/6] io: Reply to ping frames","submitter":{"id":72031,"url":"http://patchwork.ozlabs.org/api/people/72031/","name":"Brandon Carpenter","email":"brandon.carpenter@cypherpath.com"},"content":"On Mon, Sep 11, 2017 at 10:10 AM, Daniel P. Berrange \n<berrange@redhat.com> wrote:\n> It feels like this is still dangerous - the client simply has to \n> interleave each \"ping\" with a 1 byte binary frame to get around this \n> limit. We need to make sure we have an absolute cap on the output \n> buffer size.\n\nOkay. I see that now that I look at it more closely. This breed of \nasynchronous I/O is tricky because the conditions for reading/writing \nare all over the place. There's a lot of context to keep in your head.\n\nI have a fix. And I realized that I was missing a patch in the series \nfor RFC-compliant closing of websocket connections, which I must have \nlost during a rebase. Should I submit v3 of the patch series or just \nadd those patches to this thread?\n\nThank you,\n--\nBrandon Carpenter | Software Engineer\nCypherpath, Inc.\n400 Columbia Point Drive Ste 101 | Richland, Washington USA\nOffice: (650) 713-3060","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=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=cypherpath.com header.i=@cypherpath.com\n\theader.b=\"hYzLmOvN\"; dkim-atps=neutral"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xrcwl4VfFz9s7g\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 12 Sep 2017 05:11:34 +1000 (AEST)","from localhost ([::1]:60053 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 1drU7H-0008Q4-Se\n\tfor incoming@patchwork.ozlabs.org; Mon, 11 Sep 2017 15:11:31 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:52561)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <brandon.carpenter@cypherpath.com>)\n\tid 1drU6x-0008Pi-D7\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 15:11:12 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <brandon.carpenter@cypherpath.com>)\n\tid 1drU6u-00053Z-Mo\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 15:11:11 -0400","from mail-io0-x22f.google.com ([2607:f8b0:4001:c06::22f]:37878)\n\tby eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)\n\t(Exim 4.71) (envelope-from <brandon.carpenter@cypherpath.com>)\n\tid 1drU6u-00052i-GP\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 15:11:08 -0400","by mail-io0-x22f.google.com with SMTP id j141so32770938ioj.4\n\tfor <qemu-devel@nongnu.org>; Mon, 11 Sep 2017 12:11:08 -0700 (PDT)","from [10.10.7.25] (68-113-0-218.static.knwc.wa.charter.com.\n\t[68.113.0.218]) by smtp.gmail.com with ESMTPSA id\n\to206sm8171407oif.26.2017.09.11.12.04.16\n\t(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tMon, 11 Sep 2017 12:04:17 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=cypherpath.com; s=google;\n\th=date:from:subject:to:cc:message-id:in-reply-to:references\n\t:mime-version; bh=1KI+Sn1WSi74SHzCEnOl0mCW+WPLzQa1/7IlXD74ewk=;\n\tb=hYzLmOvNkeMsqoF4lIP7+qKf3jU/mYWhcm0jK5eD/XsMj1C2y0J/pRHSYdcttIEJ73\n\tdI/RZhmUVE0BuNZGkOEo4QNAXON+cfI2n7nLNwaDG/6I4R8Z+keAUgsukcVk8AgoPpiw\n\t2Jrsfd75OLrqAec3W5mJGgz85WkWzFUHWUqKU=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:subject:to:cc:message-id:in-reply-to\n\t:references:mime-version;\n\tbh=1KI+Sn1WSi74SHzCEnOl0mCW+WPLzQa1/7IlXD74ewk=;\n\tb=gz1b3BmCieFF/jAgJFwhWJbeNz5dtea+yJtYUKYkaBlV+rd8vxznURXHfs/lC/tv8m\n\tkuoPeGfI2hwnK6GM7lH4CHW04/ZdbBT4CqQUfURqBWeqZrq2Q77ylQtQRB573WtlrNdB\n\tIXtEJuO92HCQsYYyaPSZoETZ0nmQaQ4wjmYcLIus7KVMXLXKl7l09ANTmtnB1uDyZ5iY\n\tL5xzIxyqrttKGAC+JPu2Nmc6UL9L9QtWLI1o05iyedMJbP+vY+F+0zeGk2Msidp9Ays3\n\tfNEIXMRaQnFVK+zndgB34+JOKMib2BvT1pEYdXey57ViHxT4XLYCyx3sX74fgwpz3/Qt\n\tvKUg==","X-Gm-Message-State":"AHPjjUj7DaEjGBBNRJN5vnAHwNaA6b6L2Jux/NVuXSNuQkqnvAQuAQUv\n\tYuCadI2pxktmCsW4PqXheSWPZTJCOKgB20Lr66M5w8ji08Q9HndyoFTsLKJGDbppy+G5RY9CVM4\n\t=","X-Google-Smtp-Source":"AOwi7QDsGDjGT0o2o57BuYUuDGkY/JfKCEKw1aLE/qerLEOIZOqUsad0H67RcazgZiRY4gxiPhNE3Q==","X-Received":"by 10.202.237.131 with SMTP id\n\tl125mr11384643oih.254.1505156657959; \n\tMon, 11 Sep 2017 12:04:17 -0700 (PDT)","Date":"Mon, 11 Sep 2017 12:04:15 -0700","From":"Brandon Carpenter <brandon.carpenter@cypherpath.com>","To":"\"Daniel P. Berrange\" <berrange@redhat.com>","Message-Id":"<1505156655.1214.3@smtp.gmail.com>","In-Reply-To":"<20170911171015.GU21444@redhat.com>","References":"<20170724184217.21381-1-brandon.carpenter@cypherpath.com>\n\t<20170908173801.15205-7-brandon.carpenter@cypherpath.com>\n\t<20170911085043.GE21444@redhat.com>\n\t<1505149415.1214.1@smtp.gmail.com>\n\t<20170911171015.GU21444@redhat.com>","X-Mailer":"geary/makepkg~g00718198","MIME-Version":"1.0","X-detected-operating-system":"by eggs.gnu.org: Genre and OS details not\n\trecognized.","X-Received-From":"2607:f8b0:4001:c06::22f","Content-Type":"text/plain; charset=\"US-ASCII\"; format=flowed","X-Content-Filtered-By":"Mailman/MimeDel 2.1.21","Subject":"Re: [Qemu-devel] [PATCH v2 6/6] io: Reply to ping frames","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":"qemu-devel@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>"}},{"id":1766781,"web_url":"http://patchwork.ozlabs.org/comment/1766781/","msgid":"<20170912085750.GA17633@redhat.com>","list_archive_url":null,"date":"2017-09-12T08:57:50","subject":"Re: [Qemu-devel] [PATCH v2 6/6] io: Reply to ping frames","submitter":{"id":2694,"url":"http://patchwork.ozlabs.org/api/people/2694/","name":"Daniel P. Berrangé","email":"berrange@redhat.com"},"content":"On Mon, Sep 11, 2017 at 12:04:15PM -0700, Brandon Carpenter wrote:\n> On Mon, Sep 11, 2017 at 10:10 AM, Daniel P. Berrange <berrange@redhat.com>\n> wrote:\n> > It feels like this is still dangerous - the client simply has to\n> > interleave each \"ping\" with a 1 byte binary frame to get around this\n> > limit. We need to make sure we have an absolute cap on the output buffer\n> > size.\n> \n> Okay. I see that now that I look at it more closely. This breed of\n> asynchronous I/O is tricky because the conditions for reading/writing are\n> all over the place. There's a lot of context to keep in your head.\n> \n> I have a fix. And I realized that I was missing a patch in the series for\n> RFC-compliant closing of websocket connections, which I must have lost\n> during a rebase. Should I submit v3 of the patch series or just add those\n> patches to this thread?\n\nIt is generally preferred practice to submit new top level threads, rather\nthan sending more patches to a previous thread.\n\nRegards,\nDaniel","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=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ext-mx04.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx04.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=berrange@redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xrzH014bPz9s81\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 12 Sep 2017 18:58:35 +1000 (AEST)","from localhost ([::1]:34338 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 1drh1e-0004DV-19\n\tfor incoming@patchwork.ozlabs.org; Tue, 12 Sep 2017 04:58:34 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:36813)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <berrange@redhat.com>) id 1drh14-0004Bl-VY\n\tfor qemu-devel@nongnu.org; Tue, 12 Sep 2017 04:58:00 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <berrange@redhat.com>) id 1drh11-0008CZ-1h\n\tfor qemu-devel@nongnu.org; Tue, 12 Sep 2017 04:57:59 -0400","from mx1.redhat.com ([209.132.183.28]:60810)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <berrange@redhat.com>) id 1drh10-0008B4-Sg\n\tfor qemu-devel@nongnu.org; Tue, 12 Sep 2017 04:57:54 -0400","from smtp.corp.redhat.com\n\t(int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14])\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 2C28A8553C;\n\tTue, 12 Sep 2017 08:57:53 +0000 (UTC)","from redhat.com (unknown [10.42.22.189])\n\tby smtp.corp.redhat.com (Postfix) with ESMTPS id 9D7B75F910;\n\tTue, 12 Sep 2017 08:57:52 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 2C28A8553C","Date":"Tue, 12 Sep 2017 09:57:50 +0100","From":"\"Daniel P. Berrange\" <berrange@redhat.com>","To":"Brandon Carpenter <brandon.carpenter@cypherpath.com>","Message-ID":"<20170912085750.GA17633@redhat.com>","References":"<20170724184217.21381-1-brandon.carpenter@cypherpath.com>\n\t<20170908173801.15205-7-brandon.carpenter@cypherpath.com>\n\t<20170911085043.GE21444@redhat.com>\n\t<1505149415.1214.1@smtp.gmail.com>\n\t<20170911171015.GU21444@redhat.com>\n\t<1505156655.1214.3@smtp.gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<1505156655.1214.3@smtp.gmail.com>","User-Agent":"Mutt/1.8.3 (2017-05-23)","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.14","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.28]);\n\tTue, 12 Sep 2017 08:57:53 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","Subject":"Re: [Qemu-devel] [PATCH v2 6/6] io: Reply to ping frames","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>","Reply-To":"\"Daniel P. Berrange\" <berrange@redhat.com>","Cc":"qemu-devel@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>"}},{"id":1766782,"web_url":"http://patchwork.ozlabs.org/comment/1766782/","msgid":"<20170912090104.GB17633@redhat.com>","list_archive_url":null,"date":"2017-09-12T09:01:04","subject":"Re: [Qemu-devel] [PATCH v2 6/6] io: Reply to ping frames","submitter":{"id":2694,"url":"http://patchwork.ozlabs.org/api/people/2694/","name":"Daniel P. Berrangé","email":"berrange@redhat.com"},"content":"On Mon, Sep 11, 2017 at 10:43:21AM -0700, Brandon Carpenter wrote:\n> On Mon, Sep 11, 2017 at 10:37 AM, Daniel P. Berrange <berrange@redhat.com>\n> wrote:\n> > At the time qio_channel_websock_decode_header is run, 'encinput' is only\n> > guaranteed to contain enough data to decode the header.\n> \n> Because the PING opcode is a control frame, this bit of code earlier in the\n> function will ensure the entire frame has been read before the PING\n> processing occurs:\n> \n> >       if (ioc->encinput.offset < ioc->payload_remain) {\n> >             /* Wait for the entire payload before processing control\n> > frames\n> >              * because the payload will most likely be echoed back. */\n> >             if (ioc->opcode & QIO_CHANNEL_WEBSOCK_CONTROL_OPCODE_MASK) {\n> >                 return QIO_CHANNEL_ERR_BLOCK;\n> >             }\n> >             payload_len = ioc->encinput.offset - (ioc->encinput.offset %\n> > 4);\n\nThe problem is in the qio_channel_websock_read_wire method we refuse\nto read more than 4k into encinput. So if the ping payload is greater\nthan 4k this will just loop forever.\n\nRegards,\nDaniel","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=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ext-mx04.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx04.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=berrange@redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xrzLY1WvYz9s8J\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 12 Sep 2017 19:01:41 +1000 (AEST)","from localhost ([::1]:34350 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 1drh4d-0005hT-Bo\n\tfor incoming@patchwork.ozlabs.org; Tue, 12 Sep 2017 05:01:39 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:37939)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <berrange@redhat.com>) id 1drh4E-0005gv-8V\n\tfor qemu-devel@nongnu.org; Tue, 12 Sep 2017 05:01:19 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <berrange@redhat.com>) id 1drh48-0002Ye-Mg\n\tfor qemu-devel@nongnu.org; Tue, 12 Sep 2017 05:01:14 -0400","from mx1.redhat.com ([209.132.183.28]:41194)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <berrange@redhat.com>) id 1drh48-0002Xv-H4\n\tfor qemu-devel@nongnu.org; Tue, 12 Sep 2017 05:01:08 -0400","from smtp.corp.redhat.com\n\t(int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16])\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 6B84C85543;\n\tTue, 12 Sep 2017 09:01:07 +0000 (UTC)","from redhat.com (unknown [10.42.22.189])\n\tby smtp.corp.redhat.com (Postfix) with ESMTPS id DCD525C1A1;\n\tTue, 12 Sep 2017 09:01:06 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 6B84C85543","Date":"Tue, 12 Sep 2017 10:01:04 +0100","From":"\"Daniel P. Berrange\" <berrange@redhat.com>","To":"Brandon Carpenter <brandon.carpenter@cypherpath.com>","Message-ID":"<20170912090104.GB17633@redhat.com>","References":"<20170724184217.21381-1-brandon.carpenter@cypherpath.com>\n\t<20170908173801.15205-7-brandon.carpenter@cypherpath.com>\n\t<20170911173743.GV21444@redhat.com>\n\t<1505151801.1214.2@smtp.gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<1505151801.1214.2@smtp.gmail.com>","User-Agent":"Mutt/1.8.3 (2017-05-23)","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.16","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.28]);\n\tTue, 12 Sep 2017 09:01:07 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","Subject":"Re: [Qemu-devel] [PATCH v2 6/6] io: Reply to ping frames","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>","Reply-To":"\"Daniel P. Berrange\" <berrange@redhat.com>","Cc":"qemu-devel@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>"}},{"id":1767164,"web_url":"http://patchwork.ozlabs.org/comment/1767164/","msgid":"<1505230161.29344.0@smtp.gmail.com>","list_archive_url":null,"date":"2017-09-12T15:29:21","subject":"Re: [Qemu-devel] [PATCH v2 6/6] io: Reply to ping frames","submitter":{"id":72031,"url":"http://patchwork.ozlabs.org/api/people/72031/","name":"Brandon Carpenter","email":"brandon.carpenter@cypherpath.com"},"content":"On Tue, Sep 12, 2017 at 2:01 AM, Daniel P. Berrange \n<berrange@redhat.com> wrote:\n> The problem is in the qio_channel_websock_read_wire method we refuse \n> to read more than 4k into encinput. So if the ping payload is greater \n> than 4k this will just loop forever.\n\nThe RFC limits the payload length of control messages to 126 bytes, , \nlimiting the total message size to 132 bytes. This is enforced in \nqio_channel_websock_decode_header(). If anything larger is sent in a \ncontrol message, including pings, the connection is immediately closed.\n--\nBrandon Carpenter | Software Engineer\nCypherpath, Inc.\n400 Columbia Point Drive Ste 101 | Richland, Washington USA\nOffice: (650) 713-3060","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=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=cypherpath.com header.i=@cypherpath.com\n\theader.b=\"AOCN7odZ\"; dkim-atps=neutral"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xs7yv1wCwz9s82\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 13 Sep 2017 01:30:15 +1000 (AEST)","from localhost ([::1]:36528 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 1drn8f-0002qU-7t\n\tfor incoming@patchwork.ozlabs.org; Tue, 12 Sep 2017 11:30:13 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:44150)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <brandon.carpenter@cypherpath.com>)\n\tid 1drn7t-0002ke-S2\n\tfor qemu-devel@nongnu.org; Tue, 12 Sep 2017 11:29:30 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <brandon.carpenter@cypherpath.com>)\n\tid 1drn7s-0003Lc-PN\n\tfor qemu-devel@nongnu.org; Tue, 12 Sep 2017 11:29:25 -0400","from mail-pg0-x22e.google.com ([2607:f8b0:400e:c05::22e]:35111)\n\tby eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)\n\t(Exim 4.71) (envelope-from <brandon.carpenter@cypherpath.com>)\n\tid 1drn7s-0003LI-J0\n\tfor qemu-devel@nongnu.org; Tue, 12 Sep 2017 11:29:24 -0400","by mail-pg0-x22e.google.com with SMTP id 188so21857372pgb.2\n\tfor <qemu-devel@nongnu.org>; Tue, 12 Sep 2017 08:29:24 -0700 (PDT)","from [10.10.7.25] (68-113-0-218.static.knwc.wa.charter.com.\n\t[68.113.0.218]) by smtp.gmail.com with ESMTPSA id\n\tt76sm10605861pfj.43.2017.09.12.08.29.22\n\t(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tTue, 12 Sep 2017 08:29:22 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=cypherpath.com; s=google;\n\th=date:from:subject:to:cc:message-id:in-reply-to:references\n\t:mime-version; bh=1mnbKbP9+gcdjQwiM87haIKy5sz2OPmk72aVDaXdD2M=;\n\tb=AOCN7odZvkRt89P2qF4weu7iv9voAla2C3aa1VmI277U9Rn405AMnDjn1F8UF/CKuw\n\thidYaUKXsDVLKmNYol7wXZZPJveVA1z32QgCs4Rfqau1ugvntRFxKQH8H+Wxkc0ttqlc\n\tpb8X9Ugb/mE6k4OZwnehaZlOu4/74MdK4/ehs=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:subject:to:cc:message-id:in-reply-to\n\t:references:mime-version;\n\tbh=1mnbKbP9+gcdjQwiM87haIKy5sz2OPmk72aVDaXdD2M=;\n\tb=SmzSJGj6ch3+cQCUSEDJGWfY85U1rdPUyn1XzgSlqGAgwcKBnIBG7JxWnaenAo8YXw\n\t/FThUhZdYCv3POxlVdxFhItJd6Y51XsiJzy4ssWX19cJHUQK3gbB+6YpyqQy0z4jZ3If\n\t5AC5eJ5su4bMggY1dYYJkwfMpccD2IVJVTAbfOhozTh6s/PFmjD1xjfa87pRq6xv1zo9\n\tV6Zsgs6f0pXINW2+WVM3zYdy9zNwtAYxHscI19cTdI31nriCd5MH52H1h1IUxdf58Qqd\n\tT3+7Pc392Qk5SrDxw2A44QRo2YUZfZABXYAuygGgi2s7PG1UaV9qsES2WMXodJGbgq3K\n\t6fUw==","X-Gm-Message-State":"AHPjjUj5qIDewLgYf1yglrDzazAO2xCF6RsZsWpn7P/qRqEFz2a7Kieg\n\tmKujD7CBH1z/7Ig3sgkRbKNppksPSHzkDwHzTKPaUw2zwAbWX+Inyxc/4L+souYqhHMQ0z6zJJY\n\tpkq7X","X-Google-Smtp-Source":"ADKCNb725mQKKTmr+CAHBaN6W+Rs4r7VAIAW+9s1fkYjXHZAiPXJwhsaFPCqgRK4Me80bZ71TO3org==","X-Received":"by 10.84.164.199 with SMTP id l7mr11119535plg.314.1505230163654; \n\tTue, 12 Sep 2017 08:29:23 -0700 (PDT)","Date":"Tue, 12 Sep 2017 08:29:21 -0700","From":"Brandon Carpenter <brandon.carpenter@cypherpath.com>","To":"\"Daniel P. Berrange\" <berrange@redhat.com>","Message-Id":"<1505230161.29344.0@smtp.gmail.com>","In-Reply-To":"<20170912090104.GB17633@redhat.com>","References":"<20170724184217.21381-1-brandon.carpenter@cypherpath.com>\n\t<20170908173801.15205-7-brandon.carpenter@cypherpath.com>\n\t<20170911173743.GV21444@redhat.com>\n\t<1505151801.1214.2@smtp.gmail.com>\n\t<20170912090104.GB17633@redhat.com>","X-Mailer":"geary/makepkg~g00718198","MIME-Version":"1.0","X-detected-operating-system":"by eggs.gnu.org: Genre and OS details not\n\trecognized.","X-Received-From":"2607:f8b0:400e:c05::22e","Content-Type":"text/plain; charset=\"US-ASCII\"; format=flowed","X-Content-Filtered-By":"Mailman/MimeDel 2.1.21","Subject":"Re: [Qemu-devel] [PATCH v2 6/6] io: Reply to ping frames","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":"qemu-devel@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>"}}]