[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] virtio-balloon: fix integer overflow in BALLOON
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH] virtio-balloon: fix integer overflow in BALLOON_CHANGE QMP event |
Date: |
Thu, 18 Apr 2013 13:11:23 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130402 Thunderbird/17.0.5 |
On 04/18/2013 11:05 AM, Luiz Capitulino wrote:
> Because dev->actual is uint32_t, the expression 'dev->actual <<
> VIRTIO_BALLOON_PFN_SHIFT' is truncated to 32 bits. This overflows when
> dev->actual >= 1048576.
>
> To reproduce:
>
> 1. Start a VM with a QMP socket and 5G of RAM
> 2. Connect to the QMP socket, negotiate capabilities and issue:
>
> { "execute":"balloon", "arguments": { "value": 1073741824 } }
>
> 3. What the BALLOON_CHANGE QMP event, the last one will incorretly be:
>
> { "timestamp": { "seconds": 1366228965, "microseconds": 245466 },
> "event": "BALLOON_CHANGE", "data": { "actual": 5368709120 } }
>
> To fix it this commit casts it to ram_addr_t, which is ram_size's type.
>
> Signed-off-by: Luiz Capitulino <address@hidden>
> ---
> hw/virtio/virtio-balloon.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Eric Blake <address@hidden>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature