-
Notifications
You must be signed in to change notification settings - Fork 186
virtio: validate descriptor index from avail ring #2780
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -41,6 +41,8 @@ pub enum QueueError { | |||||
| TooLong, | ||||||
| #[error("Invalid queue size {0}. Must be a power of 2.")] | ||||||
| InvalidQueueSize(u16), | ||||||
| #[error("descriptor index {0} is out of range")] | ||||||
| InvalidDescriptorIndex(u16), | ||||||
| } | ||||||
|
|
||||||
| pub struct QueueDescriptor { | ||||||
|
|
@@ -240,6 +242,10 @@ impl SplitQueueGetWork { | |||||
| mem: GuestMemory, | ||||||
| params: QueueParams, | ||||||
| ) -> Result<Self, QueueError> { | ||||||
| if params.size == 0 { | ||||||
|
||||||
| if params.size == 0 { | |
| if !params.size.is_power_of_two() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
InvalidDescriptorIndexerror message doesn’t include the queue size / valid range, which makes debugging guest issues harder. Consider includingqueue_sizein the variant (e.g., store both the index andqueue_size) and mention the valid range in the error text.