From patchwork Sat Sep 3 06:33:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prasad Pandit X-Patchwork-Id: 665391 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 3sR5nn0pP5z9s3s for ; Sat, 3 Sep 2016 16:34:52 +1000 (AEST) Received: from localhost ([::1]:45129 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bg4XM-0002M8-Hf for incoming@patchwork.ozlabs.org; Sat, 03 Sep 2016 02:34:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34192) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bg4Wf-0001gb-Uh for qemu-devel@nongnu.org; Sat, 03 Sep 2016 02:34:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bg4Wc-0007OK-O8 for qemu-devel@nongnu.org; Sat, 03 Sep 2016 02:34:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38608) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bg4Wc-0007NA-IV for qemu-devel@nongnu.org; Sat, 03 Sep 2016 02:33:58 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 505694E4CF; Sat, 3 Sep 2016 06:33:56 +0000 (UTC) Received: from javelin.localdomain (vpn1-7-21.ams2.redhat.com [10.36.7.21]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u836Xo2N007049 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sat, 3 Sep 2016 02:33:53 -0400 From: P J P To: Qemu Developers Date: Sat, 3 Sep 2016 12:03:48 +0530 Message-Id: <1472884428-9975-1-git-send-email-ppandit@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Sat, 03 Sep 2016 06:33:56 +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] scsi: pvscsi: request descriptor data_length to 32 bit 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: Dmitry Fleytman , Paolo Bonzini , Li Qiang , Prasad J Pandit Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Prasad J Pandit In PVSCSI paravirtual SCSI bus, the request descriptor data length is defined to be 64 bit. While building SG list from a request descriptor, it gets truncated to 32bit in routine 'pvscsi_convert_sglist'. This could lead to an infinite loop situation for arbitrarily large 'dataLen' values. Define local variable 'data_length' to be 32 bit, to avoid it. Reported-by: Li Qiang Signed-off-by: Prasad J Pandit --- hw/scsi/vmw_pvscsi.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/scsi/vmw_pvscsi.c b/hw/scsi/vmw_pvscsi.c index 4245c15..4d38330 100644 --- a/hw/scsi/vmw_pvscsi.c +++ b/hw/scsi/vmw_pvscsi.c @@ -629,7 +629,7 @@ static void pvscsi_convert_sglist(PVSCSIRequest *r) { int chunk_size; - uint64_t data_length = r->req.dataLen; + uint32_t data_length = r->req.dataLen; PVSCSISGState sg = r->sg; while (data_length) { while (!sg.resid) { @@ -637,8 +637,7 @@ pvscsi_convert_sglist(PVSCSIRequest *r) trace_pvscsi_convert_sglist(r->req.context, r->sg.dataAddr, r->sg.resid); } - assert(data_length > 0); - chunk_size = MIN((unsigned) data_length, sg.resid); + chunk_size = MIN(data_length, sg.resid); if (chunk_size) { qemu_sglist_add(&r->sgl, sg.dataAddr, chunk_size); }