diff mbox series

[net] net/sched: flower: Add lock protection when remove filter handle

Message ID 20240220085928.9161-1-jianbol@nvidia.com (mailing list archive)
State Accepted
Commit 1fde0ca3a0de7e9f917668941156959dd5e9108b
Delegated to: Netdev Maintainers
Headers show
Series [net] net/sched: flower: Add lock protection when remove filter handle | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 956 this patch: 956
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 10 of 10 maintainers
netdev/build_clang success Errors and warnings before: 973 this patch: 973
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: 973 this patch: 973
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 12 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
netdev/contest success net-next-2024-02-22--00-00 (tests: 1455)

Commit Message

Jianbo Liu Feb. 20, 2024, 8:59 a.m. UTC
As IDR can't protect itself from the concurrent modification, place
idr_remove() under the protection of tp->lock.

Fixes: 08a0063df3ae ("net/sched: flower: Move filter handle initialization earlier")
Signed-off-by: Jianbo Liu <jianbol@nvidia.com>
Reviewed-by: Cosmin Ratiu <cratiu@nvidia.com>
Reviewed-by: Gal Pressman <gal@nvidia.com>
---
 net/sched/cls_flower.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Jiri Pirko Feb. 20, 2024, 9:17 a.m. UTC | #1
Tue, Feb 20, 2024 at 09:59:28AM CET, jianbol@nvidia.com wrote:
>As IDR can't protect itself from the concurrent modification, place
>idr_remove() under the protection of tp->lock.
>
>Fixes: 08a0063df3ae ("net/sched: flower: Move filter handle initialization earlier")
>Signed-off-by: Jianbo Liu <jianbol@nvidia.com>
>Reviewed-by: Cosmin Ratiu <cratiu@nvidia.com>
>Reviewed-by: Gal Pressman <gal@nvidia.com>

Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Jamal Hadi Salim Feb. 20, 2024, 2:53 p.m. UTC | #2
On Tue, Feb 20, 2024 at 4:17 AM Jiri Pirko <jiri@resnulli.us> wrote:
>
> Tue, Feb 20, 2024 at 09:59:28AM CET, jianbol@nvidia.com wrote:
> >As IDR can't protect itself from the concurrent modification, place
> >idr_remove() under the protection of tp->lock.
> >
> >Fixes: 08a0063df3ae ("net/sched: flower: Move filter handle initialization earlier")
> >Signed-off-by: Jianbo Liu <jianbol@nvidia.com>
> >Reviewed-by: Cosmin Ratiu <cratiu@nvidia.com>
> >Reviewed-by: Gal Pressman <gal@nvidia.com>
>
> Reviewed-by: Jiri Pirko <jiri@nvidia.com>

Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>

Jianbo,  do you have a new test case that caught this that we can use?
Just curious why it hasnt been caught earlier (it's been there for
about a year).

cheers,
jamal
Jianbo Liu Feb. 21, 2024, 8:06 a.m. UTC | #3
On Tue, 2024-02-20 at 09:53 -0500, Jamal Hadi Salim wrote:
> On Tue, Feb 20, 2024 at 4:17 AM Jiri Pirko <jiri@resnulli.us> wrote:
> > 
> > Tue, Feb 20, 2024 at 09:59:28AM CET, jianbol@nvidia.com wrote:
> > > As IDR can't protect itself from the concurrent modification,
> > > place
> > > idr_remove() under the protection of tp->lock.
> > > 
> > > Fixes: 08a0063df3ae ("net/sched: flower: Move filter handle
> > > initialization earlier")
> > > Signed-off-by: Jianbo Liu <jianbol@nvidia.com>
> > > Reviewed-by: Cosmin Ratiu <cratiu@nvidia.com>
> > > Reviewed-by: Gal Pressman <gal@nvidia.com>
> > 
> > Reviewed-by: Jiri Pirko <jiri@nvidia.com>
> 
> Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
> 
> Jianbo,  do you have a new test case that caught this that we can
> use?
> Just curious why it hasnt been caught earlier (it's been there for
> about a year).

I don't have the test case, sorry.
The issue was caught when we stressed performance on BlueField-3.

Thanks!
Jianbo

> 
> cheers,
> jamal
patchwork-bot+netdevbpf@kernel.org Feb. 22, 2024, 1:20 a.m. UTC | #4
Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Tue, 20 Feb 2024 08:59:28 +0000 you wrote:
> As IDR can't protect itself from the concurrent modification, place
> idr_remove() under the protection of tp->lock.
> 
> Fixes: 08a0063df3ae ("net/sched: flower: Move filter handle initialization earlier")
> Signed-off-by: Jianbo Liu <jianbol@nvidia.com>
> Reviewed-by: Cosmin Ratiu <cratiu@nvidia.com>
> Reviewed-by: Gal Pressman <gal@nvidia.com>
> 
> [...]

Here is the summary with links:
  - [net] net/sched: flower: Add lock protection when remove filter handle
    https://git.kernel.org/netdev/net/c/1fde0ca3a0de

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c
index bfedc3d4423d..e1314674b4a9 100644
--- a/net/sched/cls_flower.c
+++ b/net/sched/cls_flower.c
@@ -2460,8 +2460,11 @@  static int fl_change(struct net *net, struct sk_buff *in_skb,
 	}
 
 errout_idr:
-	if (!fold)
+	if (!fold) {
+		spin_lock(&tp->lock);
 		idr_remove(&head->handle_idr, fnew->handle);
+		spin_unlock(&tp->lock);
+	}
 	__fl_put(fnew);
 errout_tb:
 	kfree(tb);