Skip to contentSkip to conversation

bnxt_en: Fix array overrun in bnxt_fill_l2_rewrite_fields().

PATCH Applied Michael Chan 2 participants 2 messages Nov 13, 2019

Subsystems (3)
lore
Share & tools
lore

Michael Chan

author maintainer
#0 lore raw

PATCH 1/1 bnxt_en: Fix array overrun in bnxt_fill_l2_rewrite_fields().

From: Venkat Duvvuru <[email protected]>

Fix the array overrun while keeping the eth_addr and eth_addr_mask pointers as u16 to avoid unaligned u16 access. These were overlooked when modifying the code to use u16 pointer for proper alignment.

Fixes 90f906243bf6 ("bnxt_en: Add support for L2 rewrite")
---
 drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c | 4 ++--
 drivers/net/ethernet/broadcom/bnxt/bnxt_tc.h | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c +2 -2
index 174412a..0cc6ec5 100644
@@ -166,8 +166,8 @@ bnxt_fill_l2_rewrite_fields(struct bnxt_tc_actions *actions,
 			actions->l2_rewrite_dmac[j] = cpu_to_be16(*(p + j));
 	}
 
-	if (!is_wildcard(&eth_addr_mask[ETH_ALEN], ETH_ALEN)) {
-		if (!is_exactmatch(&eth_addr_mask[ETH_ALEN], ETH_ALEN))
+	if (!is_wildcard(&eth_addr_mask[ETH_ALEN / 2], ETH_ALEN)) {
+		if (!is_exactmatch(&eth_addr_mask[ETH_ALEN / 2], ETH_ALEN))
 			return -EINVAL;
 		/* FW expects smac to be in u16 array format */
 		p = &eth_addr[ETH_ALEN / 2];
drivers/net/ethernet/broadcom/bnxt/bnxt_tc.h +2 -2
index 2867549..10c62b0 100644
@@ -64,9 +64,9 @@ struct bnxt_tc_tunnel_key {
 
 #define bnxt_eth_addr_key_mask_invalid(eth_addr, eth_addr_mask)		\
 	((is_wildcard(&(eth_addr)[0], ETH_ALEN) &&			\
-	 is_wildcard(&(eth_addr)[ETH_ALEN], ETH_ALEN)) ||		\
+	 is_wildcard(&(eth_addr)[ETH_ALEN / 2], ETH_ALEN)) ||		\
 	(is_wildcard(&(eth_addr_mask)[0], ETH_ALEN) &&			\
-	 is_wildcard(&(eth_addr_mask)[ETH_ALEN], ETH_ALEN)))
+	 is_wildcard(&(eth_addr_mask)[ETH_ALEN / 2], ETH_ALEN)))
 
 struct bnxt_tc_actions {
 	u32				flags;
Signature · 1 line
2.5.1
maintainer Applied
#1 lore raw

From: Michael Chan <[email protected]>
Date: Wed, 13 Nov 2019 13:51:19 -0500

Quoted 10 lines

From: Venkat Duvvuru <[email protected]>

Fix the array overrun while keeping the eth_addr and eth_addr_mask pointers as u16 to avoid unaligned u16 access. These were overlooked when modifying the code to use u16 pointer for proper alignment.

Fixes 90f906243bf6 ("bnxt_en: Add support for L2 rewrite")

Applied.