]> git.proxmox.com Git - mirror_qemu.git/commitdiff
ps2: check PS2Queue wptr pointer in post_load routine
authorliujunjie <liujunjie23@huawei.com>
Thu, 7 Jun 2018 08:02:37 +0000 (16:02 +0800)
committerGerd Hoffmann <kraxel@redhat.com>
Mon, 18 Jun 2018 10:06:45 +0000 (12:06 +0200)
In commit 802cbcb7300, most issues have been fixed when qemu guest
migration. But the queue size still need to check whether is equal to
PS2_QUEUE_SIZE. If yes, the wptr should set as 0. Or, wptr would larger
than PS2_QUEUE_SIZE and never come back when ps2_queue_noirq is called.
This could lead to OOB access, add check to avoid it.

Signed-off-by: liujunjie <liujunjie23@huawei.com>
Reviewed-by: Gonglei <arei.gonglei@huawei.com>
Message-id: 20180607080237.12360-1-liujunjie23@huawei.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
hw/input/ps2.c

index eeec6180d0f30faa2a77e42d9a01267cbbffe41c..fdfcadf9a1780a0689850529f61574519f8b1213 100644 (file)
@@ -927,7 +927,7 @@ static void ps2_common_post_load(PS2State *s)
 
     /* reset rptr/wptr/count */
     q->rptr = 0;
-    q->wptr = size;
+    q->wptr = (size == PS2_QUEUE_SIZE) ? 0 : size;
     q->count = size;
     s->update_irq(s->update_arg, q->count != 0);
 }