qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <aliguori@us.ibm.com>
To: qemu-devel@nongnu.org, Aurelien Jarno <aurelien@aurel32.net>,
	Paul Brook <paul@codesourcery.com>
Subject: [Qemu-devel] Re: [PATCH][RFC] Fix CVE-2008-0928 - insufficient block device address range checking
Date: Fri, 27 Feb 2009 11:07:58 -0600	[thread overview]
Message-ID: <49A81DEE.9060909@us.ibm.com> (raw)
In-Reply-To: <20090227165743.GE5000@blackpad>

Eduardo Habkost wrote:
>> Basically, this patch makes the BlockDriver API guarantee that all requests are
>> within 0..bdrv_getlength() which to me seems like a Good Thing.
>>
>> What do others think?
>>
>> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
>>
>> diff --git a/block.c b/block.c
>> index 4f4bf7c..ab88d05 100644
>> --- a/block.c
>> +++ b/block.c
>> @@ -318,6 +318,7 @@ int bdrv_file_open(BlockDriverState **pbs, const char *filename, int flags)
>>          bdrv_delete(bs);
>>          return ret;
>>      }
>> +    bs->growable = 1;
>>     
>
> Is this really safe on all places where bdrv_file_open() is called? The
> original patch has added a BDRV_O_AUTOGROW and it was used on most
> bdrv_file_open() calls, but not on block-vpc.c.
>   

Yes. This is what bdrv_file_open() means as opposed to bdrv_open().

FWIW, I didn't write the original patch, but my guess is that 
block-vpc.c write support is relatively new. Before write support was 
added (less than a month ago), there was no reason to allow a VPC to 
grow. But this definitely demonstrates a problem with the old patch. It 
would have broken block-vpc write support.

>
> The original fix didn't allow out-of-bound read requests even on growable
> devices. But I think the above is safe: raw_pread() should return an
> error on out-of-bound read requests.
>   

An out of bound read request will return an error, so, yeah, I'm 
perfectly happy with it.

>> +
>> +    len = bdrv_getlength(bs);
>>     
>
> Cool, this helps solving two problems with the original approach:
>
> - The block-based vs. byte-based range checking
>   (https://bugzilla.redhat.com/show_bug.cgi?id=485148)
> - Removable devices where we can't be sure the media hasn't changed
>   since the last time we checked the length
>
> The only thing that I am worried about is the performance impact
> of calling raw_getlength() on every request for raw devices such as
> CD-ROMs. I hope it won't trigger some expensive operation on the physical
> device every time we ask for the media size.
>   

If it does, then we'll fix that properly. bdrv_getlength() needs to be 
fast to be useful.

>> +static int bdrv_check_request(BlockDriverState *bs, int64_t sector_num,
>> +                              int nb_sectors)
>> +{
>> +    int64_t offset;
>> +
>> +    /* Deal with byte accesses */
>> +    if (sector_num < 0)
>> +        offset = -sector_num;
>>     
>
> Uh? Where is this feature used?
>   

SCSI generic pass through. Avi has patches to eliminate this an 
introduce a new API but they haven't been merged yet.

Regards,

Anthony Liguori

      reply	other threads:[~2009-02-27 17:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-27 16:20 [Qemu-devel] [PATCH][RFC] Fix CVE-2008-0928 - insufficient block device address range checking Anthony Liguori
2009-02-27 16:57 ` [Qemu-devel] " Eduardo Habkost
2009-02-27 17:07   ` Anthony Liguori [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=49A81DEE.9060909@us.ibm.com \
    --to=aliguori@us.ibm.com \
    --cc=aurelien@aurel32.net \
    --cc=paul@codesourcery.com \
    --cc=qemu-devel@nongnu.org \
    /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).