qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] cirrus: keep vga vram pointer within bounds
@ 2017-10-10 21:36 P J P
  2017-10-11  0:23 ` no-reply
  0 siblings, 1 reply; 2+ messages in thread
From: P J P @ 2017-10-10 21:36 UTC (permalink / raw)
  To: Qemu Developers; +Cc: Gerd Hoffmann, Niu Guoxiang, Prasad J Pandit

From: Prasad J Pandit <pjp@fedoraproject.org>

'dst' pointer could exceed vga vram size when writing to the
cirrus memory area; it'd lead to an OOB access issue. Add check
to avoid it.

Reported-by: Niu Guoxiang <niuguoxiang@huawei.com>
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
---
 hw/display/cirrus_vga.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/hw/display/cirrus_vga.c b/hw/display/cirrus_vga.c
index afc290ab91..451a736262 100644
--- a/hw/display/cirrus_vga.c
+++ b/hw/display/cirrus_vga.c
@@ -2047,8 +2047,11 @@ static void cirrus_mem_writeb_mode4and5_8bpp(CirrusVGAState * s,
 	}
 	val <<= 1;
 	dst++;
+        if (dst >= s->vga.vram_ptr + s->vga.vram_size) {
+            break;
+        }
     }
-    memory_region_set_dirty(&s->vga.vram, offset, 8);
+    memory_region_set_dirty(&s->vga.vram, offset, x);
 }
 
 static void cirrus_mem_writeb_mode4and5_16bpp(CirrusVGAState * s,
@@ -2071,8 +2074,11 @@ static void cirrus_mem_writeb_mode4and5_16bpp(CirrusVGAState * s,
 	}
 	val <<= 1;
 	dst += 2;
+        if (dst >= s->vga.vram_ptr + s->vga.vram_size) {
+            break;
+        }
     }
-    memory_region_set_dirty(&s->vga.vram, offset, 16);
+    memory_region_set_dirty(&s->vga.vram, offset, x<<1);
 }
 
 /***************************************
-- 
2.13.6

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

* Re: [Qemu-devel] [PATCH] cirrus: keep vga vram pointer within bounds
  2017-10-10 21:36 [Qemu-devel] [PATCH] cirrus: keep vga vram pointer within bounds P J P
@ 2017-10-11  0:23 ` no-reply
  0 siblings, 0 replies; 2+ messages in thread
From: no-reply @ 2017-10-11  0:23 UTC (permalink / raw)
  To: ppandit; +Cc: famz, qemu-devel, kraxel, niuguoxiang, pjp

Hi,

This series seems to have some coding style problems. See output below for
more information:

Type: series
Message-id: 20171010213608.31567-1-ppandit@redhat.com
Subject: [Qemu-devel] [PATCH] cirrus: keep vga vram pointer within bounds

=== TEST SCRIPT BEGIN ===
#!/bin/bash

BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0

git config --local diff.renamelimit 0
git config --local diff.renames True

commits="$(git log --format=%H --reverse $BASE..)"
for c in $commits; do
    echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
    if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
        failed=1
        echo
    fi
    n=$((n+1))
done

exit $failed
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'
62900c4b66 cirrus: keep vga vram pointer within bounds

=== OUTPUT BEGIN ===
Checking PATCH 1/1: cirrus: keep vga vram pointer within bounds...
ERROR: spaces required around that '<<' (ctx:VxV)
#40: FILE: hw/display/cirrus_vga.c:2081:
+    memory_region_set_dirty(&s->vga.vram, offset, x<<1);
                                                    ^

total: 1 errors, 0 warnings, 24 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

=== OUTPUT END ===

Test command exited with code: 1


---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@freelists.org

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

end of thread, other threads:[~2017-10-11  2:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-10 21:36 [Qemu-devel] [PATCH] cirrus: keep vga vram pointer within bounds P J P
2017-10-11  0:23 ` no-reply

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