virtio-blk: limit seg_max to a safe value
authorStefan Hajnoczi <stefanha@redhat.com>
Mon, 24 May 2021 15:40:20 +0000 (16:40 +0100)
committerMichael S. Tsirkin <mst@redhat.com>
Sat, 3 Jul 2021 08:50:53 +0000 (04:50 -0400)
commit63947b3434f475418b9677a393d025c0962c2cf8
tree96114c339dce8f5912b75e40f65277fccff4cca5
parent7a43ce37cd595ed7b6e6a48bdb3a598e647aa738
virtio-blk: limit seg_max to a safe value

The struct virtio_blk_config seg_max value is read from the device and
incremented by 2 to account for the request header and status byte
descriptors added by the driver.

In preparation for supporting untrusted virtio-blk devices, protect
against integer overflow and limit the value to a safe maximum.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Link: https://lore.kernel.org/r/20210524154020.98195-1-stefanha@redhat.com
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
drivers/block/virtio_blk.c