2020-05-30 02:46:53

by Jia-Ju Bai

[permalink] [raw]
Subject: [PATCH] net: vmxnet3: fix possible buffer overflow caused by bad DMA value in vmxnet3_get_rss()

The value adapter->rss_conf is stored in DMA memory, and it is assigned
to rssConf, so rssConf->indTableSize can be modified at anytime by
malicious hardware. Because rssConf->indTableSize is assigned to n,
buffer overflow may occur when the code "rssConf->indTable[n]" is
executed.

To fix this possible bug, n is checked after being used.

Signed-off-by: Jia-Ju Bai <[email protected]>
---
drivers/net/vmxnet3/vmxnet3_ethtool.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/net/vmxnet3/vmxnet3_ethtool.c b/drivers/net/vmxnet3/vmxnet3_ethtool.c
index 6528940ce5f3..b53bb8bcd47f 100644
--- a/drivers/net/vmxnet3/vmxnet3_ethtool.c
+++ b/drivers/net/vmxnet3/vmxnet3_ethtool.c
@@ -700,6 +700,8 @@ vmxnet3_get_rss(struct net_device *netdev, u32 *p, u8 *key, u8 *hfunc)
*hfunc = ETH_RSS_HASH_TOP;
if (!p)
return 0;
+ if (n > UPT1_RSS_MAX_IND_TABLE_SIZE)
+ return 0;
while (n--)
p[n] = rssConf->indTable[n];
return 0;
--
2.17.1


2020-06-01 18:55:22

by David Miller

[permalink] [raw]
Subject: Re: [PATCH] net: vmxnet3: fix possible buffer overflow caused by bad DMA value in vmxnet3_get_rss()

From: Jia-Ju Bai <[email protected]>
Date: Sat, 30 May 2020 10:41:50 +0800

> The value adapter->rss_conf is stored in DMA memory, and it is assigned
> to rssConf, so rssConf->indTableSize can be modified at anytime by
> malicious hardware. Because rssConf->indTableSize is assigned to n,
> buffer overflow may occur when the code "rssConf->indTable[n]" is
> executed.
>
> To fix this possible bug, n is checked after being used.
>
> Signed-off-by: Jia-Ju Bai <[email protected]>

Applied, thanks.