Skip to contentSkip to conversation

net/bnxt: fix memory corruption in tunnel entry list

PATCH New Manish Kurup 2 participants 2 messages Oct 5 – Oct 13 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/bnxt: fix memory corruption in tunnel entry list

From: Kishore Padmanabha <[email protected]>

When the app tunnel table is full, ref_cnt is never zero, so free_entry ends up as -1 and the wrong tunnel slot gets updated. Use the correct index instead of free_entry.

Fixes bdf4a3c6316b ("net/bnxt: support tunnel offload")
---
 drivers/net/bnxt/tf_ulp/ulp_tun.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/bnxt/tf_ulp/ulp_tun.c +1 -1
index b90b4bf252..8ecdac0dcc 100644
@@ -33,7 +33,7 @@ ulp_app_tun_search_entry(struct bnxt_ulp_context *ulp_ctx,
 				    app_tunnel,
 				    sizeof(struct rte_flow_tunnel))) {
 				*tun_entry =  &tun_ent_list[i];
-				tun_ent_list[free_entry].ref_cnt++;
+				tun_ent_list[i].ref_cnt++;
 				return rc;
 			}
 		}
Signature · 1 line
2.31.1
#1 lore raw

PATCH v2 1/1 net/bnxt: fix memory corruption in tunnel entry list

From: Kishore Padmanabha <[email protected]>

In ulp_app_tun_search_entry(), when a matching tunnel entry is found at index i, the reference count was incremented on tun_ent_list[free_entry] instead of tun_ent_list[i]. free_entry is -1 when no unused slot precedes the match (always the case when the table is full), so this wrote before the start of the array; otherwise it bumped the count of an unused slot and left the matched entry's count unchanged. Use the matching index.

Fixes bdf4a3c6316b ("net/bnxt: support tunnel offload")

---
v2:
- Reword the commit message: free_entry is -1 whenever no unused slot precedes the matching entry, not only when the table is full
- No code change

 drivers/net/bnxt/tf_ulp/ulp_tun.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/bnxt/tf_ulp/ulp_tun.c +1 -1
index b90b4bf2523..8ecdac0dcce 100644
@@ -33,7 +33,7 @@ ulp_app_tun_search_entry(struct bnxt_ulp_context *ulp_ctx,
 				    app_tunnel,
 				    sizeof(struct rte_flow_tunnel))) {
 				*tun_entry =  &tun_ent_list[i];
-				tun_ent_list[free_entry].ref_cnt++;
+				tun_ent_list[i].ref_cnt++;
 				return rc;
 			}
 		}
Signature · 1 line
2.47.3