Skip to contentSkip to conversation

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

PATCH Applied Jianbo Liu 4 participants 5 messages Feb 20, 2024 – Feb 22, 2024

Subsystems (3)
lore
Share & tools
lore

Jianbo Liu

author
#0 lore raw

PATCH 1/1 net/sched: flower: Add lock protection when remove filter handle

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")
---
 net/sched/cls_flower.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
net/sched/cls_flower.c +4 -1
index bfedc3d4423d..e1314674b4a9 100644
@@ -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);
Signature · 1 line
2.26.2
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Tue, Feb 20, 2024 at 09:59:28AM CET, [email protected] 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")
maintainer Acked-by
#2 lore raw
Quoted 11 lines · Jiri Pirko
Quoted 7 lines · Tue, Feb 20, 2024 at 09:59:28AM CET, [email protected] 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")

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

author
#3 lore raw
Quoted 13 lines · Jamal Hadi Salim
Quoted 12 lines · Jiri Pirko
Quoted 9 lines · Tue, Feb 20, 2024 at 09:59:28AM CET, [email protected] 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")

Quoted 8 lines
Quoted 1 line

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

Quoted 3 lines

cheers,
jamal

#4 lore raw
In reply to Jianbo Liu
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 9 lines · 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")

[...]

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!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html