All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: Laszlo Ersek <lersek@redhat.com>
Cc: Li Qiang <liq3ea@gmail.com>,
	qemu-devel@nongnu.org, ghoffman@redhat.com, liqiang6-s@360.cn
Subject: Re: [Qemu-devel] [PATCH] cirrus: fix oob access issue
Date: Tue, 24 Jan 2017 13:29:58 +0100	[thread overview]
Message-ID: <1485260998.32716.45.camel@redhat.com> (raw)
In-Reply-To: <b269fc2b-e211-cc70-0b7e-da6b3180df88@redhat.com>

> >>>      if (pitch < 0) {
> >>>          int64_t min = addr
> >>> -            + ((int64_t)s->cirrus_blt_height-1) * pitch;
> >>> +            + ((int64_t)s->cirrus_blt_height-1) * pitch
> >>> +            - s->cirrus_blt_width;
> >>>          int32_t max = addr
> >>>              + s->cirrus_blt_width;
> >>>          if (min < 0 || max > s->vga.vram_size) {
> >>>
> >>
> >> I believe this is incorrect. In this case (AFAIR), "addr" points to the
> >> left-most pixel (= lowest address) of the bottom line (= highest
> >> address).
> > 
> > If I read the code correctly it is backwards *both* x and y axis, so
> > addr is the right-most pixel of the bottom line.
> 
> What is "max" then? If "addr" is the right-most pixel of the bottom
> line, then "max" has the highest address just past the rectangle, and
> then adding anything non-negative to it makes no sense.

That is (with the patch applied) inconsistent indeed.  We must either
subtract s->cirrus_blt_width from min (addr == right-most), or add it to
max (addr == left-most), but certainly not both.

> ... Really as I remember it from the downstream review, the pitch is
> negative (bottom-up), but the horizontal direction remains left to right.

Looking at cirrus_vga_rop.h I see:
 - cirrus_bitblt_rop_fwd_*() increment src and dst while walking the
   scanline, and
 - cirrus_bitblt_rop_bkwd_*() decrement src and dst ...

I still think x axis goes backwards too and therefore addr is the
right-most pixel.

cheers,
  Gerd

  parent reply	other threads:[~2017-01-24 12:30 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-24  9:34 [Qemu-devel] [PATCH] cirrus: fix oob access issue Li Qiang
2017-01-24  9:50 ` no-reply
2017-01-24 10:23 ` Laszlo Ersek
2017-01-24 10:48   ` Gerd Hoffmann
2017-01-24 11:17     ` Laszlo Ersek
2017-01-24 11:24       ` Laszlo Ersek
2017-01-24 12:29       ` Gerd Hoffmann [this message]
2017-01-24 15:31         ` Wolfgang Bumiller
2017-01-24 16:12           ` Laszlo Ersek
2017-01-25  1:18             ` Li Qiang
2017-01-25  3:31               ` Laszlo Ersek
2017-01-25  7:26                 ` Gerd Hoffmann
2017-01-25  7:18             ` Gerd Hoffmann
2017-01-25 10:13               ` Laszlo Ersek
  -- strict thread matches above, loose matches on Subject: below --
2017-01-24  9:58 Li Qiang

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=1485260998.32716.45.camel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=ghoffman@redhat.com \
    --cc=lersek@redhat.com \
    --cc=liq3ea@gmail.com \
    --cc=liqiang6-s@360.cn \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.