diff mbox series

[net-next,3/3] bnxt_en: Fix RCU locking for ntuple filters in bnxt_rx_flow_steer()

Message ID 20240105235439.28282-4-michael.chan@broadcom.com (mailing list archive)
State Accepted
Commit d8214d0f0135010acf7205c646cda31601bbb7ad
Delegated to: Netdev Maintainers
Headers show
Series bnxt_en: ntuple filter fixes | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1082 this patch: 1082
netdev/cc_maintainers success CCed 0 of 0 maintainers
netdev/build_clang success Errors and warnings before: 1109 this patch: 1109
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 1111 this patch: 1111
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 9 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Michael Chan Jan. 5, 2024, 11:54 p.m. UTC
Similar to the previous patch, RCU locking was released too early
in bnxt_rx_flow_steer().  Fix it to unlock after reading fltr->base.sw_id
to guarantee that fltr won't be freed while we are still reading it.

Fixes: cb5bdd292dc0 ("bnxt_en: Add bnxt_lookup_ntp_filter_from_idx() function")
Reported-by: Simon Horman <horms@kernel.org>
Link: https://lore.kernel.org/netdev/20231225165653.GH5962@kernel.org/
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Simon Horman Jan. 8, 2024, 10:19 a.m. UTC | #1
On Fri, Jan 05, 2024 at 03:54:39PM -0800, Michael Chan wrote:
> Similar to the previous patch, RCU locking was released too early
> in bnxt_rx_flow_steer().  Fix it to unlock after reading fltr->base.sw_id
> to guarantee that fltr won't be freed while we are still reading it.
> 
> Fixes: cb5bdd292dc0 ("bnxt_en: Add bnxt_lookup_ntp_filter_from_idx() function")
> Reported-by: Simon Horman <horms@kernel.org>
> Link: https://lore.kernel.org/netdev/20231225165653.GH5962@kernel.org/
> Signed-off-by: Michael Chan <michael.chan@broadcom.com>

Thanks Michael,

I agree that this addresses the issue flagged at the Link above.
That it is a bug-fix, and should have a Fixes tag.
And that as the cited commit has not propagated beyond net-next
it is appropriate to target this patch at net-next.

Reviewed-by: Simon Horman <horms@kernel.org>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index fb5af8a34c8f..0aacd3c6ed5c 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -14020,8 +14020,8 @@  static int bnxt_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb,
 	rcu_read_lock();
 	fltr = bnxt_lookup_ntp_filter_from_idx(bp, new_fltr, idx);
 	if (fltr) {
-		rcu_read_unlock();
 		rc = fltr->base.sw_id;
+		rcu_read_unlock();
 		goto err_free;
 	}
 	rcu_read_unlock();