From patchwork Fri Nov 11 16:55:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 693812 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 ozlabs.org (Postfix) with ESMTPS id 3tFmXT2Dl8z9t0t for ; Sat, 12 Nov 2016 04:06:17 +1100 (AEDT) Received: from localhost ([::1]:54050 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c5FHK-0001TD-RJ for incoming@patchwork.ozlabs.org; Fri, 11 Nov 2016 12:06:14 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59412) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c5F6u-0006Ns-18 for qemu-devel@nongnu.org; Fri, 11 Nov 2016 11:55:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c5F6r-0002cl-DB for qemu-devel@nongnu.org; Fri, 11 Nov 2016 11:55:28 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55344) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c5F6p-0002b6-8E; Fri, 11 Nov 2016 11:55:23 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (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 7119C61B84; Fri, 11 Nov 2016 16:55:22 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-63.ams2.redhat.com [10.36.116.63]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uABGtD4E010087; Fri, 11 Nov 2016 11:55:21 -0500 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 11 Nov 2016 17:55:04 +0100 Message-Id: <1478883311-24052-6-git-send-email-kwolf@redhat.com> In-Reply-To: <1478883311-24052-1-git-send-email-kwolf@redhat.com> References: <1478883311-24052-1-git-send-email-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 11 Nov 2016 16:55:22 +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] [PULL 05/12] raw_bsd: don't check size alignment when only offset is set 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Tomáš Golembiovský We make sure that the size is aligned to sector length to prevent any round ups. Otherwise we could end up reading/writing data outside the area specified by user. This is only needed when user supplies the size option to avoid any surprises. It is not necessary when only offset is set. More over, the check made it difficult to use the offset option without size option. The check puts unneeded restriction on the offset which had to be aligned too. Because bdrv_getlength() returns aligned value having unaligned offset would make the check fail. Signed-off-by: Tomáš Golembiovský Signed-off-by: Kevin Wolf --- block/raw_bsd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/raw_bsd.c b/block/raw_bsd.c index cf7a560..8a5b9b0 100644 --- a/block/raw_bsd.c +++ b/block/raw_bsd.c @@ -119,7 +119,7 @@ static int raw_read_options(QDict *options, BlockDriverState *bs, /* Make sure size is multiple of BDRV_SECTOR_SIZE to prevent rounding * up and leaking out of the specified area. */ - if (!QEMU_IS_ALIGNED(s->size, BDRV_SECTOR_SIZE)) { + if (s->has_size && !QEMU_IS_ALIGNED(s->size, BDRV_SECTOR_SIZE)) { error_setg(errp, "Specified size is not multiple of %llu", BDRV_SECTOR_SIZE); ret = -EINVAL;