Skip to content

Commit 206cc44

Browse files
md-samimstsirkin
authored andcommitted
virtio: reject shm region if length is zero
Prevent usage of shared memory regions where the length is zero, as such configurations are not valid and may lead to unexpected behavior. Signed-off-by: Sami Uddin <sami.md.ko@gmail.com> Message-Id: <20250511222153.2332-1-sami.md.ko@gmail.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
1 parent 9d4f22f commit 206cc44

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

include/linux/virtio_config.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,8 @@ static inline
329329
bool virtio_get_shm_region(struct virtio_device *vdev,
330330
struct virtio_shm_region *region, u8 id)
331331
{
332+
if (!region->len)
333+
return false;
332334
if (!vdev->config->get_shm_region)
333335
return false;
334336
return vdev->config->get_shm_region(vdev, region, id);

0 commit comments

Comments
 (0)