qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] do boundary check based on absolute value
@ 2008-12-04 21:44 Glauber Costa
  2008-12-04 22:36 ` [Qemu-devel] " Anthony Liguori
  2008-12-05 12:00 ` [Qemu-devel] " René Rebe
  0 siblings, 2 replies; 4+ messages in thread
From: Glauber Costa @ 2008-12-04 21:44 UTC (permalink / raw)
  To: qemu-devel; +Cc: avi, kvm

For backward operations, dstpitch and srcpitch can
be negative. This leads BLTUNSAFE macro into an
overflow, and as a result, it avoids performing
operations that are perfectly valid.

The visible effect that led to that patch was the gnome-panel
bar in Fedora10. Before this patch, you could see garbage
clobbering a big portion of the bar.

After this patch, this garbage is gone.

Signed-off-by: Glauber Costa <glommer@redhat.com>
---
 hw/cirrus_vga.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
index e0cf458..5690719 100644
--- a/hw/cirrus_vga.c
+++ b/hw/cirrus_vga.c
@@ -221,15 +221,17 @@
 #define CIRRUS_HOOK_NOT_HANDLED 0
 #define CIRRUS_HOOK_HANDLED 1
 
+#define ABS(a) ((signed)(a) > 0 ? a : -a)
+
 #define BLTUNSAFE(s) \
     ( \
         ( /* check dst is within bounds */ \
-            (s)->cirrus_blt_height * (s)->cirrus_blt_dstpitch \
+            (s)->cirrus_blt_height * ABS((s)->cirrus_blt_dstpitch) \
                 + ((s)->cirrus_blt_dstaddr & (s)->cirrus_addr_mask) > \
                     (s)->vram_size \
         ) || \
         ( /* check src is within bounds */ \
-            (s)->cirrus_blt_height * (s)->cirrus_blt_srcpitch \
+            (s)->cirrus_blt_height * ABS((s)->cirrus_blt_srcpitch) \
                 + ((s)->cirrus_blt_srcaddr & (s)->cirrus_addr_mask) > \
                     (s)->vram_size \
         ) \
-- 
1.5.6.5

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Qemu-devel] Re: [PATCH] do boundary check based on absolute value
  2008-12-04 21:44 [Qemu-devel] [PATCH] do boundary check based on absolute value Glauber Costa
@ 2008-12-04 22:36 ` Anthony Liguori
  2008-12-05 12:00 ` [Qemu-devel] " René Rebe
  1 sibling, 0 replies; 4+ messages in thread
From: Anthony Liguori @ 2008-12-04 22:36 UTC (permalink / raw)
  To: Glauber Costa; +Cc: qemu-devel, kvm, avi

Glauber Costa wrote:
> For backward operations, dstpitch and srcpitch can
> be negative. This leads BLTUNSAFE macro into an
> overflow, and as a result, it avoids performing
> operations that are perfectly valid.
>
> The visible effect that led to that patch was the gnome-panel
> bar in Fedora10. Before this patch, you could see garbage
> clobbering a big portion of the bar.
>
> After this patch, this garbage is gone.
>
>   

Applied.  Thanks.

Regards,

Anthony Liguori

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] do boundary check based on absolute value
  2008-12-04 21:44 [Qemu-devel] [PATCH] do boundary check based on absolute value Glauber Costa
  2008-12-04 22:36 ` [Qemu-devel] " Anthony Liguori
@ 2008-12-05 12:00 ` René Rebe
  2008-12-05 12:04   ` Glauber Costa
  1 sibling, 1 reply; 4+ messages in thread
From: René Rebe @ 2008-12-05 12:00 UTC (permalink / raw)
  To: qemu-devel; +Cc: avi, kvm

Hi,

Glauber Costa wrote:
> For backward operations, dstpitch and srcpitch can
> be negative. This leads BLTUNSAFE macro into an
> overflow, and as a result, it avoids performing
> operations that are perfectly valid.
>
> The visible effect that led to that patch was the gnome-panel
> bar in Fedora10. Before this patch, you could see garbage
> clobbering a big portion of the bar.
>
> After this patch, this garbage is gone.
>   
Confirmed to fix corruption with simple window mangers like
blackbox/fluxbox when moving windows out of the screen
bounds, which had on my TODO for review.
> Signed-off-by: Glauber Costa <glommer@redhat.com>
> ---
>  hw/cirrus_vga.c |    6 ++++--
>  1 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
> index e0cf458..5690719 100644
> --- a/hw/cirrus_vga.c
> +++ b/hw/cirrus_vga.c
> @@ -221,15 +221,17 @@
>  #define CIRRUS_HOOK_NOT_HANDLED 0
>  #define CIRRUS_HOOK_HANDLED 1
>  
> +#define ABS(a) ((signed)(a) > 0 ? a : -a)
> +
>  #define BLTUNSAFE(s) \
>      ( \
>          ( /* check dst is within bounds */ \
> -            (s)->cirrus_blt_height * (s)->cirrus_blt_dstpitch \
> +            (s)->cirrus_blt_height * ABS((s)->cirrus_blt_dstpitch) \
>                  + ((s)->cirrus_blt_dstaddr & (s)->cirrus_addr_mask) > \
>                      (s)->vram_size \
>          ) || \
>          ( /* check src is within bounds */ \
> -            (s)->cirrus_blt_height * (s)->cirrus_blt_srcpitch \
> +            (s)->cirrus_blt_height * ABS((s)->cirrus_blt_srcpitch) \
>                  + ((s)->cirrus_blt_srcaddr & (s)->cirrus_addr_mask) > \
>                      (s)->vram_size \
>          ) \
>   

-- 
  René Rebe - ExactCODE GmbH - Europe, Germany, Berlin
  http://exactcode.de | http://t2-project.org | http://rene.rebe.name

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] do boundary check based on absolute value
  2008-12-05 12:00 ` [Qemu-devel] " René Rebe
@ 2008-12-05 12:04   ` Glauber Costa
  0 siblings, 0 replies; 4+ messages in thread
From: Glauber Costa @ 2008-12-05 12:04 UTC (permalink / raw)
  To: qemu-devel

>
> Confirmed to fix corruption with simple window mangers like
> blackbox/fluxbox when moving windows out of the screen
> bounds, which had on my TODO for review.

Great!

-- 
Glauber  Costa.
"Free as in Freedom"
http://glommer.net

"The less confident you are, the more serious you have to act."

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-12-05 12:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-04 21:44 [Qemu-devel] [PATCH] do boundary check based on absolute value Glauber Costa
2008-12-04 22:36 ` [Qemu-devel] " Anthony Liguori
2008-12-05 12:00 ` [Qemu-devel] " René Rebe
2008-12-05 12:04   ` Glauber Costa

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).