Skip to contentSkip to conversation

net/enic: fix potential null dereference in flow mask check

PATCH Applied Alexey Simakov 3 participants 5 messages Jul 7 – Jul 10 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/enic: fix potential null dereference in flow mask check

The functions enic_copy_item_ipv4_v1(), enic_copy_item_udp_v1(), and enic_copy_item_tcp_v1() each initialize a local 'mask' variable from item->mask and substitute it with a hardcoded mask if NULL. However, the subsequent mask_exact_match() call uses item->mask directly instead of the local 'mask' variable, which will dereference NULL when item->mask is NULL.

Use the local 'mask' variable (which has been validated and possibly substituted) instead of item->mask.

Fixes aa3d2ff82198 ("net/enic: flow API for Legacy NICs")
---
 .mailmap                     | 1 +
 drivers/net/enic/enic_flow.c | 6 +++---
 2 files changed, 4 insertions(+), 3 deletions(-)
.mailmap +1 -0
index 4b5eb0c841..b154cd25a9 100644
@@ -71,6 +71,7 @@ Alexander Skorichenko <[email protected]>
 Alexander Solganik <[email protected]>
 Alexander V Gutkin <[email protected]>
 Alexandre Ferrieux <[email protected]>
+Alexey Simakov <[email protected]>
 Alexey Kardashevskiy <[email protected]>
 Alfredo Cardigliano <[email protected]>
 Ali Alnubani <[email protected]> <[email protected]>
drivers/net/enic/enic_flow.c +3 -3
index 758000ea21..539b0eb725 100644
@@ -407,7 +407,7 @@ enic_copy_item_ipv4_v1(struct copy_item_args *arg)
 
 	/* check that the supplied mask exactly matches capability */
 	if (!mask_exact_match((const uint8_t *)&supported_mask,
-			      (const uint8_t *)item->mask, sizeof(*mask))) {
+			      (const uint8_t *)mask, sizeof(*mask))) {
 		ENICPMD_LOG(ERR, "IPv4 exact match mask");
 		return ENOTSUP;
 	}
@@ -445,7 +445,7 @@ enic_copy_item_udp_v1(struct copy_item_args *arg)
 
 	/* check that the supplied mask exactly matches capability */
 	if (!mask_exact_match((const uint8_t *)&supported_mask,
-			      (const uint8_t *)item->mask, sizeof(*mask))) {
+			      (const uint8_t *)mask, sizeof(*mask))) {
 		ENICPMD_LOG(ERR, "UDP exact match mask");
 		return ENOTSUP;
 	}
@@ -484,7 +484,7 @@ enic_copy_item_tcp_v1(struct copy_item_args *arg)
 
 	/* check that the supplied mask exactly matches capability */
 	if (!mask_exact_match((const uint8_t *)&supported_mask,
-			     (const uint8_t *)item->mask, sizeof(*mask))) {
+			     (const uint8_t *)mask, sizeof(*mask))) {
 		ENICPMD_LOG(ERR, "TCP exact match mask");
 		return ENOTSUP;
 	}
Signature · 1 line
2.34.1
Acked-by on v1 1/1
#1 lore raw
Quoted 73 lines

-----Original Message-----
From: Alexey Simakov <[email protected]>
Sent: Tuesday, July 7, 2026 5:59 PM
To: Thomas Monjalon <[email protected]>; John Daley (johndale) <[email protected]>; Hyong Youb Kim (hyonkim) <[email protected]>; Nelson Escobar (neescoba) <[email protected]>
Cc: [email protected]; [email protected]; Alexey Simakov <[email protected]>
Subject: [PATCH] net/enic: fix potential null dereference in flow mask check

The functions enic_copy_item_ipv4_v1(), enic_copy_item_udp_v1(), and enic_copy_item_tcp_v1() each initialize a local 'mask' variable from item->mask and substitute it with a hardcoded mask if NULL. However, the subsequent mask_exact_match() call uses item->mask directly instead of the local 'mask' variable, which will dereference NULL when item->mask is NULL.

Use the local 'mask' variable (which has been validated and possibly substituted) instead of item->mask.

Fixes aa3d2ff82198 ("net/enic: flow API for Legacy NICs")
---
 .mailmap                     | 1 +
 drivers/net/enic/enic_flow.c | 6 +++---
 2 files changed, 4 insertions(+), 3 deletions(-)
.mailmap +1 -0
index 4b5eb0c841..b154cd25a9 100644
@@ -71,6 +71,7 @@ Alexander Skorichenko <[email protected]>
 Alexander Solganik <[email protected]>
 Alexander V Gutkin <[email protected]>
 Alexandre Ferrieux <[email protected]>
