aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLi Hangjing <lihangjing@baidu.com>2019-12-16 10:30:50 +0800
committerMichael Roth <mdroth@linux.vnet.ibm.com>2020-05-11 15:25:04 -0500
commitdef30090ad7917c9a6c68065922759dd83900d6f (patch)
treee0ec6613a22f333ceae4c96703c334b316f1656b
parent52a02834e0d54d59d9665e2d39c2259345df2335 (diff)
virtio-blk: fix out-of-bounds access to bitmap in notify_guest_bh
When the number of a virtio-blk device's virtqueues is larger than BITS_PER_LONG, the out-of-bounds access to bitmap[ ] will occur. Fixes: e21737ab15 ("virtio-blk: multiqueue batch notify") Cc: qemu-stable@nongnu.org Cc: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Li Hangjing <lihangjing@baidu.com> Reviewed-by: Xie Yongji <xieyongji@baidu.com> Reviewed-by: Chai Wen <chaiwen@baidu.com> Message-id: 20191216023050.48620-1-lihangjing@baidu.com Message-Id: <20191216023050.48620-1-lihangjing@baidu.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> (cherry picked from commit 725fe5d10dbd4259b1853b7d253cef83a3c0d22a) Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
-rw-r--r--hw/block/dataplane/virtio-blk.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c
index 119906a5fe..1b52e8159c 100644
--- a/hw/block/dataplane/virtio-blk.c
+++ b/hw/block/dataplane/virtio-blk.c
@@ -67,7 +67,7 @@ static void notify_guest_bh(void *opaque)
memset(s->batch_notify_vqs, 0, sizeof(bitmap));
for (j = 0; j < nvqs; j += BITS_PER_LONG) {
- unsigned long bits = bitmap[j];
+ unsigned long bits = bitmap[j / BITS_PER_LONG];
while (bits != 0) {
unsigned i = j + ctzl(bits);