net/sched: flower: Fix wrong handle assignment during filter change
Subsystems (3)
PATCH 1/1 net/sched: flower: Fix wrong handle assignment during filter change
Commit 08a0063df3ae ("net/sched: flower: Move filter handle initialization earlier") moved filter handle initialization but an assignment of the handle to fnew->handle is done regardless of fold value. This is wrong because if fold != NULL (so fold->handle == handle) no new handle is allocated and passed handle is assigned to fnew->handle. Then if any subsequent action in fl_change() fails then the handle value is removed from IDR that is incorrect as we will have still valid old filter instance with handle that is not present in IDR.
Fix this issue by moving the assignment so it is done only when passed fold == NULL.
Prior the patch:
[root@machine tc-testing]# ./tdc.py -d enp1s0f0np0 -e 14be
Test 14be: Concurrently replace same range of 100k flower filters from 10 tc instances
exit: 123
exit: 0
RTNETLINK answers: Invalid argument
We have an error talking to the kernel
Command failed tmp/replace_6:1885
All test results:
1..1
not ok 1 14be - Concurrently replace same range of 100k flower filters from 10 tc instances
Command exited with 123, expected 0
RTNETLINK answers: Invalid argument
We have an error talking to the kernel
Command failed tmp/replace_6:1885
After the patch:
[root@machine tc-testing]# ./tdc.py -d enp1s0f0np0 -e 14be
Test 14be: Concurrently replace same range of 100k flower filters from 10 tc instances
All test results:
1..1
ok 1 14be - Concurrently replace same range of 100k flower filters from 10 tc instances
--- net/sched/cls_flower.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/cls_flower.c +1 -1
@@ -2231,8 +2231,8 @@ static int fl_change(struct net *net, struct sk_buff *in_skb,kfree (fnew); goto errout_tb; } + fnew->handle = handle; } - fnew->handle = handle; err =tcf_exts_init_ex (&fnew->exts, net,TCA_FLOWER_ACT ,0 , tp, handle, !tc_skip_hw (fnew->flags));
Signature · 1 line
2.39.1
Quoted 34 lines · Ivan Vecera
Commit
08a0063df3ae("net/sched: flower: Move filter handle initialization earlier") moved filter handle initialization but an assignment of the handle tofnew->handleis done regardless of fold value. This is wrong because if fold != NULL (sofold->handle== handle) no new handle is allocated and passed handle is assigned tofnew->handle. Then if any subsequent action infl_change()fails then the handle value is removed from IDR that is incorrect as we will have still valid old filter instance with handle that is not present in IDR.
Fix this issue by moving the assignment so it is done only when passed fold == NULL.Prior the patch:
[root@machine tc-testing]# ./tdc.py -d enp1s0f0np0 -e 14be
Test 14be: Concurrently replace same range of 100k flower filters from 10 tc instances
exit: 123
exit: 0
RTNETLINK answers: Invalid argument
We have an error talking to the kernel
Command failed tmp/replace_6:1885All test results:
1..1
not ok 1 14be - Concurrently replace same range of 100k flower filters from 10 tc instances
Command exited with 123, expected 0
RTNETLINK answers: Invalid argument
We have an error talking to the kernel
Command failed tmp/replace_6:1885After the patch:
[root@machine tc-testing]# ./tdc.py -d enp1s0f0np0 -e 14be
Test 14be: Concurrently replace same range of 100k flower filters from 10 tc instances
Quoted 7 lines
All test results:
1..1
ok 1 14be - Concurrently replace same range of 100k flower filters from 10 tc instancesFixes 08a0063df3ae ("net/sched: flower: Move filter handle initialization earlier")Signed-off-by Ivan Vecera <[email protected]>
This patch was applied to netdev/net.git (main) by Paolo Abeni <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Paolo Abeni <[email protected]>:
Quoted 11 lines · On Tue, 25 Apr 2023 16:06:04 +0200 you wrote:
Commit
08a0063df3ae("net/sched: flower: Move filter handle initialization earlier") moved filter handle initialization but an assignment of the handle tofnew->handleis done regardless of fold value. This is wrong because if fold != NULL (sofold->handle== handle) no new handle is allocated and passed handle is assigned tofnew->handle. Then if any subsequent action infl_change()fails then the handle value is removed from IDR that is incorrect as we will have still valid old filter instance with handle that is not present in IDR.
Fix this issue by moving the assignment so it is done only when passed fold == NULL.
Quoted 1 line
[...]
Here is the summary with links:
- [net] net/sched: flower: Fix wrong handle assignment during filter change
https://git.kernel.org/netdev/net/c/32eff6bacec2
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html