From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: Jan Beulich <JBeulich@novell.com>
Cc: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: Re: [PATCH] linux-2.6.18/blkback: don't fail empty barrier requests
Date: Thu, 26 May 2011 08:41:55 -0400 [thread overview]
Message-ID: <20110526124154.GC3386@dumpdata.com> (raw)
In-Reply-To: <4DDE3DEE0200007800043A39@vpn.id2.novell.com>
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@novell.com>
> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
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@novell.com>
> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
>
> --- 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@lists.xensource.com
> http://lists.xensource.com/xen-devel
prev parent reply other threads:[~2011-05-26 12:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-26 9:47 [PATCH] linux-2.6.18/blkback: don't fail empty barrier requests Jan Beulich
2011-05-26 12:41 ` Konrad Rzeszutek Wilk [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110526124154.GC3386@dumpdata.com \
--to=konrad.wilk@oracle.com \
--cc=JBeulich@novell.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).