virtio-blk: fix out-of-bounds access to bitmap in notify_guest_bh
PATCH 1/1 virtio-blk: fix out-of-bounds access to bitmap in notify_guest_bh
From: Li Hangjing <[email protected]>
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 Stefan Hajnoczi <[email protected]>
Signed-off-by Li Hangjing <[email protected]>
Reviewed-by Xie Yongji <[email protected]>
Reviewed-by Chai Wen <[email protected]>
--- hw/block/dataplane/virtio-blk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/block/dataplane/virtio-blk.c +1 -1
@@ -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);
Signature · 1 line
2.15.1.windows.2
Quoted 11 lines · Li hangjing
From: Li Hangjing <[email protected]>
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 Stefan Hajnoczi <[email protected]>Signed-off-by Li Hangjing <[email protected]>Reviewed-by Xie Yongji <[email protected]>Reviewed-by Chai Wen <[email protected]>
Quoted 3 lines
--- hw/block/dataplane/virtio-blk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Ouch, thank you for the fix! Applied to my block tree:
https://github.com/stefanha/qemu/commits/block
Stefan