virtio-blk: Add validation for block size in config space
authorXie Yongji <xieyongji@bytedance.com>
Mon, 9 Aug 2021 10:16:09 +0000 (18:16 +0800)
committerMichael S. Tsirkin <mst@redhat.com>
Wed, 11 Aug 2021 10:44:24 +0000 (06:44 -0400)
commit82e89ea077b93b3c131fa175b0df3acb5b1d5cdf
tree42f68656fd5af5f72814197e1885885a4a1e5583
parente74cfa91f42c50f7f649b0eca46aa049754ccdbd
virtio-blk: Add validation for block size in config space

An untrusted device might presents an invalid block size
in configuration space. This tries to add validation for it
in the validate callback and clear the VIRTIO_BLK_F_BLK_SIZE
feature bit if the value is out of the supported range.

And we also double check the value in virtblk_probe() in
case that it's changed after the validation.

Signed-off-by: Xie Yongji <xieyongji@bytedance.com>
Link: https://lore.kernel.org/r/20210809101609.148-1-xieyongji@bytedance.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
drivers/block/virtio_blk.c