[PATCH v1 13/31] net/ntnic: fix untrusted loop bound

Serhii Iliushyk sil-plv at napatech.com
Tue Jan 21 18:07:51 CET 2025


From: Danylo Vodopianov <dvo-plv at napatech.com>

Replace while with if statement to avoid infinite loop
in case ther_type will be modified with extenral source.

Coverity issue: 448917
Fixes: c6821abf58e8 ("net/ntnic: add flow items GTP and actions raw encap/decap")

Signed-off-by: Danylo Vodopianov <dvo-plv at napatech.com>
---
 drivers/net/ntnic/ntnic_filter/ntnic_filter.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ntnic/ntnic_filter/ntnic_filter.c b/drivers/net/ntnic/ntnic_filter/ntnic_filter.c
index e00b10ff82..b07e16c1d3 100644
--- a/drivers/net/ntnic/ntnic_filter/ntnic_filter.c
+++ b/drivers/net/ntnic/ntnic_filter/ntnic_filter.c
@@ -53,7 +53,7 @@ int interpret_raw_data(uint8_t *data, uint8_t *preserve, int size, struct rte_fl
 		goto interpret_end;
 
 	/* VLAN */
-	while (ether_type == rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN) ||
+	if (ether_type == rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN) ||
 		ether_type == rte_cpu_to_be_16(RTE_ETHER_TYPE_QINQ) ||
 		ether_type == rte_cpu_to_be_16(RTE_ETHER_TYPE_QINQ1)) {
 		if (size - pkti == 0)
-- 
2.45.0



More information about the dev mailing list