Hi, +-- On Mon, 19 Oct 2020, BALATON Zoltan wrote --+ | On Mon, 19 Oct 2020, P J P wrote: | > dst_x = ... (s->regs.dst_x(=0) + 1 - s->regs.dst_width(=16383)) | > dst_y = ... (s->regs.dst_y(=0) + 1 - s->regs.dst_height(=16383)) | > | > ati_2d_blt | > pixman_blt(0x7f03cbe00000, 0x7f03cbe00000, 131064, 131064, 32, 32, | > src_x=0, src_y=-16382, dst_x=0, dst_y=-16382, 16383, 16383) | > | > Shown as negative values due to signed '%d' conversion. | | Checking the docs again I see that the allowed range of at least | s->regs.[src|dst]_[xy] can actually be negative (-8192:8191)
* But 'struct ATIVGARegs' declares these fields as 'uint32_t' type. Ie. no negativeve values. * I guess that range applies to src->regs.dst_[width|height] too? Considering it being subtracted from s->regs.dst_[xy] values above. | > uint8_t *end = s->vga.vram_ptr + s->vga.vram_size; | > if (dst_bits >= end || dst_bits + dst_x + (dst_y + s->regs.dst_height) * | > dst_stride >= end) { | > qemu_log_mask(LOG_UNIMP, "blt outside vram not implemented\n"); | > return; | | ... Could it be it overflows? * Yes, following expression dst_y(=4294950914(=-16382)) + s->regs.dst_height(=16383)) overflows to => 1 Ie. (dst_bits + dst_x(=0) + (1) * dst_stride >= end) returns false. | maybe rather add additional term for src|dst_x|y to the already existing | checks if their condition cannot be fixed to detect it properly. === diff --git a/hw/display/ati_2d.c b/hw/display/ati_2d.c index 524bc03a83..5fa7362305 100644 --- a/hw/display/ati_2d.c +++ b/hw/display/ati_2d.c @@ -54,9 +54,9 @@ void ati_2d_blt(ATIVGAState *s) ... - if (dst_bits >= end || dst_bits + dst_x + (dst_y + s->regs.dst_height) * - dst_stride >= end) { + if (dst_x > 0x3fff || dst_y > 0x3fff || dst_bits >= end + || dst_bits + dst_x + (dst_y + s->regs.dst_height) + * dst_stride >= end) { qemu_log_mask(LOG_UNIMP, "blt outside vram not implemented\n"); return; } ... - if (src_bits >= end || src_bits + src_x + - (src_y + s->regs.dst_height) * src_stride >= end) { + if (src_x > 0x3fff || src_y > 0x3ff || src_bits >= end + || src_bits + src_x + (src_y + s->regs.dst_height) + * src_stride >= end) { qemu_log_mask(LOG_UNIMP, "blt outside vram not implemented\n"); return; } === * Does it look okay? Thank you. -- Prasad J Pandit / Red Hat Product Security Team 8685 545E B54C 486B C6EB 271E E285 8B5A F050 DE8D