summaryrefslogtreecommitdiff
path: root/hw/display
diff options
context:
space:
mode:
authorlinzhecheng <linzhecheng@huawei.com>2018-01-11 21:27:24 +0800
committerGerd Hoffmann <kraxel@redhat.com>2018-01-25 10:18:39 +0100
commit191f59dc17396bb5a8da50f8c59b6e0a430711a4 (patch)
tree3c58d8420a96ae8502c8781ed9c3a5e4413bc90a /hw/display
parent834a336eb911db8a8ca00e760ee6a85faca19414 (diff)
vga: check the validation of memory addr when draw text
Start a vm with qemu-kvm -enable-kvm -vnc :66 -smp 1 -m 1024 -hda redhat_5.11.qcow2 -device pcnet -vga cirrus, then use VNC client to connect to VM, and excute the code below in guest OS will lead to qemu crash: int main() { iopl(3); srand(time(NULL)); int a,b; while(1){ a = rand()%0x100; b = 0x3c0 + (rand()%0x20); outb(a,b); } return 0; } The above code is writing the registers of VGA randomly. We can write VGA CRT controller registers index 0x0C or 0x0D (which is the start address register) to modify the the display memory address of the upper left pixel or character of the screen. The address may be out of the range of vga ram. So we should check the validation of memory address when reading or writing it to avoid segfault. Signed-off-by: linzhecheng <linzhecheng@huawei.com> Message-id: 20180111132724.13744-1-linzhecheng@huawei.com Fixes: CVE-2018-5683 Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'hw/display')
-rw-r--r--hw/display/vga.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/hw/display/vga.c b/hw/display/vga.c
index a0412000a5..6e78a4e156 100644
--- a/hw/display/vga.c
+++ b/hw/display/vga.c
@@ -1279,6 +1279,9 @@ static void vga_draw_text(VGACommonState *s, int full_update)
cx_min = width;
cx_max = -1;
for(cx = 0; cx < width; cx++) {
+ if (src + sizeof(uint16_t) > s->vram_ptr + s->vram_size) {
+ break;
+ }
ch_attr = *(uint16_t *)src;
if (full_update || ch_attr != *ch_attr_ptr || src == cursor_ptr) {
if (cx < cx_min)