From patchwork Tue May 24 08:59:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Lieven X-Patchwork-Id: 9133019 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0DA1D607D5 for ; Tue, 24 May 2016 09:00:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 052522824F for ; Tue, 24 May 2016 09:00:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ECF2D2828D; Tue, 24 May 2016 09:00:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 049902824F for ; Tue, 24 May 2016 09:00:04 +0000 (UTC) Received: from localhost ([::1]:52331 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b58C2-0003ia-TE for patchwork-qemu-devel@patchwork.kernel.org; Tue, 24 May 2016 05:00:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46935) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b58Bk-0003fw-V3 for qemu-devel@nongnu.org; Tue, 24 May 2016 04:59:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b58Be-0000SR-9H for qemu-devel@nongnu.org; Tue, 24 May 2016 04:59:43 -0400 Received: from mx-v6.kamp.de ([2a02:248:0:51::16]:58083 helo=mx01.kamp.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b58Bd-0000R0-Us for qemu-devel@nongnu.org; Tue, 24 May 2016 04:59:38 -0400 Received: (qmail 1798 invoked by uid 89); 24 May 2016 08:59:33 -0000 Received: from [195.62.97.28] by client-16-kamp (envelope-from , uid 89) with qmail-scanner-2010/03/19-MF (clamdscan: 0.99.2/21601. hbedv: 8.3.40.16/7.12.93.58. avast: 1.2.2/16052301. spamassassin: 3.4.1. Clear:RC:1(195.62.97.28):. Processed in 0.065066 secs); 24 May 2016 08:59:33 -0000 Received: from smtp.kamp.de (HELO submission.kamp.de) ([195.62.97.28]) by mx01.kamp.de with ESMTPS (DHE-RSA-AES256-GCM-SHA384 encrypted); 24 May 2016 08:59:32 -0000 X-GL_Whitelist: yes Received: (qmail 7028 invoked from network); 24 May 2016 08:59:32 -0000 Received: from lieven-pc.kamp-intra.net (HELO lieven-pc) (relay@kamp.de@::ffff:172.21.12.60) by submission.kamp.de with ESMTPS (DHE-RSA-AES256-GCM-SHA384 encrypted) ESMTPA; 24 May 2016 08:59:32 -0000 Received: by lieven-pc (Postfix, from userid 1000) id DF15D20752; Tue, 24 May 2016 10:59:31 +0200 (CEST) From: Peter Lieven To: qemu-block@nongnu.org Date: Tue, 24 May 2016 10:59:28 +0200 Message-Id: <1464080368-29584-1-git-send-email-pl@kamp.de> X-Mailer: git-send-email 1.9.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a02:248:0:51::16 Subject: [Qemu-devel] [PATCH] block/iscsi: avoid potential overflow of acb->task->cdb 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: Peter Lieven , pbonzini@redhat.com, famz@redhat.com, qemu-devel@nongnu.org, qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP at least in the path via virtio-blk the maximum size is not restricted. Cc: qemu-stable@nongnu.org Signed-off-by: Peter Lieven Reviewed-by: Fam Zheng --- block/iscsi.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/block/iscsi.c b/block/iscsi.c index 2ca8e72..e7d5f7b 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -833,6 +833,13 @@ static BlockAIOCB *iscsi_aio_ioctl(BlockDriverState *bs, return &acb->common; } + if (acb->ioh->cmd_len > SCSI_CDB_MAX_SIZE) { + error_report("iSCSI: ioctl error CDB exceeds max size (%d > %d)", + acb->ioh->cmd_len, SCSI_CDB_MAX_SIZE); + qemu_aio_unref(acb); + return NULL; + } + acb->task = malloc(sizeof(struct scsi_task)); if (acb->task == NULL) { error_report("iSCSI: Failed to allocate task for scsi command. %s",