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

Re: [Xen-devel] [PATCH] linux-2.6.18/blkback: don't fail empty barrier r

To: Jan Beulich <JBeulich@xxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH] linux-2.6.18/blkback: don't fail empty barrier requests
From: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
Date: Thu, 26 May 2011 08:41:55 -0400
Cc: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Thu, 26 May 2011 05:42:43 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <4DDE3DEE0200007800043A39@xxxxxxxxxxxxxxxxxx>
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: <4DDE3DEE0200007800043A39@xxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.21 (2010-09-15)
On Thu, May 26, 2011 at 10:47:58AM +0100, Jan Beulich wrote:
> The sector number on empty barrier requests may (will?) be
> uninitialized (neither bio_init() nor rq_init() set the respective
> fields), which allows for exceeding the actual (virtual) disk's size.
> 
> Inspired by Konrad's "When writting barriers set the sector number to
> zero...", but instead of zapping the sector number (which is wrong for
> non-empty ones) just ignore the sector number when the sector count is
> zero.
> 
> While at it also add overflow checking to the math in vbd_translate().
> 
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>
> Cc: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>

Acked-by.
> 
> --- a/drivers/xen/blkback/vbd.c
> +++ b/drivers/xen/blkback/vbd.c
> @@ -108,8 +108,14 @@ int vbd_translate(struct phys_req *req, 
>       if ((operation != READ) && vbd->readonly)
>               goto out;
>  
> -     if (unlikely((req->sector_number + req->nr_sects) > vbd_sz(vbd)))
> -             goto out;
> +     if (likely(req->nr_sects)) {
> +             blkif_sector_t end = req->sector_number + req->nr_sects;
> +
> +             if (unlikely(end < req->sector_number))
> +                     goto out;
> +             if (unlikely(end > vbd_sz(vbd)))
> +                     goto out;
> +     }
>  
>       req->dev  = vbd->pdevice;
>       req->bdev = vbd->bdev;
> 
> 
> 

> Subject: xen/blkback: don't fail empty barrier requests
> 
> The sector number on empty barrier requests may (will?) be
> uninitialized (neither bio_init() nor rq_init() set the respective
> fields), which allows for exceeding the actual (virtual) disk's size.
> 
> Inspired by Konrad's "When writting barriers set the sector number to
> zero...", but instead of zapping the sector number (which is wrong for
> non-empty ones) just ignore the sector number when the sector count is
> zero.
> 
> While at it also add overflow checking to the math in vbd_translate().
> 
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>
> Cc: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
> 
> --- a/drivers/xen/blkback/vbd.c
> +++ b/drivers/xen/blkback/vbd.c
> @@ -108,8 +108,14 @@ int vbd_translate(struct phys_req *req, 
>       if ((operation != READ) && vbd->readonly)
>               goto out;
>  
> -     if (unlikely((req->sector_number + req->nr_sects) > vbd_sz(vbd)))
> -             goto out;
> +     if (likely(req->nr_sects)) {
> +             blkif_sector_t end = req->sector_number + req->nr_sects;
> +
> +             if (unlikely(end < req->sector_number))
> +                     goto out;
> +             if (unlikely(end > vbd_sz(vbd)))
> +                     goto out;
> +     }
>  
>       req->dev  = vbd->pdevice;
>       req->bdev = vbd->bdev;

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


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

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