Skip to content

virtio-devices: Check MSI-X vector bounds before table access - #8138

Merged
rbradford merged 6 commits into
cloud-hypervisor:mainfrom
weltling:msix-vector-oob-panic
May 5, 2026
Merged

virtio-devices: Check MSI-X vector bounds before table access#8138
rbradford merged 6 commits into
cloud-hypervisor:mainfrom
weltling:msix-vector-oob-panic

Conversation

@weltling

@weltling weltling commented May 4, 2026

Copy link
Copy Markdown
Member

A malicious or buggy guest can write an out-of-bounds value to queue_msix_vector or msix_config. When the device later triggers an interrupt, it indexes into table_entries with the unchecked vector, causing a panic.

Validate the vector against the MSI-X table size in both trigger() and notifier() paths, logging a warning and returning early when the vector exceeds the table bounds.

Added also initial unit tests module and tests covering the behavior.

@weltling
weltling requested a review from a team as a code owner May 4, 2026 21:05
@weltling
weltling force-pushed the msix-vector-oob-panic branch from d0e1116 to 089c689 Compare May 4, 2026 21:29
}

if vector as usize >= self.msix_table_size {
warn!("MSI-X vector {vector} out of range, no notifier");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What does "no notifier" mean here? is it "not notifying" ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

As the notifier() method returns the EventFd associated with a given MSI-X vector, when the vector is out of range there's none exists. Rephrased to "notifier unavailable" to make that clearer.

Thanks

weltling added 6 commits May 4, 2026 23:48
A malicious or buggy guest can write an out-of-bounds value to
queue_msix_vector or msix_config. When the device later triggers
an interrupt, it indexes into table_entries with the unchecked
vector, causing a panic.

Validate the vector against the MSI-X table size in both trigger()
and notifier() paths, logging a warning and returning early when
the vector exceeds the table bounds.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
Verify that firing an interrupt with a queue vector beyond the
MSI-X table size returns Ok without panicking.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
Verify that triggering an interrupt when the vector is set to
VIRTQ_MSI_NO_VECTOR short-circuits and returns Ok.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
Verify that requesting a notifier with an out-of-bounds MSI-X
vector returns None instead of panicking.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
Verify that a valid in bounds vector with MSI-X enabled
successfully triggers the interrupt source group.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
Verify that firing a config change interrupt with msix_config
vector beyond the table size returns Ok without panicking.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
@weltling
weltling force-pushed the msix-vector-oob-panic branch from 089c689 to 7614530 Compare May 4, 2026 21:56

@phip1611 phip1611 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Code-wise LGTM

@rbradford
rbradford added this pull request to the merge queue May 5, 2026
Merged via the queue into cloud-hypervisor:main with commit 6daa9e1 May 5, 2026
41 checks passed
@weltling
weltling deleted the msix-vector-oob-panic branch May 5, 2026 11:20
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.

3 participants