qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "René Rebe" <rene@exactcode.de>
To: qemu-devel@nongnu.org
Cc: avi@redhat.com, kvm@vger.kernel.org
Subject: Re: [Qemu-devel] [PATCH] do boundary check based on absolute value
Date: Fri, 05 Dec 2008 13:00:35 +0100	[thread overview]
Message-ID: <493917E3.5020404@exactcode.de> (raw)
In-Reply-To: <1228427046-28875-1-git-send-email-glommer@redhat.com>

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

  parent reply	other threads:[~2008-12-05 12:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2008-12-05 12:04   ` [Qemu-devel] " Glauber Costa

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=493917E3.5020404@exactcode.de \
    --to=rene@exactcode.de \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=qemu-devel@nongnu.org \
    /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).