* [Qemu-devel] [5880] do boundary check based on absolute value (Glauber Costa)
@ 2008-12-04 22:36 Anthony Liguori
0 siblings, 0 replies; only message in thread
From: Anthony Liguori @ 2008-12-04 22:36 UTC (permalink / raw)
To: qemu-devel
Revision: 5880
http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5880
Author: aliguori
Date: 2008-12-04 22:36:38 +0000 (Thu, 04 Dec 2008)
Log Message:
-----------
do boundary check based on absolute value (Glauber Costa)
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>
Modified Paths:
--------------
trunk/hw/cirrus_vga.c
Modified: trunk/hw/cirrus_vga.c
===================================================================
--- trunk/hw/cirrus_vga.c 2008-12-04 21:39:21 UTC (rev 5879)
+++ trunk/hw/cirrus_vga.c 2008-12-04 22:36:38 UTC (rev 5880)
@@ -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 \
) \
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2008-12-04 22:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-04 22:36 [Qemu-devel] [5880] do boundary check based on absolute value (Glauber Costa) Anthony Liguori
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).