Skip to content

Conversation

@benhillis
Copy link
Member

A queue_size of 0 causes division-by-zero panics in get_available_descriptor_index and set_used_descriptor, which both compute modulo queue_size. Reject it early in QueueCore::new.

A queue_size of 0 causes division-by-zero panics in
get_available_descriptor_index and set_used_descriptor, which both
compute modulo queue_size. Reject it early in QueueCore::new.
@benhillis benhillis requested a review from a team as a code owner February 10, 2026 16:46
Copilot AI review requested due to automatic review settings February 10, 2026 16:46
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Rejects invalid virtio queue configurations where queue_size == 0, preventing division-by-zero panics in core ring index math. This fits into the virtio device infrastructure by hardening queue initialization against invalid guest-provided parameters.

Changes:

  • Add a new QueueError::InvalidQueueSize error variant.
  • Validate QueueParams.size != 0 early in QueueCore::new and return a structured error otherwise.

Comment on lines +52 to +54
if params.size == 0 {
return Err(QueueError::InvalidQueueSize);
}
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a unit test covering the new params.size == 0 validation path in QueueCore::new (expecting Err(QueueError::InvalidQueueSize)) to prevent regressions back to modulo-by-zero panics.

Copilot generated this review using guidance from repository custom instructions.
@benhillis
Copy link
Member Author

Included this fix in #2780

@benhillis benhillis closed this Feb 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant