Require a VMXNET3 configuration to have at least one TX queue and one RX
queue.
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4729
Reported-by: Karl Mehltretter <kmehltretter@gmail.com>
Signed-off-by: Andrew Nguyen <xmphyr@gmail.com>
---
This is a resolution for issue #4729:
https://gitlab.com/qemu-project/qemu/-/work_items/4729. The issue is that
a VMXNET3 configuration with 0 RX queues is loaded. When one of these RX
queues is accessed anyway, say, rxq_descr[0], it could have an invalid
interrupt index that was never validated in the first place.
---
Changes in v3:
- Deleted the v1 commit
Cahnges in v2:
- vmxnet3.c: undid v1
- vmxnet3.c: when validating the queues, not interrupt indexes, check for minimum of one
Changes in v1:
- vmxnet3.c: changed the RX queue interrupt index validation for loop to a do-while loop
---
hw/net/vmxnet3.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c
index 24c551a054..875c998d63 100644
--- a/hw/net/vmxnet3.c
+++ b/hw/net/vmxnet3.c
@@ -1382,17 +1382,18 @@ static bool vmxnet3_validate_queues(VMXNET3State *s)
{
/*
* txq_num and rxq_num are total number of queues
- * configured by guest. These numbers must not
- * exceed corresponding maximal values.
+ * configured by guest. These numbers must be at
+ * least one and not exceed corresponding maximal
+ * values.
*/
- if (s->txq_num > VMXNET3_DEVICE_MAX_TX_QUEUES) {
+ if (s->txq_num <= 0 || s->txq_num > VMXNET3_DEVICE_MAX_TX_QUEUES) {
qemu_log_mask(LOG_GUEST_ERROR, "vmxnet3: Bad TX queues number: %d\n",
s->txq_num);
return false;
}
- if (s->rxq_num > VMXNET3_DEVICE_MAX_RX_QUEUES) {
+ if (s->rxq_num <= 0 || s->rxq_num > VMXNET3_DEVICE_MAX_RX_QUEUES) {
qemu_log_mask(LOG_GUEST_ERROR, "vmxnet3: Bad RX queues number: %d\n",
s->rxq_num);
return false;
---
base-commit: 6bf90d4fc5027567cb704d7888f5ec792b4ed75a
change-id: 20261115-4729-out-of-bounds-rx-interrupt-idx-78d69a7d847d
Best regards,
--
Andrew Nguyen <xmphyr@gmail.com>