summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorDmitry Fleytman <dmitry@daynix.com>2014-04-04 12:45:20 +0300
committerPeter Maydell <peter.maydell@linaro.org>2014-04-14 11:50:22 +0100
commit9878d173f574df74bde0ff50b2f81009fbee81bb (patch)
tree032e4b216e9b304b6c5beb0fa7182488a2b0f4fb /hw
parent8c6c0478996e8f77374e69b6df68655b0b4ba689 (diff)
downloadqemu-9878d173f574df74bde0ff50b2f81009fbee81bb.tar.gz
qemu-9878d173f574df74bde0ff50b2f81009fbee81bb.tar.bz2
qemu-9878d173f574df74bde0ff50b2f81009fbee81bb.zip
vmxnet3: validate queues configuration coming from guest
CVE-2013-4544 Signed-off-by: Dmitry Fleytman <dmitry@daynix.com> Reported-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Message-id: 1396604722-11902-3-git-send-email-dmitry@daynix.com Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw')
-rw-r--r--hw/net/vmxnet3.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c
index 0b317f83ff..4fefc7bb49 100644
--- a/hw/net/vmxnet3.c
+++ b/hw/net/vmxnet3.c
@@ -1336,6 +1336,23 @@ static void vmxnet3_validate_interrupts(VMXNET3State *s)
}
}
+static void 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.
+ */
+
+ if (s->txq_num > VMXNET3_DEVICE_MAX_TX_QUEUES) {
+ hw_error("Bad TX queues number: %d\n", s->txq_num);
+ }
+
+ if (s->rxq_num > VMXNET3_DEVICE_MAX_RX_QUEUES) {
+ hw_error("Bad RX queues number: %d\n", s->rxq_num);
+ }
+}
+
static void vmxnet3_activate_device(VMXNET3State *s)
{
int i;
@@ -1382,7 +1399,7 @@ static void vmxnet3_activate_device(VMXNET3State *s)
VMXNET3_READ_DRV_SHARED8(s->drv_shmem, devRead.misc.numRxQueues);
VMW_CFPRN("Number of TX/RX queues %u/%u", s->txq_num, s->rxq_num);
- assert(s->txq_num <= VMXNET3_DEVICE_MAX_TX_QUEUES);
+ vmxnet3_validate_queues(s);
qdescr_table_pa =
VMXNET3_READ_DRV_SHARED64(s->drv_shmem, devRead.misc.queueDescPA);