* [PATCH v2] net/nfp: fix uninit local var in nfp_pre_tun_table_check_del
@ 2026-11-16 17:18 Mark Bulatov
2026-11-17 18:56 ` Stephen Hemminger
2026-11-19 18:15 ` [PATCH v3] " Mark Bulatov
0 siblings, 2 replies; 3+ messages in thread
From: Mark Bulatov @ 2026-11-16 17:18 UTC (permalink / raw)
To: Chaoyong He, Niklas Söderlund; +Cc: dev, stable, Mark Bulatov
If the search fails, it leads to a null pointer dereference when attempting
to initialize nfp_mac_idx.
Fix this by adding a check.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: d3c33bdf1f18 ("net/nfp: prepare for IPv4 UDP tunnel decap flow action")
Cc: stable@dpdk.org
Signed-off-by: Mark Bulatov <ms.bulatov7@gmail.com>
---
v2 changes: Correction of the Fixes tag and addition of find_entry
initialization at the point of declaration
v1 link:
https://patches.dpdk.org/project/dpdk/patch/20261113142207.5537-1-ms.bulatov7@gmail.com/
drivers/net/nfp/flower/nfp_flower_flow.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c
index ad0fe9a8ef..2372d2fdb9 100644
--- a/drivers/net/nfp/flower/nfp_flower_flow.c
+++ b/drivers/net/nfp/flower/nfp_flower_flow.c
@@ -3793,7 +3793,7 @@ nfp_pre_tun_table_check_del(struct nfp_flower_representor *repr,
uint16_t nfp_mac_idx;
struct nfp_flow_priv *priv;
struct nfp_pre_tun_entry *entry;
- struct nfp_pre_tun_entry *find_entry;
+ struct nfp_pre_tun_entry *find_entry = NULL;
struct nfp_fl_rule_metadata *nfp_flow_meta;
priv = repr->app_fw_flower->flow_priv;
@@ -3828,6 +3828,13 @@ nfp_pre_tun_table_check_del(struct nfp_flower_representor *repr,
}
nfp_flow_meta = nfp_flow->payload.meta;
+
+ if (find_entry == NULL) {
+ PMD_DRV_LOG(ERR, "Pre-tunnel table search failed.");
+ ret = -EINVAL;
+ goto free_entry;
+ }
+
nfp_mac_idx = (find_entry->mac_index << 8) |
NFP_FLOWER_CMSG_PORT_TYPE_OTHER_PORT |
NFP_TUN_PRE_TUN_IDX_BIT;
--
2.39.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] net/nfp: fix uninit local var in nfp_pre_tun_table_check_del
2026-11-16 17:18 [PATCH v2] net/nfp: fix uninit local var in nfp_pre_tun_table_check_del Mark Bulatov
@ 2026-11-17 18:56 ` Stephen Hemminger
2026-11-19 18:15 ` [PATCH v3] " Mark Bulatov
1 sibling, 0 replies; 3+ messages in thread
From: Stephen Hemminger @ 2026-11-17 18:56 UTC (permalink / raw)
To: Mark Bulatov; +Cc: Chaoyong He, Niklas Söderlund, dev, stable
On Mon, 16 Nov 2026 20:18:56 +0300
Mark Bulatov <ms.bulatov7@gmail.com> wrote:
> If the search fails, it leads to a null pointer dereference when attempting
> to initialize nfp_mac_idx.
>
> Fix this by adding a check.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Fixes: d3c33bdf1f18 ("net/nfp: prepare for IPv4 UDP tunnel decap flow action")
> Cc: stable@dpdk.org
>
> Signed-off-by: Mark Bulatov <ms.bulatov7@gmail.com>
> ---
AI review had observations worth doing a cleanup pass to fix.
[PATCH 1/2] net/nfp: fix uninit local var in nfp_pre_tun_table_check_del
Info: the commit message covers only half of the bug.
find_entry can reach the dereference in two states. If no
pre_tun_bitmap[] slot is set, the loop body never runs and
find_entry is uninitialized. If slots are set but none matches,
find_entry holds the NULL from the last search. pre_tun_cnt counts
entries for all representors, so pre_tun_cnt > 1 does not mean
this representor's MAC is in the table. Suggested body:
find_entry is left uninitialized if no pre-tunnel slot is in
use, and is NULL if no slot matches this representor's MAC.
Either case is then dereferenced when computing nfp_mac_idx.
Initialize find_entry and fail the delete if no entry is found.
Info: put the check directly after the search loop.
The check sits after "nfp_flow_meta = nfp_flow->payload.meta;",
which has nothing to do with it. It reads better as part of the
search:
for (i = 1; i < NFP_TUN_PRE_TUN_RULE_LIMIT; i++) {
...
}
if (find_entry == NULL) {
PMD_DRV_LOG(ERR, "Pre-tunnel table entry not found.");
ret = -EINVAL;
goto free_entry;
}
nfp_flow_meta = nfp_flow->payload.meta;
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v3] net/nfp: fix uninit local var in nfp_pre_tun_table_check_del
2026-11-16 17:18 [PATCH v2] net/nfp: fix uninit local var in nfp_pre_tun_table_check_del Mark Bulatov
2026-11-17 18:56 ` Stephen Hemminger
@ 2026-11-19 18:15 ` Mark Bulatov
1 sibling, 0 replies; 3+ messages in thread
From: Mark Bulatov @ 2026-11-19 18:15 UTC (permalink / raw)
To: Chaoyong He, Niklas Söderlund; +Cc: dev, stable, Mark Bulatov
find_entry is left uninitialized if no pre-tunnel slot is in
use, and is NULL if no slot matches this representor's MAC.
Either case is then dereferenced when computing nfp_mac_idx.
Initialize find_entry and fail the delete if no entry is found.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: d3c33bdf1f18 ("net/nfp: prepare for IPv4 UDP tunnel decap flow action")
Cc: stable@dpdk.org
Signed-off-by: Mark Bulatov <ms.bulatov7@gmail.com>
---
v3 changes: The check was moved to a higher level, and
the description was corrected.
v2 link:
https://patches.dpdk.org/project/dpdk/patch/20261116171857.5306-1-ms.bulatov7@gmail.com/
v2 changes: Correction of the Fixes tag and addition of find_entry
initialization at the point of declaration
v1 link:
https://patches.dpdk.org/project/dpdk/patch/20261113142207.5537-1-ms.bulatov7@gmail.com/
drivers/net/nfp/flower/nfp_flower_flow.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c
index ad0fe9a8ef..9dbf9b934a 100644
--- a/drivers/net/nfp/flower/nfp_flower_flow.c
+++ b/drivers/net/nfp/flower/nfp_flower_flow.c
@@ -3793,7 +3793,7 @@ nfp_pre_tun_table_check_del(struct nfp_flower_representor *repr,
uint16_t nfp_mac_idx;
struct nfp_flow_priv *priv;
struct nfp_pre_tun_entry *entry;
- struct nfp_pre_tun_entry *find_entry;
+ struct nfp_pre_tun_entry *find_entry = NULL;
struct nfp_fl_rule_metadata *nfp_flow_meta;
priv = repr->app_fw_flower->flow_priv;
@@ -3827,6 +3827,12 @@ nfp_pre_tun_table_check_del(struct nfp_flower_representor *repr,
}
}
+ if (find_entry == NULL) {
+ PMD_DRV_LOG(ERR, "Pre-tunnel table entry not found.");
+ ret = -EINVAL;
+ goto free_entry;
+ }
+
nfp_flow_meta = nfp_flow->payload.meta;
nfp_mac_idx = (find_entry->mac_index << 8) |
NFP_FLOWER_CMSG_PORT_TYPE_OTHER_PORT |
--
2.39.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-20 10:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-16 17:18 [PATCH v2] net/nfp: fix uninit local var in nfp_pre_tun_table_check_del Mark Bulatov
2026-11-17 18:56 ` Stephen Hemminger
2026-11-19 18:15 ` [PATCH v3] " Mark Bulatov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox