Skip to content

Commit 3f7d9c1

Browse files
LPhghPaolo Abeni
authored andcommitted
virtio_net: Add hash_key_length check
Add hash_key_length check in virtnet_probe() to avoid possible out of bound errors when setting/reading the hash key. Fixes: c7114b1 ("drivers/net/virtio_net: Added basic RSS support.") Signed-off-by: Philo Lu <[email protected]> Signed-off-by: Xuan Zhuo <[email protected]> Acked-by: Joe Damato <[email protected]> Acked-by: Michael S. Tsirkin <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent 86a48a0 commit 3f7d9c1

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/net/virtio_net.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6451,6 +6451,12 @@ static int virtnet_probe(struct virtio_device *vdev)
64516451
if (vi->has_rss || vi->has_rss_hash_report) {
64526452
vi->rss_key_size =
64536453
virtio_cread8(vdev, offsetof(struct virtio_net_config, rss_max_key_size));
6454+
if (vi->rss_key_size > VIRTIO_NET_RSS_MAX_KEY_SIZE) {
6455+
dev_err(&vdev->dev, "rss_max_key_size=%u exceeds the limit %u.\n",
6456+
vi->rss_key_size, VIRTIO_NET_RSS_MAX_KEY_SIZE);
6457+
err = -EINVAL;
6458+
goto free;
6459+
}
64546460

64556461
vi->rss_hash_types_supported =
64566462
virtio_cread32(vdev, offsetof(struct virtio_net_config, supported_hash_types));

0 commit comments

Comments
 (0)