rust-vmm / vm-virtio

virtio implementation
Apache License 2.0
364 stars 87 forks source link

virtio-queue: do not iterate over more than 2^32 bytes #236

Closed Ablu closed 1 year ago

Ablu commented 1 year ago

When fuzzing a SCSI vhost-user device, the fuzzer invented a (rather large) self referential descriptor. virtio-scsi then requires reporting the "residual" bytes, which when summing up the remaining bytes can overflow 2^32 bytes. Since the spec mandates that descriptor chains must not exceed 2^32 bytes, let's just terminate iteration once we overrun.

The tests demonstrate how the overflows happened before. While virtio-queue does not directly suffer from any consequences, this guards consumers from having to handle this on their own.

Link: https://rust-vmm.slack.com/archives/CFH3R8PFV/p1682002847952759

Summary of the PR

Terminate iterating over a descriptor chain that is longer than 2^32 bytes.

Requirements

Before submitting your PR, please make sure you addressed the following requirements: