qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: john cooper <john.cooper@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: john.cooper@redhat.com, Rusty Russell <rusty@rustcorp.com.au>,
	qemu-devel@nongnu.org, Vadim Rozenfeld <vrozenfe@redhat.com>,
	jens.axboe@oracle.com, Avi Kivity <avi@redhat.com>
Subject: [Qemu-devel] Re: [PATCH] fix virtio_blk serial pci config breakage, v2
Date: Wed, 07 Oct 2009 01:49:26 -0400	[thread overview]
Message-ID: <4ACC2BE6.2080205@redhat.com> (raw)
In-Reply-To: <20091005195409.GB3399@redhat.com>

Michael S. Tsirkin wrote:
>> +    put_le16(p + 0, 0x0);                            /* ATA device */
>> +    padstr((char *)(p + 23), QEMU_VERSION, 8);       /* firmware revision */
> 
> QEMU version is currently a string like "0.11.50" which is exactly 8
> bytes. What if someone makes it longer?  padstr will not 0
> terminate string, and only partial data will be there.

This code treats the field similar to the logic from which
it derives (hw/ide.c) in that the field need not be nul
terminated.  Quiet truncation to 8 bytes can occur here
and in the existing usage but in a practical sense I don't
see much of a recourse.  We can flag a warning but the
data is realistically a best-effort attempt to provide
relevant information in this field.  IOW overflowing
this field probably isn't justification alone to modify
a too long qemu version string.

> Also, identify is pre-initialized to 0, isn't it?
> So just strcpy should be enough, here and elsewhere,
> no need to roll our own padstr.

Actually this is an oversight in the local padstr() which
should be padding the balance of the field with ' ' vs. '\0'.

>> +            memcpy(req->elem.in_sg[0].iov_base, s->identify,
>> +                req->elem.in_sg[0].iov_len);
> 
> Is this safe? Can guest make iov_len bigger than size of s->identity?

Good point, a malicious/buggy guest can.  The memcpy
length should be capped. 

>> +    virtio_identify_template(s);
>> +    strncpy((char *)&s->identify[VIRTIO_BLK_ID_SN],
>> +        (char *)drive_get_serial(bs), VIRTIO_BLK_ID_SN_BYTES);
> 
> This can silently truncate the serial, can't it?

Yes, it is the same disposition as ide/scsi's treatment
of the S/N.  My concern was of keeping the behavior
consistent.

Thanks,

-john

-- 
john.cooper@redhat.com

  reply	other threads:[~2009-10-07  5:57 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-07 18:14 [Qemu-devel] [PATCH] qemu: make virtio-blk PCI compliant by default Michael S. Tsirkin
2009-09-08  7:40 ` [Qemu-devel] " john cooper
2009-09-08  7:58   ` Michael S. Tsirkin
2009-09-21 11:09     ` Rusty Russell
2009-09-21 15:47       ` john cooper
2009-09-22  9:30         ` Avi Kivity
2009-09-22 14:21           ` john cooper
2009-09-22 14:27             ` Avi Kivity
2009-09-22 14:41               ` Michael S. Tsirkin
2009-09-22 14:45                 ` Avi Kivity
2009-09-22 15:09               ` john cooper
2009-09-23  1:59                 ` Anthony Liguori
2009-09-23  4:56                   ` john cooper
2009-09-29  6:09                     ` [Qemu-devel] [PATCH 0/2] fix virtio_blk serial pci config breakage john cooper
2009-09-29  6:58                       ` [Qemu-devel] " Michael S. Tsirkin
2009-09-29  7:22                         ` Avi Kivity
2009-09-29  8:54                           ` Michael S. Tsirkin
2009-09-29  9:16                             ` Avi Kivity
2009-09-29 13:55                             ` Anthony Liguori
2009-09-29 14:06                               ` Michael S. Tsirkin
2009-09-29 14:14                                 ` Anthony Liguori
2009-09-29 16:24                                   ` Avi Kivity
2009-09-29 16:30                                   ` Michael S. Tsirkin
2009-09-29 17:26                                     ` Anthony Liguori
2009-09-29 17:31                                       ` Michael S. Tsirkin
2009-09-29 17:28                               ` Rusty Russell
2009-09-29 17:31                                 ` Anthony Liguori
2009-09-30  1:12                                   ` Rusty Russell
2009-09-30  1:22                                     ` Jamie Lokier
2009-10-05 15:44                                     ` john cooper
2009-09-29 18:44                               ` john cooper
2009-09-29 20:55                                 ` Anthony Liguori
2009-09-30  1:19                                   ` Rusty Russell
2009-09-30  2:17                                     ` Anthony Liguori
2009-09-30 12:00                                       ` Rusty Russell
2009-09-30 18:04                                         ` Jamie Lokier
2009-10-05 15:41                                           ` john cooper
2009-09-30 11:47                                   ` Paul Brook
2009-10-05 15:40                                     ` john cooper
2009-09-29 13:51                       ` Anthony Liguori
2009-09-29 16:22                         ` Avi Kivity
2009-09-29 17:24                           ` Anthony Liguori
2009-09-29  6:09                     ` [Qemu-devel] [PATCH 1/2] " john cooper
2009-09-29  9:01                       ` [Qemu-devel] " Michael S. Tsirkin
2009-10-05 15:47                       ` [Qemu-devel] [PATCH] fix virtio_blk serial pci config breakage, v2 john cooper
2009-10-05 19:54                         ` [Qemu-devel] " Michael S. Tsirkin
2009-10-07  5:49                           ` john cooper [this message]
2009-10-07 13:48                             ` Anthony Liguori
2009-10-07 13:52                               ` Michael S. Tsirkin
2009-10-07 13:55                                 ` Anthony Liguori
2009-10-07 15:38                                   ` john cooper
2009-10-05 20:15                         ` Michael S. Tsirkin
2009-10-06 14:23                         ` Anthony Liguori
2009-09-29  6:10                     ` [Qemu-devel] [PATCH 2/2] fix virtio_blk serial pci config breakage john cooper
2009-09-29  6:57                       ` [Qemu-devel] " Michael S. Tsirkin
2009-09-29 17:14                       ` Rusty Russell
2009-09-14 11:39   ` [Qemu-devel] Re: [PATCH] qemu: make virtio-blk PCI compliant by default Michael S. Tsirkin
2009-09-15  7:29     ` john cooper
2009-09-22  5:06     ` Rusty Russell

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=4ACC2BE6.2080205@redhat.com \
    --to=john.cooper@redhat.com \
    --cc=avi@redhat.com \
    --cc=jens.axboe@oracle.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rusty@rustcorp.com.au \
    --cc=vrozenfe@redhat.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).