From: Helge Deller <deller@gmx.de>
To: peter.maydell@linaro.org, qemu-devel@nongnu.org
Cc: "Helge Deller" <deller@gmx.de>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
"Richard Henderson" <rth@twiddle.net>
Subject: [PULL v5 06/12] hw/display/artist: Check offset in draw_line to avoid buffer over-run
Date: Wed, 26 Aug 2020 23:13:39 +0200 [thread overview]
Message-ID: <20200826211345.14295-7-deller@gmx.de> (raw)
In-Reply-To: <20200826211345.14295-1-deller@gmx.de>
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
Invalid I/O writes can craft an offset out of the vram_buffer range.
We avoid:
Program terminated with signal SIGSEGV, Segmentation fault.
284 *dst &= ~plane_mask;
(gdb) bt
#0 0x000055d5dccdc5c0 in artist_rop8 (s=0x55d5defee510, dst=0x7f8e84ed8216 <error: Cannot access memory at address 0x7f8e84ed8216>, val=0 '\000') at hw/display/artist.c:284
#1 0x000055d5dccdcf83 in fill_window (s=0x55d5defee510, startx=22, starty=5674, width=65, height=5697) at hw/display/artist.c:551
#2 0x000055d5dccddfb9 in artist_reg_write (opaque=0x55d5defee510, addr=1051140, val=4265537, size=4) at hw/display/artist.c:902
#3 0x000055d5dcb42a7c in memory_region_write_accessor (mr=0x55d5defeea10, addr=1051140, value=0x7ffe57db08c8, size=4, shift=0, mask=4294967295, attrs=...) at memory.c:483
Reported-by: LLVM libFuzzer
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Helge Deller <deller@gmx.de>
---
hw/display/artist.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/hw/display/artist.c b/hw/display/artist.c
index de56200dbf..a206afe641 100644
--- a/hw/display/artist.c
+++ b/hw/display/artist.c
@@ -555,7 +555,7 @@ static void fill_window(ARTISTState *s, int startx, int starty,
static void draw_line(ARTISTState *s, int x1, int y1, int x2, int y2,
bool update_start, int skip_pix, int max_pix)
{
- struct vram_buffer *buf;
+ struct vram_buffer *buf = &s->vram_buffer[ARTIST_BUFFER_AP];
uint8_t color;
int dx, dy, t, e, x, y, incy, diago, horiz;
bool c1;
@@ -563,6 +563,12 @@ static void draw_line(ARTISTState *s, int x1, int y1, int x2, int y2,
trace_artist_draw_line(x1, y1, x2, y2);
+ if (x1 * y1 >= buf->size || x2 * y2 >= buf->size) {
+ qemu_log_mask(LOG_GUEST_ERROR,
+ "draw_line (%d,%d) (%d,%d)\n", x1, y1, x2, y2);
+ return;
+ }
+
if (update_start) {
s->vram_start = (x2 << 16) | y2;
}
@@ -620,7 +626,6 @@ static void draw_line(ARTISTState *s, int x1, int y1, int x2, int y2,
x = x1;
y = y1;
color = artist_get_color(s);
- buf = &s->vram_buffer[ARTIST_BUFFER_AP];
do {
if (c1) {
--
2.21.3
next prev parent reply other threads:[~2020-08-26 21:24 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-26 21:13 [PULL v5 00/12] The following changes since commit 3461487523b897d324e8d91f3fd20ed55f849544: Helge Deller
2020-08-26 21:13 ` [PULL v5 01/12] hw/hppa: Sync hppa_hardware.h file with SeaBIOS sources Helge Deller
2020-08-26 21:13 ` [PULL v5 02/12] seabios-hppa: Update to SeaBIOS hppa version 1 Helge Deller
2020-08-26 21:13 ` [PULL v5 03/12] hw/hppa: Implement proper SeaBIOS version check Helge Deller
2020-08-26 21:13 ` [PULL v5 04/12] hw/display/artist.c: fix out of bounds check Helge Deller
2020-08-26 21:13 ` [PULL v5 05/12] hw/hppa/lasi: Don't abort on invalid IMR value Helge Deller
2020-08-26 21:13 ` Helge Deller [this message]
2020-08-26 21:13 ` [PULL v5 07/12] hw/display/artist: Refactor artist_rop8() to avoid buffer over-run Helge Deller
2020-08-26 21:13 ` [PULL v5 08/12] Revert "hw/display/artist: Avoid drawing line when nothing to display" Helge Deller
2020-08-26 21:13 ` [PULL v5 09/12] hw/display/artist: Prevent out of VRAM buffer accesses Helge Deller
2020-08-26 21:13 ` [PULL v5 10/12] hw/display/artist: Unbreak size mismatch memory accesses Helge Deller
2020-08-26 21:13 ` [PULL v5 11/12] hw/display/artist: Fix invalidation of lines in artist_draw_line() Helge Deller
2020-08-26 21:13 ` [PULL v5 12/12] hw/display/artist: Fix invalidation of lines near screen border Helge Deller
2020-08-27 10:20 ` [PULL v5 00/12] The following changes since commit 3461487523b897d324e8d91f3fd20ed55f849544: Peter Maydell
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=20200826211345.14295-7-deller@gmx.de \
--to=deller@gmx.de \
--cc=f4bug@amsat.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/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).