WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 09/10] blktap: device_info validation fixes.

To: Xen <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH 09/10] blktap: device_info validation fixes.
From: Daniel Stodden <daniel.stodden@xxxxxxxxxx>
Date: Tue, 8 Mar 2011 16:42:56 -0800
Cc: Jeremy Fitzhardinge <jeremy@xxxxxxxx>, Daniel Stodden <daniel.stodden@xxxxxxxxxx>
Delivery-date: Tue, 08 Mar 2011 16:52:02 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <1299631377-7853-1-git-send-email-daniel.stodden@xxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <1299631377-7853-1-git-send-email-daniel.stodden@xxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
- Logical block size <= 4k is too paranoid.
- Use ilog2 and add more comments.
---
 drivers/block/blktap/device.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/block/blktap/device.c b/drivers/block/blktap/device.c
index 0e8eb0a..2379643 100644
--- a/drivers/block/blktap/device.c
+++ b/drivers/block/blktap/device.c
@@ -315,12 +315,13 @@ blktap_device_validate_info(struct blktap *tap,
        unsigned int phys_mask;
        int sector_order;
 
-       sector_order = ffs(info->sector_size) - 1;
+       /* sector size is is 2^(n >= 9) */
+       sector_order = ilog2(info->sector_size);
        if (sector_order <  9 ||
-           sector_order > 12 ||
            info->sector_size != 1U<<sector_order)
                goto fail;
 
+       /* make sure capacity doesn't overflow */
        if (!info->capacity ||
            (info->capacity > ULLONG_MAX >> sector_order))
                goto fail;
-- 
1.7.0.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>