[{"id":1759611,"web_url":"http://patchwork.ozlabs.org/comment/1759611/","msgid":"<cac1b4fa-1774-0871-ad93-1983aed8da68@redhat.com>","list_archive_url":null,"date":"2017-08-29T19:13:16","subject":"Re: [Qemu-devel] [PATCH v2 1/3] nbd-client: avoid read_reply_co\n\tentry if send failed","submitter":{"id":6591,"url":"http://patchwork.ozlabs.org/api/people/6591/","name":"Eric Blake","email":"eblake@redhat.com"},"content":"On 08/29/2017 07:27 AM, Stefan Hajnoczi wrote:\n> The following segfault is encountered if the NBD server closes the UNIX\n> domain socket immediately after negotiation:\n> \n\n> \n> In the mean time blk_co_preadv() can be called and nbd_coroutine_end()\n> calls aio_wake() on read_reply_co.  At this point in time\n> read_reply_co's ctx isn't set because it has never been entered yet.\n> \n> This patch simplifies the nbd_co_send_request() ->\n> nbd_co_receive_reply() -> nbd_coroutine_end() lifecycle to just\n> nbd_co_send_request() -> nbd_co_receive_reply().  The request is \"ended\"\n> if an error occurs at any point.  Callers no longer have to invoke\n> nbd_coroutine_end().\n\nVladimir's work also eliminated a separate call to nbd_coroutine_end.\nThere will be some interesting rebase issues to resolve between the two,\nbut I think we'll get there.\n\n> \n> This cleanup also eliminates the segfault because we don't call\n> aio_co_schedule() to wake up s->read_reply_co if sending the request\n> failed.  It is only necessary to wake up s->read_reply_co if a reply was\n> received.\n> \n> Note this only happens with UNIX domain sockets on Linux.  It doesn't\n> seem possible to reproduce this with TCP sockets.\n> \n> Suggested-by: Paolo Bonzini <pbonzini@redhat.com>\n> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>\n> ---\n>  block/nbd-client.c | 25 +++++++++----------------\n>  1 file changed, 9 insertions(+), 16 deletions(-)\n> \n\nReviewed-by: Eric Blake <eblake@redhat.com>","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-mx02.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx02.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=eblake@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 3xhdbR5Bm5z9s8J\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 30 Aug 2017 05:13:54 +1000 (AEST)","from localhost ([::1]:46624 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 1dmlxP-0004l1-0X\n\tfor incoming@patchwork.ozlabs.org; Tue, 29 Aug 2017 15:13:51 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:59051)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <eblake@redhat.com>) id 1dmlx3-0004jW-Ok\n\tfor qemu-devel@nongnu.org; Tue, 29 Aug 2017 15:13:30 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <eblake@redhat.com>) id 1dmlx2-0002a9-KP\n\tfor qemu-devel@nongnu.org; Tue, 29 Aug 2017 15:13:29 -0400","from mx1.redhat.com ([209.132.183.28]:51922)\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 1dmlww-0002Xq-JB; Tue, 29 Aug 2017 15:13:22 -0400","from smtp.corp.redhat.com\n\t(int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11])\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 5CDC7883D6;\n\tTue, 29 Aug 2017 19:13:21 +0000 (UTC)","from [10.10.122.186] (ovpn-122-186.rdu2.redhat.com [10.10.122.186])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id E05D55C7B1;\n\tTue, 29 Aug 2017 19:13:17 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 5CDC7883D6","To":"Stefan Hajnoczi <stefanha@redhat.com>, qemu-devel@nongnu.org","References":"<20170829122745.14309-1-stefanha@redhat.com>\n\t<20170829122745.14309-2-stefanha@redhat.com>","From":"Eric Blake <eblake@redhat.com>","Openpgp":"url=http://people.redhat.com/eblake/eblake.gpg","Organization":"Red Hat, Inc.","Message-ID":"<cac1b4fa-1774-0871-ad93-1983aed8da68@redhat.com>","Date":"Tue, 29 Aug 2017 14:13:16 -0500","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.3.0","MIME-Version":"1.0","In-Reply-To":"<20170829122745.14309-2-stefanha@redhat.com>","Content-Type":"multipart/signed; micalg=pgp-sha256;\n\tprotocol=\"application/pgp-signature\";\n\tboundary=\"tO9m19jCn9x7tL2M4o4wBHMkLrCEFG9H7\"","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.11","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.26]);\n\tTue, 29 Aug 2017 19:13:21 +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","X-Content-Filtered-By":"Mailman/MimeDel 2.1.21","Subject":"Re: [Qemu-devel] [PATCH v2 1/3] nbd-client: avoid read_reply_co\n\tentry if send failed","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":"Kevin Wolf <kwolf@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>,\n\tVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,\n\tqemu-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>"}},{"id":1775761,"web_url":"http://patchwork.ozlabs.org/comment/1775761/","msgid":"<1fef363e-7ff3-a39e-bad6-18e9d927b37d@redhat.com>","list_archive_url":null,"date":"2017-09-26T18:12:42","subject":"Re: [Qemu-devel] [PATCH v2 1/3] nbd-client: avoid read_reply_co\n\tentry if send failed","submitter":{"id":6591,"url":"http://patchwork.ozlabs.org/api/people/6591/","name":"Eric Blake","email":"eblake@redhat.com"},"content":"CC: qemu-stable@nongnu.org\n\nOn 08/29/2017 07:27 AM, Stefan Hajnoczi wrote:\n> The following segfault is encountered if the NBD server closes the UNIX\n> domain socket immediately after negotiation:\n> \n>   Program terminated with signal SIGSEGV, Segmentation fault.\n...\n> Note this only happens with UNIX domain sockets on Linux.  It doesn't\n> seem possible to reproduce this with TCP sockets.\n> \n> Suggested-by: Paolo Bonzini <pbonzini@redhat.com>\n> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>\n> ---\n>  block/nbd-client.c | 25 +++++++++----------------\n>  1 file changed, 9 insertions(+), 16 deletions(-)\n>","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=eblake@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 3y1pwd6JC4z9t3m\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 27 Sep 2017 04:13:20 +1000 (AEST)","from localhost ([::1]:50594 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 1dwuMA-0005Ku-2K\n\tfor incoming@patchwork.ozlabs.org; Tue, 26 Sep 2017 14:13:18 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:40540)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <eblake@redhat.com>) id 1dwuLm-0005I4-59\n\tfor qemu-devel@nongnu.org; Tue, 26 Sep 2017 14:12:55 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <eblake@redhat.com>) id 1dwuLl-0004TV-10\n\tfor qemu-devel@nongnu.org; Tue, 26 Sep 2017 14:12:54 -0400","from mx1.redhat.com ([209.132.183.28]:52842)\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 1dwuLf-0004Rx-I8; Tue, 26 Sep 2017 14:12: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 738CF356D8;\n\tTue, 26 Sep 2017 18:12:46 +0000 (UTC)","from [10.10.124.97] (ovpn-124-97.rdu2.redhat.com [10.10.124.97])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 39EAA413C;\n\tTue, 26 Sep 2017 18:12:43 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 738CF356D8","To":"Stefan Hajnoczi <stefanha@redhat.com>, qemu-devel@nongnu.org","References":"<20170829122745.14309-1-stefanha@redhat.com>\n\t<20170829122745.14309-2-stefanha@redhat.com>","From":"Eric Blake <eblake@redhat.com>","Openpgp":"url=http://people.redhat.com/eblake/eblake.gpg","Organization":"Red Hat, Inc.","Message-ID":"<1fef363e-7ff3-a39e-bad6-18e9d927b37d@redhat.com>","Date":"Tue, 26 Sep 2017 13:12:42 -0500","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.3.0","MIME-Version":"1.0","In-Reply-To":"<20170829122745.14309-2-stefanha@redhat.com>","Content-Type":"multipart/signed; micalg=pgp-sha256;\n\tprotocol=\"application/pgp-signature\";\n\tboundary=\"m5DJNMVqmWag1b65IuTpATId7UNhCRhtT\"","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.30]);\n\tTue, 26 Sep 2017 18:12: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","X-Content-Filtered-By":"Mailman/MimeDel 2.1.21","Subject":"Re: [Qemu-devel] [PATCH v2 1/3] nbd-client: avoid read_reply_co\n\tentry if send failed","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":"Kevin Wolf <kwolf@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>,\n\tVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,\n\tqemu-stable <qemu-stable@nongnu.org>, 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>"}}]