net/sched Bind logic fixes for cls_fw, cls_u32 and cls_route
Subsystems (3)
Jamal Hadi Salim
maintainerv2 cover net/sched Bind logic fixes for cls_fw, cls_u32 and cls_route
From: valis <[email protected]>
Three classifiers (cls_fw, cls_u32 and cls_route) always copy tcf_result struct into the new instance of the filter on update.
This causes a problem when updating a filter bound to a class, as tcf_unbind_filter() is always called on the old instance in the success path, decreasing filter_cnt of the still referenced class and allowing it to be deleted, leading to a use-after-free.
This patch set fixes this issue in all affected classifiers by no longer copying the tcf_result struct from the old filter.
v1 -> v2:
- Resubmission and SOB by Jamal
valis (3):
net/sched: cls_u32: No longer copy tcf_result on update to avoid
use-after-free
net/sched: cls_fw: No longer copy tcf_result on update to avoid
use-after-free
net/sched: cls_route: No longer copy tcf_result on update to avoid
use-after-free
net/sched/cls_fw.c | 1 - net/sched/cls_route.c | 1 - net/sched/cls_u32.c | 1 - 3 files changed, 3 deletions(-)
--
2.34.1
Jamal Hadi Salim
maintainerPATCH v2 1/3 net/sched: cls_u32: No longer copy tcf_result on update to avoid use-after-free
From: valis <[email protected]>
When u32_change() is called on an existing filter, the whole tcf_result struct is always copied into the new instance of the filter.
This causes a problem when updating a filter bound to a class, as tcf_unbind_filter() is always called on the old instance in the success path, decreasing filter_cnt of the still referenced class and allowing it to be deleted, leading to a use-after-free.
Fix this by no longer copying the tcf_result struct from the old filter.
--- net/sched/cls_u32.c | 1 - 1 file changed, 1 deletion(-)
net/sched/cls_u32.c +0 -1
@@ -826,7 +826,6 @@ static struct tc_u_knode *u32_init_knode(struct net *net, struct tcf_proto *tp, new->ifindex = n->ifindex; new->fshift = n->fshift; - new->res = n->res; new->flags = n->flags;RCU_INIT_POINTER (new->ht_down, ht);
Signature · 1 line
2.34.1
Jamal Hadi Salim
maintainerPATCH v2 2/3 net/sched: cls_fw: No longer copy tcf_result on update to avoid use-after-free
In reply to Jamal Hadi SalimFrom: valis <[email protected]>
When fw_change() is called on an existing filter, the whole tcf_result struct is always copied into the new instance of the filter.
This causes a problem when updating a filter bound to a class, as tcf_unbind_filter() is always called on the old instance in the success path, decreasing filter_cnt of the still referenced class and allowing it to be deleted, leading to a use-after-free.
Fix this by no longer copying the tcf_result struct from the old filter.
--- net/sched/cls_fw.c | 1 - 1 file changed, 1 deletion(-)
net/sched/cls_fw.c +0 -1
@@ -267,7 +267,6 @@ static int fw_change(struct net *net, struct sk_buff *in_skb,return -ENOBUFS ; fnew->id = f->id; - fnew->res = f->res; fnew->ifindex = f->ifindex; fnew->tp = f->tp;
Signature · 1 line
2.34.1
Jamal Hadi Salim
maintainerPATCH v2 3/3 net/sched: cls_route: No longer copy tcf_result on update to avoid use-after-free
In reply to Jamal Hadi SalimFrom: valis <[email protected]>
When route4_change() is called on an existing filter, the whole tcf_result struct is always copied into the new instance of the filter.
This causes a problem when updating a filter bound to a class, as tcf_unbind_filter() is always called on the old instance in the success path, decreasing filter_cnt of the still referenced class and allowing it to be deleted, leading to a use-after-free.
Fix this by no longer copying the tcf_result struct from the old filter.
--- net/sched/cls_route.c | 1 - 1 file changed, 1 deletion(-)
net/sched/cls_route.c +0 -1
@@ -513,7 +513,6 @@ static int route4_change(struct net *net, struct sk_buff *in_skb,if (fold) { f->id = fold->id; f->iif = fold->iif; - f->res = fold->res; f->handle = fold->handle; f->tp = fold->tp;
Signature · 1 line
2.34.1
Quoted 24 lines · Jamal Hadi Salim
From: valis <[email protected]>
Three classifiers (
cls_fw,cls_u32andcls_route) always copytcf_resultstruct into the new instance of the filter on update.This causes a problem when updating a filter bound to a class, as
tcf_unbind_filter()is always called on the old instance in the success path, decreasingfilter_cntof the still referenced class and allowing it to be deleted, leading to a use-after-free.This patch set fixes this issue in all affected classifiers by no longer copying the
tcf_resultstruct from the old filter.v1 -> v2:
- Resubmission and SOB by Jamalvalis (3):
net/sched:cls_u32: No longer copytcf_resulton update to avoid
use-after-free
net/sched:cls_fw: No longer copytcf_resulton update to avoid
use-after-free
net/sched:cls_route: No longer copytcf_resulton update to avoid
use-after-free
Quoted 4 lines
net/sched/cls_fw.c | 1 - net/sched/cls_route.c | 1 - net/sched/cls_u32.c | 1 - 3 files changed, 3 deletions(-)
For the series,
Quoted 24 lines · Jamal Hadi Salim
From: valis <[email protected]>
Three classifiers (
cls_fw,cls_u32andcls_route) always copytcf_resultstruct into the new instance of the filter on update.This causes a problem when updating a filter bound to a class, as
tcf_unbind_filter()is always called on the old instance in the success path, decreasingfilter_cntof the still referenced class and allowing it to be deleted, leading to a use-after-free.This patch set fixes this issue in all affected classifiers by no longer copying the
tcf_resultstruct from the old filter.v1 -> v2:
- Resubmission and SOB by Jamalvalis (3):
net/sched:cls_u32: No longer copytcf_resulton update to avoid
use-after-free
net/sched:cls_fw: No longer copytcf_resulton update to avoid
use-after-free
net/sched:cls_route: No longer copytcf_resulton update to avoid
use-after-free
Quoted 7 lines
net/sched/cls_fw.c | 1 - net/sched/cls_route.c | 1 - net/sched/cls_u32.c | 1 - 3 files changed, 3 deletions(-)--
2.34.1
For the series,
Quoted 25 lines · Jamal Hadi Salim
From: valis <[email protected]>
Three classifiers (
cls_fw,cls_u32andcls_route) always copytcf_resultstruct into the new instance of the filter on update.This causes a problem when updating a filter bound to a class, as
tcf_unbind_filter()is always called on the old instance in the success path, decreasingfilter_cntof the still referenced class and allowing it to be deleted, leading to a use-after-free.This patch set fixes this issue in all affected classifiers by no longer copying the
tcf_resultstruct from the old filter.v1 -> v2:
- Resubmission and SOB by Jamalvalis (3):
net/sched:cls_u32: No longer copytcf_resulton update to avoid
use-after-free
net/sched:cls_fw: No longer copytcf_resulton update to avoid
use-after-free
net/sched:cls_route: No longer copytcf_resulton update to avoid
use-after-free
Quoted 5 lines
net/sched/cls_fw.c | 1 - net/sched/cls_route.c | 1 - net/sched/cls_u32.c | 1 - 3 files changed, 3 deletions(-)
For the series,
Quoted 2 lines
--
2.34.1
This series was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 11 lines · On Sat, 29 Jul 2023 08:31:59 -0400 you wrote:
From: valis <[email protected]>
Three classifiers (
cls_fw,cls_u32andcls_route) always copytcf_resultstruct into the new instance of the filter on update.This causes a problem when updating a filter bound to a class, as
tcf_unbind_filter()is always called on the old instance in the success path, decreasingfilter_cntof the still referenced class and allowing it to be deleted, leading to a use-after-free.[...]
Here is the summary with links:
- [net,v2,1/3] net/sched: cls_u32: No longer copy tcf_result on update to avoid use-after-free
https://git.kernel.org/netdev/net/c/3044b16e7c6f - [net,v2,2/3] net/sched: cls_fw: No longer copy tcf_result on update to avoid use-after-free https://git.kernel.org/netdev/net/c/76e42ae83199 - [net,v2,3/3] net/sched: cls_route: No longer copy tcf_result on update to avoid use-after-free https://git.kernel.org/netdev/net/c/b80b829e9e2c
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html