From: "Jan Beulich" <JBeulich@novell.com>
To: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>, xen-devel@lists.xensource.com
Subject: Re: [GIT PULL] for-2.6.32/bug-fixes
Date: Tue, 17 May 2011 11:07:05 +0100 [thread overview]
Message-ID: <4DD264E90200007800041973@vpn.id2.novell.com> (raw)
In-Reply-To: <4DD260700200007800041962@vpn.id2.novell.com>
>>> On 17.05.11 at 11:48, "Jan Beulich" <JBeulich@novell.com> wrote:
>>>> On 16.05.11 at 22:35, Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> wrote:
>> with xen-blkback wherein a barrier request would have been discarded (and an
> error
>> returned) b/c the sector provided via the request was -1. The -1 sector made
>> vbd_translate return an error (it checked the sector number against the size
> of
>> the disk) and it would never go through trying to do a barrier. The second
> bug-fix
>> is also in my devel/xen-blkback-v3.2 upstream tree.
>
> Is this really correct? You appear to assume that BLKIF_OP_WRITE_BARRIER
> always has no data, but the rest of the code in the driver (and
> the frontend) doesn't seem to imply that (see e.g. the check
> immediately following the switch statement your patch modifies).
> Hence shouldn't you clear the sector number only when
> req->nr_segments is zero? Or alternatively, shouldn't
> vbd_translate() simply not fail when req->nr_sects is zero?
>
> Additionally, looking at the check in vbd_translate(), wouldn't you
> think there ought to be overflow checking for the addition, too?
Altogether e.g.
Subject: xen/blkback: don't fail empty barrier requests
The sector number on empty barrier requests may (will?) be -1, which,
given that it's being treated as unsigned 64-bit quantity, will almost
always exceed the actual (virtual) disk's size.
Inspired by Konrad's "When writting barriers set the sector number to
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
@@ -114,8 +114,14 @@ int vbd_translate(struct phys_req *req,
if (vbd->bdev == NULL)
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;
next prev parent reply other threads:[~2011-05-17 10:07 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-16 20:35 [GIT PULL] for-2.6.32/bug-fixes Konrad Rzeszutek Wilk
2011-05-17 9:48 ` Jan Beulich
2011-05-17 10:07 ` Jan Beulich [this message]
2011-05-17 14:16 ` Konrad Rzeszutek Wilk
2011-05-17 15:06 ` Jan Beulich
2011-05-17 15:57 ` Konrad Rzeszutek Wilk
2011-05-17 16:24 ` Jan Beulich
2011-05-17 16:43 ` Konrad Rzeszutek Wilk
-- strict thread matches above, loose matches on Subject: below --
2011-05-18 6:22 Jan Beulich
2011-05-18 13:24 ` Konrad Rzeszutek Wilk
2011-05-18 14:31 ` Jan Beulich
2011-05-18 14:56 ` Konrad Rzeszutek Wilk
2011-05-18 15:03 ` Jan Beulich
2011-05-18 15:13 ` Konrad Rzeszutek Wilk
2011-05-18 15:23 ` Jan Beulich
2011-01-27 18:52 Konrad Rzeszutek Wilk
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=4DD264E90200007800041973@vpn.id2.novell.com \
--to=jbeulich@novell.com \
--cc=jeremy@goop.org \
--cc=konrad.wilk@oracle.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).