Skip to contentSkip to conversation

net/ice/base: fix out of memory bound for MAC addresses

PATCH In review Qi Zhang 2 participants 3 messages Mar 17, 2021 – Mar 24, 2021 Network drivers

lore
Share & tools
lore

Qi Zhang

author
#0 lore raw

PATCH 1/1 net/ice/base: fix out of memory bound for MAC addresses

Not enough memory be allocated for dev->data->mac_address which cause out of bound memory access when iterate all mac addresses by dev_info.max_mac_addrs.

Fixes f9cf4f864150 ("net/ice: support device initialization")
---
 drivers/net/ice/ice_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ice/ice_ethdev.c +1 -1
index 8999d441ac..22104250fa 100644
@@ -809,7 +809,7 @@ ice_init_mac_address(struct rte_eth_dev *dev)
 		(struct rte_ether_addr *)hw->port_info[0].mac.perm_addr);
 
 	dev->data->mac_addrs =
-		rte_zmalloc(NULL, sizeof(struct rte_ether_addr), 0);
+		rte_zmalloc(NULL, sizeof(struct rte_ether_addr) * ICE_NUM_MACADDR_MAX, 0);
 	if (!dev->data->mac_addrs) {
 		PMD_INIT_LOG(ERR,
 			     "Failed to allocate memory to store mac address");
Signature · 1 line
2.26.2
Acked-by on v1 1/1
#1 lore raw
Quoted 37 lines

-----Original Message-----
From: Zhang, Qi Z <[email protected]>
Sent: Wednesday, March 17, 2021 14:02
To: Yang, Qiming <[email protected]>
Cc: [email protected]; Yigit, Ferruh <[email protected]>; Zhang, Qi Z <[email protected]>; [email protected]
Subject: [PATCH] net/ice/base: fix out of memory bound for MAC addresses

Not enough memory be allocated for dev->data->mac_address which cause out of bound memory access when iterate all mac addresses by dev_info.max_mac_addrs.

Fixes f9cf4f864150 ("net/ice: support device initialization")
---
 drivers/net/ice/ice_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ice/ice_ethdev.c +2 -2
index 8999d441ac..22104250fa 100644
@@ -809,7 +809,7 @@ ice_init_mac_address(struct rte_eth_dev *dev)
 		(struct rte_ether_addr *)hw->port_info[0].mac.perm_addr);
 
 	dev->data->mac_addrs =
-		rte_zmalloc(NULL, sizeof(struct rte_ether_addr), 0);
+		rte_zmalloc(NULL, sizeof(struct rte_ether_addr) *
+ICE_NUM_MACADDR_MAX, 0);
 	if (!dev->data->mac_addrs) {
 		PMD_INIT_LOG(ERR,
 			     "Failed to allocate memory to store mac address");
--
Quoted 1 line

2.26.2

author Applied
#2 lore raw
Quoted 40 lines

-----Original Message-----
From: Yang, Qiming <[email protected]>
Sent: Thursday, March 18, 2021 10:07 AM
To: Zhang, Qi Z <[email protected]>
Cc: [email protected]; Yigit, Ferruh <[email protected]>; [email protected]
Subject: RE: [PATCH] net/ice/base: fix out of memory bound for MAC addresses

Quoted 29 lines

-----Original Message-----
From: Zhang, Qi Z <[email protected]>
Sent: Wednesday, March 17, 2021 14:02
To: Yang, Qiming <[email protected]>
Cc: [email protected]; Yigit, Ferruh <[email protected]>; Zhang, Qi Z <[email protected]>; [email protected]
Subject: [PATCH] net/ice/base: fix out of memory bound for MAC addresses

Not enough memory be allocated for dev->data->mac_address which cause out of bound memory access when iterate all mac addresses by dev_info.max_mac_addrs.

Fixes f9cf4f864150 ("net/ice: support device initialization")
---
 drivers/net/ice/ice_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/net/ice/ice_ethdev.c index 8999d441ac..22104250fa 100644

drivers/net/ice/ice_ethdev.c +0 -0
@@ -809,7 +809,7 @@ ice_init_mac_address(struct rte_eth_dev *dev)
 (struct rte_ether_addr *)hw->port_info[0].mac.perm_addr);
 
Quoted 11 lines
Quoted 9 lines
drivers/net/ice/ice_ethdev.c +2 -2
 dev->data->mac_addrs =
-rte_zmalloc(NULL, sizeof(struct rte_ether_addr), 0);
+rte_zmalloc(NULL, sizeof(struct rte_ether_addr) *
+ICE_NUM_MACADDR_MAX, 0);
 if (!dev->data->mac_addrs) {
 PMD_INIT_LOG(ERR,
      "Failed to allocate memory to store mac address");
--

2.26.2

Applied to dpdk-next-net-intel.

Thanks
Qi