From nobody Sun Feb 8 08:43:09 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1532381979374444.9960366061131; Mon, 23 Jul 2018 14:39:39 -0700 (PDT) Received: from localhost ([::1]:36857 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhiYM-0000Ew-9z for importer@patchew.org; Mon, 23 Jul 2018 17:39:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43592) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhLL-0004Vj-4P for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:22:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhLH-0005iL-V0 for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:22:07 -0400 Received: from mail-oi0-x22e.google.com ([2607:f8b0:4003:c06::22e]:38220) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhLH-0005i4-PS; Mon, 23 Jul 2018 16:22:03 -0400 Received: by mail-oi0-x22e.google.com with SMTP id v8-v6so3487938oie.5; Mon, 23 Jul 2018 13:22:03 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id q63-v6sm1777701oia.54.2018.07.23.13.22.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:22:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=uhtN4B6lzqouWLStU3aNeInL/uWL5A7nLQfzGQKmqwo=; b=nA0jY4rspZLfcEBKhKstTjdrDd4BL6OT/OPacaDzkKhckXaWDRrV+7LtVa02gdL/V8 0qY/Dl0FWXykhuF/Kxu9u8zfanNDMu3JsrD0a9ohK7hcp5vH+bBh5PL/t2tidhILW06S BSHsUladWdzLfs8b44WIdWpLUdVbPUp80Gbgu3sclmtwmkMGSdU2NEsmOMHh/sbI6usV IeOKa1HZTlehonZIadO6QWpFEjb/A5xOMqvAdVDCPyGQNY3GuiyMy12VLsiDSEoYwR15 LwhwM9FZE7Qrs3aHm0M+RYi2qZrz6gj8e6CmCjesEBCnOjBG8/vJDSkNKIMjgbp3pkDZ os5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=uhtN4B6lzqouWLStU3aNeInL/uWL5A7nLQfzGQKmqwo=; b=KcSXu1izGPfM5N8OodwE9MBaHkt7W5gB/B7GTk3aqvfUZxpVI+sRWk7zvlYIemFInG eaW5TDXtRIcOPgAPD9R1luasiG9n0TiVlLmBSM9sOVjQhxMEfDLsmsH3uLUfJEy/cCbJ 0fTNPdo/SXRLbbT8D1hhuFUlf9BHZc99gmgyp/nQs+tncG6ZmGkBRwPMfHsk+xLKFZBM Qac2Gsnw7u90ZFge+OvL8pCPOSTm1z1UmP4gkEt6N7a+Ey0JsQtT3PFyBGa7vs3+sUeC co8P/tfQVy03wHpAVCiR+r86P2MuHU/FN4wAwKesqug4TV77m0bQlfPlv8y3Lg1wQedg KLbQ== X-Gm-Message-State: AOUpUlHBj9bX2L9JtnjPgBa2CL1rwz6LzvWxksdpJBlrJ94UpRYIjalL ZcFo7fZ5+SLhJH09HrFFZhCB73Nvbi9NgQ== X-Google-Smtp-Source: AAOMgpdsd0zfQ7As26Wfzk6zrSxAYUnC/OoUnwcSm1a5zmZLuTiEIAQXymY1KbHBRN6f+ECyYmUN8g== X-Received: by 2002:aca:cdc2:: with SMTP id d185-v6mr329199oig.350.1532377322536; Mon, 23 Jul 2018 13:22:02 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:42 -0500 Message-Id: <20180723201748.25573-94-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::22e Subject: [Qemu-devel] [PATCH 93/99] nbd/server: Reject 0-length block status request 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: qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Eric Blake The NBD spec says that behavior is unspecified if the client requests 0 length for block status; but since the structured reply is documenting as returning a non-zero length, it's easier to just diagnose this with an EINVAL error than to figure out what to return. CC: qemu-stable@nongnu.org Signed-off-by: Eric Blake Message-Id: <20180621124937.166549-1-eblake@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy (cherry picked from commit d8b20291cba6aa9bb295885a34f2b5f05d59d1b2) Signed-off-by: Michael Roth --- nbd/server.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nbd/server.c b/nbd/server.c index 9e1f227178..493a926e06 100644 --- a/nbd/server.c +++ b/nbd/server.c @@ -2007,6 +2007,10 @@ static coroutine_fn int nbd_handle_request(NBDClient= *client, "discard failed", errp); =20 case NBD_CMD_BLOCK_STATUS: + if (!request->len) { + return nbd_send_generic_reply(client, request->handle, -EINVAL, + "need non-zero length", errp); + } if (client->export_meta.valid && client->export_meta.base_allocati= on) { return nbd_co_send_block_status(client, request->handle, blk_bs(exp->blk), request->fro= m, --=20 2.17.1