From patchwork Fri Jun 27 14:11:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 364985 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 156AD140087 for ; Sat, 28 Jun 2014 00:14:04 +1000 (EST) Received: from localhost ([::1]:50602 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X0Wuf-0007jO-UP for incoming@patchwork.ozlabs.org; Fri, 27 Jun 2014 10:14:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56257) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X0Wsl-0003wh-15 for qemu-devel@nongnu.org; Fri, 27 Jun 2014 10:12:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X0Wsf-0006ri-2Y for qemu-devel@nongnu.org; Fri, 27 Jun 2014 10:12:02 -0400 Received: from mail-wi0-x233.google.com ([2a00:1450:400c:c05::233]:44364) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X0Wse-0006rV-Se; Fri, 27 Jun 2014 10:11:57 -0400 Received: by mail-wi0-f179.google.com with SMTP id cc10so2903915wib.0 for ; Fri, 27 Jun 2014 07:11:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=WtFZxFEI+cSoXSzf3PHmKlYo69vPCRWISq9iVol905E=; b=GRhjw2k9yOUNUrbcpQ1oMSKg1+KAUmPC7BPd92HHJoRhHPCr397qE5DwRAAu+r83/Z C0bQUKxiDhwEuK8vHYFxfy9zU1762fL6h6SU55Dc3dDuYUcNU3lCv10T+5XZbo9g26e3 bUfwCSgBilfx1U4o0l5rTEBPYAoRtga3agv1dafqxl7mfno+N96EU3tr7Il4UEEZ8a6A Zb/v+pBMwbQXuGh8jveqixzPIfAmF3jgI7HQnI+P4nWhwzFup+hzqmah6orRZyCBU6xY Vm9gl72wk5niVE51ClbmcD1IHC44cJhwB3Q1W/3+wPYP4Ii86SOjFwXeKdAP4u2oC05A rUng== X-Received: by 10.194.157.195 with SMTP id wo3mr3174705wjb.130.1403878316088; Fri, 27 Jun 2014 07:11:56 -0700 (PDT) Received: from playground.station (net-37-117-147-170.cust.vodafonedsl.it. [37.117.147.170]) by mx.google.com with ESMTPSA id s3sm21647584wje.36.2014.06.27.07.11.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Jun 2014 07:11:55 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 27 Jun 2014 16:11:43 +0200 Message-Id: <1403878306-22683-3-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1403878306-22683-1-git-send-email-pbonzini@redhat.com> References: <1403878306-22683-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::233 Cc: qemu-stable@nongnu.org, Hani Benhabiles Subject: [Qemu-devel] [PULL 2/5] nbd: Don't validate from and len in NBD_CMD_DISC. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Hani Benhabiles These values aren't used in this case. Currently, the from field in the request sent by the nbd kernel module leading to a false error message when ending the connection with the client. $ qemu-nbd some.img -v // After nbd-client -d /dev/nbd0 nbd.c:nbd_trip():L1031: From: 18446744073709551104, Len: 0, Size: 20971520, Offset: 0 nbd.c:nbd_trip():L1032: requested operation past EOF--bad client? nbd.c:nbd_receive_request():L638: read failed Signed-off-by: Hani Benhabiles Cc: qemu-stable@nongnu.org Signed-off-by: Paolo Bonzini --- nbd.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/nbd.c b/nbd.c index e0d032c..8d8bc40 100644 --- a/nbd.c +++ b/nbd.c @@ -1001,6 +1001,7 @@ static void nbd_trip(void *opaque) struct nbd_request request; struct nbd_reply reply; ssize_t ret; + uint32_t command; TRACE("Reading request."); if (client->closing) { @@ -1023,8 +1024,8 @@ static void nbd_trip(void *opaque) reply.error = -ret; goto error_reply; } - - if ((request.from + request.len) > exp->size) { + command = request.type & NBD_CMD_MASK_COMMAND; + if (command != NBD_CMD_DISC && (request.from + request.len) > exp->size) { LOG("From: %" PRIu64 ", Len: %u, Size: %" PRIu64 ", Offset: %" PRIu64 "\n", request.from, request.len, @@ -1033,7 +1034,7 @@ static void nbd_trip(void *opaque) goto invalid_request; } - switch (request.type & NBD_CMD_MASK_COMMAND) { + switch (command) { case NBD_CMD_READ: TRACE("Request type is READ");