From patchwork Fri Sep 5 16:51:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Lieven X-Patchwork-Id: 386464 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 901261400F0 for ; Sat, 6 Sep 2014 02:54:31 +1000 (EST) Received: from localhost ([::1]:59127 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XPwmL-0003EZ-Pz for incoming@patchwork.ozlabs.org; Fri, 05 Sep 2014 12:54:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54850) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XPwkQ-0008P7-MG for qemu-devel@nongnu.org; Fri, 05 Sep 2014 12:52:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XPwkK-0001zR-Sr for qemu-devel@nongnu.org; Fri, 05 Sep 2014 12:52:30 -0400 Received: from mx-v6.kamp.de ([2a02:248:0:51::16]:44046 helo=mx01.kamp.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XPwkK-0001zJ-JX for qemu-devel@nongnu.org; Fri, 05 Sep 2014 12:52:24 -0400 Received: (qmail 9305 invoked by uid 89); 5 Sep 2014 16:52:22 -0000 Received: from [82.141.1.145] by client-16-kamp (envelope-from , uid 89) with qmail-scanner-2010/03/19-MF (clamdscan: 0.98.4/19339. hbedv: 8.3.24.22/7.11.170.236. spamassassin: 3.4.0. Clear:RC:1(82.141.1.145):SA:0(-1.2/5.0):. Processed in 1.973224 secs); 05 Sep 2014 16:52:22 -0000 Received: from ns.kamp-intra.net (HELO dns.kamp-intra.net) ([82.141.1.145]) by mx01.kamp.de with SMTP; 5 Sep 2014 16:52:19 -0000 X-GL_Whitelist: yes Received: from lieven-pc.kamp-intra.net (lieven-pc.kamp-intra.net [172.21.12.60]) by dns.kamp-intra.net (Postfix) with ESMTP id 7531C20695; Fri, 5 Sep 2014 18:51:29 +0200 (CEST) Received: by lieven-pc.kamp-intra.net (Postfix, from userid 1000) id 6D1C9614E2; Fri, 5 Sep 2014 18:51:29 +0200 (CEST) From: Peter Lieven To: qemu-devel@nongnu.org Date: Fri, 5 Sep 2014 18:51:26 +0200 Message-Id: <1409935888-18552-3-git-send-email-pl@kamp.de> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1409935888-18552-1-git-send-email-pl@kamp.de> References: <1409935888-18552-1-git-send-email-pl@kamp.de> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a02:248:0:51::16 Cc: kwolf@redhat.com, stefanha@redhat.com, Peter Lieven , mreitz@redhat.com, ronniesahlberg@gmail.com, pbonzini@redhat.com Subject: [Qemu-devel] [PATCH 2/4] block: immediately cancel oversized read/write requests 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 Signed-off-by: Peter Lieven --- block.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/block.c b/block.c index 2c4a5de..fa4c34b 100644 --- a/block.c +++ b/block.c @@ -3215,6 +3215,13 @@ static int coroutine_fn bdrv_co_do_readv(BlockDriverState *bs, return -EINVAL; } + if (bs->bl.max_transfer_length && nb_sectors > bs->bl.max_transfer_length) { + error_report("read of %d sectors at sector %ld exceeds device max" + " transfer length of %d sectors.", nb_sectors, sector_num, + bs->bl.max_transfer_length); + return -EINVAL; + } + return bdrv_co_do_preadv(bs, sector_num << BDRV_SECTOR_BITS, nb_sectors << BDRV_SECTOR_BITS, qiov, flags); } @@ -3507,6 +3514,13 @@ static int coroutine_fn bdrv_co_do_writev(BlockDriverState *bs, return -EINVAL; } + if (bs->bl.max_transfer_length && nb_sectors > bs->bl.max_transfer_length) { + error_report("write of %d sectors at sector %ld exceeds device max" + " transfer length of %d sectors.", nb_sectors, sector_num, + bs->bl.max_transfer_length); + return -EINVAL; + } + return bdrv_co_do_pwritev(bs, sector_num << BDRV_SECTOR_BITS, nb_sectors << BDRV_SECTOR_BITS, qiov, flags); }