From: Wen Congyang <wency@cn.fujitsu.com>
To: Stefan Weil <weil@mail.berlios.de>
Cc: Peter Maydell <peter.maydell@linaro.org>,
Anthony Liguori <aliguori@us.ibm.com>,
qemu-devel <qemu-devel@nongnu.org>,
Corentin Chary <corentin.chary@gmail.com>
Subject: Re: [Qemu-devel] Re: [PATCH RESEND 2/2] vnc: Fix heap corruption
Date: Thu, 03 Mar 2011 09:37:33 +0800 [thread overview]
Message-ID: <4D6EF0DD.1010405@cn.fujitsu.com> (raw)
In-Reply-To: <4D6EC463.50807@mail.berlios.de>
At 03/03/2011 06:27 AM, Stefan Weil Write:
> Am 02.03.2011 23:01, schrieb Stefan Weil:
>> Am 02.03.2011 19:47, schrieb Peter Maydell:
>>> On 2 March 2011 18:36, Stefan Weil <weil@mail.berlios.de> wrote:
>>>> No. I dont't think that the third parameter of bitmap_clear is
>>>> ok like that. See my patch for the correct value.
>>>
>>> Wen's patch:
>>>
>>> + const size_t width = ds_get_width(vd->ds) / 16;
>>> [...]
>>> - bitmap_set(width_mask, 0, (ds_get_width(vd->ds) / 16));
>>> - bitmap_clear(width_mask, (ds_get_width(vd->ds) / 16),
>>> - VNC_DIRTY_WORDS * BITS_PER_LONG);
>>> + bitmap_set(width_mask, 0, width);
>>> + bitmap_clear(width_mask, width, VNC_DIRTY_WORDS * BITS_PER_LONG
>>> - width);
>>>
>>> Your patch:
>>>
>>> bitmap_clear(width_mask, (ds_get_width(vd->ds) / 16),
>>> - VNC_DIRTY_WORDS * BITS_PER_LONG);
>>> + (VNC_MAX_WIDTH - ds_get_width(vd->ds)) / 16);
>>>
>>> Since ui/vnc.h has:
>>>
>>> #define VNC_DIRTY_WORDS (VNC_MAX_WIDTH / (16 * BITS_PER_LONG))
>>>
>>> the third parameter to bitmap_clear is the same value in
>>> both cases, isn't it? Or is this a rounding bug?
>>>
>>> -- PMM
>>
>> Because of rounding effects, both values can be different.
>>
>> The part missing in my patch is correct handling of another
>> rounding effect:
>>
>> VNC_DIRTY_WORDS is exact for 32 bit long values (and the
>> "old" code which used uint32_t until some weeks ago), where
>> VNC_DIRTY_WORDS = 2560/16/32 = 5.
>>
>> For 64 bit values, VNC_DIRTY_WORDS = 2560/16/64 = 2 (rounded)!
>>
>> Stefan W.
>
>
> Is bitmap_clear() really needed here? Meanwhile I think it is not,
> so this might be a new patch variant...
I do not know why we call bitmap_clear() hear. I only know it is
the same as the old code:
-static inline void vnc_set_bits(uint32_t *d, int n, int nb_words)
-{
- int j;
-
- j = 0;
- while (n >= 32) {
- d[j++] = -1;
- n -= 32;
- }
- if (n > 0)
- d[j++] = (1 << n) - 1;
- while (j < nb_words) <=== bitmap_clear()
- d[j++] = 0;
-}
- vnc_set_bits(width_mask, (ds_get_width(vd->ds) / 16), VNC_DIRTY_WORDS);
+ bitmap_set(width_mask, 0, (ds_get_width(vd->ds) / 16));
+ bitmap_clear(width_mask, (ds_get_width(vd->ds) / 16),
+ VNC_DIRTY_WORDS * BITS_PER_LONG);
>
>
>
next prev parent reply other threads:[~2011-03-03 1:38 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-02 3:46 [Qemu-devel] [PATCH RESEND v2 1/2] fix vnc regression Wen Congyang
2011-03-02 3:58 ` [Qemu-devel] [PATCH RESEND 2/2] vnc: Fix heap corruption Wen Congyang
2011-03-02 10:57 ` [Qemu-devel] " Corentin Chary
2011-03-02 18:36 ` Stefan Weil
2011-03-02 18:47 ` Peter Maydell
2011-03-02 22:01 ` Stefan Weil
2011-03-02 22:27 ` Stefan Weil
2011-03-03 1:37 ` Wen Congyang [this message]
2011-03-02 22:40 ` Peter Maydell
2011-03-02 10:56 ` [Qemu-devel] Re: [PATCH RESEND v2 1/2] fix vnc regression Corentin Chary
2011-03-03 2:44 ` [Qemu-devel] [PATCH 3/3] correct VNC_DIRTY_WORDS on 64 bit machine Wen Congyang
2011-03-03 6:41 ` [Qemu-devel] " Corentin Chary
2011-03-03 6:42 ` Wen Congyang
2011-03-03 6:49 ` [Qemu-devel] [PATCH v2 " Wen Congyang
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=4D6EF0DD.1010405@cn.fujitsu.com \
--to=wency@cn.fujitsu.com \
--cc=aliguori@us.ibm.com \
--cc=corentin.chary@gmail.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=weil@mail.berlios.de \
/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).