+Alexey Simakov <[email protected]>
 Alexey Kardashevskiy <[email protected]>
 Alfredo Cardigliano <[email protected]>
 Ali Alnubani <[email protected]> <[email protected]>
drivers/net/enic/enic_flow.c +3 -4
index 758000ea21..539b0eb725 100644
@@ -407,7 +407,7 @@ enic_copy_item_ipv4_v1(struct copy_item_args *arg)
 
 	/* check that the supplied mask exactly matches capability */
 	if (!mask_exact_match((const uint8_t *)&supported_mask,
-			      (const uint8_t *)item->mask, sizeof(*mask))) {
+			      (const uint8_t *)mask, sizeof(*mask))) {
 		ENICPMD_LOG(ERR, "IPv4 exact match mask");
 		return ENOTSUP;
 	}
@@ -445,7 +445,7 @@ enic_copy_item_udp_v1(struct copy_item_args *arg)
 
 	/* check that the supplied mask exactly matches capability */
 	if (!mask_exact_match((const uint8_t *)&supported_mask,
-			      (const uint8_t *)item->mask, sizeof(*mask))) {
+			      (const uint8_t *)mask, sizeof(*mask))) {
 		ENICPMD_LOG(ERR, "UDP exact match mask");
 		return ENOTSUP;
 	}
@@ -484,7 +484,7 @@ enic_copy_item_tcp_v1(struct copy_item_args *arg)
 
 	/* check that the supplied mask exactly matches capability */
 	if (!mask_exact_match((const uint8_t *)&supported_mask,
-			     (const uint8_t *)item->mask, sizeof(*mask))) {
+			     (const uint8_t *)mask, sizeof(*mask))) {
 		ENICPMD_LOG(ERR, "TCP exact match mask");
 		return ENOTSUP;
 	}
--
Quoted 1 line

2.34.1

Can you remove .mailmap diff?

The enic patch looks like a valid fix.

Thanks.
-Hyong

#2 lore raw

09/07/2026 11:57, Hyong Youb Kim (hyonkim):

Quoted 13 lines

From: Alexey Simakov <[email protected]>

.mailmap Alexander Skorichenko <[email protected]> · line 77

Quoted 10 lines
.mailmap +1 -0
@@ -71,6 +71,7 @@ Alexander Skorichenko <[email protected]>
 Alexander Solganik <[email protected]>
 Alexander V Gutkin <[email protected]>
 Alexandre Ferrieux <[email protected]>
+Alexey Simakov <[email protected]>
 Alexey Kardashevskiy <[email protected]>
 Alfredo Cardigliano <[email protected]>
 Ali Alnubani <[email protected]> <[email protected]>

Can you remove .mailmap diff?

Why are you asking that?
Any new contributor must be in this file. If it is not done, I add it manually in the commit.

#3 lore raw
Quoted 26 lines

-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Thursday, July 9, 2026 9:04 PM
To: Hyong Youb Kim (hyonkim) <[email protected]>
Cc: Alexey Simakov <[email protected]>; John Daley (johndale) <[email protected]>; Nelson Escobar (neescoba) <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH] net/enic: fix potential null dereference in flow mask check

09/07/2026 11:57, Hyong Youb Kim (hyonkim):

Quoted 13 lines

From: Alexey Simakov <[email protected]>

.mailmap Alexander Skorichenko <[email protected]> · line 77

Quoted 10 lines
.mailmap +1 -0
@@ -71,6 +71,7 @@ Alexander Skorichenko <[email protected]>
 Alexander Solganik <[email protected]>
 Alexander V Gutkin <[email protected]>
 Alexandre Ferrieux <[email protected]>
+Alexey Simakov <[email protected]>
 Alexey Kardashevskiy <[email protected]>
 Alfredo Cardigliano <[email protected]>
 Ali Alnubani <[email protected]> <[email protected]>

Can you remove .mailmap diff?

Quoted 4 lines

Why are you asking that?
Any new contributor must be in this file. If it is not done, I add it manually in the commit.

My bad. I did not know.

Thanks.
-Hyong

#4 lore raw
In reply to Hyong Youb Kim (hyonkim)
Quoted 10 lines
Quoted 10 lines

The functions enic_copy_item_ipv4_v1(), enic_copy_item_udp_v1(), and enic_copy_item_tcp_v1() each initialize a local 'mask' variable from item->mask and substitute it with a hardcoded mask if NULL. However, the subsequent mask_exact_match() call uses item->mask directly instead of the local 'mask' variable, which will dereference NULL when item->mask is NULL.

Use the local 'mask' variable (which has been validated and possibly substituted) instead of item->mask.

Quoted 7 lines
Quoted 5 lines
Fixes aa3d2ff82198 ("net/enic: flow API for Legacy NICs")

---

The enic patch looks like a valid fix.

Applied, thanks.