From patchwork Sat Nov 17 22:32:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eric Blake X-Patchwork-Id: 999408 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42y8yT03zNz9sB5 for ; Sun, 18 Nov 2018 09:33:37 +1100 (AEDT) Received: from localhost ([::1]:50611 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gO99i-0006ql-Jz for incoming@patchwork.ozlabs.org; Sat, 17 Nov 2018 17:33:34 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53820) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gO98m-0006Ed-LL for qemu-devel@nongnu.org; Sat, 17 Nov 2018 17:32:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gO98l-0008CR-RC for qemu-devel@nongnu.org; Sat, 17 Nov 2018 17:32:36 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48162) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gO98f-0008BH-IB; Sat, 17 Nov 2018 17:32:29 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3080D307D843; Sat, 17 Nov 2018 22:32:28 +0000 (UTC) Received: from red.redhat.com (ovpn-121-37.rdu2.redhat.com [10.10.121.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7D04586E2F; Sat, 17 Nov 2018 22:32:27 +0000 (UTC) From: Eric Blake To: qemu-devel@nongnu.org Date: Sat, 17 Nov 2018 16:32:21 -0600 Message-Id: <20181117223221.2198751-1-eblake@redhat.com> In-Reply-To: <353b130c-aefb-ec4c-411b-571a79ec76e2@redhat.com> References: <353b130c-aefb-ec4c-411b-571a79ec76e2@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Sat, 17 Nov 2018 22:32:28 +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 Subject: [Qemu-devel] [PATCH 1.5/6] nbd/server: Ignore write errors when replying to NBD_OPT_ABORT X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "open list:Network Block Dev..." Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Commit 37ec36f6 intentionally ignores errors when trying to reply to an NBD_OPT_ABORT request for plaintext clients, but did not make the same change for a TLS server. Since NBD_OPT_ABORT is documented as being a potential for an EPIPE when the client hangs up without waiting for our reply, we don't need to pollute the server's output with that failure. Signed-off-by: Eric Blake Reviewed-by: Daniel P. Berrangé --- nbd/server.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/nbd/server.c b/nbd/server.c index 056cfa5ad47..dc04513de70 100644 --- a/nbd/server.c +++ b/nbd/server.c @@ -1134,12 +1134,16 @@ static int nbd_negotiate_options(NBDClient *client, uint16_t myflags, return -EINVAL; default: - ret = nbd_opt_drop(client, NBD_REP_ERR_TLS_REQD, errp, + /* Let the client keep trying, unless they asked to + * quit. Always try to give an error back to the + * client; but when replying to OPT_ABORT, be aware + * that the client may hang up before receiving the + * error, in which case we are fine ignoring the + * resulting EPIPE. */ + ret = nbd_opt_drop(client, NBD_REP_ERR_TLS_REQD, + option == NBD_OPT_ABORT ? NULL : errp, "Option 0x%" PRIx32 " not permitted before TLS", option); - /* Let the client keep trying, unless they asked to - * quit. In this mode, we've already sent an error, so - * we can't ack the abort. */ if (option == NBD_OPT_ABORT) { return 1; }