Skip to contentSkip to conversation

net: rocker: set limit to DMA buffer size

PATCH Applied P J P 3 participants 3 messages Oct 12, 2016 – Oct 21, 2016

lore
Share & tools
lore

P J P

author
#0 lore raw

PATCH 1/1 net: rocker: set limit to DMA buffer size

From: Prasad J Pandit <[email protected]>

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.

---
 hw/net/rocker/rocker.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/net/rocker/rocker.c +1 -1
index 30f2ce4..e9d215a 100644
@@ -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;
Signature · 1 line
2.5.5
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Wed, Oct 12, 2016 at 11:10:55AM CEST, [email protected] wrote:

From: Prasad J Pandit <[email protected]>

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.

Applied
#2 lore raw
Quoted 10 lines · Jiri Pirko
Quoted 9 lines · Wed, Oct 12, 2016 at 11:10:55AM CEST, [email protected] wrote:

From: Prasad J Pandit <[email protected]>

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.

Quoted 3 lines
Quoted 2 lines

Applied, thanks.