diff mbox

net: rocker: set limit to DMA buffer size

Message ID 1476263455-24839-1-git-send-email-ppandit@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Prasad Pandit Oct. 12, 2016, 9:10 a.m. UTC
From: Prasad J Pandit <pjp@fedoraproject.org>

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>
---
 hw/net/rocker/rocker.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jiri Pirko Oct. 12, 2016, 9:52 a.m. UTC | #1
Wed, Oct 12, 2016 at 11:10:55AM CEST, ppandit@redhat.com wrote:
>From: Prasad J Pandit <pjp@fedoraproject.org>
>
>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>
Jason Wang Oct. 21, 2016, 1:33 a.m. UTC | #2
On 2016年10月12日 17:52, Jiri Pirko wrote:
> Wed, Oct 12, 2016 at 11:10:55AM CEST, ppandit@redhat.com wrote:
>> From: Prasad J Pandit <pjp@fedoraproject.org>
>>
>> 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>

Applied, thanks.
diff mbox

Patch

diff --git a/hw/net/rocker/rocker.c b/hw/net/rocker/rocker.c
index 30f2ce4..e9d215a 100644
--- a/hw/net/rocker/rocker.c
+++ b/hw/net/rocker/rocker.c
@@ -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;