]> git.proxmox.com Git - mirror_qemu.git/commitdiff
net: rocker: set limit to DMA buffer size
authorPrasad J Pandit <pjp@fedoraproject.org>
Wed, 12 Oct 2016 09:10:55 +0000 (14:40 +0530)
committerJason Wang <jasowang@redhat.com>
Wed, 26 Oct 2016 01:57:59 +0000 (09:57 +0800)
Rocker network switch emulator has test registers to help debug
DMA operations. While testing host DMA access, a buffer address
is written to register 'TEST_DMA_ADDR' and its size is written to
register 'TEST_DMA_SIZE'. When performing TEST_DMA_CTRL_INVERT
test, if DMA buffer size was greater than 'INT_MAX', it leads to
an invalid buffer access. Limit the DMA buffer size to avoid it.

Reported-by: Huawei PSIRT <psirt@huawei.com>
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
hw/net/rocker/rocker.c

index 30f2ce417be54fc8cb30c29f3ac31d1ade381fd3..e9d215aa4df186faccc69503acbe4c73ee75b37d 100644 (file)
@@ -860,7 +860,7 @@ static void rocker_io_writel(void *opaque, hwaddr addr, uint32_t val)
         rocker_msix_irq(r, val);
         break;
     case ROCKER_TEST_DMA_SIZE:
-        r->test_dma_size = val;
+        r->test_dma_size = val & 0xFFFF;
         break;
     case ROCKER_TEST_DMA_ADDR + 4:
         r->test_dma_addr = ((uint64_t)val) << 32 | r->lower32;