From: Mohammad Shuab Siddique <mohammad-shuab.siddique@broadcom.com>
To: dev@dpdk.org
Cc: kishore.padmanabha@broadcom.com,
Mohammad Shuab Siddique <mohammad-shuab.siddique@broadcom.com>,
stable@dpdk.org, Dakota Sicher <dakota.sicher@broadcom.com>
Subject: [PATCH v3] net/bnxt: fix flow create segfault
Date: Mon, 28 Sep 2026 18:23:48 -0600 [thread overview]
Message-ID: <20260929002348.1208423-1-Mohammad-Shuab.Siddique@broadcom.com> (raw)
In-Reply-To: <20260918032701.763364-1-Mohammad-Shuab.Siddique@broadcom.com>
From: Mohammad Shuab Siddique <mohammad-shuab.siddique@broadcom.com>
When creating a flow that requires a destination queue but none is
specified in the flow create command, find_matching_vnic() returns
NULL and the code falls through to insert the new filter into
vnic->filter, dereferencing the NULL vnic and causing a segfault.
Reject a flow create with no destination up front, right after
bnxt_validate_and_parse_flow() and before bnxt_match_filter() is
called (skipped for HWRM_CFA_TUNNEL_REDIRECT_FILTER, which has no
destination VNIC by design). Checking this only after
bnxt_match_filter() is not enough: when the new filter's pattern
matches an already-installed flow with a different destination,
bnxt_match_filter() unlinks that flow's old filter, links the new
(about-to-be-rejected) one in its place, frees the old filter, and
repoints the existing flow's flow->filter at the new one, all before
returning -EXDEV. Rejecting the missing-destination case afterward
then frees that same new filter while it is still linked into
vnic->filter and still referenced by the pre-existing flow, leaving
that unrelated flow's HW filter deleted and flow->filter pointing at
freed memory. Checking before bnxt_match_filter() ever runs avoids
triggering that mutation in the first place.
Fixes: 59119d49529e ("net/bnxt: fix flow create when RSS is disabled")
Cc: stable@dpdk.org
Signed-off-by: Dakota Sicher <dakota.sicher@broadcom.com>
Signed-off-by: Mohammad Shuab Siddique <mohammad-shuab.siddique@broadcom.com>
---
v3:
* Moved the NULL-vnic check from right before the done: label (after
the tunnel-redirect/EM/NTUPLE filter setup, where v2 had it) to
right after bnxt_validate_and_parse_flow(), before
bnxt_match_filter() runs. Stephen Hemminger found that checking
only after bnxt_match_filter() has already run is not enough: for
a flow that turns out to be an update (matches an existing flow's
pattern with a different destination), bnxt_match_filter() has
already unlinked the old filter, linked the new one in its place,
freed the old one, and repointed the existing flow's flow->filter
at the new one before returning -EXDEV -- rejecting afterward then
frees that same new filter while it is still linked into
vnic->filter and referenced by the pre-existing flow, corrupting
that unrelated flow. Kishore Padmanabha separately flagged the old
check's location as dead code once this move landed, since the
earlier check already guarantees a match by the time execution
reaches that point.
v2:
* Changed the NULL check from "if (!vnic)" to "if (vnic == NULL)" to
match this file's established convention for pointer NULL checks.
* Kept RTE_FLOW_ERROR_TYPE_HANDLE rather than RTE_FLOW_ERROR_TYPE_ACTION
as one reviewer suggested: every other rte_flow_error_set() call in
this function uses RTE_FLOW_ERROR_TYPE_HANDLE regardless of the
underlying cause.
* Fixed the new branch to reset ret = -EINVAL before goto free_filter,
instead of leaving a stale update_flow-path -EXDEV to reach
free_flow and report a misleading success-like error.
drivers/net/bnxt/bnxt_flow.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/net/bnxt/bnxt_flow.c b/drivers/net/bnxt/bnxt_flow.c
index 4bf38043b5..62dbb028f0 100644
--- a/drivers/net/bnxt/bnxt_flow.c
+++ b/drivers/net/bnxt/bnxt_flow.c
@@ -2047,6 +2047,16 @@ bnxt_flow_create(struct rte_eth_dev *dev,
if (ret != 0)
goto free_filter;
+ if (filter->filter_type != HWRM_CFA_TUNNEL_REDIRECT_FILTER &&
+ find_matching_vnic(bp, filter) == NULL) {
+ rte_flow_error_set(error, EINVAL,
+ RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
+ "Missing destination action for flow.");
+ bnxt_hwrm_clear_l2_filter(bp, filter);
+ ret = -EINVAL;
+ goto free_filter;
+ }
+
ret = bnxt_match_filter(bp, filter);
if (ret == -EEXIST) {
PMD_DRV_LOG_LINE(DEBUG, "Flow already exists.");
--
2.47.3
prev parent reply other threads:[~2026-09-29 0:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-18 3:27 [PATCH] net/bnxt: fix flow create segfault Mohammad Shuab Siddique
2026-09-21 2:18 ` [PATCH v2] " Mohammad Shuab Siddique
2026-09-21 15:46 ` Stephen Hemminger
2026-09-29 0:23 ` Mohammad Shuab Siddique [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260929002348.1208423-1-Mohammad-Shuab.Siddique@broadcom.com \
--to=mohammad-shuab.siddique@broadcom.com \
--cc=dakota.sicher@broadcom.com \
--cc=dev@dpdk.org \
--cc=kishore.padmanabha@broadcom.com \
--cc=stable@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox