netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net/sched: flower: Add lock protection when remove filter handle
@ 2024-02-20  8:59 Jianbo Liu
  2024-02-20  9:17 ` Jiri Pirko
  2024-02-22  1:20 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 5+ messages in thread
From: Jianbo Liu @ 2024-02-20  8:59 UTC (permalink / raw)
  To: netdev, davem
  Cc: Jianbo Liu, Cosmin Ratiu, Gal Pressman, Jamal Hadi Salim,
	Cong Wang, Jiri Pirko, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Simon Horman, Paul Blakey, Marcelo Ricardo Leitner

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(-)

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);
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net] net/sched: flower: Add lock protection when remove filter handle
  2024-02-20  8:59 [PATCH net] net/sched: flower: Add lock protection when remove filter handle Jianbo Liu
@ 2024-02-20  9:17 ` Jiri Pirko
  2024-02-20 14:53   ` Jamal Hadi Salim
  2024-02-22  1:20 ` patchwork-bot+netdevbpf
  1 sibling, 1 reply; 5+ messages in thread
From: Jiri Pirko @ 2024-02-20  9:17 UTC (permalink / raw)
  To: Jianbo Liu
  Cc: netdev, davem, Cosmin Ratiu, Gal Pressman, Jamal Hadi Salim,
	Cong Wang, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Simon Horman, Paul Blakey, Marcelo Ricardo Leitner

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>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net] net/sched: flower: Add lock protection when remove filter handle
  2024-02-20  9:17 ` Jiri Pirko
@ 2024-02-20 14:53   ` Jamal Hadi Salim
  2024-02-21  8:06     ` Jianbo Liu
  0 siblings, 1 reply; 5+ messages in thread
From: Jamal Hadi Salim @ 2024-02-20 14:53 UTC (permalink / raw)
  To: Jiri Pirko
  Cc: Jianbo Liu, netdev, davem, Cosmin Ratiu, Gal Pressman, Cong Wang,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
	Paul Blakey, Marcelo Ricardo Leitner

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net] net/sched: flower: Add lock protection when remove filter handle
  2024-02-20 14:53   ` Jamal Hadi Salim
@ 2024-02-21  8:06     ` Jianbo Liu
  0 siblings, 0 replies; 5+ messages in thread
From: Jianbo Liu @ 2024-02-21  8:06 UTC (permalink / raw)
  To: jhs@mojatatu.com, jiri@resnulli.us
  Cc: davem@davemloft.net, Gal Pressman, Paul Blakey,
	marcelo.leitner@gmail.com, xiyou.wangcong@gmail.com,
	pabeni@redhat.com, Cosmin Ratiu, edumazet@google.com,
	netdev@vger.kernel.org, horms@kernel.org, kuba@kernel.org

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net] net/sched: flower: Add lock protection when remove filter handle
  2024-02-20  8:59 [PATCH net] net/sched: flower: Add lock protection when remove filter handle Jianbo Liu
  2024-02-20  9:17 ` Jiri Pirko
@ 2024-02-22  1:20 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-02-22  1:20 UTC (permalink / raw)
  To: Jianbo Liu
  Cc: netdev, davem, cratiu, gal, jhs, xiyou.wangcong, jiri, edumazet,
	kuba, pabeni, horms, paulb, marcelo.leitner

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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-02-22  1:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-20  8:59 [PATCH net] net/sched: flower: Add lock protection when remove filter handle Jianbo Liu
2024-02-20  9:17 ` Jiri Pirko
2024-02-20 14:53   ` Jamal Hadi Salim
2024-02-21  8:06     ` Jianbo Liu
2024-02-22  1:20 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).