From: Jason Wang <jasowang@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: aliguori@us.ibm.com, pmatouse@redhat.com,
Alexander Graf <agraf@suse.de>,
qemu-devel@nongnu.org, Cornelia Huck <cornelia.huck@de.ibm.com>,
Richard Henderson <rth@twiddle.net>
Subject: Re: [Qemu-devel] [PATCH 2/3] virtio-ccw: check config length before accessing it
Date: Tue, 07 May 2013 13:42:47 +0800 [thread overview]
Message-ID: <51889457.3090609@redhat.com> (raw)
In-Reply-To: <517CE073.1090506@redhat.com>
On 04/28/2013 04:40 PM, Jason Wang wrote:
> On 04/28/2013 04:32 PM, Michael S. Tsirkin wrote:
>> On Fri, Apr 26, 2013 at 04:34:03PM +0800, Jason Wang wrote:
>>> virtio-rng-ccw has zero config length, so we need validate the config length
>>> before trying to access it. Otherwise we may crash since vdev->config is NULL.
>>>
>>> Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
>>> Cc: Richard Henderson <rth@twiddle.net>
>>> Cc: Alexander Graf <agraf@suse.de>
>>> Signed-off-by: Jason Wang <jasowang@redhat.com>
>> The real problem is dev->vdev->get_config being NULL,
>> isn't it? So why not validate it and be done with it?
> Ok, this looks more clear. Will do it in V2.
Recheck the code, looks like {get|set}_config() has been validated in
virtio_bus_get_vdev_config(). So the codes were ok here, will drop this
patch also.
>>> ---
>>> hw/s390x/virtio-ccw.c | 4 ++--
>>> 1 files changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
>>> index 56539d3..8d0dff5 100644
>>> --- a/hw/s390x/virtio-ccw.c
>>> +++ b/hw/s390x/virtio-ccw.c
>>> @@ -260,7 +260,7 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw)
>>> }
>>> }
>>> len = MIN(ccw.count, dev->vdev->config_len);
>>> - if (!ccw.cda) {
>>> + if (!ccw.cda || !len) {
>>> ret = -EFAULT;
>>> } else {
>>> dev->vdev->get_config(dev->vdev, dev->vdev->config);
>>> @@ -279,7 +279,7 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw)
>>> }
>>> len = MIN(ccw.count, dev->vdev->config_len);
>>> hw_len = len;
>>> - if (!ccw.cda) {
>>> + if (!ccw.cda || !len) {
>>> ret = -EFAULT;
>>> } else {
>>> config = cpu_physical_memory_map(ccw.cda, &hw_len, 0);
>>> --
>>> 1.7.1
>
next prev parent reply other threads:[~2013-05-07 5:43 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-26 8:34 [Qemu-devel] [PATCH 1/3] virtio-pci: properly validate address before accessing config Jason Wang
2013-04-26 8:34 ` [Qemu-devel] [PATCH 2/3] virtio-ccw: check config length before accessing it Jason Wang
2013-04-28 8:32 ` Michael S. Tsirkin
2013-04-28 8:40 ` Jason Wang
2013-05-07 5:42 ` Jason Wang [this message]
2013-04-26 8:34 ` [Qemu-devel] [PATCH 3/3] s390-virtio-bus: sync config only when config_len is not zero Jason Wang
2013-04-26 17:07 ` Alexander Graf
2013-04-27 5:14 ` Jason Wang
2013-04-28 8:31 ` Michael S. Tsirkin
2013-04-28 8:39 ` Jason Wang
2013-04-26 14:27 ` [Qemu-devel] [PATCH 1/3] virtio-pci: properly validate address before accessing config Petr Matousek
2013-04-27 5:13 ` Jason Wang
2013-04-28 11:29 ` Petr Matousek
2013-04-29 7:34 ` [Qemu-devel] [oss-security] " Kurt Seifried
2013-04-29 7:51 ` Michael S. Tsirkin
2013-04-27 19:05 ` [Qemu-devel] " Michael S. Tsirkin
2013-04-27 19:26 ` Michael S. Tsirkin
2013-04-28 7:54 ` Jason Wang
2013-04-28 8:35 ` Michael S. Tsirkin
2013-05-02 14:35 ` Andreas Färber
2013-05-06 3:17 ` Jason Wang
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=51889457.3090609@redhat.com \
--to=jasowang@redhat.com \
--cc=agraf@suse.de \
--cc=aliguori@us.ibm.com \
--cc=cornelia.huck@de.ibm.com \
--cc=mst@redhat.com \
--cc=pmatouse@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/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).